Пример #1
0
 public override void Handle <T1>(Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage <T1> wrappedMessage)
 {
     lock (this)
     {
         try
         {
             ConsensusOutcome outcome = _raftMachine.handle(wrappedMessage.message());
             if (outcome.NeedsFreshSnapshot())
             {
                 Optional <JobHandle> downloadJob = _downloadService.scheduleDownload(_catchupAddressProvider);
                 if (downloadJob.Present)
                 {
                     downloadJob.get().waitTermination();
                 }
             }
             else
             {
                 NotifyCommitted(outcome.CommitIndex);
             }
         }
         catch (Exception e)
         {
             _log.error("Error handling message", e);
             _raftMachine.panic();
             _localDatabase.panic(e);
         }
     }
 }
Пример #2
0
 protected internal override void ChannelRead0(ChannelHandlerContext ctx, Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> msg)
 {
     this.Msg = msg;
 }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeDecodeRaftMessage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldEncodeDecodeRaftMessage()
        {
            ClusterId clusterId = new ClusterId(System.Guid.randomUUID());

            Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> idAwareMessage = Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage.of(Instant.now(), clusterId, RaftMessage);

            _outbound.writeOutbound(idAwareMessage);

            object o;

            while ((o = _outbound.readOutbound()) != null)
            {
                _inbound.writeInbound(o);
            }
            Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> message = _handler.RaftMessage;
            assertEquals(clusterId, message.clusterId());
            RaftMessageEquals(RaftMessage, message.message());
            assertNull(_inbound.readInbound());
            ReferenceCountUtil.release(_handler.msg);
        }