当前位置: 首页>>代码示例>>Java>>正文


Java TaskInfoState.SUCCESS属性代码示例

本文整理汇总了Java中com.vmware.vim25.TaskInfoState.SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java TaskInfoState.SUCCESS属性的具体用法?Java TaskInfoState.SUCCESS怎么用?Java TaskInfoState.SUCCESS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.vmware.vim25.TaskInfoState的用法示例。


在下文中一共展示了TaskInfoState.SUCCESS属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logTaskInfo

private void logTaskInfo(TaskInfo info) {
    if (info == null) {
        logger.debug("Deleted task info key");
        return;
    }

    TaskInfoState state = info.getState();

    Integer progress = info.getProgress();
    if (state == TaskInfoState.SUCCESS) {
        progress = Integer.valueOf(100);
    } else if (progress == null) {
        progress = Integer.valueOf(0);
    }

    LocalizableMessage desc = info.getDescription();
    String description = desc != null ? desc.getMessage() : "";

    XMLGregorianCalendar queueT = info.getQueueTime();
    String queueTime = queueT != null
            ? queueT.toGregorianCalendar().getTime().toString() : "";

    XMLGregorianCalendar startT = info.getStartTime();
    String startTime = startT != null
            ? startT.toGregorianCalendar().getTime().toString() : "";

    XMLGregorianCalendar completeT = info.getCompleteTime();
    String completeTime = completeT != null
            ? completeT.toGregorianCalendar().getTime().toString() : "";

    logger.debug("Save task info key: " + info.getKey() + " name: "
            + info.getName() + " target: " + info.getEntityName()
            + " state: " + state.name() + " progress: " + progress
            + "% description: " + description + " queue-time: " + queueTime
            + " start-time: " + startTime + " complete-time: "
            + completeTime);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:37,代码来源:VMPropertyHandler.java

示例2: logTaskInfo

private void logTaskInfo(TaskInfo info) {
    String key = info.getKey();
    String name = info.getName();
    String target = info.getEntityName();
    TaskInfoState state = info.getState();
    Integer progress = info.getProgress();
    if (state == TaskInfoState.SUCCESS) {
        progress = Integer.valueOf(100);
    } else if (progress == null) {
        progress = Integer.valueOf(0);
    }
    LocalizableMessage desc = info.getDescription();
    String description = desc != null ? desc.getMessage() : "";
    TaskReason reason = info.getReason();
    String initiatedBy = "";
    if (reason != null) {
        if (reason instanceof TaskReasonUser) {
            initiatedBy = ((TaskReasonUser) reason).getUserName();
        } else if (reason instanceof TaskReasonSystem) {
            initiatedBy = "System";
        } else if (reason instanceof TaskReasonSchedule) {
            initiatedBy = ((TaskReasonSchedule) reason).getName();
        } else if (reason instanceof TaskReasonAlarm) {
            initiatedBy = ((TaskReasonAlarm) reason).getAlarmName();
        }
    }

    XMLGregorianCalendar queueT = info.getQueueTime();
    String queueTime = queueT != null
            ? queueT.toGregorianCalendar().getTime().toString() : "";
    XMLGregorianCalendar startT = info.getStartTime();
    String startTime = startT != null
            ? startT.toGregorianCalendar().getTime().toString() : "";
    XMLGregorianCalendar completeT = info.getCompleteTime();
    String completeTime = completeT != null
            ? completeT.toGregorianCalendar().getTime().toString() : "";
    logger.debug(key + " name: " + name + " target: " + target + " state: "
            + state + " progress: " + progress + "% description: "
            + description + " initiated: " + initiatedBy + " queue-time: "
            + queueTime + " start-time: " + startTime + " complete-time: "
            + completeTime);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:42,代码来源:Actions.java

示例3: createSnapshot

private void createSnapshot(Connection connection, SnapshotContext context,
                            DeferredResult<SnapshotContext> deferredResult) {
    ManagedObjectReference vmMoRef = CustomProperties.of(context.computeDescription).getMoRef(CustomProperties.MOREF);

    if (vmMoRef == null) {
        deferredResult.fail(new IllegalStateException("Cannot find VM to snapshot"));
        return;
    }

    ManagedObjectReference task;
    TaskInfo info;
    try {
        logInfo("Creating snapshot for compute resource %s", context.computeDescription.name);
        task = connection.getVimPort()
                .createSnapshotTask(vmMoRef, context.snapshotState.name, context.snapshotState.description, context.snapshotMemory, false);
        info = VimUtils.waitTaskEnd(connection, task);
        if (info.getState() != TaskInfoState.SUCCESS) {
            VimUtils.rethrow(info.getError());
        }
    } catch (Exception e) {
        deferredResult.fail(e);
        return;
    }

    CustomProperties.of(context.snapshotState).put(CustomProperties.MOREF, (ManagedObjectReference) info.getResult());
    context.snapshotState.isCurrent = true; //mark this as current snapshot

    // create a new xenon SnapshotState
    logInfo(String.format("Creating a new snapshot state for compute : %s", context.computeDescription.name));
    Operation createSnapshotState = Operation.createPost(PhotonModelUriUtils.createInventoryUri(getHost(),
            SnapshotService.FACTORY_LINK))
            .setBody(context.snapshotState);

    if (context.existingSnapshotState != null) {
        // un-mark old snapshot as current snapshot
        context.existingSnapshotState.isCurrent = false;
        Operation patchOldSnapshot = Operation
                .createPatch(UriUtils.buildUri(getHost(), context.existingSnapshotState.documentSelfLink))
                .setBody(context.existingSnapshotState);
        OperationSequence.create(createSnapshotState)
                .next(patchOldSnapshot)
                .setCompletion((o, e) -> {
                    if (e != null && !e.isEmpty()) {
                        deferredResult.fail(e.values().iterator().next());
                    }
                    deferredResult.complete(context);
                }).sendWith(this);
    } else {
        context.computeDescription.customProperties.put(ComputeProperties.CUSTOM_PROP_COMPUTE_HAS_SNAPSHOTS, "true");
        // patch compute adding the property '_hasSnapshots' with true
        Operation patchCompute = Operation
                .createPatch(UriUtils.buildUri(getHost(), context.snapshotState.computeLink))
                .setBody(context.computeDescription);

        OperationSequence.create(createSnapshotState)
                .next(patchCompute)
                .setCompletion((o, e) -> {
                    if (e != null && !e.isEmpty()) {
                        deferredResult.fail(e.values().iterator().next());
                    }
                    logInfo(String.format("Created a new snapshot state for compute : %s", context.computeDescription.name));
                    deferredResult.complete(context);
                }).sendWith(this);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:65,代码来源:VSphereAdapterSnapshotService.java

示例4: deleteSnapshot

private void deleteSnapshot(SnapshotContext context, Connection connection, DeferredResult<SnapshotContext> deferredResult) {
    final SnapshotState snapshot = context.snapshotState;
    // Physical snapshot processing
    ManagedObjectReference snapshotMoref = CustomProperties.of(snapshot)
            .getMoRef(CustomProperties.MOREF);

    if (snapshotMoref == null) {
        deferredResult.fail(new IllegalStateException(String.format("Cannot find the snapshot %s to removed", snapshotMoref)));
        return;
    }

    ManagedObjectReference task;
    TaskInfo info;
    try {
        logInfo("Deleting snapshot with name %s", context.snapshotState.name);
        task = connection.getVimPort()
                .removeSnapshotTask(snapshotMoref, REMOVE_CHILDREN, SNAPSHOT_CONSOLIDATION);
        info = VimUtils.waitTaskEnd(connection, task);
        if (info.getState() != TaskInfoState.SUCCESS) {
            VimUtils.rethrow(info.getError());
        }
    } catch (Exception e) {
        logSevere("Deleting the snapshot %s failed", context.snapshotState.name);
        deferredResult.fail(e);
        return;
    }

    logInfo("Deleted the snapshot with name %s successfully", context.snapshotState.name);

    // Once the actual snapshot delete is successful, process the update of the children
    // snapshot states and the next current snapshot
    final List<SnapshotState> childSnapshots = new ArrayList<>();
    DeferredResult<List<SnapshotState>> dr = getChildSnapshots(snapshot.documentSelfLink) ;
    List<SnapshotState> updatedChildSnapshots = new ArrayList<>();
    dr.whenComplete((o, e) -> {
        if (e != null) {
            logSevere("Retrieving the details of children snapshots failed");
            deferredResult.fail(e);
            return;
        }
        childSnapshots.addAll(o);
        logInfo("Retrieving the details of %s children snapshots ", childSnapshots.size());
        // Update the children
        if (!childSnapshots.isEmpty()) {
            logInfo("Updating the state of child snapshots of: %s", snapshot.name);
            childSnapshots.forEach(c -> {
                c.parentLink = snapshot.parentLink;
                updatedChildSnapshots.add(c);
            });
            context.snapshotOperations =
                    updatedChildSnapshots
                            .stream()
                            .map(childSnapshot -> Operation.createPatch(
                                    PhotonModelUriUtils
                                            .createInventoryUri(getHost(), childSnapshot.documentSelfLink))
                                    .setBody(childSnapshot)
                                    .setReferer(getUri()))
                            .collect(Collectors.toList());
        }
        processNextStepsForDeleteOperation(context, deferredResult);
    });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:62,代码来源:VSphereAdapterSnapshotService.java

示例5: revertSnapshot

private void revertSnapshot(SnapshotContext context, Connection connection, DeferredResult<SnapshotContext> deferredResult) {
    final SnapshotState snapshot = context.snapshotState;
    SnapshotState existingSnapshotState = context.existingSnapshotState;
    // Physical snapshot processing
    ManagedObjectReference snapshotMoref = CustomProperties.of(snapshot)
            .getMoRef(CustomProperties.MOREF);

    if (snapshotMoref == null) {
        deferredResult.fail(new IllegalStateException(String.format("Cannot find the snapshot %s to revert to", snapshotMoref)));
        return;
    }

    ManagedObjectReference task;
    TaskInfo info;
    try {
        logInfo("Reverting to  snapshot with name %s", context.snapshotState.name);
        task = connection.getVimPort()
                .revertToSnapshotTask(snapshotMoref, null, false);
        info = VimUtils.waitTaskEnd(connection, task);
        if (info.getState() != TaskInfoState.SUCCESS) {
            VimUtils.rethrow(info.getError());
        }
    } catch (Exception e) {
        logSevere("Reverting to the snapshot %s failed", context.snapshotState.name);
        deferredResult.fail(e);
        return;
    }

    // Check if we're trying to revert to the current snapshot. In that case we need not
    // update the isCurrent for both the snapshot states (existing and the reverted).
    // Also sending multiple patch requests on the same snapshot document will
    // cause concurrency issue
    if (snapshot.isCurrent) {
        deferredResult.complete(context);
    } else {
        snapshot.isCurrent = true;

        context.snapshotOperations.add(Operation
                .createPatch(UriUtils.buildUri(getHost(), snapshot.documentSelfLink))
                .setBody(snapshot)
                .setReferer(getUri()));

        if (existingSnapshotState != null) {
            existingSnapshotState.isCurrent = false;
            context.snapshotOperations.add(Operation
                    .createPatch(UriUtils.buildUri(getHost(), existingSnapshotState.documentSelfLink))
                    .setBody(existingSnapshotState)
                    .setReferer(getUri()));
        }

        OperationJoin.JoinedCompletionHandler joinCompletion = (ox,
                                                                exc) -> {
            if (exc != null) {
                this.logSevere(() -> String.format("Error updating the snapshot states: %s",
                        Utils.toString(exc)));
                deferredResult.fail(
                        new IllegalStateException("Error updating the snapshot states"));
                return;
            }
            deferredResult.complete(context);
        };

        OperationJoin joinOp = OperationJoin.create(context.snapshotOperations);
        joinOp.setCompletion(joinCompletion);
        joinOp.sendWith(this.getHost());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:67,代码来源:VSphereAdapterSnapshotService.java


注:本文中的com.vmware.vim25.TaskInfoState.SUCCESS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。