protected void PropageteRequestToWorkers(RestRequest request, Queue queue, Worker worker, Worker coworker)
        {
            var           requestForMaster = request.AddParameter("Cooperator", coworker.Address);
            IRestResponse response;

            if (WorkerQueries.IsWorkerAlive(DBConnection, worker.Id))
            {
                response = PropagateRequest(requestForMaster, worker);
                if (response.ResponseStatus == ResponseStatus.TimedOut ||
                    response.ResponseStatus == ResponseStatus.Error)
                {
                    response = PropagateRequest(request, coworker);
                    QueuesQueries.swapWorkers(DBConnection, queue);
                }
            }
            else
            {
                response = PropagateRequest(request, coworker);
                QueuesQueries.swapWorkers(DBConnection, queue);
            }
            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new BadRequestException();
            }
        }
Example #2
0
 protected override void swapWorkers(ICollection collection)
 {
     QueuesQueries.swapWorkers(DBConnection, (Queue)collection);
 }