Пример #1
0
        protected void PropageteRequestToWorkers(RestRequest request, Topic topic, 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);
                    TopicsQueries.swapWorkers(DBConnection, topic);
                }
            }
            else
            {
                response = PropagateRequest(request, coworker);
                TopicsQueries.swapWorkers(DBConnection, topic);
            }
            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new BadRequestException();
            }
        }
Пример #2
0
 protected override void swapWorkers(ICollection collection)
 {
     TopicsQueries.swapWorkers(DBConnection, (Topic)collection);
 }