コード例 #1
0
 /// <summary>
 /// sends some problem related message via problemClient
 /// </summary>
 /// <param name="request"></param>
 public void SendProblemRelatedMessage(Message request)
 {
     Message[] requests = creator.Create(request);
     log.DebugFormat("Sending after computations: {0}", request.ToString());
     Message[] responses;
     lock (SyncRoot)
     {
         responses = this.SendMessages(problemClient, requests);
     }
     foreach (var response in responses)
     {
         messageQueue.Enqueue(response);
     }
 }
コード例 #2
0
        /// <summary>
        /// sends problem to cluster, returns unique problem id
        /// </summary>
        /// <returns></returns>
        public virtual SolveRequestResponse SendProblem()
        {
            SolveRequest problemRequest = core.GetRequest();

            problemRequest.IdSpecified = false;

            Message[]            requests      = creator.Create(problemRequest);
            Message[]            responses     = this.SendMessages(clusterClient, requests);
            SolveRequestResponse solveResponse = null;

            foreach (var response in responses)
            {
                switch (response.MessageType)
                {
                case MessageType.SolveRequestResponseMessage:
                    log.Debug("SolveRequestResponse acquired: handling");
                    if (solveResponse != null)
                    {
                        throw new Exception("Multiple SolveRequestResponse messages in CC");
                    }
                    solveResponse = response.Cast <SolveRequestResponse>();
                    break;

                case MessageType.NoOperationMessage:
                    log.Debug("NoOperation acquired: updating backups");
                    UpdateBackups(response.Cast <NoOperation>());
                    break;

                default:
                    throw new Exception("Invalid message delivered in CC's sendProblem procedure "
                                        + response.ToString());
                }
            }
            if (solveResponse == null)
            {
                throw new Exception("No solveRequestResponse in CC");
            }

            return(solveResponse);
        }