@Override public void close() { Closeable.closeQuietly(timeStamp); } }
@Nullable @Override public Object defaultValue() { throw new IORuntimeException("field " + name() + " required"); } }
public static void deleteDir(@NotNull File dir) { try { IOTools.deleteDirWithFiles(dir, 20); } catch (Throwable e) { e.printStackTrace(); } }
} finally { try { IOTools.deleteDirWithFiles(new File(input), 2); IOTools.deleteDirWithFiles(new File(output), 2); } catch (IORuntimeException e) { e.printStackTrace();
@AfterClass public static void afterClass() { for (File file : pathsToDelete) { IOTools.shallowDeleteDirWithFiles(file); } }
public void close() { Closeable.closeQuietly(minCycleValue, maxCycleValue, modCount); }
@NotNull @Override @SuppressWarnings("rawtypes") public BytesRef read(Bytes in, long size, @Nullable BytesRef using) { if (size < 0L || size > (long) Integer.MAX_VALUE) { throw new IORuntimeException("byte[] size should be non-negative int, " + size + " given. Memory corruption?"); } int arrayLength = (int) size; if (using == null) { using = new BytesRef(new byte[arrayLength]); } else if (using.bytes.length < arrayLength) { using.bytes = new byte[arrayLength]; } in.read(using.bytes, 0, arrayLength); using.offset = 0; using.length = arrayLength; return using; }
@After public void after() { try { IOTools.deleteDirWithFiles(path, 2); } catch (Exception ignored) { } }
@After public void teardown() { try { IOTools.shallowDeleteDirWithFiles(chroniclePath); } catch (Exception e) { if (e instanceof AccessDeniedException && OS.isWindows()) System.err.println(e); else throw e; } }
public void close() { Closeable.closeQuietly(lock); }
@Override public long index() throws IORuntimeException { if (this.wire.headerNumber() == Long.MIN_VALUE) { try { wire.headerNumber(queue.rollCycle().toIndex(cycle, store.lastSequenceNumber(StoreAppender.this))); long headerNumber0 = wire.headerNumber(); assert (((AbstractWire) this.wire).isInsideHeader()); return isMetaData() ? headerNumber0 : headerNumber0 + 1; } catch (IOException e) { throw new IORuntimeException(e); } } return isMetaData() ? Long.MIN_VALUE : this.wire.headerNumber() + 1; }
@Test public void shouldDetermineQueueDirectoryFromQueueFile() { final Path path = Paths.get(OS.USER_DIR, TEST_QUEUE_FILE); try (final ChronicleQueue queue = ChronicleQueue.singleBuilder(path) .testBlockSize() .build()) { assertThat(queue.createTailer().readingDocument().isPresent(), is(false)); } finally { IOTools.deleteDirWithFiles(path.toFile(), 20); } }
@Test public void testEmptyDirectory() { @NotNull File dir = new File(OS.TARGET, getClass().getSimpleName() + "-" + System.nanoTime()); dir.mkdir(); @NotNull RollingChronicleQueue queue = binary(dir).testBlockSize().build(); assertEquals(Integer.MAX_VALUE, queue.firstCycle()); assertEquals(Long.MAX_VALUE, queue.firstIndex()); assertEquals(Integer.MIN_VALUE, queue.lastCycle()); queue.close(); IOTools.shallowDeleteDirWithFiles(dir.getAbsolutePath()); }
private void onCleanup() { Closeable.closeQuietly(writePosition); Closeable.closeQuietly(indexing); mappedBytes.release(); }
@Override public void init(JLBH jlbh) { IOTools.deleteDirWithFiles("replica", 10); Byteable byteable = (Byteable) datum; long capacity = byteable.maxSize(); byteable.bytesStore(NativeBytesStore.nativeStore(capacity), 0, capacity); datumBytes = ((Byteable) datum).bytesStore(); datumWrite = datumBytes.bytesForWrite(); sourceQueue = single("replica").build(); sinkQueue = single("replica").build(); appender = sourceQueue.acquireAppender(); tailer = sinkQueue.createTailer(); this.jlbh = jlbh; }
private void closeTL(ThreadLocal<WeakReference<LongArrayValuesHolder>> tl) { WeakReference<LongArrayValuesHolder> weakReference = tl.get(); if (weakReference == null) return; LongArrayValuesHolder holder = weakReference.get(); if (holder != null) Closeable.closeQuietly(holder.values); }
public static void close() { closeQuietly(loop); }
@Override public void close() { Closeable.closeQuietly(index2Index); Closeable.closeQuietly(nextEntryToBeIndexed); // Eagerly clean up the contents of thread locals but only for this thread. // The contents of the thread local for other threads will be cleaned up in // MappedFile.performRelease closeTL(indexArray); closeTL(index2indexArray); }
@Override public void close() { if (isClosed.getAndSet(true)) return; closeQuietly(directoryListing, queueLock, writeLock, lastAcknowledgedIndexReplicated, lastIndexReplicated); synchronized (closers) { closers.forEach((k, v) -> v.accept(k)); closers.clear(); } this.pool.close(); closeQuietly(metaStore); }
@Override public boolean action() throws InvalidEventHandlerException, InterruptedException { if (isClosed()) { Closeable.closeQuietly(serviceImpl); Closeable.closeQuietly(serviceIn); Closeable.closeQuietly(outputQueue); Closeable.closeQuietly(inputQueues); throw new InvalidEventHandlerException(); } boolean busy = false; for (MethodReader reader : serviceIn) { busy |= reader.readOne(); } return busy; }