use of com.eightkdata.mongowp.client.core.MongoConnection.RemoteCommandResponse in project torodb by torodb.
the class RecoveryService method cloneDatabases.
private void cloneDatabases(@Nonnull MongoClient remoteClient) throws CloningException, MongoException, UserException {
enableDataImportMode();
try {
Stream<String> dbNames;
try (MongoConnection remoteConnection = remoteClient.openConnection()) {
RemoteCommandResponse<ListDatabasesReply> remoteResponse = remoteConnection.execute(ListDatabasesCommand.INSTANCE, "admin", true, Empty.getInstance());
if (!remoteResponse.isOk()) {
throw remoteResponse.asMongoException();
}
dbNames = remoteResponse.getCommandReply().get().getDatabases().stream().map(db -> db.getName());
}
dbNames.filter(this::isReplicable).forEach(databaseName -> {
MyWritePermissionSupplier writePermissionSupplier = new MyWritePermissionSupplier(databaseName);
CloneOptions options = new CloneOptions(true, true, true, false, databaseName, Collections.<String>emptySet(), writePermissionSupplier, (colName) -> replFilters.getCollectionPredicate().test(databaseName, colName), (collection, indexName, unique, keys) -> replFilters.getIndexPredicate().test(databaseName, collection, indexName, unique, keys));
try {
cloner.cloneDatabase(databaseName, remoteClient, server, options);
} catch (MongoException ex) {
throw new CloningException(ex);
}
});
} finally {
disableDataImportMode();
}
}
use of com.eightkdata.mongowp.client.core.MongoConnection.RemoteCommandResponse in project torodb by torodb.
the class TopologyHeartbeatHandler method doHeartbeat.
@GuardedBy("executor")
private void doHeartbeat(final TopologyCoordinator coord, final HostAndPort target) {
if (stopped) {
LOGGER.trace("Ignoring heartbeat to {} because the handler has " + "been stopped", target);
return;
}
Instant start = clock.instant();
RemoteCommandRequest<ReplSetHeartbeatArgument> request = coord.prepareHeartbeatRequest(start, replSetName, target);
CompletableFuture<RemoteCommandResponse<ReplSetHeartbeatReply>> hbHandle = networkHandler.sendHeartbeat(request).exceptionally(t -> onNetworkError(t, target, start));
executor.onCurrentVersion().andThenAcceptAsync(hbHandle, (coord2, response) -> handleHeartbeatResponse(coord2, target, request.getCmdObj(), response));
}
Aggregations