use of org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal 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.messaging.CoreReplicatedContentMarshal in project neo4j by neo4j.
the class RaftContentByteBufferMarshalTest method shouldSerializeIdRangeRequest.
@Test
public void shouldSerializeIdRangeRequest() throws Exception {
// given
CoreReplicatedContentMarshal serializer = new CoreReplicatedContentMarshal();
ReplicatedContent in = new ReplicatedIdAllocationRequest(memberId, IdType.NODE, 100, 200);
// when
ByteBuf buf = Unpooled.buffer();
assertMarshalingEquality(serializer, buf, in);
}
use of org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal in project neo4j by neo4j.
the class RaftContentByteBufferMarshalTest method shouldSerializeMemberSet.
@Test
public void shouldSerializeMemberSet() throws Exception {
// given
CoreReplicatedContentMarshal serializer = new CoreReplicatedContentMarshal();
MemberIdSet in = new MemberIdSet(asSet(new MemberId(UUID.randomUUID()), new MemberId(UUID.randomUUID())));
// when
ByteBuf buf = Unpooled.buffer();
assertMarshalingEquality(serializer, buf, in);
}
use of org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal in project neo4j by neo4j.
the class RaftContentByteBufferMarshalTest method shouldSerializeTransactionRepresentation.
@Test
public void shouldSerializeTransactionRepresentation() throws Exception {
// given
CoreReplicatedContentMarshal serializer = new CoreReplicatedContentMarshal();
Collection<StorageCommand> commands = new ArrayList<>();
IndexCommand.AddNodeCommand addNodeCommand = new IndexCommand.AddNodeCommand();
addNodeCommand.init(0, 0, 0, 0);
commands.add(addNodeCommand);
byte[] extraHeader = new byte[0];
PhysicalTransactionRepresentation txIn = new PhysicalTransactionRepresentation(commands);
txIn.setHeader(extraHeader, -1, -1, 0, 0, 0, 0);
ReplicatedTransaction in = ReplicatedTransactionFactory.createImmutableReplicatedTransaction(txIn);
// when
ByteBuf buf = Unpooled.buffer();
serializer.marshal(in, new NetworkFlushableByteBuf(buf));
ReplicatedTransaction out = (ReplicatedTransaction) serializer.unmarshal(new NetworkReadableClosableChannelNetty4(buf));
TransactionRepresentation txOut = ReplicatedTransactionFactory.extractTransactionRepresentation(out, extraHeader);
// then
assertEquals(in, out);
assertEquals(txIn, txOut);
}
use of org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal in project neo4j by neo4j.
the class SegmentedRaftLogPartialEntryRecoveryTest method createRaftLog.
private SegmentedRaftLog createRaftLog(long rotateAtSize) {
File directory = new File(RAFT_LOG_DIRECTORY_NAME);
logDirectory = dir.directory(directory.getName());
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("100 entries", logProvider).newInstance();
return new SegmentedRaftLog(fsRule.get(), logDirectory, rotateAtSize, new CoreReplicatedContentMarshal(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
}
Aggregations