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


Java Operation.hasBody方法代码示例

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


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

示例1: handleStart

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

        ResourceEnumerationTaskState state = getBody(start);
        validateState(state);
        start.setBody(state).complete();

        sendSelfPatch(state, TaskStage.STARTED, null);
    } catch (Throwable e) {
        start.fail(e);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:18,代码来源:ResourceEnumerationTaskService.java

示例2: handlePatch

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

    // Complete the operation.
    patchOp.complete();

    ImageEnumerateRequest adapterRequest = patchOp.getBody(ImageEnumerateRequest.class);

    // PATCH the task with 'completed' TaskState
    ImageEnumerationTaskState taskResponse = new ImageEnumerationTaskState();
    taskResponse.taskInfo = this.completedTaskState;
    if (taskResponse.taskInfo.failure != null) {
        taskResponse.failureMessage = taskResponse.taskInfo.failure.message;
    }

    sendRequest(Operation.createPatch(adapterRequest.taskReference).setBody(taskResponse));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:MockAdapter.java

示例3: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation start) {
    try {
        if (!start.hasBody()) {
            start.fail(new IllegalArgumentException("body is required"));
            return;
        }
        StatsCollectionTaskState state = start.getBody(StatsCollectionTaskState.class);
        int expirationHours = Integer
                .getInteger(STATS_COLLECTION_EXPIRATION_HOURS, DEFAULT_COLLECTION_EXPIRATION_HOURS);
        setExpiration(state, expirationHours, TimeUnit.HOURS);
        validateState(state);
        logInfo(() -> String.format("Starting stats collection task for: %s",
                state.resourcePoolLink));
        start.complete();
        state.taskInfo = TaskUtils.createTaskState(TaskStage.STARTED);
        state.taskSubStage = StatsCollectionStage.INIT;
        handleStagePatch(start, state);
    } catch (Throwable e) {
        start.fail(e);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:StatsCollectionTaskService.java

示例4: 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;
    }

    // Immediately complete the Operation from calling task.
    op.complete();

    // initialize context object
    AWSLoadBalancerContext context = new AWSLoadBalancerContext(this,
            op.getBody(LoadBalancerInstanceRequest.class));

    DeferredResult.completed(context)
            .thenCompose(this::populateContext)
            .thenCompose(this::handleInstanceRequest)
            .whenComplete((o, e) -> {
                // Once done patch the calling task with correct stage.
                if (e == null) {
                    context.taskManager.finishTask();
                } else {
                    context.taskManager.patchTaskToFailure(e);
                }
            });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:AWSLoadBalancerService.java

示例5: 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:
        SubnetInstanceRequest request = op.getBody(SubnetInstanceRequest.class);
        ProvisionSubnetTaskState provisionSubnetTaskState = new ProvisionSubnetTaskState();
        provisionSubnetTaskState.taskInfo = createFailedTaskInfo();

        sendRequest(Operation.createPatch(
                request.taskReference).setBody(
                provisionSubnetTaskState));
        op.complete();
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:MockAdapter.java

示例6: 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

示例7: handlePost

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Override the handlePost method to set the documentSelfLink. We don't want to have multiple
 * certificate states with the same certificate, so we build the documentSelfLink ourselves
 *
 * @param op
 */
@Override
public void handlePost(Operation op) {
    if (op.isSynchronize()) {
        op.complete();
        return;
    }
    if (op.hasBody()) {
        SslTrustCertificateState body = (SslTrustCertificateState) op.getBody(this.stateType);
        if (body == null) {
            op.fail(new IllegalArgumentException("structured body is required"));
            return;
        }

        if (body.documentSourceLink != null) {
            op.fail(new IllegalArgumentException("clone request not supported"));
            return;
        }

        body.documentSelfLink = generateSelfLink(body);
        op.setBody(body);
        op.complete();
    } else {
        op.fail(new IllegalArgumentException("body is required"));
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:32,代码来源:SslTrustCertificateFactoryService.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;
    }
    ComputeStatsRequest statsRequest = op.getBody(ComputeStatsRequest.class);
    op.complete();
    TaskManager taskManager = new TaskManager(this, statsRequest.taskReference,
            statsRequest.resourceLink());
    if (statsRequest.isMockRequest) {
        // patch status to parent task
        taskManager.finishTask();
        return;
    }
    AWSStatsDataHolder statsData = new AWSStatsDataHolder();
    statsData.statsRequest = statsRequest;
    statsData.taskManager = taskManager;
    getVMDescription(statsData);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:AWSStatsService.java

示例9: 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;
    }

    // initialize context object
    AzureLoadBalancerContext context = new AzureLoadBalancerContext(
            this, op.getBody(LoadBalancerInstanceRequest.class));

    // Immediately complete the Operation from calling task.
    op.complete();

    DeferredResult.completed(context)
            .thenCompose(this::populateContext)
            .thenCompose(this::handleLoadBalancerInstanceRequest)
            // Once done patch the calling task with correct stage.
            .whenComplete((o, e) -> context.finish(e));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:AzureLoadBalancerService.java

示例10: 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

示例11: 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

示例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: processInput

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private SubnetState processInput(Operation op) {
    if (!op.hasBody()) {
        throw (new IllegalArgumentException("body is required"));
    }
    SubnetState state = op.getBody(SubnetState.class);
    validateState(state);
    return state;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:9,代码来源:SubnetService.java

示例15: 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;
    }

    NicSecurityGroupsTaskState state = start
            .getBody(NicSecurityGroupsTaskState.class);
    try {
        Utils.validateState(getStateDescription(), state);
    } catch (Exception e) {
        start.fail(e);
        return;
    }

    validateSecurityGroupsEndpoint(state)
            .whenComplete((ignore, e) -> {
                if (e != null) {
                    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,代码行数:32,代码来源:NicSecurityGroupsTaskService.java


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