private static MessageHistory readHistoryFromWire(final Wire wire, MessageHistory history) { final StringBuilder sb = SBP.acquireStringBuilder(); ValueIn valueIn = wire.read(sb); if (!MethodReader.HISTORY.contentEquals(sb)) return null; valueIn.object(history, MessageHistory.class); return history; }
/** * used by {@link Demarshallable} * * @param wire a wire */ @UsedViaReflection private SCQRoll(@NotNull WireIn wire) { length = wire.read(RollFields.length).int32(); format = wire.read(RollFields.format).text(); epoch = wire.read(RollFields.epoch).int64(); ValueIn rollTimeVIN = wire.read(RollFields.rollTime); if (rollTimeVIN.hasNext()) rollTime = rollTimeVIN.time(); String zoneId = wire.read(RollFields.rollTimeZone).text(); if (zoneId != null) rollTimeZone = ZoneId.of(zoneId); else rollTimeZone = null; }
@Nullable static SingleChronicleQueueStore loadStore(@NotNull Wire wire) { final StringBuilder eventName = new StringBuilder(); wire.readEventName(eventName); if (eventName.toString().equals(MetaDataKeys.header.name())) { final SingleChronicleQueueStore store = wire.read().typedMarshallable(); if (store == null) { throw new IllegalArgumentException("Unable to load wire store"); } return store; } LOGGER.warn("Unable to load store file from input. Queue file may be corrupted."); return null; }
/** * used by {@link Demarshallable} * * @param wire a wire */ @UsedViaReflection private SCQIndexing(@NotNull WireIn wire) { this(wire.read(IndexingFields.indexCount).int32(), wire.read(IndexingFields.indexSpacing).int32(), wire.read(IndexingFields.index2Index).int64ForBinding(wire.newLongReference()), wire.read(IndexingFields.lastIndex).int64ForBinding(wire.newLongReference()), wire::newLongArrayReference); }
@SuppressWarnings("unused") @UsedViaReflection SCQMeta(@NotNull WireIn wire) { this.roll = Objects.requireNonNull(wire.read(MetaDataField.roll).typedMarshallable()); this.deltaCheckpointInterval = wire.bytes().readRemaining() > 0 ? wire.read(MetaDataField.deltaCheckpointInterval).int32() : -1; // disabled. this.sourceId = wire.bytes().readRemaining() > 0 ? wire.read(MetaDataField.sourceId).int32() : 0; }
protected void readMarshallableFields(@NotNull WireIn wireIn) { dataFileVersion = wireIn.read(() -> "dataFileVersion").text(); keyClass = wireIn.read(() -> "keyClass").typeLiteral(); keySizeMarshaller = wireIn.read(() -> "keySizeMarshaller").object(SizeMarshaller.class); keyReader = wireIn.read(() -> "keyReader").object(SizedReader.class); keyDataAccess = wireIn.read(() -> "keyDataAccess").object(DataAccess.class); checksumEntries = wireIn.read(() -> "checksumEntries").bool(); actualSegments = wireIn.read(() -> "actualSegments").int32(); hashSplitting = wireIn.read(() -> "hashSplitting").typedMarshallable(); chunkSize = wireIn.read(() -> "chunkSize").int64(); maxChunksPerEntry = wireIn.read(() -> "maxChunksPerEntry").int32(); actualChunksPerSegmentTier = wireIn.read(() -> "actualChunksPerSegmentTier").int64(); segmentHeaderSize = wireIn.read(() -> "segmentHeaderSize").int32(); tierHashLookupValueBits = wireIn.read(() -> "tierHashLookupValueBits").int32(); tierHashLookupKeyBits = wireIn.read(() -> "tierHashLookupKeyBits").int32(); tierHashLookupSlotSize = wireIn.read(() -> "tierHashLookupSlotSize").int32(); tierHashLookupCapacity = wireIn.read(() -> "tierHashLookupCapacity").int64(); maxEntriesPerHashLookup = wireIn.read(() -> "maxEntriesPerHashLookup").int64(); tierHashLookupInnerSize = wireIn.read(() -> "tierHashLookupInnerSize").int64(); tierHashLookupOuterSize = wireIn.read(() -> "tierHashLookupOuterSize").int64(); tierFreeListInnerSize = wireIn.read(() -> "tierFreeListInnerSize").int64(); tierFreeListOuterSize = wireIn.read(() -> "tierFreeListOuterSize").int64();
@Override public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException { wire.read(() -> "spec").text(this, (o, s) -> o.spec = s) .read(() -> "name").text(this, (o, s) -> o.name = s) .read(() -> "cluster").text(this, (o, s) -> o.cluster = s) .read(() -> "maxEntries").int64(this, (o, e) -> o.maxEntries = e) .read(() -> "averageValueSize").int32(this, (o, e) -> o.averageValueSize = e) .read(() -> "putReturnsNull").bool(this, (o, b) -> o.putReturnsNull = b) .read(() -> "removeReturnsNull").bool(this, (o, b) -> o.removeReturnsNull = b); }
@Override public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException { wire.read(MapEventFields.assetName).text(this, (o, s) -> assetName = s); wire.read(MapEventFields.key).object(Object.class, this, (o, x) -> o.key = (K) x); wire.read(MapEventFields.oldValue).object(Object.class, this, (o, x) -> o.oldValue = (V) x); wire.read(MapEventFields.value).object(Object.class, this, (o, x) -> o.value = (V) x); wire.read(MapEventFields.isReplicationEvent).bool(this, (o, x) -> o.isReplicationEvent = x); wire.read(MapEventFields.hasValueChanged).bool(this, (o, x) -> o.hasValueChanged = x); }
@Nullable Bootstrap b = valueIn.typedMarshallable(); valueIn.marshallable(replicatedEntry); Jvm.debug().on(getClass(), "server : received lastUpdateTime"); final long time = valueIn.int64(); final byte id = d.read(() -> "id").int8();
public void process(ValueIn in, Object using){ status = in.int8(); messageCount = in.int64(); time = in.int64(); storedFilter = in.text(); if(status == ReactiveStatus.ERROR){ valueFromQueue = in.throwable(false); }else { if(using== null) { valueFromQueue = in.object(); }else{ valueFromQueue = in.object(using, using.getClass()); } } }
/** * Read next message, forward or backward, depending on the settings of the Tailer * * @param tailer ExcerptTailer * @return entry or null, if no entry available */ private String readNextEntry(@NotNull final ExcerptTailer tailer) { DocumentContext dc = tailer.readingDocument(); try { if (dc.isPresent()) { Object parent = dc.wire().parent(); assert parent == tailer; return dc.wire().read().text(); } return null; } finally { dc.close(); } }
@Override public void onConsumer(@NotNull final WireIn inWire) { inWire.readDocument(null, d -> { StringBuilder sb = Wires.acquireStringBuilder(); @NotNull ValueIn valueIn = d.readEventName(sb); if (reply.contentEquals(sb)) { valueIn.marshallable(m -> { @Nullable final K topic = m.read(() -> "topic").object(kClass); @Nullable final V message = m.read(() -> "message").object(vClass); RemoteKVSSubscription.this.onEvent(topic, message, subscriber); }); } else if (onEndOfSubscription.contentEquals(sb)) { RemoteKVSSubscription.this.onEndOfSubscription(); hub.unsubscribe(tid()); } }); } });
@Override public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException { wire.read(() -> "spec").text(this, (o, s) -> o.spec = s) .read(() -> "name").text(this, (o, s) -> o.name = s) .read(() -> "valueType").typeLiteral(this, (o, t) -> o.valueType = t) .read(() -> "recurse").bool(this, (o, b) -> o.recurse = b); }
@Override public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException { wire.read(() -> "diskPath").text(this, (o, c) -> o.diskPath = c) .read(() -> "keyType").typeLiteral(this, (o, c) -> o.keyType = c) .read(() -> "valueType").typeLiteral(this, (o, c) -> o.valueType = c) .read(() -> "compression").text(this, (o, c) -> o.compression = c) .read(() -> "putReturnsNull").bool(this, (o, e) -> o.putReturnsNull = e) .read(() -> "removeReturnsNull").bool(this, (o, e) -> o.removeReturnsNull = e) .read(() -> "entries").int64(this, (o, e) -> o.entries = e) .read(() -> "averageSize").float64(this, (o, e) -> o.averageSize = e); }
@UsedViaReflection private UberHandler(@NotNull WireIn wire) { remoteIdentifier = wire.read(() -> "remoteIdentifier").int32(); localIdentifier = wire.read(() -> "localIdentifier").int32(); @Nullable final WireType wireType = wire.read(() -> "wireType").object(WireType.class); clusterName = wire.read(() -> "clusterName").text(); wireType(wireType); }
@Override protected void readMarshallableFields(@NotNull WireIn wireIn) { super.readMarshallableFields(wireIn); valueClass = wireIn.read(() -> "valueClass").typeLiteral(); valueSizeMarshaller = wireIn.read(() -> "valueSizeMarshaller").object(SizeMarshaller.class); valueReader = wireIn.read(() -> "valueReader").object(SizedReader.class); valueDataAccess = wireIn.read(() -> "valueDataAccess").object(DataAccess.class); constantlySizedEntry = wireIn.read(() -> "constantlySizedEntry").bool(); alignment = wireIn.read(() -> "alignment").int32(); worstAlignment = wireIn.read(() -> "worstAlignment").int32(); }
@Override public void readMarshallable(@NotNull WireIn wire) throws IORuntimeException { ValueIn valueIn = wire.getValueIn(); for (int i = 0; i < NUMBER_OF_LONGS; i++) assertEquals(i, valueIn.int64()); //Jvm.pause(PAUSE_READ_MS); }
@NotNull private List<Integer> fillResults(@NotNull ExcerptTailer tailer, @NotNull List<Integer> results) { for (int i = 0; i < 10; i++) { try (DocumentContext documentContext = tailer.readingDocument()) { if (!documentContext.isPresent()) break; results.add(documentContext.wire().read(() -> "msg").int32()); } } return results; }
/** * used by {@link Demarshallable} * * @param wire a wire */ @SuppressWarnings("unused") @UsedViaReflection private SingleTableStore(@NotNull WireIn wire) { assert wire.startUse(); try { this.wireType = Objects.requireNonNull(wire.read(MetaDataField.wireType).object(WireType.class)); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); if (wire.bytes().readRemaining() > 0) { this.recovery = Objects.requireNonNull(wire.read(MetaDataField.recovery).typedMarshallable()); } else { this.recovery = new SimpleStoreRecovery(); // disabled. } if (wire.bytes().readRemaining() > 0) { this.metadata = Objects.requireNonNull(wire.read(MetaDataField.metadata).typedMarshallable()); } else { this.metadata = (T) Metadata.NoMeta.INSTANCE; } mappedWire = wireType.apply(mappedBytes); } finally { assert wire.endUse(); } }
private void readDocument(@NotNull ThreadLocal<ExcerptTailer> tlt, String text) { try (DocumentContext dc = tlt.get().readingDocument()) { if (!dc.isPresent()) return; Assert.assertEquals(dc.index(), dc.wire().read(() -> "key").int64()); Assert.assertEquals(text, dc.wire().read(() -> "text").text()); } }