Exemple #1
0
 protected internal override void Decode(ChannelHandlerContext ctx, object msg, IList <object> @out)
 {
     if (msg is ReplicatedContent)
     {
         _replicatedContents.AddLast(( ReplicatedContent )msg);
     }
     else if (msg is RaftLogEntryTermsDecoder.RaftLogEntryTerms)
     {
         foreach (long term in ((RaftLogEntryTermsDecoder.RaftLogEntryTerms)msg).Terms())
         {
             _raftLogEntryTerms.AddLast(term);
         }
     }
     else if (msg is RaftMessageDecoder.ClusterIdAwareMessageComposer)
     {
         if (_messageComposer != null)
         {
             throw new System.InvalidOperationException("Received raft message header. Pipeline already contains message header waiting to build.");
         }
         _messageComposer = (RaftMessageDecoder.ClusterIdAwareMessageComposer)msg;
     }
     else
     {
         throw new System.InvalidOperationException("Unexpected object in the pipeline: " + msg);
     }
     if (_messageComposer != null)
     {
         Optional <Org.Neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage> clusterIdAwareMessage = _messageComposer.maybeCompose(_clock, _raftLogEntryTerms, _replicatedContents);
         clusterIdAwareMessage.ifPresent(message =>
         {
             Clear(message);
             @out.Add(message);
         });
     }
 }
Exemple #2
0
 private void Clear(Org.Neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage message)
 {
     _messageComposer = null;
     if (_replicatedContents.Count > 0 || _raftLogEntryTerms.Count > 0)
     {
         throw new System.InvalidOperationException(string.Format("Message [{0}] was composed without using all resources in the pipeline. " + "Pipeline still contains Replicated contents[{1}] and RaftLogEntryTerms [{2}]", message, Stringify(_replicatedContents), Stringify(_raftLogEntryTerms)));
     }
 }