@Override public void flush() { for (SequentialFile file : files) { try { file.sync(); } catch (Exception e) { criticalErrorListener.onIOException(e, "Error during JDBC file sync.", file); } } }
private void cleanupIncompleteFiles() throws Exception { if (largeMessagesFactory != null) { List<String> tmpFiles = largeMessagesFactory.listFiles("tmp"); for (String tmpFile : tmpFiles) { SequentialFile file = largeMessagesFactory.createSequentialFile(tmpFile); file.delete(); } } }
@Override public void executeOnCompletion(final IOCallback runnable) { // There are no executeOnCompletion calls while using the DummyOperationContext // However we keep the code here for correctness runnable.done(); }
@Override public void flushBuffer(final ByteBuffer buffer, final boolean requestedSync, final List<IOCallback> callbacks) { buffer.flip(); if (buffer.limit() == 0) { factory.releaseBuffer(buffer); } else { writeDirect(buffer, requestedSync, new DelegateCallback(callbacks)); } }
@Override public boolean checkPageFileExists(final int pageNumber) { String fileName = createFileName(pageNumber); try { checkFileFactory(); } catch (Exception ignored) { } SequentialFile file = fileFactory.createSequentialFile(fileName); return file.exists(); }
/** When closing a file from a finalize block, you cant wait on syncs or anything like that. * otherwise the VM may hung. Especially on the testsuite. */ default void close(boolean waitSync) throws Exception { // by default most implementations are just using the regular close.. // if the close needs sync, please use this parameter or fianlizations may get stuck close(); }
@Override public int calculateBlockStart(final int position) { int alignment = factory.getAlignment(); int pos = (position / alignment + (position % alignment != 0 ? 1 : 0)) * alignment; return pos; }
@Override public void write(final ActiveMQBuffer bytes, final boolean sync) throws IOException, InterruptedException, ActiveMQException { if (sync) { SimpleWaitIOCallback completion = new SimpleWaitIOCallback(); write(bytes, true, completion); completion.waitCompletion(); } else { write(bytes, false, DummyCallback.getInstance()); } }
@Override public File getFolder() { SequentialFileFactory factoryUsed = this.fileFactory; if (factoryUsed != null) { return factoryUsed.getDirectory(); } else { return null; } }
@Override protected ByteBuffer newBuffer(int size, final int limit) { // For NIO, we don't need to allocate a buffer the entire size of the timed buffer, unlike AIO size = limit; return super.newBuffer(size, limit); }
@Override public MappedSequentialFileFactory setDatasync(boolean enabled) { super.setDatasync(enabled); return this; }
@Override public void activateBuffer(final SequentialFile file) { if (timedBuffer != null) { file.setTimedBuffer(timedBuffer); } }
@Override public void executeOnCompletion(final IOCallback runnable) { runnable.done(); } };
@Override public void flushBuffer(final ByteBuffer buffer, final boolean requestedSync, final List<IOCallback> callbacks) { buffer.flip(); if (buffer.limit() == 0) { factory.releaseBuffer(buffer); } else { writeDirect(buffer, requestedSync, new DelegateCallback(callbacks)); } }
@Override protected ByteBuffer newBuffer(int size, final int limit) { // For NIO, we don't need to allocate a buffer the entire size of the timed buffer, unlike AIO size = limit; return super.newBuffer(size, limit); }
@Override public void executeOnCompletion(IOCallback runnable, boolean storeOnly) { // There are no executeOnCompletion calls while using the DummyOperationContext // However we keep the code here for correctness runnable.done(); }
@Override public void executeOnCompletion(final IOCallback runnable) { // There are no executeOnCompletion calls while using the DummyOperationContext // However we keep the code here for correctness runnable.done(); }
@Override public void executeOnCompletion(IOCallback runnable, boolean storeOnly) { runnable.done(); } }