com.ksyun.api.sdk.kec.KSCKECClient Maven / Gradle / Ivy
package com.ksyun.api.sdk.kec;
import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Node;
import com.ksc.ClientConfiguration;
import com.ksc.ClientConfigurationFactory;
import com.ksc.KscServiceException;
import com.ksc.KscWebServiceClient;
import com.ksc.KscWebServiceRequest;
import com.ksc.KscWebServiceResponse;
import com.ksc.Request;
import com.ksc.Response;
import com.ksc.auth.AWSCredentialsProvider;
import com.ksc.auth.DefaultAWSCredentialsProviderChain;
import com.ksc.auth.credentials.AWSCredentials;
import com.ksc.http.DefaultErrorResponseHandler;
import com.ksc.http.ExecutionContext;
import com.ksc.http.HttpResponseHandler;
import com.ksc.http.StaxResponseHandler;
import com.ksc.internal.StaticCredentialsProvider;
import com.ksc.metrics.RequestMetricCollector;
import com.ksc.transform.LegacyErrorUnmarshaller;
import com.ksc.transform.StandardErrorUnmarshaller;
import com.ksc.transform.Unmarshaller;
import com.ksc.util.CredentialUtils;
import com.ksc.util.KscRequestMetrics;
import com.ksc.util.KscRequestMetrics.Field;
import com.ksyun.api.sdk.kec.model.CreateImageRequest;
import com.ksyun.api.sdk.kec.model.CreateImageResult;
import com.ksyun.api.sdk.kec.model.DescribeImagesRequest;
import com.ksyun.api.sdk.kec.model.DescribeImagesResult;
import com.ksyun.api.sdk.kec.model.DescribeInstanceVncRequest;
import com.ksyun.api.sdk.kec.model.DescribeInstanceVncResult;
import com.ksyun.api.sdk.kec.model.DescribeInstancesRequest;
import com.ksyun.api.sdk.kec.model.DescribeInstancesResult;
import com.ksyun.api.sdk.kec.model.ModifyImageAttributeRequest;
import com.ksyun.api.sdk.kec.model.ModifyImageAttributeResult;
import com.ksyun.api.sdk.kec.model.ModifyInstanceAttributeRequest;
import com.ksyun.api.sdk.kec.model.ModifyInstanceAttributeResult;
import com.ksyun.api.sdk.kec.model.ModifyInstanceImageRequest;
import com.ksyun.api.sdk.kec.model.ModifyInstanceImageResult;
import com.ksyun.api.sdk.kec.model.RebootInstancesRequest;
import com.ksyun.api.sdk.kec.model.RebootInstancesResult;
import com.ksyun.api.sdk.kec.model.RemoveImagesRequest;
import com.ksyun.api.sdk.kec.model.RemoveImagesResult;
import com.ksyun.api.sdk.kec.model.RunInstancesRequest;
import com.ksyun.api.sdk.kec.model.RunInstancesResult;
import com.ksyun.api.sdk.kec.model.StartInstancesRequest;
import com.ksyun.api.sdk.kec.model.StartInstancesResult;
import com.ksyun.api.sdk.kec.model.StopInstancesRequest;
import com.ksyun.api.sdk.kec.model.StopInstancesResult;
import com.ksyun.api.sdk.kec.model.TerminateInstancesRequest;
import com.ksyun.api.sdk.kec.model.TerminateInstancesResult;
import com.ksyun.api.sdk.kec.transform.CreateImageRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.CreateImageResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.DescribeImagesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.DescribeImagesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.DescribeInstanceVncRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.DescribeInstanceVncResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.DescribeInstancesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.DescribeInstancesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.ModifyImageAttributeRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.ModifyImageAttributeResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.ModifyInstanceAttributeRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.ModifyInstanceAttributeResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.ModifyInstanceImageRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.ModifyInstanceImageResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.RebootInstancesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.RebootInstancesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.RemoveImagesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.RemoveImagesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.RunInstancesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.RunInstancesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.StartInstancesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.StartInstancesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.StopInstancesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.StopInstancesResultStaxUnmarshaller;
import com.ksyun.api.sdk.kec.transform.TerminateInstancesRequestMarshaller;
import com.ksyun.api.sdk.kec.transform.TerminateInstancesResultStaxUnmarshaller;
public class KSCKECClient extends KscWebServiceClient implements KSCKEC {
/** Provider for AWS credentials. */
private AWSCredentialsProvider kscCredentialsProvider;
/** Default signing name for the service. */
private static final String DEFAULT_SIGNING_NAME = "kec";
/** The region metadata service name for computing region endpoints. */
private static final String DEFAULT_ENDPOINT_PREFIX = "kec";
/**
* Client configuration factory providing ClientConfigurations tailored to
* this client
*/
protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
/**
* List of exception unmarshallers for all modeled exceptions
*/
protected final List> exceptionUnmarshallers = new ArrayList>();
/**
* Constructs a new client to invoke service methods on KSC. A credentials
* provider chain will be used that searches for credentials in this order:
*
* - Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
* - Java System Properties - aws.accessKeyId and aws.secretKey
* - Instance profile credentials delivered through the KSC metadata
* service
*
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @see DefaultAWSCredentialsProviderChain
*/
public KSCKECClient() {
this(new DefaultAWSCredentialsProviderChain(), configFactory.getConfig());
}
/**
* Constructs a new client to invoke service methods on Amazon EC2. A
* credentials provider chain will be used that searches for credentials in
* this order:
*
* - Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
* - Java System Properties - aws.accessKeyId and aws.secretKey
* - Instance profile credentials delivered through the KSC metadata
* service
*
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param clientConfiguration
* The client configuration options controlling how this client
* connects to KSC (ex: proxy settings, retry counts, etc.).
*
* @see DefaultAWSCredentialsProviderChain
*/
public KSCKECClient(ClientConfiguration clientConfiguration) {
this(new DefaultAWSCredentialsProviderChain(), clientConfiguration);
}
/**
* Constructs a new client to invoke service methods on Amazon EC2 using the
* specified AWS account credentials.
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentials
* The AWS credentials (access key ID and secret key) to use when
* authenticating with AWS services.
*/
public KSCKECClient(AWSCredentials awsCredentials) {
this(awsCredentials, configFactory.getConfig());
}
/**
* Constructs a new client to invoke service methods on Amazon EC2 using the
* specified AWS account credentials and client configuration options.
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentials
* The AWS credentials (access key ID and secret key) to use when
* authenticating with AWS services.
* @param clientConfiguration
* The client configuration options controlling how this client
* connects to Amazon EC2 (ex: proxy settings, retry counts,
* etc.).
*/
public KSCKECClient(AWSCredentials awsCredentials, ClientConfiguration clientConfiguration) {
super(clientConfiguration);
this.kscCredentialsProvider = new StaticCredentialsProvider(awsCredentials);
init();
}
/**
* Constructs a new client to invoke service methods on Amazon EC2 using the
* specified AWS account credentials provider.
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
*/
public KSCKECClient(AWSCredentialsProvider awsCredentialsProvider) {
this(awsCredentialsProvider, configFactory.getConfig());
}
/**
* Constructs a new client to invoke service methods on Amazon EC2 using the
* specified AWS account credentials provider and client configuration
* options.
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
* @param clientConfiguration
* The client configuration options controlling how this client
* connects to Amazon EC2 (ex: proxy settings, retry counts,
* etc.).
*/
public KSCKECClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) {
this(awsCredentialsProvider, clientConfiguration, null);
}
/**
* Constructs a new client to invoke service methods on Amazon EC2 using the
* specified AWS account credentials provider, client configuration options,
* and request metric collector.
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
* @param clientConfiguration
* The client configuration options controlling how this client
* connects to Amazon EC2 (ex: proxy settings, retry counts,
* etc.).
* @param requestMetricCollector
* optional request metric collector
*/
public KSCKECClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration,
RequestMetricCollector requestMetricCollector) {
super(clientConfiguration, requestMetricCollector);
this.kscCredentialsProvider = awsCredentialsProvider;
init();
}
private void init() {
exceptionUnmarshallers.add(new LegacyErrorUnmarshaller());
exceptionUnmarshallers.add(new StandardErrorUnmarshaller());
setServiceNameIntern(DEFAULT_SIGNING_NAME);
setEndpointPrefix(DEFAULT_ENDPOINT_PREFIX);
// calling this.setEndPoint(...) will also modify the signer accordingly
setEndpoint("http://kec.cn-beijing-6.api.ksyun.com");
//HandlerChainFactory chainFactory = new HandlerChainFactory();
/*
* requestHandler2s .addAll(chainFactory
* .newRequestHandlerChain("/com/ksc/services/kec/request.handlers"));
* requestHandler2s .addAll(chainFactory
* .newRequestHandler2Chain("/com/ksc/services/kec/request.handler2s"));
*/
}
@Override
public DescribeInstancesResult describeInstances() {
return describeInstances(new DescribeInstancesRequest());
}
@Override
public DescribeInstancesResult describeInstances(DescribeInstancesRequest describeInstancesRequest) {
ExecutionContext executionContext = createExecutionContext(describeInstancesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DescribeInstancesRequestMarshaller()
.marshall(super.beforeMarshalling(describeInstancesRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new DescribeInstancesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
/**
* Normal invoke with authentication. Credentials are required and may be
* overriden at the request level.
**/
private Response invoke(Request request,
HttpResponseHandler> responseHandler, ExecutionContext executionContext) {
executionContext.setCredentialsProvider(
CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), kscCredentialsProvider));
return doInvoke(request, responseHandler, executionContext);
}
/**
* Invoke the request using the http client. Assumes credentials (or lack
* thereof) have been configured in the ExecutionContext beforehand.
**/
private Response doInvoke(Request request,
HttpResponseHandler> responseHandler, ExecutionContext executionContext) {
request.setEndpoint(endpoint);
request.setTimeOffset(timeOffset);
DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
@Override
public StartInstancesResult startInstances(StartInstancesRequest startInstancesRequest) {
ExecutionContext executionContext = createExecutionContext(startInstancesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = new StartInstancesRequestMarshaller().marshall(startInstancesRequest);
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new StartInstancesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
@Override
public StopInstancesResult stopInstances(StopInstancesRequest stopInstancesRequest) {
ExecutionContext executionContext = createExecutionContext(stopInstancesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new StopInstancesRequestMarshaller().marshall(stopInstancesRequest);
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new StopInstancesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
@Override
public RebootInstancesResult rebootInstances(RebootInstancesRequest rebootInstancesRequest) {
ExecutionContext executionContext = createExecutionContext(rebootInstancesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new RebootInstancesRequestMarshaller().marshall(rebootInstancesRequest);
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new RebootInstancesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
@Override
public DescribeImagesResult describeImages(DescribeImagesRequest describeImagesRequest) {
// TODO Auto-generated method stub
ExecutionContext executionContext = createExecutionContext(describeImagesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DescribeImagesRequestMarshaller().marshall(describeImagesRequest);
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new DescribeImagesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
@Override
public RunInstancesResult runInstances(RunInstancesRequest runInstancesRequest) {
ExecutionContext executionContext = createExecutionContext(runInstancesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new RunInstancesRequestMarshaller()
.marshall(super.beforeMarshalling(runInstancesRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new RunInstancesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
@Override
public TerminateInstancesResult terminateInstances(TerminateInstancesRequest terminateInstancesRequest) {
ExecutionContext executionContext = createExecutionContext(terminateInstancesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new TerminateInstancesRequestMarshaller()
.marshall(super.beforeMarshalling(terminateInstancesRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new TerminateInstancesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
@Override
public ModifyInstanceAttributeResult modifyInstanceAttribute(ModifyInstanceAttributeRequest modifyInstanceAttributeRequest) {
ExecutionContext executionContext = createExecutionContext(modifyInstanceAttributeRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ModifyInstanceAttributeRequestMarshaller()
.marshall(super.beforeMarshalling(modifyInstanceAttributeRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new ModifyInstanceAttributeResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
/**
* 创建镜像
*/
@Override
public CreateImageResult createImage(CreateImageRequest createImageRequest){
ExecutionContext executionContext = createExecutionContext(createImageRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new CreateImageRequestMarshaller()
.marshall(super.beforeMarshalling(createImageRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new CreateImageResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
/**
* 修改镜像
*/
@Override
public ModifyImageAttributeResult modifyImageAttribute(ModifyImageAttributeRequest modifyImageAttributeRequest){
ExecutionContext executionContext = createExecutionContext(modifyImageAttributeRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ModifyImageAttributeRequestMarshaller()
.marshall(super.beforeMarshalling(modifyImageAttributeRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new ModifyImageAttributeResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
/**
* 刪除鏡像
*/
@Override
public RemoveImagesResult removeImages(RemoveImagesRequest removeImagesRequest){
ExecutionContext executionContext = createExecutionContext(removeImagesRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new RemoveImagesRequestMarshaller()
.marshall(super.beforeMarshalling(removeImagesRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new RemoveImagesResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
/**
* 更换或者重新安装实例操作系统
*/
public ModifyInstanceImageResult modifyInstanceImage(ModifyInstanceImageRequest modifyInstanceImageRequest){
ExecutionContext executionContext = createExecutionContext(modifyInstanceImageRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ModifyInstanceImageRequestMarshaller()
.marshall(super.beforeMarshalling(modifyInstanceImageRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new ModifyInstanceImageResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
/**
* 获取VNC信息
*/
public DescribeInstanceVncResult describeInstanceVnc(DescribeInstanceVncRequest describeInstanceVncRequest){
ExecutionContext executionContext = createExecutionContext(describeInstanceVncRequest);
KscRequestMetrics kscRequestMetrics = executionContext.getKscRequestMetrics();
kscRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
kscRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DescribeInstanceVncRequestMarshaller()
.marshall(super.beforeMarshalling(describeInstanceVncRequest));
// Binds the request metrics to the current request.
request.setKscRequestMetrics(kscRequestMetrics);
} finally {
kscRequestMetrics.endEvent(Field.RequestMarshallTime);
}
StaxResponseHandler responseHandler = new StaxResponseHandler(
new DescribeInstanceVncResultStaxUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getKscResponse();
} finally {
endClientExecution(kscRequestMetrics, request, response);
}
}
}