示例#1
0
  private void syncVolumeVolumeSize(final ReturnValueCompletion<VolumeSize> completion) {
    SyncVolumeSizeOnPrimaryStorageMsg smsg = new SyncVolumeSizeOnPrimaryStorageMsg();
    smsg.setPrimaryStorageUuid(self.getPrimaryStorageUuid());
    smsg.setVolumeUuid(self.getUuid());
    smsg.setInstallPath(self.getInstallPath());
    bus.makeTargetServiceIdByResourceUuid(
        smsg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid());
    bus.send(
        smsg,
        new CloudBusCallBack(completion) {
          @Override
          public void run(MessageReply reply) {
            if (!reply.isSuccess()) {
              completion.fail(reply.getError());
              return;
            }

            SyncVolumeSizeOnPrimaryStorageReply r = reply.castReply();
            self.setActualSize(r.getActualSize());
            self.setSize(r.getSize());
            self = dbf.updateAndRefresh(self);

            VolumeSize size = new VolumeSize();
            size.actualSize = r.getActualSize();
            size.size = r.getSize();
            completion.success(size);
          }
        });
  }
示例#2
0
  protected void recoverVolume(Completion completion) {
    final VolumeInventory vol = getSelfInventory();
    List<RecoverDataVolumeExtensionPoint> exts =
        pluginRgty.getExtensionList(RecoverDataVolumeExtensionPoint.class);
    for (RecoverDataVolumeExtensionPoint ext : exts) {
      ext.preRecoverDataVolume(vol);
    }

    CollectionUtils.safeForEach(
        exts,
        new ForEachFunction<RecoverDataVolumeExtensionPoint>() {
          @Override
          public void run(RecoverDataVolumeExtensionPoint ext) {
            ext.beforeRecoverDataVolume(vol);
          }
        });

    VolumeStatus oldStatus = self.getStatus();

    if (self.getInstallPath() != null) {
      self.setStatus(VolumeStatus.Ready);
    } else {
      self.setStatus(VolumeStatus.NotInstantiated);
    }
    self = dbf.updateAndRefresh(self);

    new FireVolumeCanonicalEvent().fireVolumeStatusChangedEvent(oldStatus, getSelfInventory());

    CollectionUtils.safeForEach(
        exts,
        new ForEachFunction<RecoverDataVolumeExtensionPoint>() {
          @Override
          public void run(RecoverDataVolumeExtensionPoint ext) {
            ext.afterRecoverDataVolume(vol);
          }
        });

    completion.success();
  }