@NotNull public static WriteMarshallable newMapReplicationHandler(long lastUpdateTime, @NotNull Class keyType, @NotNull Class valueType, String csp, long cid) { @NotNull final MapReplicationHandler h = new MapReplicationHandler (lastUpdateTime, keyType, valueType); return w -> w.writeDocument(true, d -> d.writeEventName(CoreFields.csp).text(csp) .writeEventName(CoreFields.cid).int64(cid) .writeEventName(CoreFields.handler).typedMarshallable(h)); }
outWire.writeDocument(true, wire -> outWire.writeEventName(CoreFields.tid).int64(tid));
private static WriteMarshallable heartbeatHandler(final long heartbeatTimeoutMs, final long heartbeatIntervalMs, final long cid) { return w -> w.writeDocument(true, d -> d.writeEventName(CoreFields.csp).text("/") .writeEventName(CoreFields.cid).int64(cid) .writeEventName(CoreFields.handler).typedMarshallable(new HeartbeatHandler(heartbeatTimeoutMs, heartbeatIntervalMs))); }
@Override public void onInitialize(@NotNull WireOut outWire) { if (nc().isAcceptor()) heartbeatHandler(heartbeatTimeoutMs, heartbeatIntervalMs, cid()).writeMarshallable (outWire); @NotNull final WriteMarshallable heartbeatMessage = w -> { w.writeDocument(true, d -> d.write(CoreFields.cid).int64(cid())); w.writeDocument(false, d -> d.write(() -> "heartbeat").text("")); }; connectionMonitor = nc().acquireConnectionListener(); timer = new Timer(nc().rootAsset().findOrCreateView(EventLoop.class)); startPeriodicHeartbeatCheck(); startPeriodicallySendingHeartbeats(heartbeatMessage); }
/** * write and exceptions and rolls back if no data was written */ void writeData(boolean isNotComplete, @NotNull Bytes inBytes, @NotNull WriteMarshallable c) { @NotNull final WriteMarshallable marshallable = out -> { final long readPosition = inBytes.readPosition(); final long position = outWire.bytes().writePosition(); try { c.writeMarshallable(outWire); } catch (Throwable t) { inBytes.readPosition(readPosition); if (LOG.isInfoEnabled()) LOG.info("While reading " + inBytes.toDebugString(), " processing wire " + c, t); outWire.bytes().writePosition(position); outWire.writeEventName(() -> "exception").throwable(t); } // write 'reply : {} ' if no data was sent if (position == outWire.bytes().writePosition()) { outWire.writeEventName(reply).marshallable(EMPTY); } }; if (isNotComplete) outWire.writeNotCompleteDocument(false, marshallable); else outWire.writeDocument(false, marshallable); logYaml(); }
outWire.writeDocument(true, wire -> outWire.writeEventName(tid).int64(inputTid));
publisher.put(key, publish -> { publish.writeDocument(true, wire -> wire.writeEventName(tid).int64 (inputTid)); publish.writeNotCompleteDocument(false, wire -> wire.writeEventName(reply)
/** * write and exceptions and rolls back if no data was written */ void writeData(@NotNull WireIn wireIn, @NotNull WriteMarshallable c) { @NotNull Bytes inBytes = wireIn.bytes(); outWire.writeDocument(false, out -> { final long readPosition = inBytes.readPosition(); final long position = outWire.bytes().writePosition(); try { c.writeMarshallable(outWire); } catch (Throwable t) { final String readingYaml = wireIn.readingPeekYaml(); inBytes.readPosition(readPosition); if (LOG.isInfoEnabled()) LOG.info("While readingBytes=" + inBytes.toDebugString() + "\nreadingYaml=" + readingYaml, "\nprocessing wire " + c, t); outWire.bytes().writePosition(position); outWire.writeEventName(() -> "readingYaml").text(readingYaml); outWire.writeEventName(() -> "exception").throwable(t); } // write 'reply : {} ' if no data was sent if (position == outWire.bytes().writePosition()) { outWire.writeEventName(reply).marshallable(EMPTY); } }); logYaml(); }
final ValueIn valueIn = inWire.readEventName(eventName); outWire.writeDocument(true, w -> w.writeEventName(CoreFields.tid).int64 (CollectionWireHandler.this.tid)); outWire.writeDocument(false, out -> {
w.writeDocument(true, d -> d.write(CoreFields.cid).int64(cid())); w.writeDocument(false, d -> { d.writeEventName(CoreFields.lastUpdateTime).int64(lastUpdateTime); d.write(() -> "id").int8(id); w.writeDocument(true, d -> d.write(CoreFields.cid).int64(cid())); w.writeDocument(false, d -> { d.writeEventName(replicationEvent).marshallable(e);
nc.wireOutPublisher().publish(w -> w.writeDocument(true, d -> d.writeEventName(CoreFields.csp).text(csp) .writeEventName(CoreFields.cid).int64(cid)
outWire.writeDocument(true, wire -> outWire.writeEventName(CoreFields.tid).int64(tid));
outWire.writeDocument(true, d -> { @NotNull final String fullName = requestContext.fullName(); outWire.write(CoreFields.csp).text(fullName + "?view=Replication") }); outWire.writeDocument(false, d -> outWire.write(bootstrap) .int64(replication.lastModificationTime(remoteIdentifier)) .writeComment("localIdentifier=" + hostId.hostId() + outWire.writeDocument(true, wire -> outWire.writeEventName(CoreFields.tid).int64(tid));
outWire.writeDocument(true, wire -> outWire.writeEventName(tid).int64(inputTid)); writeData(inWire, out -> {
outWire.writeDocument(true, wire -> outWire.writeEventName(tid).int64(inputTid));
outWire.writeDocument(true, wire -> outWire.writeEventName(CoreFields.tid).int64(tid));
outWire.writeDocument(true, wire -> outWire.writeEventName(CoreFields.tid).int64(tid));
try { outWire.writeDocument(true, wire -> outWire.writeEventName(CoreFields.tid).int64(tid));