use of org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback in project activemq-artemis by apache.
the class JDBCSequentialFile method sync.
@Override
public void sync() throws IOException {
final SimpleWaitIOCallback callback = new SimpleWaitIOCallback();
executor.execute(callback::done);
try {
callback.waitCompletion();
} catch (Exception e) {
callback.onError(ActiveMQExceptionType.IO_ERROR.getCode(), "Error during JDBC file sync.");
fileFactory.onIOError(e, "Error during JDBC file sync.", this);
}
}
use of org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback in project activemq-artemis by apache.
the class TimedSequentialFile method write.
@Override
public void write(ActiveMQBuffer bytes, boolean sync) throws Exception {
if (sync) {
if (this.timedBuffer != null) {
// the only way to avoid allocations is by using a lock-free pooled callback -> CyclicBarrier allocates on each new Generation!!!
final SimpleWaitIOCallback callback = new SimpleWaitIOCallback();
this.timedBuffer.addBytes(bytes, true, callback);
callback.waitCompletion();
} else {
this.sequentialFile.write(bytes, true);
}
} else {
if (this.timedBuffer != null) {
this.timedBuffer.addBytes(bytes, false, DummyCallback.getInstance());
} else {
this.sequentialFile.write(bytes, false);
}
}
}
use of org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback in project activemq-artemis by apache.
the class AbstractSequentialFile method write.
@Override
public void write(final EncodingSupport bytes, final boolean sync) throws InterruptedException, ActiveMQException {
if (sync) {
SimpleWaitIOCallback completion = new SimpleWaitIOCallback();
write(bytes, true, completion);
completion.waitCompletion();
} else {
write(bytes, false, DummyCallback.getInstance());
}
}
use of org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback in project activemq-artemis by apache.
the class AbstractSequentialFile method write.
@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());
}
}
use of org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback in project activemq-artemis by apache.
the class AIOSequentialFile method read.
@Override
public int read(final ByteBuffer bytes) throws Exception {
SimpleWaitIOCallback waitCompletion = new SimpleWaitIOCallback();
int bytesRead = read(bytes, waitCompletion);
waitCompletion.waitCompletion();
return bytesRead;
}
Aggregations