コード例 #1
0
 @Asynchronous
 private void doExport(Promise<?>... waitFor) {
   if (request.isLiveInstanceTouched()) {
     Promise<DatabaseInstance> db =
         rdsActivities.describeInstance(request.getInstanceName(), request.getIdentity());
     exportLiveInstance(db);
   } else {
     exportWithSnapshot();
   }
 }
コード例 #2
0
  @Asynchronous
  private void exportWithSnapshot() {
    final Promise<DatabaseInstance> database =
        rdsActivities.describeInstance(request.getInstanceName(), request.getIdentity());
    final Promise<String> snapshotName =
        controlActivities.createSnapshotName(request.getInstanceName());
    Promise<Void> done =
        rdsActivities.createSnapshot(
            snapshotName,
            Promise.asPromise(request.getInstanceName()),
            Promise.asPromise(request.getIdentity()),
            database);
    new TryCatchFinally(done) {
      @Override
      protected void doCatch(Throwable cause) {
        controlActivities.notifyJobFailed(cause);
      }

      @Override
      protected void doFinally() throws Throwable {
        rdsActivities.deleteSnapshot(snapshotName, Promise.asPromise(request.getIdentity()));
      }

      @Override
      protected void doTry() {
        Promise<Void> done = waitUntilSnapshotAvailable(snapshotName);
        Promise<ExportSnapshotRequest> snapshotRequest =
            createExportSnapshotRequest(snapshotName, database);
        done =
            exportSnapshotFlowFactory
                .getClient(workflowId + "-snapshot")
                .export(snapshotRequest, done);
        controlActivities.notifyJobCompleted(done);
      }
    };
  }