Example #1
0
  private void handle(BackupStorageDeletionMsg msg) {
    BackupStorageInventory inv = BackupStorageInventory.valueOf(self);
    extpEmitter.beforeDelete(inv);
    deleteHook();
    extpEmitter.afterDelete(inv);

    BackupStorageDeletionReply reply = new BackupStorageDeletionReply();
    tracker.untrackHook(self.getUuid());
    bus.reply(msg, reply);
  }
Example #2
0
  protected void changeStatus(BackupStorageStatus status) {
    if (status == self.getStatus()) {
      return;
    }

    BackupStorageStatus oldStatus = self.getStatus();

    self.setStatus(status);
    dbf.update(self);

    BackupStorageStatusChangedData d = new BackupStorageStatusChangedData();
    d.setBackupStorageUuid(self.getUuid());
    d.setNewStatus(status.toString());
    d.setOldStatus(oldStatus.toString());
    d.setInventory(BackupStorageInventory.valueOf(self));
    evtf.fire(BackupStorageCanonicalEvents.BACKUP_STORAGE_STATUS_CHANGED, d);

    logger.debug(
        String.format("change backup storage[uuid:%s] status to %s", self.getUuid(), status));
  }
Example #3
0
  protected void handle(APIDeleteBackupStorageMsg msg) {
    final APIDeleteBackupStorageEvent evt = new APIDeleteBackupStorageEvent(msg.getId());

    final String issuer = BackupStorageVO.class.getSimpleName();
    final List<BackupStorageInventory> ctx = BackupStorageInventory.valueOf(Arrays.asList(self));
    FlowChain chain = FlowChainBuilder.newSimpleFlowChain();
    chain.setName(String.format("delete-backup-storage-%s", msg.getUuid()));
    if (msg.getDeletionMode() == APIDeleteMessage.DeletionMode.Permissive) {
      chain
          .then(
              new NoRollbackFlow() {
                @Override
                public void run(final FlowTrigger trigger, Map data) {
                  casf.asyncCascade(
                      CascadeConstant.DELETION_CHECK_CODE,
                      issuer,
                      ctx,
                      new Completion(trigger) {
                        @Override
                        public void success() {
                          trigger.next();
                        }

                        @Override
                        public void fail(ErrorCode errorCode) {
                          trigger.fail(errorCode);
                        }
                      });
                }
              })
          .then(
              new NoRollbackFlow() {
                @Override
                public void run(final FlowTrigger trigger, Map data) {
                  casf.asyncCascade(
                      CascadeConstant.DELETION_DELETE_CODE,
                      issuer,
                      ctx,
                      new Completion(trigger) {
                        @Override
                        public void success() {
                          trigger.next();
                        }

                        @Override
                        public void fail(ErrorCode errorCode) {
                          trigger.fail(errorCode);
                        }
                      });
                }
              });
    } else {
      chain.then(
          new NoRollbackFlow() {
            @Override
            public void run(final FlowTrigger trigger, Map data) {
              casf.asyncCascade(
                  CascadeConstant.DELETION_FORCE_DELETE_CODE,
                  issuer,
                  ctx,
                  new Completion(trigger) {
                    @Override
                    public void success() {
                      trigger.next();
                    }

                    @Override
                    public void fail(ErrorCode errorCode) {
                      trigger.fail(errorCode);
                    }
                  });
            }
          });
    }

    chain
        .done(
            new FlowDoneHandler(msg) {
              @Override
              public void handle(Map data) {
                casf.asyncCascadeFull(
                    CascadeConstant.DELETION_CLEANUP_CODE, issuer, ctx, new NopeCompletion());
                bus.publish(evt);
              }
            })
        .error(
            new FlowErrorHandler(msg) {
              @Override
              public void handle(ErrorCode errCode, Map data) {
                evt.setErrorCode(
                    errf.instantiateErrorCode(SysErrors.DELETE_RESOURCE_ERROR, errCode));
                bus.publish(evt);
              }
            })
        .start();
  }
Example #4
0
 protected BackupStorageInventory getSelfInventory() {
   return BackupStorageInventory.valueOf(self);
 }