Example #1
0
 private async Task OnNextAsync(Tuple <string, Message> item)
 {
     try
     {
         this.TraceMessage(true, item);
         if (this.IsSelf(item.Item1))
         {
             this.Incoming.OnNext(item);
         }
         else if (!this.groupConfig.Settings.IsUseHttpTransportForInstanceCommunication)
         {
             ChannelFactory <IDxStoreInstance> factory = this.GetChannelFactory(item.Item1);
             await Concurrency.DropContext(WCF.WithServiceAsync <IDxStoreInstance>(factory, (IDxStoreInstance instance) => instance.PaxosMessageAsync(this.groupConfig.Self, item.Item2), null, default(CancellationToken)));
         }
         else
         {
             HttpRequest.PaxosMessage msg = new HttpRequest.PaxosMessage(this.nodeEndPoints.Self, item.Item2);
             string targetHost            = this.groupConfig.GetMemberNetworkAddress(item.Item1);
             await HttpClient.SendMessageAsync(targetHost, item.Item1, this.groupConfig.Name, msg);
         }
     }
     catch (Exception ex)
     {
         if (GroupMembersMesh.Tracer.IsTraceEnabled(TraceType.ErrorTrace))
         {
             GroupMembersMesh.Tracer.TraceError((long)this.identity.GetHashCode(), "{0}: OnNextAsync(Node:{1}, Msg:{2}) failed with {3}", new object[]
             {
                 this.identity,
                 item.Item1,
                 item.Item2,
                 ex
             });
         }
     }
 }
 private void HandleIncomingPaxosMessage(HttpRequest.PaxosMessage msg)
 {
     try
     {
         if (this.StateMachine != null && this.StateMachine.Mesh != null)
         {
             this.StateMachine.Mesh.Incoming.OnNext(Tuple.Create <string, Message>(msg.Sender, msg.Message));
         }
         else
         {
             DxStoreInstance.Tracer.TraceError <string>(0L, "{0}: HandleIncomingMessage skipped since state machine is not configured yet.", this.GroupConfig.Identity);
         }
     }
     catch (Exception arg)
     {
         DxStoreInstance.Tracer.TraceError <string, Exception>(0L, "{0}: HandleIncomingMessage caught {1}", this.GroupConfig.Identity, arg);
     }
 }