use of org.neo4j.causalclustering.catchup.tx.TxPullClient in project neo4j by neo4j.
the class RemoteStoreTest method shouldCopyStoreFilesAndPullTransactions.
@Test
public void shouldCopyStoreFilesAndPullTransactions() throws Exception {
// given
StoreId storeId = new StoreId(1, 2, 3, 4);
StoreCopyClient storeCopyClient = mock(StoreCopyClient.class);
TxPullClient txPullClient = mock(TxPullClient.class);
when(txPullClient.pullTransactions(any(), any(), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));
TransactionLogCatchUpWriter writer = mock(TransactionLogCatchUpWriter.class);
RemoteStore remoteStore = new RemoteStore(NullLogProvider.getInstance(), mock(FileSystemAbstraction.class), null, storeCopyClient, txPullClient, factory(writer), new Monitors());
// when
MemberId localhost = new MemberId(UUID.randomUUID());
remoteStore.copy(localhost, storeId, new File("destination"));
// then
verify(storeCopyClient).copyStoreFiles(eq(localhost), eq(storeId), any(StoreFileStreams.class));
verify(txPullClient).pullTransactions(eq(localhost), eq(storeId), anyLong(), any(TxPullResponseListener.class));
}
use of org.neo4j.causalclustering.catchup.tx.TxPullClient in project neo4j by neo4j.
the class RemoteStoreTest method shouldSetLastPulledTransactionId.
@Test
public void shouldSetLastPulledTransactionId() throws Exception {
// given
long lastFlushedTxId = 12;
StoreId wantedStoreId = new StoreId(1, 2, 3, 4);
MemberId localhost = new MemberId(UUID.randomUUID());
StoreCopyClient storeCopyClient = mock(StoreCopyClient.class);
when(storeCopyClient.copyStoreFiles(eq(localhost), eq(wantedStoreId), any(StoreFileStreams.class))).thenReturn(lastFlushedTxId);
TxPullClient txPullClient = mock(TxPullClient.class);
when(txPullClient.pullTransactions(eq(localhost), eq(wantedStoreId), anyLong(), any(TxPullResponseListener.class))).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));
TransactionLogCatchUpWriter writer = mock(TransactionLogCatchUpWriter.class);
RemoteStore remoteStore = new RemoteStore(NullLogProvider.getInstance(), mock(FileSystemAbstraction.class), null, storeCopyClient, txPullClient, factory(writer), new Monitors());
// when
remoteStore.copy(localhost, wantedStoreId, new File("destination"));
// then
// the interface is defined as asking for the one preceding
long previousTxId = lastFlushedTxId - 1;
verify(txPullClient).pullTransactions(eq(localhost), eq(wantedStoreId), eq(previousTxId), any(TxPullResponseListener.class));
}
use of org.neo4j.causalclustering.catchup.tx.TxPullClient in project neo4j by neo4j.
the class RemoteStoreTest method shouldCloseDownTxLogWriterIfTxStreamingFails.
@Test
public void shouldCloseDownTxLogWriterIfTxStreamingFails() throws Exception {
// given
StoreId storeId = new StoreId(1, 2, 3, 4);
StoreCopyClient storeCopyClient = mock(StoreCopyClient.class);
TxPullClient txPullClient = mock(TxPullClient.class);
TransactionLogCatchUpWriter writer = mock(TransactionLogCatchUpWriter.class);
RemoteStore remoteStore = new RemoteStore(NullLogProvider.getInstance(), mock(FileSystemAbstraction.class), null, storeCopyClient, txPullClient, factory(writer), new Monitors());
doThrow(StoreCopyFailedException.class).when(txPullClient).pullTransactions(any(MemberId.class), eq(storeId), anyLong(), any(TransactionLogCatchUpWriter.class));
// when
try {
remoteStore.copy(null, storeId, null);
} catch (StoreCopyFailedException e) {
// expected
}
// then
verify(writer).close();
}
Aggregations