use of org.neo4j.helpers.CancellationRequest in project neo4j by neo4j.
the class SwitchToSlave method copyStoreFromMaster.
void copyStoreFromMaster(MasterClient masterClient, CancellationRequest cancellationRequest, MoveAfterCopy moveAfterCopy) throws Throwable {
try {
userLog.info("Copying store from master");
StoreCopyClient.StoreCopyRequester requester = new StoreCopyClient.StoreCopyRequester() {
@Override
public Response<?> copyStore(StoreWriter writer) {
return masterClient.copyStore(new RequestContext(0, config.get(ClusterSettings.server_id).toIntegerIndex(), 0, BASE_TX_ID, 0), writer);
}
@Override
public void done() {
// Nothing to clean up here
}
};
MoveAfterCopy moveAfterCopyWithLogging = (moves, fromDirectory, toDirectory) -> {
userLog.info("Copied store from master to " + fromDirectory);
msgLog.info("Starting post copy operation to move store from " + fromDirectory + " to " + storeDir);
moveAfterCopy.move(moves, fromDirectory, toDirectory);
};
storeCopyClient.copyStore(requester, cancellationRequest, moveAfterCopyWithLogging);
startServicesAgain();
userLog.info("Finished copying store from master");
} catch (Throwable t) {
// Delete store so that we can copy from master without conflicts next time
cleanStoreDir();
throw t;
}
}
Aggregations