use of org.neo4j.causalclustering.identity.StoreId 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));
}
use of org.neo4j.causalclustering.identity.StoreId 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));
}
use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.
the class TxPullRequestHandlerTest method shouldRespondWithCompleteStreamOfTransactions.
@Test
public void shouldRespondWithCompleteStreamOfTransactions() throws Exception {
// given
StoreId storeId = new StoreId(1, 2, 3, 4);
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
when(transactionIdStore.getLastCommittedTransactionId()).thenReturn(15L);
LogicalTransactionStore logicalTransactionStore = mock(LogicalTransactionStore.class);
when(logicalTransactionStore.getTransactions(14L)).thenReturn(txCursor(cursor(tx(14), tx(15))));
TxPullRequestHandler txPullRequestHandler = new TxPullRequestHandler(new CatchupServerProtocol(), () -> storeId, () -> true, () -> transactionIdStore, () -> logicalTransactionStore, BATCH_SIZE, new Monitors(), NullLogProvider.getInstance());
// when
txPullRequestHandler.channelRead0(context, new TxPullRequest(13, storeId));
// then
verify(context, times(2)).write(ResponseMessageType.TX);
verify(context).write(new TxPullResponse(storeId, tx(14)));
verify(context).write(new TxPullResponse(storeId, tx(15)));
verify(context).write(ResponseMessageType.TX_STREAM_FINISHED);
verify(context).write(new TxStreamFinishedResponse(SUCCESS_END_OF_STREAM, 15L));
}
use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.
the class TxPullResponseEncodeDecodeTest method shouldEncodeAndDecodePullResponseMessage.
@Test
public void shouldEncodeAndDecodePullResponseMessage() {
// given
EmbeddedChannel channel = new EmbeddedChannel(new TxPullResponseEncoder(), new TxPullResponseDecoder());
TxPullResponse sent = new TxPullResponse(new StoreId(1, 2, 3, 4), newCommittedTransactionRepresentation());
// when
channel.writeOutbound(sent);
channel.writeInbound(new Object[] { channel.readOutbound() });
// then
TxPullResponse received = (TxPullResponse) channel.readInbound();
assertNotSame(sent, received);
assertEquals(sent, received);
}
use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.
the class TxPullRequestHandlerTest method shouldRespondWithEndOfStreamIfThereAreNoTransactions.
@Test
public void shouldRespondWithEndOfStreamIfThereAreNoTransactions() throws Exception {
// given
StoreId storeId = new StoreId(1, 2, 3, 4);
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
when(transactionIdStore.getLastCommittedTransactionId()).thenReturn(14L);
LogicalTransactionStore logicalTransactionStore = mock(LogicalTransactionStore.class);
TxPullRequestHandler txPullRequestHandler = new TxPullRequestHandler(new CatchupServerProtocol(), () -> storeId, () -> true, () -> transactionIdStore, () -> logicalTransactionStore, BATCH_SIZE, new Monitors(), NullLogProvider.getInstance());
// when
txPullRequestHandler.channelRead0(context, new TxPullRequest(14, storeId));
// then
verify(context).write(ResponseMessageType.TX_STREAM_FINISHED);
verify(context).write(new TxStreamFinishedResponse(SUCCESS_END_OF_STREAM, 14L));
}
Aggregations