本文整理汇总了Java中com.amazonaws.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于com.amazonaws包,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: populateAndEndSubsegment
import com.amazonaws.Response; //导入依赖的package包/类
private void populateAndEndSubsegment(Subsegment currentSubsegment, Request<?> request, Response<?> response) {
if (null != response) {
String requestId = null;
if (response.getAwsResponse() instanceof AmazonWebServiceResult<?>) { // Not all services return responses extending AmazonWebServiceResult (e.g. S3)
ResponseMetadata metadata = ((AmazonWebServiceResult<?>) response.getAwsResponse()).getSdkResponseMetadata();
if (null != metadata) {
requestId = metadata.getRequestId();
if (null != requestId) {
currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, requestId);
}
}
} else if (null != response.getHttpResponse()) { // S3 does not follow request id header convention
if (null != response.getHttpResponse().getHeader(S3_REQUEST_ID_HEADER_KEY)) {
currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, response.getHttpResponse().getHeader(S3_REQUEST_ID_HEADER_KEY));
}
if (null != response.getHttpResponse().getHeader(S3_EXTENDED_REQUEST_ID_HEADER_KEY)) {
currentSubsegment.putAws(EXTENDED_REQUEST_ID_SUBSEGMENT_KEY, response.getHttpResponse().getHeader(S3_EXTENDED_REQUEST_ID_HEADER_KEY));
}
}
currentSubsegment.putAllAws(extractResponseParameters(request, response.getAwsResponse()));
currentSubsegment.putAllHttp(extractHttpResponseInformation(response.getHttpResponse()));
}
finalizeSubsegment(request);
}
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:26,代码来源:TracingHandler.java
示例2: execute
import com.amazonaws.Response; //导入依赖的package包/类
/**
* Executes the request and returns the result.
*
* @param request The AmazonWebServices request to send to the remote server
* @param responseHandler A response handler to accept a successful response from the
* remote server
* @param errorResponseHandler A response handler to accept an unsuccessful response from the
* remote server
* @param executionContext Additional information about the context of this web service
* call
* @deprecated Use {@link #requestExecutionBuilder()} to configure and execute a HTTP request.
*/
@Deprecated
public <T> Response<T> execute(Request<?> request,
HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler,
HttpResponseHandler<AmazonServiceException> errorResponseHandler,
ExecutionContext executionContext) {
HttpResponseHandler<T> adaptedRespHandler = new AwsResponseHandlerAdapter<T>(
getNonNullResponseHandler(responseHandler),
request,
executionContext.getAwsRequestMetrics(),
responseMetadataCache);
return requestExecutionBuilder()
.request(request)
.requestConfig(new AmazonWebServiceRequestAdapter(request.getOriginalRequest()))
.errorResponseHandler(new AwsErrorResponseHandler(errorResponseHandler, executionContext.getAwsRequestMetrics()))
.executionContext(executionContext)
.execute(adaptedRespHandler);
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:30,代码来源:AmazonHttpClient.java
示例3: execRequest
import com.amazonaws.Response; //导入依赖的package包/类
private void execRequest(String endpoint, int status) {
AWSRequestMetrics metrics = new AWSRequestMetricsFullSupport();
metrics.addProperty(AWSRequestMetrics.Field.ServiceName, "AmazonCloudWatch");
metrics.addProperty(AWSRequestMetrics.Field.ServiceEndpoint, endpoint);
metrics.addProperty(AWSRequestMetrics.Field.StatusCode, "" + status);
if (status == 503) {
metrics.addProperty(AWSRequestMetrics.Field.AWSErrorCode, "Throttled");
}
String counterName = "BytesProcessed";
String timerName = "ClientExecuteTime";
metrics.setCounter(counterName, 12345);
metrics.getTimingInfo().addSubMeasurement(timerName, TimingInfo.unmodifiableTimingInfo(100000L, 200000L));
Request<?> req = new DefaultRequest(new ListMetricsRequest(), "AmazonCloudWatch");
req.setAWSRequestMetrics(metrics);
req.setEndpoint(URI.create(endpoint));
HttpResponse hr = new HttpResponse(req, new HttpPost(endpoint));
hr.setStatusCode(status);
Response<?> resp = new Response<>(null, new HttpResponse(req, new HttpPost(endpoint)));
collector.collectMetrics(req, resp);
}
开发者ID:Netflix,项目名称:spectator,代码行数:24,代码来源:SpectatorRequestMetricCollectorTest.java
示例4: invoke
import com.amazonaws.Response; //导入依赖的package包/类
private <T> T invoke(HttpMethodName httpMethodName, String resourcePath, Object representation,
HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler)
throws AmazonClientException {
ExecutionContext executionContext = createExecutionContext();
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(AWSRequestMetrics.Field.RequestMarshallTime.name());
Request request = buildRequest(httpMethodName, resourcePath, representation);
awsRequestMetrics.endEvent(AWSRequestMetrics.Field.RequestMarshallTime.name());
awsRequestMetrics.startEvent(AWSRequestMetrics.Field.CredentialsRequestTime.name());
AWSCredentials credentials = awsCredentialsProvider.getCredentials();
awsRequestMetrics.endEvent(AWSRequestMetrics.Field.CredentialsRequestTime.name());
executionContext.setCredentials(credentials);
awsRequestMetrics.startEvent(AWSRequestMetrics.Field.ClientExecuteTime.name());
Response<T> response = client.execute(request, responseHandler, errorResponseHandler, executionContext);
awsRequestMetrics.endEvent(AWSRequestMetrics.Field.ClientExecuteTime.name());
awsRequestMetrics.log();
return response.getAwsResponse();
}
开发者ID:awslabs,项目名称:aws-hal-client-java,代码行数:25,代码来源:HalClient.java
示例5: afterResponse
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public void afterResponse(Request<?> request, Response<?> response) {
if (isSubsegmentDuplicate(recorder.getCurrentSubsegmentOptional(), request)) {
Optional<Subsegment> currentSubsegmentOptional = recorder.getCurrentSubsegmentOptional();
if (!currentSubsegmentOptional.isPresent()) {
return;
}
Subsegment currentSubsegment = currentSubsegmentOptional.get();
populateAndEndSubsegment(currentSubsegment, request, response, null);
}
}
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:12,代码来源:TracingHandler.java
示例6: executeWithTimer
import com.amazonaws.Response; //导入依赖的package包/类
/**
* Start and end client execution timer around the execution of the request. It's important
* that the client execution task is canceled before the InterruptedExecption is handled by
* {@link #execute()} so * the interrupt status doesn't leak out to the callers code
*/
private Response<Output> executeWithTimer() throws InterruptedException {
try {
executionContext.setClientExecutionTrackerTask(
clientExecutionTimer.startTimer(getClientExecutionTimeout(requestConfig)));
return doExecute();
} finally {
executionContext.getClientExecutionTrackerTask().cancelTask();
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:AmazonHttpClient.java
示例7: doExecute
import com.amazonaws.Response; //导入依赖的package包/类
private Response<Output> doExecute() throws InterruptedException {
runBeforeRequestHandlers();
setSdkTransactionId(request);
setUserAgent(request);
ProgressListener listener = requestConfig.getProgressListener();
// add custom headers
request.getHeaders().putAll(config.getHeaders());
request.getHeaders().putAll(requestConfig.getCustomRequestHeaders());
// add custom query parameters
mergeQueryParameters(requestConfig.getCustomQueryParameters());
Response<Output> response = null;
final InputStream origContent = request.getContent();
final InputStream toBeClosed = beforeRequest(); // for progress tracking
// make "notCloseable", so reset would work with retries
final InputStream notCloseable = (toBeClosed == null) ? null
: ReleasableInputStream.wrap(toBeClosed).disableClose();
request.setContent(notCloseable);
try {
publishProgress(listener, ProgressEventType.CLIENT_REQUEST_STARTED_EVENT);
response = executeHelper();
publishProgress(listener, ProgressEventType.CLIENT_REQUEST_SUCCESS_EVENT);
awsRequestMetrics.getTimingInfo().endTiming();
afterResponse(response);
return response;
} catch (AmazonClientException e) {
publishProgress(listener, ProgressEventType.CLIENT_REQUEST_FAILED_EVENT);
afterError(response, e);
throw e;
} finally {
// Always close so any progress tracking would get the final events propagated.
closeQuietly(toBeClosed, log);
request.setContent(origContent); // restore the original content
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:36,代码来源:AmazonHttpClient.java
示例8: afterError
import com.amazonaws.Response; //导入依赖的package包/类
private void afterError(Response<?> response,
AmazonClientException e) throws InterruptedException {
for (RequestHandler2 handler2 : requestHandler2s) {
handler2.afterError(request, response, e);
checkInterrupted(response);
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:8,代码来源:AmazonHttpClient.java
示例9: execute
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public <Input, Output> Output execute(
ClientExecutionParams<Input, Output> executionParams) {
final Input input = executionParams.getInput();
ExecutionContext executionContext = createExecutionContext(
executionParams.getRequestConfig());
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(AWSRequestMetrics.Field.ClientExecuteTime);
Request<Input> request = null;
Response<Output> response = null;
try {
awsRequestMetrics.startEvent(AWSRequestMetrics.Field.RequestMarshallTime);
try {
request = executionParams.getMarshaller().marshall(input);
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(AWSRequestMetrics.Field.RequestMarshallTime);
}
response = invoke(request,
executionParams.getRequestConfig(),
executionContext,
executionParams.getResponseHandler(),
executionParams.getErrorResponseHandler());
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics,
executionParams.getRequestConfig(),
request,
response);
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:37,代码来源:ClientHandlerImpl.java
示例10: invoke
import com.amazonaws.Response; //导入依赖的package包/类
/**
* Normal invoke with authentication. Credentials are required and may be overriden at the
* request level.
**/
private <Output, Input> Response<Output> invoke(Request<Input> request,
RequestConfig requestConfig,
ExecutionContext executionContext,
HttpResponseHandler<Output> responseHandler,
HttpResponseHandler<? extends SdkBaseException> errorResponseHandler) {
executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(
requestConfig, awsCredentialsProvider));
return doInvoke(request, requestConfig, executionContext, responseHandler,
errorResponseHandler);
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:17,代码来源:ClientHandlerImpl.java
示例11: doInvoke
import com.amazonaws.Response; //导入依赖的package包/类
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been
* configured in the ExecutionContext beforehand.
**/
private <Output, Input> Response<Output> doInvoke(Request<Input> request,
RequestConfig requestConfig,
ExecutionContext executionContext,
HttpResponseHandler<Output> responseHandler,
HttpResponseHandler<? extends SdkBaseException> errorResponseHandler) {
request.setEndpoint(endpoint);
return client.requestExecutionBuilder()
.request(request)
.requestConfig(requestConfig)
.executionContext(executionContext)
.errorResponseHandler(errorResponseHandler)
.execute(responseHandler);
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:ClientHandlerImpl.java
示例12: endClientExecution
import com.amazonaws.Response; //导入依赖的package包/类
/**
* Convenient method to end the client execution without logging the awsRequestMetrics.
*/
private void endClientExecution(AWSRequestMetrics awsRequestMetrics,
RequestConfig requestConfig,
Request<?> request,
Response<?> response) {
if (request != null) {
awsRequestMetrics.endEvent(AWSRequestMetrics.Field.ClientExecuteTime);
awsRequestMetrics.getTimingInfo().endTiming();
RequestMetricCollector metricCollector = findRequestMetricCollector(requestConfig);
metricCollector.collectMetrics(request, response);
awsRequestMetrics.log();
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:16,代码来源:ClientHandlerImpl.java
示例13: afterResponse
import com.amazonaws.Response; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void afterResponse(Request<?> request, Response<?> response) {
AWSRequestMetrics awsRequestMetrics = request == null ? null : request
.getAWSRequestMetrics();
Object awsResponse = response == null ? null : response
.getAwsResponse();
TimingInfo timingInfo = awsRequestMetrics == null ? null
: awsRequestMetrics.getTimingInfo();
old.afterResponse(request, awsResponse, timingInfo);
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:12,代码来源:RequestHandler2Adaptor.java
示例14: setup
import com.amazonaws.Response; //导入依赖的package包/类
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
stackedRequestHandler = new StackedRequestHandler(new ArrayList<RequestHandler2>());
response = new Response<String>("Dummy response", new HttpResponse(request, new HttpGet()));
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:8,代码来源:StackedRequestHandlerTest.java
示例15: perform
import com.amazonaws.Response; //导入依赖的package包/类
/**
* Perform this request.
*/
@Override
public T perform() {
final Response<T> rsp = new AmazonHttpClient(new ClientConfiguration())
.requestExecutionBuilder()
.executionContext(new ExecutionContext(true))
.request(this.request)
.errorResponseHandler(this.errHandler)
.execute(this.respHandler);
return rsp.getAwsResponse();
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:14,代码来源:EsHttpRequest.java
示例16: collectMetrics
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public void collectMetrics(Request<?> request, Response<?> response)
{
AWSRequestMetrics metrics = request.getAWSRequestMetrics();
TimingInfo timingInfo = metrics.getTimingInfo();
Number requestCounts = timingInfo.getCounter(Field.RequestCount.name());
Number retryCounts = timingInfo.getCounter(Field.HttpClientRetryCount.name());
Number throttleExceptions = timingInfo.getCounter(Field.ThrottleException.name());
TimingInfo requestTime = timingInfo.getSubMeasurement(Field.HttpRequestTime.name());
if (requestCounts != null) {
stats.updateAwsRequestCount(requestCounts.longValue());
}
if (retryCounts != null) {
stats.updateAwsRetryCount(retryCounts.longValue());
}
if (throttleExceptions != null) {
stats.updateAwsThrottleExceptionsCount(throttleExceptions.longValue());
}
if (requestTime != null && requestTime.getTimeTakenMillisIfKnown() != null) {
stats.addAwsRequestTime(new Duration(requestTime.getTimeTakenMillisIfKnown(), MILLISECONDS));
}
}
开发者ID:y-lan,项目名称:presto,代码行数:28,代码来源:PrestoS3FileSystemMetricCollector.java
示例17: collectMetrics
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public void collectMetrics(Request<?> request, Response<?> response) {
final AWSRequestMetrics metrics = request.getAWSRequestMetrics();
if (metrics.isEnabled()) {
final Map<String, String> baseTags = getBaseTags(request);
final TimingInfo timing = metrics.getTimingInfo();
for (Field counter : COUNTERS) {
Optional.ofNullable(timing.getCounter(counter.name()))
.filter(v -> v.longValue() > 0)
.ifPresent(v -> registry.counter(metricId(counter, baseTags)).increment(v.longValue()));
}
for (Field timer : TIMERS) {
Optional.ofNullable(timing.getLastSubMeasurement(timer.name()))
.filter(TimingInfo::isEndTimeKnown)
.ifPresent(t -> registry.timer(metricId(timer, baseTags))
.record(t.getEndTimeNano() - t.getStartTimeNano(), TimeUnit.NANOSECONDS));
}
notEmpty(metrics.getProperty(Field.ThrottleException)).ifPresent(throttleExceptions -> {
final Id throttling = metricId("throttling", baseTags);
throttleExceptions.forEach(ex ->
registry.counter(throttling.withTag("throttleException", ex.getClass().getSimpleName()))
.increment());
});
}
}
开发者ID:Netflix,项目名称:spectator,代码行数:29,代码来源:SpectatorRequestMetricCollector.java
示例18: createSpeech
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public CreateSpeechResult createSpeech(CreateSpeechRequest createSpeechRequest) throws AmazonServiceException,
AmazonClientException {
ExecutionContext executionContext = createExecutionContext(createSpeechRequest);
Request<CreateSpeechRequest> request = CreateSpeechRequestMarshallerFactory.getMarshaller(
createSpeechRequest.getMethodType()).marshall(createSpeechRequest);
CreateSpeechResultUnmarshaller unmarshaller = new CreateSpeechResultUnmarshaller();
StreamResponseHandler<CreateSpeechResult> responseHandler =
new StreamResponseHandler<CreateSpeechResult>(unmarshaller);
Response<CreateSpeechResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}
开发者ID:IvonaSoftware,项目名称:ivona-speechcloud-sdk-java,代码行数:14,代码来源:IvonaSpeechCloudClient.java
示例19: listVoices
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public ListVoicesResult listVoices(ListVoicesRequest listVoicesRequest) throws AmazonServiceException,
AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listVoicesRequest);
Request<ListVoicesRequest> request = ListVoicesRequestMarshallerFactory.getMarshaller(
listVoicesRequest.getMethodType()).marshall(listVoicesRequest);
Unmarshaller<ListVoicesResult, JsonUnmarshallerContext> unmarshaller = new ListVoicesResultJsonUnmarshaller();
JsonResponseHandler<ListVoicesResult> responseHandler =
new JsonResponseHandler<ListVoicesResult>(unmarshaller);
Response<ListVoicesResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}
开发者ID:IvonaSoftware,项目名称:ivona-speechcloud-sdk-java,代码行数:14,代码来源:IvonaSpeechCloudClient.java
示例20: getLexicon
import com.amazonaws.Response; //导入依赖的package包/类
@Override
public GetLexiconResult getLexicon(GetLexiconRequest getLexiconRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(getLexiconRequest);
GetLexiconRequestMarshaller marshaller = new GetLexiconPostRequestMarshaller();
Request<GetLexiconRequest> request = marshaller.marshall(getLexiconRequest);
Unmarshaller<GetLexiconResult, JsonUnmarshallerContext> unmarshaller = new GetLexiconResultJsonUnmarshaller();
JsonResponseHandler<GetLexiconResult> responseHandler = new JsonResponseHandler<GetLexiconResult>(unmarshaller);
Response<GetLexiconResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}
开发者ID:IvonaSoftware,项目名称:ivona-speechcloud-sdk-java,代码行数:14,代码来源:IvonaSpeechCloudClient.java
注:本文中的com.amazonaws.Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论