/** * @return creates a new instance of mapped bytes, because, for example the tailer and appender * can be at different locations. */ @NotNull @Override public MappedBytes bytes() { return MappedBytes.mappedBytes(mappedFile); }
/** * @return creates a new instance of mapped bytes, because, for example the tailer and appender * can be at different locations. */ @NotNull @Override public MappedBytes bytes() { return MappedBytes.mappedBytes(mappedFile); }
@NotNull @Override public String dump() { MappedBytes bytes = MappedBytes.mappedBytes(mappedFile); try { bytes.readLimit(bytes.realCapacity()); return Wires.fromSizePrefixedBlobs(bytes); } finally { bytes.release(); } }
@NotNull @Override public String dump() { MappedBytes bytes = MappedBytes.mappedBytes(mappedFile); try { bytes.readLimit(bytes.realCapacity()); return Wires.fromSizePrefixedBlobs(bytes); } finally { bytes.release(); } }
private static void dumpFile(@NotNull File file, @NotNull PrintStream out, long upperLimit) { Bytes<ByteBuffer> buffer = Bytes.elasticByteBuffer(); try { MappedBytes bytes = MappedBytes.mappedBytes(file, 4 << 20, OS.pageSize(), !OS.isWindows()); bytes.readLimit(bytes.realCapacity()); StringBuilder sb = new StringBuilder();
long start1 = System.currentTimeMillis(); String filename = baseDir + "/" + count++; queues[i] = MappedBytes.mappedBytes(filename, pagesPer10Second * (4 << 10)); long time1 = System.currentTimeMillis() - start1; if (time1 > 20)
public void checkFileContents(@NotNull File file, String expected) throws FileNotFoundException { @NotNull MappedBytes bytes = MappedBytes.mappedBytes(file, ChronicleQueue.TEST_BLOCK_SIZE); bytes.readLimit(bytes.realCapacity()); assertEquals(expected, Wires.fromSizePrefixedBlobs(bytes)); bytes.release(); }
@Test public void testInvalidFile() throws FileNotFoundException { @NotNull File dir = new File(OS.TARGET + "/deleteme-" + System.nanoTime()); dir.mkdir(); try (@NotNull MappedBytes bytes = MappedBytes.mappedBytes(new File(dir, "19700102" + SingleChronicleQueue.SUFFIX), 64 << 10)) { bytes.write8bit("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"); try (@NotNull RollingChronicleQueue queue = binary(dir) .rollCycle(RollCycles.TEST4_DAILY) .testBlockSize() .build()) { assertEquals(1, queue.firstCycle()); assertEquals(1, queue.lastCycle()); try { @NotNull ExcerptTailer tailer = queue.createTailer(); tailer.toEnd(); fail(); } catch (Exception e) { assertEquals("java.io.StreamCorruptedException: Unexpected magic number 783f3c37", e.toString()); } } } System.gc(); try { IOTools.shallowDeleteDirWithFiles(dir.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } }
dir.mkdir(); @NotNull MappedBytes bytes = MappedBytes.mappedBytes(new File(dir, "19700101" + SingleChronicleQueue.SUFFIX), ChronicleQueue.TEST_BLOCK_SIZE); @NotNull Wire wire = new BinaryWire(bytes); try (DocumentContext dc = wire.writingDocument(true)) {
dir.mkdir(); @NotNull MappedBytes bytes = MappedBytes.mappedBytes(new File(dir, "19700101-02" + SingleChronicleQueue.SUFFIX), ChronicleQueue.TEST_BLOCK_SIZE * 2); @NotNull Wire wire = new BinaryWire(bytes); try (DocumentContext dc = wire.writingDocument(true)) {
dir.mkdirs(); @NotNull MappedBytes bytes = MappedBytes.mappedBytes(new File(dir, "19700101" + SingleChronicleQueue.SUFFIX), ChronicleQueue.TEST_BLOCK_SIZE * 2); @NotNull Wire wire = new BinaryWire(bytes);
int dumpEntries = 0; try { MappedBytes bytes = MappedBytes.mappedBytes(file, 4 << 20); bytes.readLimit(bytes.realCapacity());
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 creates a new instance of mapped bytes, because, for example the tailer and appender * can be at different locations. */ @NotNull @Override public MappedBytes bytes() { return MappedBytes.mappedBytes(mappedFile); }
/** * @return creates a new instance of mapped bytes, because, for example the tailer and appender * can be at different locations. */ @NotNull @Override public MappedBytes bytes() { return MappedBytes.mappedBytes(mappedFile); }
@NotNull public static MappedBytes mappedBytes(@NotNull File file, long chunkSize) throws FileNotFoundException, IllegalStateException { return mappedBytes(file, chunkSize, OS.pageSize()); }
@NotNull public static MappedBytes mappedBytes(@NotNull File file, long chunkSize, long overlapSize) throws FileNotFoundException, IllegalStateException { @NotNull MappedFile rw = MappedFile.of(file, chunkSize, overlapSize, false); try { return mappedBytes(rw); } finally { rw.release(); } }
@NotNull public MappedBytes withSizes(long chunkSize, long overlapSize) { @NotNull MappedFile mappedFile2 = this.mappedFile.withSizes(chunkSize, overlapSize); if (mappedFile2 == this.mappedFile) return this; try { return mappedBytes(mappedFile2); } finally { mappedFile2.release(); release(); } }
@NotNull @Override public String dump() { MappedBytes bytes = MappedBytes.mappedBytes(mappedFile); try { bytes.readLimit(bytes.realCapacity()); return Wires.fromSizePrefixedBlobs(bytes); } finally { bytes.release(); } }
public ChronicleBytesCASPingPongMain() throws IOException { bytes = MappedBytes.mappedBytes("deleteme", OS.pageSize()); bytes.writeLong(COUNTER_OFFSET, 0L); bytes.writeInt(TOGGLE_OFFSET, 0); }