use of org.neo4j.causalclustering.core.replication.session.LocalOperationId in project neo4j by neo4j.
the class DistributedOperation method deserialize.
public static DistributedOperation deserialize(ReadableChannel channel) throws IOException, EndOfStreamException {
long mostSigBits = channel.getLong();
long leastSigBits = channel.getLong();
MemberId owner = new MemberId.Marshal().unmarshal(channel);
GlobalSession globalSession = new GlobalSession(new UUID(mostSigBits, leastSigBits), owner);
long localSessionId = channel.getLong();
long sequenceNumber = channel.getLong();
LocalOperationId localOperationId = new LocalOperationId(localSessionId, sequenceNumber);
ReplicatedContent content = new CoreReplicatedContentMarshal().unmarshal(channel);
return new DistributedOperation(content, globalSession, localOperationId);
}
use of org.neo4j.causalclustering.core.replication.session.LocalOperationId in project neo4j by neo4j.
the class ProgressTrackerImplTest method shouldIgnoreOtherSessions.
@Test
public void shouldIgnoreOtherSessions() throws Exception {
// given
GlobalSession sessionB = new GlobalSession(UUID.randomUUID(), null);
DistributedOperation aliasUnderSessionB = new DistributedOperation(ReplicatedInteger.valueOf(0), sessionB, new LocalOperationId(/* same id/sequence number as operationA */
operationA.operationId().localSessionId(), operationA.operationId().sequenceNumber()));
Progress progressA = tracker.start(operationA);
// when
tracker.trackReplication(aliasUnderSessionB);
tracker.trackResult(aliasUnderSessionB, Result.of("result"));
// then
assertEquals(false, progressA.isReplicated());
assertEquals(false, progressA.futureResult().isDone());
}
use of org.neo4j.causalclustering.core.replication.session.LocalOperationId in project neo4j by neo4j.
the class CommandApplicationProcessTest method outOfOrderDuplicatesShouldBeIgnoredButStillIncreaseCommandIndex.
@Test
public void outOfOrderDuplicatesShouldBeIgnoredButStillIncreaseCommandIndex() throws Exception {
// given
applicationProcess.start();
// when
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 100), globalSession, new LocalOperationId(0, 0))));
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 101), globalSession, new LocalOperationId(0, 1))));
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 102), globalSession, new LocalOperationId(0, 2))));
// duplicate of tx 101
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 101), globalSession, new LocalOperationId(0, 1))));
// duplicate of tx 100
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 100), globalSession, new LocalOperationId(0, 0))));
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 103), globalSession, new LocalOperationId(0, 3))));
raftLog.append(new RaftLogEntry(0, new DistributedOperation(tx((byte) 104), globalSession, new LocalOperationId(0, 4))));
applicationProcess.notifyCommitted(6);
applier.sync(false);
InOrder inOrder = inOrder(coreStateMachines, commandDispatcher);
// then
inOrder.verify(coreStateMachines).commandDispatcher();
inOrder.verify(commandDispatcher).dispatch(eq(tx((byte) 100)), eq(0L), anyCallback());
inOrder.verify(commandDispatcher).dispatch(eq(tx((byte) 101)), eq(1L), anyCallback());
inOrder.verify(commandDispatcher).dispatch(eq(tx((byte) 102)), eq(2L), anyCallback());
// duplicate of tx 101 not dispatched, at index 3
// duplicate of tx 100 not dispatched, at index 4
inOrder.verify(commandDispatcher).dispatch(eq(tx((byte) 103)), eq(5L), anyCallback());
inOrder.verify(commandDispatcher).dispatch(eq(tx((byte) 104)), eq(6L), anyCallback());
inOrder.verify(commandDispatcher).close();
verifyNoMoreInteractions(commandDispatcher);
}
use of org.neo4j.causalclustering.core.replication.session.LocalOperationId in project neo4j by neo4j.
the class CommandApplicationProcessTest method duplicatesShouldBeIgnoredButStillIncreaseCommandIndex.
@Test
public void duplicatesShouldBeIgnoredButStillIncreaseCommandIndex() throws Exception {
// given
applicationProcess.start();
// when
raftLog.append(new RaftLogEntry(0, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(0, new DistributedOperation(nullTx, globalSession, new LocalOperationId(0, 0))));
// duplicate
raftLog.append(new RaftLogEntry(0, new DistributedOperation(nullTx, globalSession, new LocalOperationId(0, 0))));
raftLog.append(new RaftLogEntry(0, new DistributedOperation(nullTx, globalSession, new LocalOperationId(0, 1))));
applicationProcess.notifyCommitted(3);
applier.sync(false);
InOrder inOrder = inOrder(coreStateMachines, commandDispatcher);
// then
inOrder.verify(coreStateMachines).commandDispatcher();
inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(1L), anyCallback());
// duplicate not dispatched
inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(3L), anyCallback());
inOrder.verify(commandDispatcher).close();
verifyNoMoreInteractions(commandDispatcher);
}
Aggregations