use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.
the class StoreFiles method readStoreId.
public StoreId readStoreId(File storeDir) throws IOException {
File neoStoreFile = new File(storeDir, MetaDataStore.DEFAULT_NAME);
org.neo4j.kernel.impl.store.StoreId kernelStoreId = MetaDataStore.getStoreId(pageCache, neoStoreFile);
return new StoreId(kernelStoreId.getCreationTime(), kernelStoreId.getRandomId(), kernelStoreId.getUpgradeTime(), kernelStoreId.getUpgradeId());
}
use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.
the class TxPullRequestHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, final TxPullRequest msg) throws Exception {
long firstTxId = Math.max(msg.previousTxId(), BASE_TX_ID) + 1;
long lastTxId = firstTxId;
CatchupResult status = SUCCESS_END_OF_STREAM;
StoreId localStoreId = storeIdSupplier.get();
long lastCommittedTransactionId = transactionIdStore.getLastCommittedTransactionId();
if (localStoreId == null || !localStoreId.equals(msg.expectedStoreId())) {
status = E_STORE_ID_MISMATCH;
log.info("Failed to serve TxPullRequest for tx %d and storeId %s because that storeId is different " + "from this machine with %s", lastTxId, msg.expectedStoreId(), localStoreId);
} else if (!databaseAvailable.getAsBoolean()) {
// database is not available for pulling transactions...
status = E_STORE_UNAVAILABLE;
log.info("Failed to serve TxPullRequest for tx %d because the local database is unavailable.", lastTxId);
} else if (lastCommittedTransactionId >= firstTxId) {
try (IOCursor<CommittedTransactionRepresentation> cursor = logicalTransactionStore.getTransactions(firstTxId)) {
status = SUCCESS_END_OF_BATCH;
for (int i = 0; i < batchSize; i++) {
if (cursor.next()) {
ctx.write(ResponseMessageType.TX);
CommittedTransactionRepresentation tx = cursor.get();
lastTxId = tx.getCommitEntry().getTxId();
ctx.write(new TxPullResponse(localStoreId, tx));
} else {
status = SUCCESS_END_OF_STREAM;
break;
}
}
ctx.flush();
} catch (NoSuchTransactionException e) {
status = E_TRANSACTION_PRUNED;
log.info("Failed to serve TxPullRequest for tx %d because the transaction does not exist.", lastTxId);
}
}
ctx.write(ResponseMessageType.TX_STREAM_FINISHED);
TxStreamFinishedResponse response = new TxStreamFinishedResponse(status, lastCommittedTransactionId);
ctx.write(response);
ctx.flush();
monitor.increment();
protocol.expect(State.MESSAGE_TYPE);
}
use of org.neo4j.causalclustering.identity.StoreId in project neo4j by neo4j.
the class CoreStateDownloaderTest method shouldDownloadCompleteStoreWhenEmpty.
@Test
public void shouldDownloadCompleteStoreWhenEmpty() throws Throwable {
// given
StoreId remoteStoreId = new StoreId(5, 6, 7, 8);
when(remoteStore.getStoreId(remoteMember)).thenReturn(remoteStoreId);
when(localDatabase.isEmpty()).thenReturn(true);
// when
downloader.downloadSnapshot(remoteMember, coreState);
// then
verify(remoteStore, never()).tryCatchingUp(any(), any(), any());
verify(storeCopyProcess).replaceWithStoreFrom(remoteMember, remoteStoreId);
}
Aggregations