return ScanResult.NOT_REACHED; bytes.readSkip(Wires.lengthOf(header)); continue;
private long writeHeader(@NotNull Wire wire, int safeLength) { Bytes<?> bytes = wire.bytes(); // writePosition points at the last record in the queue, so we can just skip it and we're ready for write long pos = position; long lastPos = store.writePosition(); if (pos < lastPos) { // queue moved since we last touched it - recalculate header number try { wire.headerNumber(queue.rollCycle().toIndex(cycle, store.lastSequenceNumber(this))); } catch (StreamCorruptedException ex) { Jvm.warn().on(getClass(), "Couldn't find last sequence", ex); } } int header = bytes.readVolatileInt(lastPos); assert header != NOT_INITIALIZED; lastPos += lengthOf(bytes.readVolatileInt(lastPos)) + SPB_HEADER_SIZE; bytes.writePosition(lastPos); return wire.enterHeader(safeLength); }
int len = Wires.lengthOf(header); assert Wires.isReady(header); bytes.readSkip(len);
long moveToEnd(final Wire wire) { Sequence sequence1 = this.sequence; if (sequence1 != null) { for (int i = 0; i < 128; i++) { long endAddress = writePosition.getVolatileValue(); if (endAddress == 0) return -1; long sequence = sequence1.getSequence(endAddress); if (sequence == Sequence.NOT_FOUND_RETRY) continue; if (sequence == Sequence.NOT_FOUND) return -1; Bytes<?> bytes = wire.bytes(); bytes.readPosition(endAddress); for (; ; ) { int header = bytes.readVolatileInt(endAddress); if (header == 0 || Wires.isNotComplete(header)) return sequence; int len = Wires.lengthOf(header) + 4; bytes.readSkip(len); endAddress += len; if (Wires.isData(header)) sequence += 1; } } } return -1; }
public int getWritingThreadId() { final WireStore wireStore = queue.storeForCycle(queue.cycle(), queue.epoch(), false); if (wireStore != null) { final long position = wireStore.writePosition(); final int header = wireStore.bytes().readVolatileInt(position); if (Wires.isReady(header)) { final long nextHeaderPosition = position + Wires.lengthOf(header) + Wires.SPB_HEADER_SIZE; final int unfinishedHeader = wireStore.bytes(). readVolatileInt(nextHeaderPosition); if (Wires.isNotComplete(unfinishedHeader) && unfinishedHeader != 0) { return Wires.extractTidFromHeader(unfinishedHeader); } } } return NO_CURRENT_WRITER; } }
break; long readPosition = mappedBytes.readPosition(); int length = Wires.lengthOf(header); ValueIn valueIn = mappedWire.readEventName(sb); if (StringUtils.equalsCaseIgnore(key, sb)) {
private void removeEOF(Path path) throws IOException { long blockSize = 64 << 10; long chunkSize = OS.pageAlign(blockSize); long overlapSize = OS.pageAlign(blockSize / 4); final MappedBytes mappedBytes = MappedBytes.mappedBytes(path.toFile(), chunkSize, overlapSize, false); mappedBytes.reserve(); try { final Wire wire = WireType.BINARY_LIGHT.apply(mappedBytes); final Bytes<?> bytes = wire.bytes(); bytes.readLimit(bytes.capacity()); bytes.readSkip(4); // move past header try (final SingleChronicleQueueStore qs = loadStore(wire)) { assertNotNull(qs); long l = qs.writePosition(); long len = Wires.lengthOf(bytes.readVolatileInt(l)); long eofOffset = l + len + 4L; bytes.writePosition(eofOffset); bytes.writeInt(0); } } finally { mappedBytes.release(); } }
return ScanResult.NOT_REACHED; bytes.readSkip(Wires.lengthOf(header)); continue;
private long writeHeader(@NotNull Wire wire, int safeLength) { Bytes<?> bytes = wire.bytes(); // writePosition points at the last record in the queue, so we can just skip it and we're ready for write long pos = position; long lastPos = store.writePosition(); if (pos < lastPos) { // queue moved since we last touched it - recalculate header number try { wire.headerNumber(queue.rollCycle().toIndex(cycle, store.lastSequenceNumber(this))); } catch (StreamCorruptedException ex) { Jvm.warn().on(getClass(), "Couldn't find last sequence", ex); } } int header = bytes.readVolatileInt(lastPos); assert header != NOT_INITIALIZED; lastPos += lengthOf(bytes.readVolatileInt(lastPos)) + SPB_HEADER_SIZE; bytes.writePosition(lastPos); return wire.enterHeader(safeLength); }
int len = Wires.lengthOf(header); assert Wires.isReady(header); bytes.readSkip(len);
long moveToEnd(final Wire wire) { Sequence sequence1 = this.sequence; if (sequence1 != null) { for (int i = 0; i < 128; i++) { long endAddress = writePosition.getVolatileValue(); if (endAddress == 0) return -1; long sequence = sequence1.getSequence(endAddress); if (sequence == Sequence.NOT_FOUND_RETRY) continue; if (sequence == Sequence.NOT_FOUND) return -1; Bytes<?> bytes = wire.bytes(); bytes.readPosition(endAddress); for (; ; ) { int header = bytes.readVolatileInt(endAddress); if (header == 0 || Wires.isNotComplete(header)) return sequence; int len = Wires.lengthOf(header) + 4; bytes.readSkip(len); endAddress += len; if (Wires.isData(header)) sequence += 1; } } } return -1; }
public int getWritingThreadId() { final WireStore wireStore = queue.storeForCycle(queue.cycle(), queue.epoch(), false); if (wireStore != null) { final long position = wireStore.writePosition(); final int header = wireStore.bytes().readVolatileInt(position); if (Wires.isReady(header)) { final long nextHeaderPosition = position + Wires.lengthOf(header) + Wires.SPB_HEADER_SIZE; final int unfinishedHeader = wireStore.bytes(). readVolatileInt(nextHeaderPosition); if (Wires.isNotComplete(unfinishedHeader) && unfinishedHeader != 0) { return Wires.extractTidFromHeader(unfinishedHeader); } } } return NO_CURRENT_WRITER; } }
break; long readPosition = mappedBytes.readPosition(); int length = Wires.lengthOf(header); ValueIn valueIn = mappedWire.readEventName(sb); if (StringUtils.equalsCaseIgnore(key, sb)) {