Search in sources :

Example 1 with CoreReplicatedContentMarshal

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);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) GlobalSession(org.neo4j.causalclustering.core.replication.session.GlobalSession) LocalOperationId(org.neo4j.causalclustering.core.replication.session.LocalOperationId) UUID(java.util.UUID)

Example 2 with CoreReplicatedContentMarshal

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);
}
Also used : CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) ReplicatedIdAllocationRequest(org.neo4j.causalclustering.core.state.machines.id.ReplicatedIdAllocationRequest) ReplicatedContent(org.neo4j.causalclustering.core.replication.ReplicatedContent) ByteBuf(io.netty.buffer.ByteBuf) NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) Test(org.junit.Test)

Example 3 with CoreReplicatedContentMarshal

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);
}
Also used : CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) MemberId(org.neo4j.causalclustering.identity.MemberId) MemberIdSet(org.neo4j.causalclustering.core.consensus.membership.MemberIdSet) ByteBuf(io.netty.buffer.ByteBuf) NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) Test(org.junit.Test)

Example 4 with CoreReplicatedContentMarshal

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);
}
Also used : NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) ReplicatedTransaction(org.neo4j.causalclustering.core.state.machines.tx.ReplicatedTransaction) StorageCommand(org.neo4j.storageengine.api.StorageCommand) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) NetworkReadableClosableChannelNetty4(org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4) CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) IndexCommand(org.neo4j.kernel.impl.index.IndexCommand) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) Test(org.junit.Test)

Example 5 with CoreReplicatedContentMarshal

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);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) File(java.io.File)

Aggregations

CoreReplicatedContentMarshal (org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal)7 ByteBuf (io.netty.buffer.ByteBuf)3 Test (org.junit.Test)3 MemberId (org.neo4j.causalclustering.identity.MemberId)3 NetworkFlushableByteBuf (org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf)3 File (java.io.File)2 ReplicatedContent (org.neo4j.causalclustering.core.replication.ReplicatedContent)2 ReplicatedTransaction (org.neo4j.causalclustering.core.state.machines.tx.ReplicatedTransaction)2 LogProvider (org.neo4j.logging.LogProvider)2 OnDemandJobScheduler (org.neo4j.test.OnDemandJobScheduler)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 CoreLogPruningStrategy (org.neo4j.causalclustering.core.consensus.log.segmented.CoreLogPruningStrategy)1 CoreLogPruningStrategyFactory (org.neo4j.causalclustering.core.consensus.log.segmented.CoreLogPruningStrategyFactory)1 SegmentedRaftLog (org.neo4j.causalclustering.core.consensus.log.segmented.SegmentedRaftLog)1 MemberIdSet (org.neo4j.causalclustering.core.consensus.membership.MemberIdSet)1 GlobalSession (org.neo4j.causalclustering.core.replication.session.GlobalSession)1 LocalOperationId (org.neo4j.causalclustering.core.replication.session.LocalOperationId)1 ReplicatedIdAllocationRequest (org.neo4j.causalclustering.core.state.machines.id.ReplicatedIdAllocationRequest)1 NetworkReadableClosableChannelNetty4 (org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)1