Search in sources :

Example 1 with NetworkReadableClosableChannelNetty4

use of org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4 in project neo4j by neo4j.

the class TxPullRequestDecoder method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
    long txId = msg.readLong();
    StoreId storeId = StoreIdMarshal.INSTANCE.unmarshal(new NetworkReadableClosableChannelNetty4(msg));
    out.add(new TxPullRequest(txId, storeId));
}
Also used : StoreId(org.neo4j.causalclustering.identity.StoreId) NetworkReadableClosableChannelNetty4(org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)

Example 2 with NetworkReadableClosableChannelNetty4

use of org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4 in project neo4j by neo4j.

the class TxPullResponseDecoder method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
    NetworkReadableClosableChannelNetty4 logChannel = new NetworkReadableClosableChannelNetty4(msg);
    StoreId storeId = StoreIdMarshal.INSTANCE.unmarshal(logChannel);
    LogEntryReader<NetworkReadableClosableChannelNetty4> reader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
    PhysicalTransactionCursor<NetworkReadableClosableChannelNetty4> transactionCursor = new PhysicalTransactionCursor<>(logChannel, reader);
    transactionCursor.next();
    CommittedTransactionRepresentation tx = transactionCursor.get();
    if (tx != null) {
        out.add(new TxPullResponse(storeId, tx));
    }
}
Also used : PhysicalTransactionCursor(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionCursor) RecordStorageCommandReaderFactory(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) StoreId(org.neo4j.causalclustering.identity.StoreId) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) NetworkReadableClosableChannelNetty4(org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)

Example 3 with NetworkReadableClosableChannelNetty4

use of org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4 in project neo4j by neo4j.

the class ReplicatedTokenRequestSerializer method extractCommands.

static Collection<StorageCommand> extractCommands(byte[] commandBytes) {
    ByteBuf txBuffer = Unpooled.wrappedBuffer(commandBytes);
    NetworkReadableClosableChannelNetty4 channel = new NetworkReadableClosableChannelNetty4(txBuffer);
    LogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
    LogEntryCommand entryRead;
    List<StorageCommand> commands = new LinkedList<>();
    try {
        while ((entryRead = (LogEntryCommand) reader.readLogEntry(channel)) != null) {
            commands.add(entryRead.getXaCommand());
        }
    } catch (IOException e) {
        // TODO: Handle or throw.
        e.printStackTrace();
    }
    return commands;
}
Also used : RecordStorageCommandReaderFactory(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory) LogEntryCommand(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) IOException(java.io.IOException) ByteBuf(io.netty.buffer.ByteBuf) NetworkReadableClosableChannelNetty4(org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4) LinkedList(java.util.LinkedList) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)

Example 4 with NetworkReadableClosableChannelNetty4

use of org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4 in project neo4j by neo4j.

the class GetStoreIdResponseDecoder method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
    StoreId storeId = StoreIdMarshal.INSTANCE.unmarshal(new NetworkReadableClosableChannelNetty4(msg));
    out.add(new GetStoreIdResponse(storeId));
}
Also used : StoreId(org.neo4j.causalclustering.identity.StoreId) NetworkReadableClosableChannelNetty4(org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)

Example 5 with NetworkReadableClosableChannelNetty4

use of org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4 in project neo4j by neo4j.

the class GetStoreRequestDecoder method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
    StoreId expectedStoreId = StoreIdMarshal.INSTANCE.unmarshal(new NetworkReadableClosableChannelNetty4(msg));
    out.add(new GetStoreRequest(expectedStoreId));
}
Also used : StoreId(org.neo4j.causalclustering.identity.StoreId) NetworkReadableClosableChannelNetty4(org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)

Aggregations

NetworkReadableClosableChannelNetty4 (org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)13 ByteBuf (io.netty.buffer.ByteBuf)6 Test (org.junit.Test)4 StoreId (org.neo4j.causalclustering.identity.StoreId)4 MemberId (org.neo4j.causalclustering.identity.MemberId)3 NetworkFlushableByteBuf (org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf)3 NetworkFlushableChannelNetty4 (org.neo4j.causalclustering.messaging.NetworkFlushableChannelNetty4)3 IOException (java.io.IOException)2 RecordStorageCommandReaderFactory (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory)2 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)2 StorageCommand (org.neo4j.storageengine.api.StorageCommand)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 RaftMessages (org.neo4j.causalclustering.core.consensus.RaftMessages)1 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)1 ReplicatedContent (org.neo4j.causalclustering.core.replication.ReplicatedContent)1 ReplicatedTransaction (org.neo4j.causalclustering.core.state.machines.tx.ReplicatedTransaction)1 ClusterId (org.neo4j.causalclustering.identity.ClusterId)1 CoreReplicatedContentMarshal (org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal)1 EndOfStreamException (org.neo4j.causalclustering.messaging.EndOfStreamException)1