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


Java Operation.getAction方法代码示例

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


在下文中一共展示了Operation.getAction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
        NicSecurityGroupsRequest request = op
                .getBody(NicSecurityGroupsRequest.class);
        NicSecurityGroupsTaskState taskState = new
                NicSecurityGroupsTaskState();
        taskState.taskInfo = new TaskState();
        taskState.taskInfo.stage = TaskState.TaskStage.FINISHED;
        sendRequest(Operation.createPatch(
                request.taskReference).setBody(
                taskState));
        op.complete();
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:MockAdapter.java

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

示例3: handleRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleRequest(Operation op) {
    switch (op.getAction()) {
    case PATCH:
        if (!op.hasBody()) {
            op.fail(new IllegalArgumentException("body is required"));
            return;
        }
        // initialize allocation object
        AWSNetworkContext context = new AWSNetworkContext(this,
                op.getBody(NetworkInstanceRequest.class));
        op.complete();
        handleStages(context, AWSNetworkStage.NETWORK_TASK_STATE);
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:AWSNetworkService.java

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

示例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:
        op.complete();
        ComputeStatsRequest request = op.getBody(ComputeStatsRequest.class);
        SingleResourceStatsCollectionTaskState response = new SingleResourceStatsCollectionTaskState();
        Map<String, List<ServiceStat>> statValues = new HashMap<>();
        ServiceStat key1 = new ServiceStat();
        key1.latestValue = new Random().nextInt(1000);
        key1.sourceTimeMicrosUtc = TimeUnit.MILLISECONDS
                .toMicros(System.currentTimeMillis());
        key1.unit = UNIT_1;
        statValues.put(KEY_1, Collections.singletonList(key1));
        ComputeStats stats = new ComputeStats();
        stats.statValues = statValues;
        stats.computeLink = request.resourceReference.getPath();
        response.statsList = new ArrayList<>();
        response.statsList.add(stats);
        response.taskStage = SingleResourceTaskCollectionStage.valueOf(request.nextStage);
        response.statsAdapterReference = UriUtils.buildUri(getHost(), SELF_LINK);
        this.sendRequest(Operation.createPatch(request.taskReference)
                .setBody(response));
        break;
    default:
        super.handleRequest(op);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:33,代码来源:StatsCollectionTaskServiceTest.java

示例6: issueStatsRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void issueStatsRequest(ComputeState vm, Long lastCollectionTime) throws Throwable {
    // 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 (!TestAWSProvisionTask.this.isMock) {
                    ComputeStatsResponse resp = op.getBody(ComputeStatsResponse.class);
                    if (resp.statsList.size() != 1) {
                        TestAWSProvisionTask.this.host.failIteration(
                                new IllegalStateException("response size was incorrect."));
                        return;
                    }
                    // Size == 1, because APICallCount
                    if (resp.statsList.get(0).statValues.size() == 1) {
                        TestAWSProvisionTask.this.host.failIteration(new IllegalStateException(
                                "incorrect number of metrics received."));
                        return;
                    }
                    if (lastCollectionTime != null) {
                        if (resp.statsList.get(0).statValues
                                .get(PhotonModelConstants.CPU_UTILIZATION_PERCENT)
                                .size() < 2) {
                            TestAWSProvisionTask.this.host
                                    .failIteration(new IllegalStateException(
                                            "incorrect number of data points received when collection window is specified."));
                            return;
                        }

                    }
                    if (!resp.statsList.get(0).computeLink.equals(vm.documentSelfLink)) {
                        TestAWSProvisionTask.this.host.failIteration(new IllegalStateException(
                                "Incorrect resourceReference returned."));
                        return;
                    }
                    verifyCollectedStats(resp, lastCollectionTime);
                }
                TestAWSProvisionTask.this.host.completeIteration();
            }
        }
    };
    String servicePath = UUID.randomUUID().toString();
    Operation startOp = Operation.createPost(UriUtils.buildUri(this.host, servicePath));
    this.host.startService(startOp, parentService);
    ComputeStatsRequest statsRequest = new ComputeStatsRequest();
    statsRequest.resourceReference = UriUtils.buildUri(this.host, vm.documentSelfLink);
    statsRequest.isMockRequest = this.isMock;
    statsRequest.nextStage = SingleResourceTaskCollectionStage.UPDATE_STATS.name();
    statsRequest.taskReference = UriUtils.buildUri(this.host, servicePath);
    if (lastCollectionTime != null) {
        statsRequest.lastCollectionTimeMicrosUtc = lastCollectionTime;
    }
    this.host.sendAndWait(Operation.createPatch(UriUtils.buildUri(
            this.host, AWSUriPaths.AWS_STATS_ADAPTER))
            .setBody(statsRequest)
            .setReferer(this.host.getUri()));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:58,代码来源:TestAWSProvisionTask.java

示例7: issueStatsRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void issueStatsRequest(String selfLink, boolean isComputeHost) throws Throwable {
    // 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 (!TestAzureEnumerationTask.this.isMock) {
                    ComputeStatsResponse resp = op.getBody(ComputeStatsResponse.class);
                    if (resp == null) {
                        TestAzureEnumerationTask.this.host.failIteration(
                                new IllegalStateException("response was null."));
                        return;
                    }
                    if (resp.statsList.size() != 1) {
                        TestAzureEnumerationTask.this.host.failIteration(
                                new IllegalStateException("response size was incorrect."));
                        return;
                    }
                    if (resp.statsList.get(0).statValues.size() == 0) {
                        TestAzureEnumerationTask.this.host
                                .failIteration(new IllegalStateException(
                                        "incorrect number of metrics received."));
                        return;
                    }
                    if (!resp.statsList.get(0).computeLink.equals(selfLink)) {
                        TestAzureEnumerationTask.this.host
                                .failIteration(new IllegalStateException(
                                        "Incorrect resourceReference returned."));
                        return;
                    }
                    // Verify all the stats are obtained
                    verifyStats(resp, isComputeHost);
                    // Persist stats on Verification Host for testing the computeHost stats.
                    URI persistStatsUri = UriUtils.buildUri(getHost(),
                            ResourceMetricsService.FACTORY_LINK);
                    ResourceMetricsService.ResourceMetrics resourceMetric = new ResourceMetricsService.ResourceMetrics();
                    resourceMetric.documentSelfLink = StatsUtil.getMetricKey(selfLink,
                            Utils.getNowMicrosUtc());
                    resourceMetric.entries = new HashMap<>();
                    resourceMetric.timestampMicrosUtc = Utils.getNowMicrosUtc();
                    for (String key : resp.statsList.get(0).statValues.keySet()) {
                        List<ServiceStat> stats = resp.statsList.get(0).statValues.get(key);
                        for (ServiceStat stat : stats) {
                            if (stat == null) {
                                continue;
                            }
                            resourceMetric.entries.put(key, stat.latestValue);
                        }
                    }
                    TestAzureEnumerationTask.this.host.sendRequest(Operation
                            .createPost(persistStatsUri)
                            .setReferer(TestAzureEnumerationTask.this.host.getUri())
                            .setBodyNoCloning(resourceMetric));
                }
                TestAzureEnumerationTask.this.host.completeIteration();
            }
        }
    };
    String servicePath = UUID.randomUUID().toString();
    Operation startOp = Operation.createPost(UriUtils.buildUri(this.host, servicePath));
    this.host.startService(startOp, parentService);
    ComputeStatsRequest statsRequest = new ComputeStatsRequest();
    statsRequest.resourceReference = UriUtils.buildUri(this.host, selfLink);
    statsRequest.nextStage = SingleResourceTaskCollectionStage.UPDATE_STATS.name();
    statsRequest.isMockRequest = this.isMock;
    statsRequest.taskReference = UriUtils.buildUri(this.host, servicePath);
    this.host.sendAndWait(Operation.createPatch(UriUtils.buildUri(
            this.host, AzureUriPaths.AZURE_STATS_ADAPTER))
            .setBody(statsRequest)
            .setReferer(this.host.getUri()));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:72,代码来源:TestAzureEnumerationTask.java

示例8: issueStatsRequest

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Creates a stateless service which will call GCPStatsService to collect stats of the
 * resource specified by the argument.
 * Receives response back and patches it to the caller service.
 * @param selfLink The self link to the document of enumerated resource.
 * @throws Throwable
 */
public void issueStatsRequest(String selfLink) throws Throwable {
    // 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 (!TestGCPStatsCollection.this.isMock) {
                    ComputeStatsResponse resp = op.getBody(ComputeStatsResponse.class);
                    if (resp == null) {
                        TestGCPStatsCollection.this.host.failIteration(
                                new IllegalStateException("response was null."));
                        return;
                    }
                    if (resp.statsList.size() != 1) {
                        TestGCPStatsCollection.this.host.failIteration(
                                new IllegalStateException("response size was incorrect."));
                        return;
                    }
                    if (resp.statsList.get(0).statValues.size() != 9) {
                        TestGCPStatsCollection.this.host
                                .failIteration(new IllegalStateException(
                                        "incorrect number of metrics received."));
                        return;
                    }
                    if (!resp.statsList.get(0).computeLink.equals(selfLink)) {
                        TestGCPStatsCollection.this.host
                                .failIteration(new IllegalStateException(
                                        "Incorrect resourceReference returned."));
                        return;
                    }
                }
                TestGCPStatsCollection.this.host.completeIteration();
            }
        }
    };
    String servicePath = UUID.randomUUID().toString();
    Operation startOp = Operation.createPost(UriUtils.buildUri(this.host, servicePath));
    this.host.startService(startOp, parentService);
    ComputeStatsRequest statsRequest = new ComputeStatsRequest();
    statsRequest.resourceReference = UriUtils.buildUri(this.host, selfLink);
    statsRequest.isMockRequest = this.isMock;
    statsRequest.taskReference = UriUtils.buildUri(this.host, servicePath);
    this.host.sendAndWait(Operation.createPatch(UriUtils.buildUri(
            this.host, GCPUriPaths.GCP_STATS_ADAPTER))
            .setBody(statsRequest)
            .setReferer(this.host.getUri()));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:55,代码来源:TestGCPStatsCollection.java


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