/** * Returns a set of message types that the client handles. * * @return The set of message types this client handles. */ default Set<CorfuMsgType> getHandledTypes() { return getMsgHandler().getHandledTypes(); } }
/** * Handle a incoming message on the channel. * * @param msg The incoming message * @param ctx The channel handler context */ default void handleMessage(CorfuMsg msg, ChannelHandlerContext ctx) { getMsgHandler().handle(msg, ctx); }
@Override Set<IClient> getClientsForTest() { ManagementHandler managementHandler = new ManagementHandler(); client = new ManagementClient(router, 0L); return new ImmutableSet.Builder<IClient>() .add(new BaseHandler()) .add(managementHandler) .build(); }
@Override Set<IClient> getClientsForTest() { LayoutHandler layoutHandler = new LayoutHandler(); client = new LayoutClient(router, 0L); return new ImmutableSet.Builder<IClient>() .add(new BaseHandler()) .add(layoutHandler) .build(); }
@Override Set<IClient> getClientsForTest() { LogUnitHandler logUnitHandler = new LogUnitHandler(); client = new LogUnitClient(router, 0L); return new ImmutableSet.Builder<IClient>() .add(new BaseHandler()) .add(logUnitHandler) .build(); }
@Override public ChannelFuture write(Object o) { ByteBuf b = simulateSerialization(o); sendMessageAsync(b,o); return null; }
@Override Set<IClient> getClientsForTest() { SequencerHandler sequencerHandler = new SequencerHandler(); client = new SequencerClient(router, 0L); return new ImmutableSet.Builder<IClient>() .add(sequencerHandler) .build(); }
@Override Set<IClient> getClientsForTest() { BaseHandler baseHandler = new BaseHandler(); client = new BaseClient(router, 0L); return new ImmutableSet.Builder<IClient>() .add(baseHandler) .build(); }
/** * Send a one way message using the default channel handler, * without adding a completable future. * * @param message The message to send. */ default void sendMessage(CorfuMsg message) { sendMessage(null, message); }
@Override public LayoutClient getClient(long epoch) { return new LayoutClient(router, epoch); }
/** * Handle an WRITE_OK message. * * @param msg Incoming Message * @param ctx Context * @param r Router * @return True, since this indicates success. */ @ClientHandler(type = CorfuMsgType.WRITE_OK) private static Object handleOk(CorfuMsg msg, ChannelHandlerContext ctx, IClientRouter r) { return true; }
/** * Send a message using the router channel handler and * get a completable future to be fulfilled by the reply. * * @param message The message to send. * @param <T> The type of completable to return. * @return A completable future which will be fulfilled by the reply, * or a timeout in the case there is no response. */ default <T> CompletableFuture<T> sendMessageAndGetCompletable(CorfuMsg message) { return sendMessageAndGetCompletable(null, message); }
@Override public ChannelFuture write(Object o, ChannelPromise channelPromise) { ByteBuf b = simulateSerialization(o); sendMessageAsync(b,o); return null; }
/** * Handle a NACK response from the server. * * @param msg The ping request message * @param ctx The context the message was sent under * @param r A reference to the router * @return Always True, since the ACK message was successful. */ @ClientHandler(type = CorfuMsgType.NACK) private static Object handleNack(CorfuMsg msg, ChannelHandlerContext ctx, IClientRouter r) { return false; }
@Override public ChannelFuture writeAndFlush(Object o) { ByteBuf b = simulateSerialization(o); sendMessageAsync(b,o); return null; }
/** * Handle a pong response from the server. * * @param msg The ping request message * @param ctx The context the message was sent under * @param r A reference to the router * @return Always True, since the ping message was successful. */ @ClientHandler(type = CorfuMsgType.PONG) private static Object handlePong(CorfuMsg msg, ChannelHandlerContext ctx, IClientRouter r) { return true; }
@Override public ChannelFuture writeAndFlush(Object o, ChannelPromise channelPromise) { ByteBuf b = simulateSerialization(o); sendMessageAsync(b,o); return null; }
/** * Handle an ACK response from the server. * * @param msg The ping request message * @param ctx The context the message was sent under * @param r A reference to the router * @return Always True, since the ACK message was successful. */ @ClientHandler(type = CorfuMsgType.ACK) private static Object handleAck(CorfuMsg msg, ChannelHandlerContext ctx, IClientRouter r) { return true; }