/** * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param recovery used to recover from concurrent modifications */ SingleTableStore(@NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, @NotNull StoreRecovery recovery, @NotNull T metadata) { this.wireType = wireType; this.metadata = metadata; this.recovery = recovery; this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); mappedWire = wireType.apply(mappedBytes); }
@NotNull private static Object[] testConfiguration(final WireType binary, final boolean encrypted) { return new Object[]{binary.name() + " - " + (encrypted ? "" : "not ") + "encrypted", binary, encrypted}; }
chronicleReader.withWireType(WireType.valueOf(commandLine.getOptionValue('w')));
SCQIndexing(@NotNull WireType wireType, int indexCount, int indexSpacing) { this(indexCount, indexSpacing, wireType.newLongReference().get(), wireType.newLongReference().get(), wireType.newLongArrayReference()); }
@Override public boolean writeEOF(@NotNull Wire wire, long timeoutMS) { String fileName = mappedFile.file().getAbsolutePath(); // just in case we are about to release this if (wire.bytes().tryReserve()) { try { wire.writeEndOfWire(timeoutMS, TimeUnit.MILLISECONDS, writePosition()); if (wire.bytes().writePosition() > 4 && Wires.isEndOfFile(wire.bytes().readVolatileInt(wire.bytes().writePosition() - 4))) { // only if we just written EOF QueueFileShrinkManager.scheduleShrinking(mappedFile.file(), wire.bytes().writePosition()); return true; } } finally { wire.bytes().release(); } } else { try (MappedBytes bytes = MappedBytes.mappedBytes(mappedFile.file(), mappedFile.chunkSize())) { Wire wire0 = WireType.valueOf(wire).apply(bytes); wire0.writeEndOfWire(timeoutMS, TimeUnit.MILLISECONDS, writePosition()); if (wire.bytes().writePosition() > 4 && Wires.isEndOfFile(wire.bytes().readVolatileInt(wire.bytes().writePosition() - 4))) { QueueFileShrinkManager.scheduleShrinking(mappedFile.file(), wire.bytes().writePosition()); return true; } } catch (Exception e) { Jvm.warn().on(getClass(), "unable to write the EOF file=" + fileName, e); } } return false; }
public TimedStoreRecovery(@NotNull WireType wireType) { timeStamp = wireType.newLongReference().get(); }
private String extraInfo(@NotNull ExcerptTailer tailer, @NotNull VanillaMessageHistory messageHistory) { return String.format( ". That sourceIndex was determined fom the last entry written to queue %s " + "(message index %s, message history %s). If source queue is replicated then " + "sourceIndex may not have been replicated yet", tailer.queue().fileAbsolutePath(), Long.toHexString(tailer.index()), WireType.TEXT.asString(messageHistory)); }
/** * @param rollCycle the current rollCycle * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param indexCount the number of entries in each index. * @param indexSpacing the spacing between indexed entries. */ public SingleChronicleQueueStore(@NotNull RollCycle rollCycle, @NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, int indexCount, int indexSpacing) { this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); indexCount = Maths.nextPower2(indexCount, 8); indexSpacing = Maths.nextPower2(indexSpacing, 1); this.indexing = new SCQIndexing(wireType, indexCount, indexSpacing); this.indexing.writePosition = this.writePosition = wireType.newTwoLongReference().get(); this.indexing.sequence = this.sequence = new RollCycleEncodeSequence(writePosition, rollCycle.defaultIndexCount(), rollCycle.defaultIndexSpacing()); }
SCQIndexing(@NotNull WireType wireType, int indexCount, int indexSpacing) { this(indexCount, indexSpacing, wireType.newLongReference().get(), wireType.newLongReference().get(), wireType.newLongArrayReference()); }
mappedBytes.writePosition(mappedBytes.readPosition()); long pos = recovery.writeHeader(mappedWire, safeLength, timeoutMS, null, null); LongValue longValue = wireType.newLongReference().get(); mappedWire.writeEventName(key).int64forBinding(defaultValue, longValue); mappedWire.writeAlignTo(Integer.BYTES, 0);
private String extraInfo(@NotNull ExcerptTailer tailer, @NotNull VanillaMessageHistory messageHistory) { return String.format( ". That sourceIndex was determined fom the last entry written to queue %s " + "(message index %s, message history %s). If source queue is replicated then " + "sourceIndex may not have been replicated yet", tailer.queue().fileAbsolutePath(), Long.toHexString(tailer.index()), WireType.TEXT.asString(messageHistory)); }
/** * @param rollCycle the current rollCycle * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param indexCount the number of entries in each index. * @param indexSpacing the spacing between indexed entries. */ public SingleChronicleQueueStore(@NotNull RollCycle rollCycle, @NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, int indexCount, int indexSpacing) { this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); indexCount = Maths.nextPower2(indexCount, 8); indexSpacing = Maths.nextPower2(indexSpacing, 1); this.indexing = new SCQIndexing(wireType, indexCount, indexSpacing); this.indexing.writePosition = this.writePosition = wireType.newTwoLongReference().get(); this.indexing.sequence = this.sequence = new RollCycleEncodeSequence(writePosition, rollCycle.defaultIndexCount(), rollCycle.defaultIndexSpacing()); }
private void resetWires(@NotNull ChronicleQueue queue) { WireType wireType = queue.wireType(); { Wire oldw = this.wire; this.wire = wireType.apply(store.bytes()); closableResources.wireReference = this.wire.bytes(); assert wire != oldw; if (oldw != null) { releaseWireResources(oldw); } } { Wire old = this.wireForIndex; this.wireForIndex = wireType.apply(store.bytes()); closableResources.wireForIndexReference = wireForIndex.bytes(); assert wire != old; if (old != null) { releaseWireResources(old); } } }
private boolean checkEnterpriseFeaturesRequested() { boolean result = false; if (readBufferMode != BufferMode.None) result = onlyAvailableInEnterprise("Buffering"); if (writeBufferMode != BufferMode.None) result = onlyAvailableInEnterprise("Buffering"); if (rollTimeZone != null && !rollTimeZone.getId().equals("UTC") && !rollTimeZone.getId().equals("Z")) result = onlyAvailableInEnterprise("Non-UTC roll time zone"); if (wireType == WireType.DELTA_BINARY) result = onlyAvailableInEnterprise("Wire type " + wireType.name()); if (encodingSupplier != null) result = onlyAvailableInEnterprise("Encoding"); if (key != null) result = onlyAvailableInEnterprise("Encryption"); if (hasPretouchIntervalMillis()) result = onlyAvailableInEnterprise("Out of process pretouching"); return result; }
chronicleReader.withWireType(WireType.valueOf(commandLine.getOptionValue('w')));
public TimedStoreRecovery(@NotNull WireType wireType) { timeStamp = wireType.newLongReference().get(); }
@Override public void accept(final WireIn wireIn, final Consumer<String> messageHandler) { long elementCount = 0; while (wireIn.hasMore()) { new BinaryWire(wireIn.bytes()).copyOne(wireType.apply(textConversionTarget)); elementCount++; if ((elementCount & 1) == 0) { messageHandler.accept(textConversionTarget.toString()); textConversionTarget.clear(); } } }
private boolean checkEnterpriseFeaturesRequested() { boolean result = false; if (readBufferMode != BufferMode.None) result = onlyAvailableInEnterprise("Buffering"); if (writeBufferMode != BufferMode.None) result = onlyAvailableInEnterprise("Buffering"); if (rollTimeZone != null && !rollTimeZone.getId().equals("UTC") && !rollTimeZone.getId().equals("Z")) result = onlyAvailableInEnterprise("Non-UTC roll time zone"); if (wireType == WireType.DELTA_BINARY) result = onlyAvailableInEnterprise("Wire type " + wireType.name()); if (encodingSupplier != null) result = onlyAvailableInEnterprise("Encoding"); if (key != null) result = onlyAvailableInEnterprise("Encryption"); if (hasPretouchIntervalMillis()) result = onlyAvailableInEnterprise("Out of process pretouching"); return result; }
@NotNull private WireParser<Void> wireParser() { @NotNull final WireParser<Void> parser = new VanillaWireParser<>((s, v, $) -> { }); parser.register(EventId.domain::toString, (s, v, $) -> v.text(this, (o, x) -> o.sessionDetails.domain(x))); parser.register(EventId.sessionMode::toString, (s, v, $) -> v.text(this, (o, x) -> o .sessionDetails.sessionMode(SessionMode.valueOf(x)))); parser.register(EventId.securityToken::toString, (s, v, $) -> v.text(this, (o, x) -> o .sessionDetails.securityToken(x))); parser.register(EventId.clientId::toString, (s, v, $) -> v.text(this, (o, x) -> o .sessionDetails.clientId(UUID.fromString(x)))); parser.register(EventId.wireType::toString, (s, v, $) -> v.text(this, (o, x) -> o .sessionDetails.wireType(WireType.valueOf(x)))); parser.register(EventId.hostId::toString, (s, v, $) -> v.int8(this, (o, x) -> o .sessionDetails.hostId(x))); return parser; }
mappedBytes.writePosition(mappedBytes.readPosition()); long pos = recovery.writeHeader(mappedWire, safeLength, timeoutMS, null, null); LongValue longValue = wireType.newLongReference().get(); mappedWire.writeEventName(key).int64forBinding(defaultValue, longValue); mappedWire.writeAlignTo(Integer.BYTES, 0);