use of org.apache.ignite.internal.network.handshake.HandshakeException 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.internal.network.handshake.HandshakeException in project ignite-3 by apache.
the class RecoveryServerHandshakeManager method onMessage.
/**
* {@inheritDoc}
*/
@Override
public HandshakeResult onMessage(Channel channel, NetworkMessage message) {
if (message instanceof HandshakeStartResponseMessage) {
HandshakeStartResponseMessage msg = (HandshakeStartResponseMessage) message;
UUID remoteLaunchId = msg.launchId();
String remoteConsistentId = msg.consistentId();
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.internal.network.handshake.HandshakeException 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();
}
use of org.apache.ignite.internal.network.handshake.HandshakeException in project ignite-3 by apache.
the class HandshakeHandler method channelInactive.
/**
* {@inheritDoc}
*/
@Override
public void channelInactive(ChannelHandlerContext ctx) {
// If this method is called that means channel has been closed before handshake has finished or handshake
// has failed.
manager.handshakeFuture().completeExceptionally(new HandshakeException("Channel has been closed before handshake has finished or handshake has failed"));
ctx.fireChannelInactive();
}
Aggregations