private void SendCommitUpdate(LeaderContext leaderContext) { /* * This is a commit update. That means that we just received enough success responses to an append * request to allow us to send a commit. By Raft invariants, this means that the term for the committed * entry is the current term. */ Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat appendRequest = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(_leader, leaderContext.Term, leaderContext.CommitIndex, leaderContext.Term); _outbound.send(_follower, appendRequest); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.concurrent.Future<Object> replicate0(ReplicatedContent command, boolean trackResult, org.neo4j.causalclustering.identity.MemberId leader) throws ReplicationFailureException private Future <object> Replicate0(ReplicatedContent command, bool trackResult, MemberId leader) { _replicationMonitor.startReplication(); try { OperationContext session = _sessionPool.acquireSession(); DistributedOperation operation = new DistributedOperation(command, session.GlobalSession(), session.LocalOperationId()); Progress progress = _progressTracker.start(operation); Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout progressTimeout = _progressTimeoutStrategy.newTimeout(); int attempts = 0; try { while (true) { attempts++; if (attempts > 1) { _log.info("Retrying replication. Current attempt: %d Content: %s", attempts, command); } _replicationMonitor.replicationAttempt(); AssertDatabaseAvailable(); // blocking at least until the send has succeeded or failed before retrying _outbound.send(leader, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request(_me, operation), true); progress.AwaitReplication(progressTimeout.Millis); if (progress.Replicated) { break; } progressTimeout.Increment(); leader = _leaderProvider.awaitLeader(); } } catch (InterruptedException e) { _progressTracker.abort(operation); throw new ReplicationFailureException("Interrupted while replicating", e); } System.Action <object, Exception> cleanup = (ignored1, ignored2) => _sessionPool.releaseSession(session); if (trackResult) { progress.FutureResult().whenComplete(cleanup); } else { cleanup(null, null); } _replicationMonitor.successfulReplication(); return(progress.FutureResult()); } catch (Exception t) { _replicationMonitor.failedReplication(t); throw t; } }
private void SendMessages(Outcome outcome) { foreach (RaftMessages_Directed outgoingMessage in outcome.OutgoingMessages) { try { _outbound.send(outgoingMessage.To(), outgoingMessage.Message()); } catch (Exception e) { _log.warn(format("Failed to send message %s.", outgoingMessage), e); } } }
public override void Send(MemberId to, RaftMessages_RaftMessage message, bool block) { Optional <ClusterId> clusterId = _clusterIdentity.get(); if (!clusterId.Present) { _log.warn("Attempting to send a message before bound to a cluster"); return; } Optional <CoreServerInfo> coreServerInfo = _coreTopologyService.localCoreServers().find(to); if (coreServerInfo.Present) { _outbound.send(coreServerInfo.get().RaftServer, Org.Neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage.of(clusterId.get(), message), block); } else { _unknownAddressMonitor.logAttemptToSendToMemberWithNoKnownAddress(to); } }
public override void Send(MEMBER to, MESSAGE message, bool block) { _messageLogger.logOutbound(_me, message, to); _outbound.send(to, message); }
public virtual void Replicate(ReplicatedContent content) { _outbound.send(_myself, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request(_myself, content)); }