use of com.canoo.platform.remoting.DolphinRemotingException in project dolphin-platform by canoo.
the class ClientContextImpl method disconnect.
@Override
public synchronized CompletableFuture<Void> disconnect() {
final CompletableFuture<Void> result = new CompletableFuture<>();
clientConfiguration.getBackgroundExecutor().execute(() -> {
dolphinCommandHandler.invokeDolphinCommand(new DestroyContextCommand()).handle((Void aVoid, Throwable throwable) -> {
clientConnector.disconnect();
clientSessionStore.resetSession(endpoint);
if (throwable != null) {
result.completeExceptionally(new DolphinRemotingException("Can't disconnect", throwable));
} else {
result.complete(null);
}
return null;
});
});
return result;
}
use of com.canoo.platform.remoting.DolphinRemotingException in project dolphin-platform by canoo.
the class DolphinPlatformHttpClientConnector method transmit.
public List<Command> transmit(final List<Command> commands) throws DolphinRemotingException {
Assert.requireNonNull(commands, "commands");
if (disconnecting.get()) {
LOG.warn("Canceled communication based on disconnect");
return Collections.emptyList();
}
// block if diconnect is called in other thread (poll / release)
for (Command command : commands) {
if (command instanceof DestroyContextCommand) {
disconnecting.set(true);
}
}
try {
final String data = codec.encode(commands);
final String receivedContent = client.request(servletUrl, RequestMethod.POST).withContent(data, HttpHeaderConstants.JSON_MIME_TYPE).readString().execute().get().getContent();
return codec.decode(receivedContent);
} catch (final Exception e) {
throw new DolphinRemotingException("Error in remoting layer", e);
}
}
Aggregations