<T> T decode(byte[] bytes) { return serializer.decode(bytes); }
/** * Decodes the given object using the configured {@link #serializer}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ protected <T> T decode(byte[] bytes) { return bytes != null ? serializer.decode(bytes) : null; }
/** * Decodes the given object using the configured {@link #serializer}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ protected <T> T decode(byte[] bytes) { return bytes != null ? serializer.decode(bytes) : null; }
/** * Decodes an internal object. * * @param bytes the bytes to decode * @param <T> the object type * @return the internal object */ private <T> T decodeInternal(byte[] bytes) { return INTERNAL_SERIALIZER.decode(bytes); }
/** * Decodes the given object using the configured {@link #serializer}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ private <T> T decode(byte[] bytes) { return bytes != null ? serializer.decode(bytes) : null; }
/** * Decodes the given object using the configured {@link #userSerializer}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ protected <T> T decode(byte[] bytes) { return bytes != null ? userSerializer.decode(bytes) : null; }
/** * Decodes the given object using the configured {@link #serializer}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ private <T> T decode(byte[] bytes) { return bytes != null ? serializer.decode(bytes) : null; }
/** * Decodes the given element from a string. * * @param element the element to decode * @return the decoded element */ protected E decode(String element) { return elementSerializer.decode(BaseEncoding.base16().decode(element)); }
/** * Decodes the given value from a string. * * @param value the value to decode * @return the decoded value */ protected V decode(String value) { return valueSerializer.decode(BaseEncoding.base16().decode(value)); }
<T> T copy(T value) { return serializer.decode(serializer.encode(value)); }
/** * Decodes the given object using the configured {@link #serializer()}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ protected <T> T decode(byte[] bytes) { return bytes != null ? serializer().decode(bytes) : null; }
/** * Decodes the given object using the configured {@link #serializer()}. * * @param bytes the bytes to decode * @param <T> the object type * @return the decoded object */ protected <T> T decode(byte[] bytes) { return bytes != null ? serializer().decode(bytes) : null; }
@Override public <U> U readObject() { return input.readObject(bytes -> bytes != null ? serializer.decode(bytes) : null); }
protected <T, U> void registerHandler(String type, Function<T, CompletableFuture<U>> handler) { messagingService.registerHandler(type, (e, p) -> { CompletableFuture<byte[]> future = new CompletableFuture<>(); handler.apply(serializer.decode(p)).whenComplete((result, error) -> { if (error == null) { future.complete(serializer.encode(result)); } else { future.completeExceptionally(error); } }); return future; }); }
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { messagingService.registerHandler(String.format("reset-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
@Override public void registerPublishListener(SessionId sessionId, Consumer<PublishRequest> listener, Executor executor) { messagingService.registerHandler(String.format("publish-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
@Override public void registerPublishListener(SessionId sessionId, Consumer<PublishRequest> listener, Executor executor) { messagingService.registerHandler(String.format("publish-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { messagingService.registerHandler(String.format("reset-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
@Override protected void channelRead0(ChannelHandlerContext context, DatagramPacket packet) throws Exception { byte[] payload = new byte[packet.content().readInt()]; packet.content().readBytes(payload); Message message = SERIALIZER.decode(payload); Map<BiConsumer<Address, byte[]>, Executor> listeners = NettyUnicastService.this.listeners.get(message.subject()); if (listeners != null) { listeners.forEach((consumer, executor) -> executor.execute(() -> consumer.accept(message.source(), message.payload()))); } } })
private void handleBroadcastMessage(byte[] message) { Node node = SERIALIZER.decode(message); Node oldNode = nodes.put(node.id(), node); if (oldNode != null && !oldNode.id().equals(node.id())) { post(new NodeDiscoveryEvent(NodeDiscoveryEvent.Type.LEAVE, oldNode)); post(new NodeDiscoveryEvent(NodeDiscoveryEvent.Type.JOIN, node)); } else if (oldNode == null) { post(new NodeDiscoveryEvent(NodeDiscoveryEvent.Type.JOIN, node)); } updateTimes.put(node.id(), System.currentTimeMillis()); }