Class OMPrepareRequest

java.lang.Object
org.apache.hadoop.ozone.om.request.OMClientRequest
org.apache.hadoop.ozone.om.request.upgrade.OMPrepareRequest
All Implemented Interfaces:
RequestAuditor

public class OMPrepareRequest extends OMClientRequest
OM Request used to flush all transactions to disk, take a DB snapshot, and purge the logs, leaving Ratis in a clean state without unapplied log entries. This prepares the OM for upgrades/downgrades so that no request in the log is applied to the database in the old version of the code in one OM, and the new version of the code on another OM.
  • Constructor Details

    • OMPrepareRequest

      public OMPrepareRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest omRequest)
  • Method Details

    • validateAndUpdateCache

      public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, ExecutionContext context)
      Description copied from class: OMClientRequest
      Validate the OMRequest and update the cache. This step should verify that the request can be executed, perform any authorization steps and update the in-memory cache. This step does not persist the changes to the database. To coders and reviewers, CAUTION: Do NOT bring external dependencies into this method, doing so could potentially cause divergence in OM DB states in HA. If you have to, be extremely careful. e.g. Do NOT invoke ACL check inside validateAndUpdateCache, which can use Ranger plugin that relies on external DB.
      Specified by:
      validateAndUpdateCache in class OMClientRequest
      Returns:
      the response that will be returned to the client.
    • takeSnapshotAndPurgeLogs

      public static void takeSnapshotAndPurgeLogs(long prepareIndex, org.apache.ratis.server.RaftServer.Division division) throws IOException
      Take a snapshot of the state machine at the last index, and purge at least all log with indices less than or equal to the prepare index. If there is another prepare request or cancel prepare request, this one will end up purging that request since it was allowed through the pre-append prepare gate. This means that an OM cannot support 2 prepare requests in the transaction pipeline (un-applied) at the same time.
      Throws:
      IOException