Class OperationContextImpl

java.lang.Object
org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl
All Implemented Interfaces:
IOCallback, IOCompletion, OperationContext

public class OperationContextImpl extends Object implements OperationContext
Each instance of OperationContextImpl is associated with an executor (usually an ordered Executor).

Tasks are hold until the operations are complete and executed in the natural order as soon as the operations are returned from replication and storage.

If there are no pending IO operations, the tasks are just executed at the callers thread without any context switch.

So, if you are doing operations that are not dependent on IO (e.g NonPersistentMessages) you wouldn't have any context switch.

If you need to track store operations you can set the system property "ARTEMIS_OPCONTEXT_MAX_DEBUG_TRACKERS" with the max number of trackers that you want to keep in memory.

  • Constructor Details

    • OperationContextImpl

      public OperationContextImpl(Executor executor)
  • Method Details

    • clearContext

      public static void clearContext()
    • getContext

      public static final OperationContext getContext()
    • getContext

      public static OperationContext getContext(ExecutorFactory executorFactory)
    • setContext

      public static void setContext(OperationContext context)
    • getReplicationLineUpField

      public long getReplicationLineUpField()
    • getReplicated

      public long getReplicated()
    • getStoreLineUpField

      public long getStoreLineUpField()
    • getStored

      public long getStored()
    • getPagedLinedUpField

      public long getPagedLinedUpField()
    • getPaged

      public long getPaged()
    • getMaxDebugTrackers

      protected static int getMaxDebugTrackers()
    • setMaxDebugTrackers

      protected static void setMaxDebugTrackers(int maxDebugTrackers)
    • getDebugTrackers

      protected org.apache.commons.collections.Buffer getDebugTrackers()
    • pageSyncLineUp

      public void pageSyncLineUp()
      Specified by:
      pageSyncLineUp in interface OperationContext
    • pageSyncDone

      public void pageSyncDone()
      Specified by:
      pageSyncDone in interface OperationContext
    • storeLineUp

      public void storeLineUp()
      Specified by:
      storeLineUp in interface IOCompletion
    • replicationLineUp

      public void replicationLineUp()
      Specified by:
      replicationLineUp in interface OperationContext
    • replicationDone

      public void replicationDone()
      Specified by:
      replicationDone in interface OperationContext
    • executeOnCompletion

      public void executeOnCompletion(IOCallback runnable)
      Description copied from interface: OperationContext
      Execute the task when all IO operations are complete, Or execute it immediately if nothing is pending.
      Specified by:
      executeOnCompletion in interface OperationContext
      Parameters:
      runnable - the tas to be executed.
    • executeOnCompletion

      public void executeOnCompletion(IOCallback completion, OperationConsistencyLevel consistencyLevel)
      Description copied from interface: OperationContext
      Execute the task when all IO operations are complete, Or execute it immediately if nothing is pending. Notice it's possible to pass a consistencyLevel to what should be waited before completing the operation.
      Specified by:
      executeOnCompletion in interface OperationContext
    • done

      public void done()
      Description copied from interface: IOCallback
      Method for sync notifications. When this callback method is called, there is a guarantee the data is written on the disk.

      Note:Leave this method as soon as possible, or you would be blocking the whole notification thread

      Specified by:
      done in interface IOCallback
    • complete

      public void complete()
    • onError

      public void onError(int errorCode, String errorMessage)
      Description copied from interface: IOCallback
      Method for error notifications. Observation: The whole file will be probably failing if this happens. Like, if you delete the file, you will start to get errors for these operations
      Specified by:
      onError in interface IOCallback
    • waitCompletion

      public void waitCompletion() throws Exception
      Specified by:
      waitCompletion in interface OperationContext
      Throws:
      Exception
    • waitCompletion

      public boolean waitCompletion(long timeout) throws InterruptedException, ActiveMQException
      Description copied from interface: OperationContext
      Wait for the completion of this operation.
      Specified by:
      waitCompletion in interface OperationContext
      Parameters:
      timeout - how long to wait in milliseconds
      Returns:
      true if the operation completed within the specified timeout; false if not
      Throws:
      InterruptedException
      ActiveMQException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reset

      public void reset()
      Specified by:
      reset in interface OperationContext