use of org.apache.ignite.network.OutNetworkObject in project ignite-3 by apache.
the class RecoveryClientHandshakeManager method onMessage.
/**
* {@inheritDoc}
*/
@Override
public HandshakeResult onMessage(Channel channel, NetworkMessage message) {
if (message instanceof HandshakeStartMessage) {
HandshakeStartMessage msg = (HandshakeStartMessage) message;
UUID remoteLaunchId = msg.launchId();
String remoteConsistentId = msg.consistentId();
HandshakeStartResponseMessage response = messageFactory.handshakeStartResponseMessage().launchId(launchId).consistentId(consistentId).receivedCount(0).connectionsCount(0).build();
ChannelFuture sendFuture = channel.writeAndFlush(new OutNetworkObject(response, Collections.emptyList()));
NettyUtils.toCompletableFuture(sendFuture).whenComplete((unused, throwable) -> {
if (throwable != null) {
handshakeCompleteFuture.completeExceptionally(new HandshakeException("Failed to send handshake response: " + throwable.getMessage(), throwable));
} else {
handshakeCompleteFuture.complete(new NettySender(channel, remoteLaunchId.toString(), remoteConsistentId));
}
});
return HandshakeResult.removeHandler(remoteLaunchId, remoteConsistentId);
}
handshakeCompleteFuture.completeExceptionally(new HandshakeException("Unexpected message during handshake: " + message.toString()));
return HandshakeResult.fail();
}
use of org.apache.ignite.network.OutNetworkObject in project ignite-3 by apache.
the class RecoveryServerHandshakeManager method onConnectionOpen.
/**
* {@inheritDoc}
*/
@Override
public HandshakeResult onConnectionOpen(Channel channel) {
HandshakeStartMessage handshakeStartMessage = messageFactory.handshakeStartMessage().launchId(launchId).consistentId(consistentId).build();
ChannelFuture sendFuture = channel.writeAndFlush(new OutNetworkObject(handshakeStartMessage, Collections.emptyList()));
NettyUtils.toCompletableFuture(sendFuture).whenComplete((unused, throwable) -> {
if (throwable != null) {
handshakeCompleteFuture.completeExceptionally(new HandshakeException("Failed to send handshake start message: " + throwable.getMessage(), throwable));
}
});
return HandshakeResult.noOp();
}
Aggregations