Search in sources :

Example 1 with TxPullClient

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));
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) TransactionLogCatchUpWriter(org.neo4j.causalclustering.catchup.tx.TransactionLogCatchUpWriter) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) StoreId(org.neo4j.causalclustering.identity.StoreId) TxPullResponseListener(org.neo4j.causalclustering.catchup.tx.TxPullResponseListener) Monitors(org.neo4j.kernel.monitoring.Monitors) TxPullRequestResult(org.neo4j.causalclustering.catchup.TxPullRequestResult) TxPullClient(org.neo4j.causalclustering.catchup.tx.TxPullClient) File(java.io.File) Test(org.junit.Test)

Example 2 with TxPullClient

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));
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) TxPullResponseListener(org.neo4j.causalclustering.catchup.tx.TxPullResponseListener) TxPullRequestResult(org.neo4j.causalclustering.catchup.TxPullRequestResult) MemberId(org.neo4j.causalclustering.identity.MemberId) TransactionLogCatchUpWriter(org.neo4j.causalclustering.catchup.tx.TransactionLogCatchUpWriter) StoreId(org.neo4j.causalclustering.identity.StoreId) Monitors(org.neo4j.kernel.monitoring.Monitors) TxPullClient(org.neo4j.causalclustering.catchup.tx.TxPullClient) File(java.io.File) Test(org.junit.Test)

Example 3 with TxPullClient

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();
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) TransactionLogCatchUpWriter(org.neo4j.causalclustering.catchup.tx.TransactionLogCatchUpWriter) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) StoreId(org.neo4j.causalclustering.identity.StoreId) Monitors(org.neo4j.kernel.monitoring.Monitors) TxPullClient(org.neo4j.causalclustering.catchup.tx.TxPullClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 TransactionLogCatchUpWriter (org.neo4j.causalclustering.catchup.tx.TransactionLogCatchUpWriter)3 TxPullClient (org.neo4j.causalclustering.catchup.tx.TxPullClient)3 MemberId (org.neo4j.causalclustering.identity.MemberId)3 StoreId (org.neo4j.causalclustering.identity.StoreId)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 Monitors (org.neo4j.kernel.monitoring.Monitors)3 File (java.io.File)2 TxPullRequestResult (org.neo4j.causalclustering.catchup.TxPullRequestResult)2 TxPullResponseListener (org.neo4j.causalclustering.catchup.tx.TxPullResponseListener)2