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


Java Operation.fail方法代码示例

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


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

示例1: handleRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleRequest(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    switch (op.getAction()) {
    case PATCH:
        ResourceOperationRequest request = op.getBody(ResourceOperationRequest.class);
        @SuppressWarnings("rawtypes")
        SubTaskState computeSubTaskState = new SubTaskState();
        computeSubTaskState.taskInfo = createFailedTaskInfo();
        sendRequest(Operation
                .createPatch(request.taskReference).setBody(
                        computeSubTaskState));
        op.complete();
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:MockAdapter.java

示例2: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation start) {
    if (!start.hasBody()) {
        start.fail(new IllegalArgumentException("body is required"));
        return;
    }

    ResourceAllocationTaskState state = getBody(start);

    // if we're passed a resource description link, we'll need to merge
    // state first.
    if (state.resourceDescriptionLink != null) {
        copyResourceDescription(start);
        return;
    }

    validateAndCompleteStart(start, state);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:ResourceAllocationTaskService.java

示例3: validateTransition

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Customize the validation transition logic that's part of {@code PATCH} request.
 */
@Override
protected boolean validateTransition(
        Operation patchOp,
        ImageEnumerationTaskState currentState,
        ImageEnumerationTaskState patchState) {

    boolean ok = super.validateTransition(patchOp, currentState, patchState);

    if (ok) {
        if (currentState.taskInfo.stage == TaskStage.STARTED
                && patchState.taskInfo.stage == TaskStage.STARTED) {
            patchOp.fail(new IllegalArgumentException("Cannot start task again"));
            return false;
        }
    }

    return ok;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:ImageEnumerationTaskService.java

示例4: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation start) {
    if (!start.hasBody()) {
        start.fail(new IllegalArgumentException("body is required"));
        return;
    }

    ProvisionSecurityGroupTaskState state = start
            .getBody(ProvisionSecurityGroupTaskState.class);
    try {
        state.validate();
    } catch (Exception e) {
        start.fail(e);
        return;
    }
    state.taskInfo = new TaskState();
    state.taskInfo.stage = TaskState.TaskStage.CREATED;
    state.taskSubStage = SubStage.CREATED;
    start.complete();

    // start the task
    sendSelfPatch(TaskState.TaskStage.CREATED, null);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:ProvisionSecurityGroupTaskService.java

示例5: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    op.complete();
    ComputeStatsRequest statsRequest = op.getBody(ComputeStatsRequest.class);
    AWSMockStatsDataHolder statsData = new AWSMockStatsDataHolder();
    statsData.statsRequest = statsRequest;
    statsData.taskManager = new TaskManager(this, statsRequest.taskReference,
            statsRequest.resourceLink());
    if (statsRequest.isMockRequest) {
        // patch status to parent task
        statsData.taskManager.finishTask();
        return;
    }

    getVMDescription(statsData);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:AWSMockStatsService.java

示例6: handlePut

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePut(Operation put) {
    try {
        if (!put.hasBody()) {
            throw new IllegalArgumentException("body is required");
        }

        DeploymentState newState = put.getBody(DeploymentState.class);
        DeploymentState previousState = getState(put);
        Utils.validateState(getStateDescription(), newState);
        if (previousState.descriptionLink != null
                && !Objects.equals(newState.descriptionLink, previousState.descriptionLink)) {
            throw new IllegalArgumentException("descriptionLink type can not be changed");
        }
        newState.creationTimeMicros = previousState.creationTimeMicros;
        setState(put, newState);
        put.complete();
    } catch (Throwable t) {
        logSevere(t);
        put.fail(t);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:DeploymentService.java

示例7: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    EndpointConfigRequest body = op.getBody(EndpointConfigRequest.class);

    if (body.requestType == RequestType.CHECK_IF_ACCOUNT_EXISTS) {
        checkIfAccountExistsAndGetExistingDocuments(body, op);
        return;
    }

    EndpointAdapterUtils.handleEndpointRequest(this, op, body, credentials(),
            computeDesc(), compute(), endpoint(), validate(body));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:AzureEndpointAdapterService.java

示例8: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }

    SecurityGroupEnumContext ctx = new SecurityGroupEnumContext(
            this, op.getBody(ComputeEnumerateAdapterRequest.class), op);

    if (ctx.request.original.isMockRequest) {
        op.complete();
        return;
    }

    handleEnumeration(ctx);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:18,代码来源:AWSSecurityGroupEnumerationAdapterService.java

示例9: validateStartState

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private State validateStartState(Operation start) {
    if (!start.hasBody()) {
        start.fail(new IllegalArgumentException("body is required"));
        return null;
    }

    State state = getBody(start);
    if (state.status == null) {
        start.fail(new IllegalArgumentException("status is required"));
        return null;
    }

    return state;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:15,代码来源:GatewayConfigService.java

示例10: validateUpdateState

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private State validateUpdateState(Operation update) {
    if (!update.hasBody()) {
        update.fail(new IllegalStateException("body is required"));
        return null;
    }
    return getBody(update);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:8,代码来源:GatewayConfigService.java

示例11: failRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void failRequest(Operation op, long startTimeMicros,
                         int statusCode, String msgFormat, Object... args) {
    ServiceErrorResponse rsp = new ServiceErrorResponse();
    rsp.message = String.format(msgFormat, args);
    rsp.statusCode = statusCode;
    op.fail(statusCode, new IllegalStateException(rsp.message), rsp);
    logRequest(op, startTimeMicros, statusCode, op.getContentLength());
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:9,代码来源:GatewayService.java

示例12: validateStartState

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private State validateStartState(Operation start) {
    if (!start.hasBody()) {
        start.fail(new IllegalArgumentException("body is required"));
        return null;
    }

    State state = getBody(start);
    if (state.path == null) {
        start.fail(new IllegalArgumentException("path is required"));
        return null;
    }

    return state;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:15,代码来源:GatewayPathService.java

示例13: validateUpdateState

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private State validateUpdateState(Operation update) {
    if (!update.hasBody()) {
        update.fail(new IllegalArgumentException("body is required"));
        return null;
    }

    State body = getBody(update);
    State state = getState(update);
    if (body.path != null && !state.path.equals(body.path)) {
        update.fail(new IllegalArgumentException("path cannot be changed"));
        return null;
    }
    return body;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:15,代码来源:GatewayPathService.java

示例14: handlePost

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePost(Operation post) {
    if (!post.hasBody()) {
        post.fail(new IllegalArgumentException("body is required"));
        return;
    }

    Context ctx = new Context(this, post.getBody(EndpointState.class));

    DeferredResult.completed(ctx)
            .thenCompose(ctx::getAuthentication)
            .thenCompose(ctx::getAzureClient)
            .thenCompose(ctx::getAzureLocations)
            .whenComplete((ignoreCtx, t) -> {
                try {
                    if (t != null) {
                        post.fail(t);
                        return;
                    }

                    RegionEnumerationResponse result = new RegionEnumerationResponse();
                    result.regions = ctx.azureLocations.stream()
                            .map(loc -> new RegionInfo(loc.displayName(), loc.name()))
                            .collect(Collectors.toList());

                    post.setBodyNoCloning(result).complete();
                } finally {
                    ctx.close();
                }
            });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:32,代码来源:AzureRegionEnumerationAdapterService.java

示例15: handleRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleRequest(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    switch (op.getAction()) {
    case PATCH:
        op.complete();
        ComputeStatsRequest statsRequest = op.getBody(ComputeStatsRequest.class);
        SingleResourceStatsCollectionTaskState statsResponse = new SingleResourceStatsCollectionTaskState();
        Map<String, List<ServiceStat>> statValues = new HashMap<>();
        double currentCounter = this.counter.incrementAndGet();
        ServiceStat key1 = new ServiceStat();
        key1.latestValue = currentCounter;
        long timestampMicros = Utils.getNowMicrosUtc();
        key1.sourceTimeMicrosUtc = timestampMicros;
        key1.unit = UNIT_1;
        statValues.put(KEY_1, Collections.singletonList(key1));
        sendBatchResponse(statsRequest, statsResponse, statValues, false);
        statValues.clear();
        ServiceStat key2 = new ServiceStat();
        key2.latestValue = currentCounter;
        key2.sourceTimeMicrosUtc = timestampMicros;
        key2.unit = UNIT_2;
        statValues.put(KEY_2, Collections.singletonList(key2));
        sendBatchResponse(statsRequest, statsResponse, statValues, true);
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:33,代码来源:MockStatsAdapter.java


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