use of org.neo4j.causalclustering.catchup.TxPullRequestResult 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.TxPullRequestResult 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.TxPullRequestResult in project neo4j by neo4j.
the class RemoteStore method pullTransactions.
private CatchupResult pullTransactions(MemberId from, StoreId expectedStoreId, File storeDir, long fromTxId, boolean asPartOfStoreCopy) throws IOException, StoreCopyFailedException {
try (TransactionLogCatchUpWriter writer = transactionLogFactory.create(storeDir, fs, pageCache, logProvider, fromTxId, asPartOfStoreCopy)) {
log.info("Pulling transactions from: %d", fromTxId);
long previousTxId = fromTxId - 1;
CatchupResult lastStatus;
do {
TxPullRequestResult result = txPullClient.pullTransactions(from, expectedStoreId, previousTxId, writer);
lastStatus = result.catchupResult();
previousTxId = result.lastTxId();
} while (lastStatus == SUCCESS_END_OF_BATCH);
return lastStatus;
} catch (CatchUpClientException e) {
throw new StoreCopyFailedException(e);
}
}
Aggregations