use of org.neo4j.com.RequestContext 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;
}
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class MasterClient214 method createPropertyKey.
@Override
public Response<Integer> createPropertyKey(RequestContext context, final String name) {
Serializer serializer = buffer -> writeString(buffer, name);
Deserializer<Integer> deserializer = (buffer, temporaryBuffer) -> buffer.readInt();
return sendRequest(requestTypes.type(HaRequestTypes.Type.CREATE_PROPERTY_KEY), context, serializer, deserializer);
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class SlaveUpdatePuller method doPullUpdates.
private void doPullUpdates() {
try {
RequestContext context = requestContextFactory.newRequestContext();
try (Response<Void> ignored = master.pullUpdates(context)) {
// Updates would be applied as part of response processing
monitor.pulledUpdates(context.lastAppliedTransaction());
}
invalidEpochCappedLogger.reset();
comExceptionCappedLogger.reset();
} catch (InvalidEpochException e) {
invalidEpochHandler.handle();
invalidEpochCappedLogger.warn("Pull updates by " + this + " failed at the epoch check", e);
} catch (ComException e) {
invalidEpochCappedLogger.warn("Pull updates by " + this + " failed due to network error.", e);
} catch (Throwable e) {
logger.error("Pull updates by " + this + " failed", e);
}
lastUpdateTime.setLastUpdateTime(currentTimeMillis());
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class BackupImpl method fullBackup.
@Override
public Response<Void> fullBackup(StoreWriter writer, boolean forensics) {
try (StoreWriter storeWriter = writer) {
logger.log("Full backup started...");
RequestContext copyStartContext = storeCopyServer.flushStoresAndStreamStoreFiles(FULL_BACKUP_CHECKPOINT_TRIGGER, storeWriter, forensics);
ResponsePacker responsePacker = new StoreCopyResponsePacker(logicalTransactionStore, transactionIdStore, logFileInformation, storeId, copyStartContext.lastAppliedTransaction() + 1, // mandatory transaction id
storeCopyServer.monitor());
long optionalTransactionId = copyStartContext.lastAppliedTransaction();
return responsePacker.packTransactionStreamResponse(anonymous(optionalTransactionId), null);
} finally {
logger.log("Full backup finished.");
}
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class MasterImpl method getOngoingTransactions.
// =====================================================================
// Just some methods which aren't really used when running a HA cluster,
// but exposed so that other tools can reach that information.
// =====================================================================
public Map<Integer, Collection<RequestContext>> getOngoingTransactions() {
Map<Integer, Collection<RequestContext>> result = new HashMap<>();
Set<RequestContext> contexts = conversationManager.getActiveContexts();
for (RequestContext context : contexts.toArray(new RequestContext[contexts.size()])) {
Collection<RequestContext> txs = result.computeIfAbsent(context.machineId(), k -> new ArrayList<>());
txs.add(context);
}
return result;
}
Aggregations