private static void closeQueues(final ChronicleQueue... queues) { for (ChronicleQueue queue : queues) { if (queue != null) { queue.close(); } } }
@Test public void testNoHeader() throws IOException { @NotNull File dir = new File(OS.TARGET + "/deleteme-" + System.nanoTime()); dir.mkdir(); File file = new File(dir, "19700101" + SingleChronicleQueue.SUFFIX); try (FileOutputStream fos = new FileOutputStream(file)) { byte[] bytes = new byte[1024]; for (int i = 0; i < 128; i++) { fos.write(bytes); } } @NotNull ChronicleQueue queue = binary(dir) .rollCycle(RollCycles.TEST4_DAILY) .testBlockSize() .build(); testQueue(queue); queue.close(); try { IOTools.shallowDeleteDirWithFiles(dir.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } }
assertEquals("[Backward] Wrong message " + i, msg, readNextEntry(tailer)); queue.close();
public static void main(String[] args) { long start = System.currentTimeMillis(); final TLogEntry entry = new TLogEntry(); entry.setSessionId(321234L); entry.setLogLevel(77); entry.setSecurityLevel(1234); entry.setPosixTimestamp(6141234321L); entry.setMessage("This is a test message for the system................................ A"); final LogEntryOutput output = new LogEntryOutput(1024); output.setMarshallable(entry); final ChronicleQueue queue = ChronicleQueue.singleBuilder( OS.TARGET + "/test-" + System.nanoTime()) .rollCycle(RollCycles.HOURLY) .build(); final ExcerptAppender appender = queue.acquireAppender(); Jvm.setExceptionHandlers(Slf4jExceptionHandler.FATAL, Slf4jExceptionHandler.WARN, Slf4jExceptionHandler.WARN); for (int j = 0; j < 100; ++j) { for (int i = 0; i < 100000; ++i) { appender.writeBytes(output); } System.out.println((j + 1) * 100000); // Jvm.pause(100L); } queue.close(); System.out.println("took " + (System.currentTimeMillis() - start) / 1e3); }
return; wqueue.close(); }); submit.get();
queue.close(); } finally { try {
testQueue(queue); queue.close(); try { IOTools.shallowDeleteDirWithFiles(dir.getAbsolutePath());
assertEquals("[Forward 2] Wrong Tailer index after reading msg 1", msgIndexes.get(testMessage(2)).longValue(), tailer.index()); queue.close();
@Test public void testTailAfterClose() { final ChronicleQueue queue = SingleChronicleQueueBuilder.builder(getTmpDir(), WireType.BINARY). build(); final ExcerptAppender appender = queue.acquireAppender(); appender.writeDocument(w -> w.write(TestKey.test).int32(1)); queue.close(); try { appender.writeDocument(w -> w.write(TestKey.test).int32(2)); Assert.fail(); } catch (IllegalStateException e) { // ok } } }
@Override public void close() { isClosed.set(true); activeSubscriptions.values().forEach(v -> v.set(true)); chronicleQueue.close(); } }
@Override public void postStop() throws Exception { getQueue().close(); } };
@Override public void onComplete() { subscriber.onComplete(); queue.close(); } });
@Override public void postStop() throws Exception { getQueue().close(); } };
@Override public void postStop() throws Exception { getQueue().close(); }