本文整理汇总了Java中com.vmware.xenon.common.Operation.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java Operation.getStatusCode方法的具体用法?Java Operation.getStatusCode怎么用?Java Operation.getStatusCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.xenon.common.Operation
的用法示例。
在下文中一共展示了Operation.getStatusCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTagStates
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
* Create n tagLinks
*/
private List<String> createTagStates(String prefix, int count, boolean external)
throws Throwable {
List<String> tags = new ArrayList<>();
for (int i = 0; i < count; i++) {
TagState tag = buildTagState(prefix, i, i, external);
Operation op = Operation
.createPost(UriUtils.buildUri(this.host, TagService.FACTORY_LINK))
.setBody(tag);
Operation response = this.host.waitForResponse(op);
if (response.getStatusCode() == Operation.STATUS_CODE_OK) {
tags.add(response.getBody(TagState.class).documentSelfLink);
}
}
return tags;
}
示例2: getTags
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
* Query for tagLinks
*/
public List<TagState> getTags(QueryTask queryTask) {
Operation postQuery = Operation
.createPost(UriUtils.buildUri(this.host, ServiceUriPaths.CORE_LOCAL_QUERY_TASKS))
.setBody(queryTask);
Operation queryResponse = this.host.waitForResponse(postQuery);
if (queryResponse.getStatusCode() != 200) {
return null;
}
QueryTask response = queryResponse.getBody(QueryTask.class);
List<TagState> tagList = new ArrayList<>();
response.results.documents.values().forEach(tagState -> {
TagState ts = Utils.fromJson(tagState, TagState.class);
tagList.add(ts);
});
return tagList;
}
示例3: createComputes
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
* Create given number of computes with given endpointLinks and tenantLink.
*/
private List<String> createComputes(int count, Set<String> endpointLinks, String tenantLink) {
List<String> computeLinks = new ArrayList<>();
ComputeState computeState = new ComputeState();
computeState.descriptionLink = "description-link";
computeState.id = UUID.randomUUID().toString();
computeState.name = computeState.id;
computeState.tenantLinks = Collections.singletonList(tenantLink);
computeState.endpointLinks = endpointLinks;
for (int i = 0; i < count; i++) {
Operation op = Operation
.createPost(UriUtils.buildUri(this.host, ComputeService.FACTORY_LINK))
.setBody(computeState);
Operation response = this.host.waitForResponse(op);
if (response.getStatusCode() == Operation.STATUS_CODE_OK) {
computeLinks.add(response.getBody(ComputeState.class).documentSelfLink);
}
}
return computeLinks;
}
示例4: assertNetworkInterfaceLinksAreValid
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void assertNetworkInterfaceLinksAreValid() {
for (String computeLink : this.computeStateLinks) {
Operation getCompute = Operation.createGet((UriUtils.buildUri(this.host, computeLink)))
.setReferer(this.host.getUri());
Operation compute = this.host.waitForResponse(getCompute);
if (compute.getStatusCode() == 200) {
ComputeState state = compute.getBody(ComputeState.class);
for (String nicLink : state.networkInterfaceLinks) {
Operation getNic = Operation.createGet((UriUtils.buildUri(this.host, nicLink)))
.setReferer(this.host.getUri());
Operation nic = this.host.waitForResponse(getNic);
assertEquals("GET on NIC failed.", Operation.STATUS_CODE_OK, nic.getStatusCode());
}
}
}
}
示例5: postResourceMetricsDocument
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
public static ResourceMetrics postResourceMetricsDocument(VerificationHost host) {
ResourceMetrics resourceMetrics = new ResourceMetrics();
resourceMetrics.timestampMicrosUtc = Utils.getNowMicrosUtc();
resourceMetrics.documentExpirationTimeMicros = 0;
resourceMetrics.entries = new HashMap<>();
resourceMetrics.entries.put("key", 1.1);
resourceMetrics.customProperties = new HashMap<>();
resourceMetrics.customProperties.put("key", "value");
resourceMetrics.documentSelfLink = UriUtils
.buildUriPath(ResourceMetricsService.FACTORY_LINK,
UUID.randomUUID().toString());
Operation postOp = Operation
.createPost(UriUtils.buildUri(host, ResourceMetricsService.FACTORY_LINK))
.setBody(resourceMetrics).setReferer(host.getUri());
Operation postResponse = host.waitForResponse(postOp);
if (postResponse.getStatusCode() == 200) {
return resourceMetrics;
} else {
return null;
}
}
示例6: logRequest
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private void logRequest(Operation op, long startTimeMicros, int statusCode, long contentLength) {
if (this.isRequestLoggingEnabled) {
long endTimeMicros = Utils.getSystemNowMicrosUtc();
Level level = op.getStatusCode() < Operation.STATUS_CODE_FAILURE_THRESHOLD ?
Level.INFO : Level.WARNING;
log(level, "%s %s %d %dB %.2fms", op.getAction(), op.getUri().getPath(),
statusCode, contentLength, (endTimeMicros - startTimeMicros) / 1000.0);
}
}
示例7: createValidEndpoints
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
* Create valid endpoint documents.
*/
private boolean createValidEndpoints() {
EndpointState state = new EndpointState();
state.endpointType = "Amazon Web Services";
state.id = UUID.randomUUID().toString();
state.name = state.id;
state.tenantLinks = Collections.singletonList(TENANT_LINK_1);
state.documentSelfLink = VALID_ENDPOINT_LINK_1;
Operation postEp1 = Operation
.createPost(this.host, EndpointService.FACTORY_LINK)
.setBody(state)
.setReferer(this.host.getUri());
state.documentSelfLink = VALID_ENDPOINT_LINK_2;
Operation postEp2 = Operation
.createPost(this.host, EndpointService.FACTORY_LINK)
.setBody(state)
.setReferer(this.host.getUri());
Operation postResponse1 = this.host.waitForResponse(postEp1);
Operation postResponse2 = this.host.waitForResponse(postEp2);
if (postResponse1.getStatusCode() == 200 && postResponse2.getStatusCode() == 200) {
return true;
}
return false;
}
示例8: getComputeCount
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
* Query count of computes with all given endpointLinks in a set and tenantLink.
*/
public long getComputeCount(Set<String> endpointLinks, String tenantLink) {
Query.Builder query = Query.Builder.create()
.addCollectionItemClause(ResourceState.FIELD_NAME_TENANT_LINKS, tenantLink);
for (String endpointLink : endpointLinks) {
query.addCollectionItemClause(ResourceState.FIELD_NAME_ENDPOINT_LINKS, endpointLink);
}
QueryTask queryTask = QueryTask.Builder.createDirectTask()
.setQuery(query.build())
.addOption(QueryOption.COUNT)
.build();
Operation postQuery = Operation
.createPost(UriUtils.buildUri(this.host, ServiceUriPaths.CORE_LOCAL_QUERY_TASKS))
.setBody(queryTask)
.setReferer(this.host.getUri());
Operation queryResponse = this.host.waitForResponse(postQuery);
if (queryResponse.getStatusCode() != 200) {
return -1;
}
QueryTask response = queryResponse.getBody(QueryTask.class);
return response.results.documentCount;
}
示例9: registerComputeState
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
protected ComputeState registerComputeState(ComputeState computeState) throws Throwable {
Operation operation = sendOperationSynchronously(Operation
.createPost(super.host, ComputeService.FACTORY_LINK)
.setBody(computeState));
if (operation.getStatusCode() == Operation.STATUS_CODE_OK) {
ComputeState result = operation.getBody(ComputeState.class);
markForDelete(result.documentSelfLink);
return result;
}
throw new IllegalStateException(String.valueOf(operation.getBodyRaw()));
}
示例10: patchServiceSynchronously
import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
public <T extends ServiceDocument> int patchServiceSynchronously(
String serviceUri, ComputeInstanceRequest patchBody)
throws Throwable {
TestContext ctx = this.host.testCreate(1);
Operation patchOperation = Operation
.createPatch(UriUtils.buildUri(this.host, serviceUri))
.setBody(patchBody)
.setCompletion(ctx.getCompletion());
this.host.send(patchOperation);
this.testWait(ctx);
return patchOperation.getStatusCode();
}