Search in sources :

Example 1 with JournalDeleteRecord

use of org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord in project activemq-artemis by apache.

the class JournalImpl method appendDeleteRecord.

@Override
public void appendDeleteRecord(final long id, final boolean sync, final IOCompletion callback) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("scheduling appendDeleteRecord::id=" + id);
    }
    checkJournalIsLoaded();
    lineUpContext(callback);
    checkKnownRecordID(id);
    final SimpleFuture<Boolean> result = newSyncAndCallbackResult(sync, callback);
    appendExecutor.execute(new Runnable() {

        @Override
        public void run() {
            journalLock.readLock().lock();
            try {
                JournalRecord record = null;
                if (compactor == null) {
                    record = records.remove(id);
                }
                JournalInternalRecord deleteRecord = new JournalDeleteRecord(id);
                JournalFile usedFile = appendRecord(deleteRecord, false, sync, null, callback);
                if (logger.isTraceEnabled()) {
                    logger.trace("appendDeleteRecord::id=" + id + ", usedFile = " + usedFile);
                }
                // computing the delete should be done after compacting is done
                if (record == null) {
                    compactor.addCommandDelete(id, usedFile);
                } else {
                    record.delete(usedFile);
                }
                result.set(true);
            } catch (Exception e) {
                result.fail(e);
                logger.error("appendDeleteRecord:" + e, e);
            } finally {
                journalLock.readLock().unlock();
            }
        }
    });
    result.get();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) JournalDeleteRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 2 with JournalDeleteRecord

use of org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord in project activemq-artemis by apache.

the class FileWrapperJournal method appendDeleteRecord.

@Override
public void appendDeleteRecord(long id, boolean sync, IOCompletion callback) throws Exception {
    JournalInternalRecord deleteRecord = new JournalDeleteRecord(id);
    writeRecord(deleteRecord, false, -1, false, callback);
}
Also used : JournalDeleteRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Aggregations

JournalDeleteRecord (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord)2 JournalInternalRecord (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)2 IOException (java.io.IOException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1