Search in sources :

Example 1 with StoreId

use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.

the class CoreStateDownloaderTest method shouldNotOverwriteNonEmptyMismatchingStore.

@Test
public void shouldNotOverwriteNonEmptyMismatchingStore() throws Exception {
    // given
    when(localDatabase.isEmpty()).thenReturn(false);
    StoreId remoteStoreId = new StoreId(5, 6, 7, 8);
    when(remoteStore.getStoreId(remoteMember)).thenReturn(remoteStoreId);
    // when
    try {
        downloader.downloadSnapshot(remoteMember, coreState);
        fail();
    } catch (StoreCopyFailedException e) {
    // expected
    }
    // then
    verify(remoteStore, never()).copy(any(), any(), any());
    verify(remoteStore, never()).tryCatchingUp(any(), any(), any());
}
Also used : StoreCopyFailedException(org.neo4j.causalclustering.catchup.storecopy.StoreCopyFailedException) StoreId(org.neo4j.causalclustering.identity.StoreId) Test(org.junit.Test)

Example 2 with StoreId

use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.

the class CatchupPollingProcess method pullTransactions.

private void pullTransactions() {
    MemberId upstream;
    try {
        upstream = selectionStrategyPipeline.bestUpstreamDatabase();
    } catch (UpstreamDatabaseSelectionException e) {
        log.warn("Could not find upstream database from which to pull.", e);
        return;
    }
    StoreId localStoreId = localDatabase.storeId();
    boolean moreToPull = true;
    int batchCount = 1;
    while (moreToPull) {
        moreToPull = pullAndApplyBatchOfTransactions(upstream, localStoreId, batchCount);
        batchCount++;
    }
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) StoreId(org.neo4j.causalclustering.identity.StoreId) UpstreamDatabaseSelectionException(org.neo4j.causalclustering.readreplica.UpstreamDatabaseSelectionException)

Example 3 with StoreId

use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.

the class CatchupPollingProcess method copyStore.

private void copyStore() {
    MemberId upstream;
    try {
        upstream = selectionStrategyPipeline.bestUpstreamDatabase();
    } catch (UpstreamDatabaseSelectionException e) {
        log.warn("Could not find upstream database from which to copy store", e);
        return;
    }
    StoreId localStoreId = localDatabase.storeId();
    downloadDatabase(upstream, localStoreId);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) StoreId(org.neo4j.causalclustering.identity.StoreId) UpstreamDatabaseSelectionException(org.neo4j.causalclustering.readreplica.UpstreamDatabaseSelectionException)

Example 4 with StoreId

use of org.neo4j.causalclustering.identity.StoreId 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 5 with StoreId

use of org.neo4j.causalclustering.identity.StoreId 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)

Aggregations

StoreId (org.neo4j.causalclustering.identity.StoreId)28 Test (org.junit.Test)14 Monitors (org.neo4j.kernel.monitoring.Monitors)9 File (java.io.File)6 CatchupServerProtocol (org.neo4j.causalclustering.catchup.CatchupServerProtocol)6 LogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)6 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)6 MemberId (org.neo4j.causalclustering.identity.MemberId)5 NetworkReadableClosableChannelNetty4 (org.neo4j.causalclustering.messaging.NetworkReadableClosableChannelNetty4)4 TransactionLogCatchUpWriter (org.neo4j.causalclustering.catchup.tx.TransactionLogCatchUpWriter)3 TxPullClient (org.neo4j.causalclustering.catchup.tx.TxPullClient)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)2 CatchupResult (org.neo4j.causalclustering.catchup.CatchupResult)2 TxPullRequestResult (org.neo4j.causalclustering.catchup.TxPullRequestResult)2 StoreCopyFailedException (org.neo4j.causalclustering.catchup.storecopy.StoreCopyFailedException)2 TxPullResponseListener (org.neo4j.causalclustering.catchup.tx.TxPullResponseListener)2 UpstreamDatabaseSelectionException (org.neo4j.causalclustering.readreplica.UpstreamDatabaseSelectionException)2 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)2 NoSuchTransactionException (org.neo4j.kernel.impl.transaction.log.NoSuchTransactionException)2