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


Java Operation.getBody方法代码示例

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


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

示例1: handlePut

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePut(Operation put) {
    UserToken body = put.getBody(UserToken.class);
    Map<String, String> queryParams = UriUtils.parseUriQueryParams(put.getUri());
    String appendValue = queryParams.get("append");

    UserToken currentState = new UserToken();
    currentState.token = body.token;
    currentState.user = body.user;
    if (Boolean.valueOf(appendValue)) {
        currentState.internalId = body.user + body.internalId;
    }
    log(Level.INFO, "user:%s token:%s internal:%s", currentState.user, currentState.token,
            currentState.internalId);
    put.setBody(currentState).complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:17,代码来源:TokenService.java

示例2: testGetAvailableRegions

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Test
public void testGetAvailableRegions() {

    Assume.assumeFalse(this.isMock);

    URI uri = UriUtils.buildUri(
            ServiceHost.LOCAL_HOST,
            host.getPort(),
            UriPaths.AdapterTypePath.REGION_ENUMERATION_ADAPTER.adapterLink(
                    PhotonModelConstants.EndpointType.azure.toString().toLowerCase()), null);

    Operation post = Operation.createPost(uri);
    post.setBody(endpointState);

    Operation operation = host.getTestRequestSender().sendAndWait(post);
    RegionEnumerationResponse result = operation.getBody(RegionEnumerationResponse.class);

    assertTrue(!result.regions.isEmpty());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:TestAzureEnumerationTask.java

示例3: handleDelete

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
public static void handleDelete(Operation op, StatefulService service) {
    service.logInfo("Deleting document %s, Operation ID: %d, Referrer: %s",
            op.getUri().getPath(), op.getId(), op.getRefererAsString());

    ServiceDocument currentState = service.getState(op);

    // If delete request specifies the document expiration time then set that, otherwise
    // by default set the expiration to one month later.
    if (op.hasBody()) {
        ServiceDocument opState = op.getBody(ServiceDocument.class);

        if (opState.documentExpirationTimeMicros > 0) {
            currentState.documentExpirationTimeMicros = opState.documentExpirationTimeMicros;
        }
    } else {
        currentState.documentExpirationTimeMicros = Utils.getNowMicrosUtc()
                + TimeUnit.DAYS.toMicros(31);
    }

    op.complete();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:ResourceUtils.java

示例4: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation op) {
    setOperationHandlerInvokeTimeStat(op);
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    AWSNetworkEnumerationRequest cs = op.getBody(AWSNetworkEnumerationRequest.class);
    AWSNetworkStateCreationContext context = new AWSNetworkStateCreationContext(cs, op);
    if (cs.request.isMockRequest) {
        op.complete();
    }
    try {
        handleNetworkStateChanges(context);
    } catch (Exception e) {
        op.fail(e);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:AWSNetworkStateEnumerationAdapterService.java

示例5: issueStatsRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void issueStatsRequest(ComputeState account) throws Throwable {
    List<ComputeStats> allStats = new ArrayList<>();
    // spin up a stateless service that acts as the parent link to patch back to
    StatelessService parentService = new StatelessService() {
        @Override
        public void handleRequest(Operation op) {
            if (op.getAction() == Action.PATCH) {
                if (TestAWSCostAdapterService.this.isMock) {
                    SingleResourceStatsCollectionTaskState resp = op
                            .getBody(SingleResourceStatsCollectionTaskState.class);
                    allStats.addAll(resp.statsList);
                    if (resp.isFinalBatch) {
                        verifyCollectedStats(allStats);
                        TestAWSCostAdapterService.this.host.completeIteration();
                    }
                } else {
                    TestAWSCostAdapterService.this.host.completeIteration();
                }
            }
        }
    };
    sendStatsRequest(account, parentService);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:TestAWSCostAdapterService.java

示例6: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation patch) {
    DeploymentState currentState = getState(patch);
    Function<Operation, Boolean> customPatchHandler = t -> {
        boolean hasStateChanged = false;
        DeploymentState patchBody = patch.getBody(DeploymentState.class);

        if (patchBody.descriptionLink != null) {
            if (currentState.descriptionLink == null) {
                currentState.descriptionLink = patchBody.descriptionLink;
                hasStateChanged = true;
            } else if (!Objects.equals(patchBody.descriptionLink,
                    currentState.descriptionLink)) {
                throw new IllegalArgumentException("descriptionLink type can not be changed");
            }
        }

        return hasStateChanged;
    };
    ResourceUtils.handlePatch(patch, currentState, getStateDescription(),
            DeploymentState.class, customPatchHandler);
}
 
开发者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;
    }

    // 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

示例8: 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 = new TaskState();
        computeSubTaskState.taskInfo.stage = TaskState.TaskStage.FINISHED;
        sendRequest(Operation
                .createPatch(request.taskReference).setBody(
                        computeSubTaskState));
        op.complete();
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:MockAdapter.java

示例9: getNICByAWSId

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Lookup a NIC State by aws Id
 */
public static NetworkInterfaceState getNICByAWSId(VerificationHost host, String awsId)
        throws Throwable {

    URI networkInterfacesURI = UriUtils.buildUri(host, NetworkInterfaceService.FACTORY_LINK);
    networkInterfacesURI = UriUtils.buildExpandLinksQueryUri(networkInterfacesURI);
    networkInterfacesURI = UriUtils.appendQueryParam(networkInterfacesURI, "$filter",
            String.format("id eq %s", awsId));

    Operation op = host.waitForResponse(Operation.createGet(networkInterfacesURI));
    ServiceDocumentQueryResult result = op.getBody(ServiceDocumentQueryResult.class);
    assertNotNull(result);
    assertNotNull(result.documents);
    if (result.documents.size() == 0) {
        return null;
    }
    return Utils.fromJson(result.documents.values().iterator().next(), NetworkInterfaceState.class);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:TestAWSSetupUtils.java

示例10: handleCreate

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleCreate(Operation post) {
    if (!checkForBody(post)) {
        return;
    }

    try {
        SslTrustCertificateState state = post.getBody(SslTrustCertificateState.class);
        if (state.documentVersion > 0) {
            post.complete();
            return;
        }

        boolean validated = validate(post, () -> validateStateOnStart(state));
        if (!validated) {
            return;
        }
        post.complete();
    } catch (Throwable t) {
        post.fail(t);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:SslTrustCertificateService.java

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

示例12: addOperation

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void addOperation(String uri, Operation op) {
    ServiceDocumentQueryResult q = op.getBody(ServiceDocumentQueryResult.class);

    // use service base path as tag if there is no custom value present
    this.currentTag = new Tag();
    this.currentTag.setName(uri);

    if (q.documents != null) {
        Object firstDoc = q.documents.values().iterator().next();
        ServiceDocument serviceDocument = Utils.fromJson(firstDoc, ServiceDocument.class);
        // Override the custom tag and description if present as part of documentDescription
        updateCurrentTag(this.currentTag, serviceDocument.documentDescription);
        addFactory(uri, serviceDocument);

        this.swagger.addTag(this.currentTag);
    } else if (q.documentDescription != null
            && q.documentDescription.serviceRequestRoutes != null
            && !q.documentDescription.serviceRequestRoutes.isEmpty()) {
        updateCurrentTag(this.currentTag, q.documentDescription);
        Map<String, Path> map = pathByRoutes(q.documentDescription.serviceRequestRoutes.values(),
                Path::new);
        for (Entry<String, Path> entry : map.entrySet()) {
            this.swagger.path(uri + entry.getKey(), entry.getValue());
        }

        this.swagger.addTag(this.currentTag);
    }
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:29,代码来源:SwaggerAssembler.java

示例13: handlePost

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePost(Operation post) {
    UserToken body = post.getBody(UserToken.class);
    body.internalId = UUID.randomUUID().toString();
    log(Level.INFO, "user:%s token:%s internal", body.user, body.token);
    post.complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:8,代码来源:TokenService.java

示例14: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation patch) {
    UserToken body = patch.getBody(UserToken.class);
    UserToken currentState = new UserToken();
    currentState.token = body.token;
    currentState.user = body.user;
    currentState.internalId = body.internalId;
    log(Level.INFO, "user:%s token:%s internal:%s", currentState.user, currentState.token,
            currentState.internalId);
    patch.setBody(currentState).complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:12,代码来源:TokenService.java

示例15: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation op) {
    setOperationHandlerInvokeTimeStat(op);
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    AWSComputeStateCreationRequest cs = op.getBody(AWSComputeStateCreationRequest.class);
    AWSComputeStateCreationContext context = new AWSComputeStateCreationContext(cs, op);
    if (cs.isMock) {
        op.complete();
    }
    handleComputeStateCreateOrUpdate(context);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:15,代码来源:AWSComputeStateCreationAdapterService.java


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