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


Java Operation.CompletionHandler方法代码示例

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


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

示例1: doSubStageDiskOperation

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void doSubStageDiskOperation(ProvisionDiskTaskState updatedState,
        ProvisionDiskTaskState.SubStage nextStage, DiskInstanceRequest.DiskRequestType diskRequestType) {
    Operation.CompletionHandler c = (o, e) -> {
        if (e != null) {
            failTask(e);
            return;
        }

        DiskInstanceRequest cr = new DiskInstanceRequest();
        cr.resourceReference = createInventoryUri(this.getHost(), updatedState.diskLink);
        cr.requestType = diskRequestType;

        ServiceDocument subTask = o.getBody(ServiceDocument.class);
        cr.taskReference = UriUtils.buildUri(this.getHost(), subTask.documentSelfLink);
        cr.isMockRequest = updatedState.isMockRequest;
        sendHostServiceRequest(cr, updatedState.diskAdapterReference);
    };

    // after setting boot order and rebooting, we want the sub
    // task to patch us, the main task, to the "next" state
    createSubTask(c, nextStage, updatedState);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:ProvisionDiskTaskService.java

示例2: createInternalTypeTag

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void createInternalTypeTag(SecurityGroupEnumContext context, EnumerationStages next) {
    TagService.TagState typeTag = newTagState(TAG_KEY_TYPE, ec2_security_group.toString(),
            false, context.request.parentCompute.tenantLinks);

    Operation.CompletionHandler handler = (op, ex) -> {
        if (ex != null) {
            // log the error and continue the enumeration
            logWarning(() -> String
                    .format("Error creating internal tag: %s", ex.getMessage()));
        } else {
            // if no error, store the internal tag into context
            context.internalTagLink = typeTag.documentSelfLink;
        }
        context.stage = next;
        handleEnumeration(context);
    };

    sendRequest(Operation.createPost(this, TagService.FACTORY_LINK)
            .setBody(typeTag)
            .setCompletion(handler));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:AWSSecurityGroupEnumerationAdapterService.java

示例3: createInternalTypeTag

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void createInternalTypeTag(EnumerationContext context,
        ComputeEnumerationSubStages next) {
    TagService.TagState typeTag = newTagState(TAG_KEY_TYPE,
            AzureResourceType.azure_vm.toString(),
            false, context.parentCompute.tenantLinks);

    Operation.CompletionHandler handler = (completedOp, failure) -> {
        if (failure == null) {
            // if no error, store the internal tag into context
            context.internalTagLinks.add(typeTag.documentSelfLink);
        } else {
            // log the error and continue the enumeration
            logWarning(() -> String
                    .format("Error creating internal tag: %s", failure.getMessage()));
        }
        context.subStage = next;
        handleSubStage(context);
    };

    sendRequest(Operation.createPost(this, TagService.FACTORY_LINK)
            .setBody(typeTag)
            .setCompletion(handler));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:AzureComputeEnumerationAdapterService.java

示例4: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation startPost) {
    Operation.CompletionHandler handler = (op, exc) -> {
        if (exc != null) {
            startPost.fail(exc);
        } else {
            startPost.complete();
        }
    };
    ResourceOperationUtils
            .registerResourceOperation(this, handler, createResourceOperationSpecs());
    this.clientManager = AWSClientManagerFactory
            .getClientManager(AWSConstants.AwsClientType.EC2);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:15,代码来源:AWSComputeDiskDay2Service.java

示例5: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation startPost) {
    Operation.CompletionHandler handler = (op, exc) -> {
        if (exc != null) {
            startPost.fail(exc);
        } else {
            startPost.complete();
        }
    };
    ResourceOperationUtils
            .registerResourceOperation(this, handler, getResourceOperationSpecs());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:13,代码来源:VSphereComputeDiskManagementService.java

示例6: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation startPost) {
    Operation.CompletionHandler handler = (op, exc) -> {
        if (exc != null) {
            startPost.fail(exc);
        } else {
            startPost.complete();
        }
    };
    ResourceOperationUtils.registerResourceOperation(this, handler, getResourceOperationSpecs());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:VSphereAdapterResizeComputeService.java

示例7: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation startPost) {
    this.executorService = getHost().allocateExecutor(this);

    Operation.CompletionHandler completionHandler = (op, exc) -> {
        if (exc != null) {
            startPost.fail(exc);
        } else {
            startPost.complete();
        }
    };
    ResourceOperationUtils.registerResourceOperation(this,
            completionHandler, getResourceOperationSpecs());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:15,代码来源:AzureComputeDiskDay2Service.java

示例8: triggerEnumerationAdapter

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Trigger specified enumeration adapter
 */
public void triggerEnumerationAdapter(EnumerationContext context, String adapterSelfLink,
        AzureEnumerationStages next) {
    Operation.CompletionHandler completionHandler = (o, e) -> {
        if (e != null) {
            context.error = new IllegalStateException(String.format(
                    "Error triggering Azure enumeration adapter %s", adapterSelfLink), e);

            context.taskManager.patchTaskToFailure(context.error);

            logSevere(context.error);

            return;
        }

        logFine(() -> String.format("Completed Azure enumeration adapter %s", adapterSelfLink));
        context.stage = next;
        handleEnumerationRequest(context);
    };

    ComputeEnumerateAdapterRequest azureEnumerationRequest = new ComputeEnumerateAdapterRequest(
            context.request, context.endpointAuth,
            context.parent);

    Operation.createPatch(this, adapterSelfLink)
            .setBody(azureEnumerationRequest)
            .setCompletion(completionHandler)
            .sendWith(this);
    logInfo(() -> String.format("Triggered Azure enumeration adapter %s", adapterSelfLink));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:33,代码来源:AzureEnumerationAdapterService.java

示例9: setFactoryToAvailable

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Helper method to explicitly set a factory to be "available". This is usually unnecessary, but
 * currently factories that create {@code ON_DEMAND_LOAD} services are not being set to
 * available... and currently require this work-around.
 *
 * @param host
 *            the host
 * @param factoryPath
 *            the path of the factory to explicitly set to be available
 * @param handler
 *            an optional completion handler
 */
public static void setFactoryToAvailable(ServiceHost host, String factoryPath,
        Operation.CompletionHandler handler) {
    ServiceStats.ServiceStat body = new ServiceStats.ServiceStat();
    body.name = Service.STAT_NAME_AVAILABLE;
    body.latestValue = Service.STAT_VALUE_TRUE;

    Operation put = Operation.createPut(UriUtils.buildAvailableUri(host, factoryPath))
            .setBody(body)
            .setCompletion(handler)
            .setReferer(host.getUri());
    host.sendRequest(put);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:PhotonModelMetricServices.java

示例10: disassociateResourceHelper

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void disassociateResourceHelper(String nextPageLink, SubStage next,
                                        String endpointLink) {
    Operation.CompletionHandler completionHandler = (o, e) -> {
        if (e != null) {
            logWarning(e.getMessage());
            sendFailureSelfPatch(e);
            return;
        }

        QueryTask queryTask = o.getBody(QueryTask.class);
        List<Operation> updateOperations = new ArrayList<>();

        // for each resource link in the results, get the expanded document
        // and issue an update request to its associated instance service.
        for (String selfLink : queryTask.results.documentLinks) {
            Object document = queryTask.results.documents.get(selfLink);
            ResourceState resourceState = Utils.fromJson(document, ResourceState.class);
            Operation operation = PhotonModelUtils.createRemoveEndpointLinksOperation(
                    this, endpointLink, resourceState);
            if (operation != null) {
                updateOperations.add(operation);
            }
        }

        if (updateOperations.size() == 0) {
            sendSelfPatch(TaskStage.STARTED, next);
            return;
        }

        OperationJoin joinOp = OperationJoin.create(updateOperations);
        JoinedCompletionHandler joinHandler = (ops, exc) -> {
            if (exc != null) {
                logWarning(() -> String.format("Failed delete some of the associated resources,"
                        + " reason %s", Utils.toString(exc)));
            }

            if (queryTask.results.nextPageLink == null) {
                // all resources are updated
                sendSelfPatch(TaskStage.STARTED, next);
                return;
            }
            disassociateResourceHelper(queryTask.results.nextPageLink, next, endpointLink);
        };
        joinOp.setCompletion(joinHandler);
        joinOp.sendWith(getHost());
    };
    sendRequest(Operation.createGet(createInventoryUri(this.getHost(), nextPageLink))
            .setCompletion(completionHandler));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:50,代码来源:EndpointRemovalTaskService.java


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