本文整理汇总了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);
}
}
示例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));
}
示例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);
}
}
示例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);
}
});
}
示例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);
}
}
示例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);
}
示例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"));
}
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
});
}