本文整理汇总了Java中com.amazonaws.AmazonWebServiceRequest类的典型用法代码示例。如果您正苦于以下问题:Java AmazonWebServiceRequest类的具体用法?Java AmazonWebServiceRequest怎么用?Java AmazonWebServiceRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AmazonWebServiceRequest类属于com.amazonaws包,在下文中一共展示了AmazonWebServiceRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeMarshalling_ModifiedRequestForwardedToNextInChain
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
/**
* The beforeMarshalling step is a bit different. It's expected to take the potentially
* modified {@link AmazonWebServiceRequest} returned by
* {@link RequestHandler2#beforeMarshalling(AmazonWebServiceRequest)} and forward that
* result as input to the next request handler in the chain. This tests makes sure that each
* request handler forwards the appropriate the result to the next in the chain and that the
* end result is what's returned by the last request handler in the chain
*/
@Test
public void beforeMarshalling_ModifiedRequestForwardedToNextInChain() {
final AmazonWebServiceRequest origAwsRequest = mock(AmazonWebServiceRequest.class);
final AmazonWebServiceRequest afterFirstAwsRequest = mock(AmazonWebServiceRequest.class);
final AmazonWebServiceRequest afterSecondAwsRequest = mock(AmazonWebServiceRequest.class);
final AmazonWebServiceRequest afterThirdAwsRequest = mock(AmazonWebServiceRequest.class);
doReturn(afterFirstAwsRequest).when(first).beforeMarshalling(origAwsRequest);
doReturn(afterSecondAwsRequest).when(second).beforeMarshalling(afterFirstAwsRequest);
doReturn(afterThirdAwsRequest).when(third).beforeMarshalling(afterSecondAwsRequest);
assertEquals(afterThirdAwsRequest, stackedRequestHandler.beforeMarshalling(origAwsRequest));
InOrder inOrder = inOrder(first, second, third);
inOrder.verify(first).beforeMarshalling(origAwsRequest);
inOrder.verify(second).beforeMarshalling(afterFirstAwsRequest);
inOrder.verify(third).beforeMarshalling(afterSecondAwsRequest);
}
示例2: shouldRetryCompleteMultipartUpload
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
private boolean shouldRetryCompleteMultipartUpload(AmazonWebServiceRequest originalRequest,
AmazonS3Exception exception,
int retriesAttempted) {
final RetryPolicy retryPolicy = clientConfiguration.getRetryPolicy();
if (retryPolicy == null || retryPolicy.getRetryCondition() == null) {
return false;
}
if (retryPolicy == PredefinedRetryPolicies.NO_RETRY_POLICY) {
return false;
}
return completeMultipartUploadRetryCondition.shouldRetry
(originalRequest, exception, retriesAttempted);
}
示例3: createRequest
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) {
// If the underlying AmazonS3Client has enabled accelerate mode and the original
// request operation is accelerate mode supported, then the request will use the
// s3-accelerate endpoint to performe the operations.
if (clientOptions.isAccelerateModeEnabled() && !(originalRequest instanceof S3AccelerateUnsupported)) {
if (clientOptions.isDualstackEnabled()) {
endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration);
} else {
endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration);
}
}
Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME);
request.setHttpMethod(httpMethod);
request.addHandlerContext(S3HandlerContextKeys.IS_CHUNKED_ENCODING_DISABLED,
Boolean.valueOf(clientOptions.isChunkedEncodingDisabled()));
request.addHandlerContext(S3HandlerContextKeys.IS_PAYLOAD_SIGNING_ENABLED,
Boolean.valueOf(clientOptions.isPayloadSigningEnabled()));
resolveRequestEndpoint(request, bucketName, key, endpoint);
return request;
}
示例4: runSearch
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
private void runSearch(T type) {
AmazonWebServiceRequest descRequest = buildRequest(type);
AsyncHandler describeHandler = buildHandler(type);
if (type instanceof Instance) {
this.amazonEC2Client.describeInstancesAsync(
(DescribeInstancesRequest) descRequest, describeHandler);
} else if (type instanceof NatGateway) {
this.amazonEC2Client.describeNatGatewaysAsync(
(DescribeNatGatewaysRequest) descRequest, describeHandler);
} else if (type instanceof Volume) {
this.amazonEC2Client.describeVolumesAsync(
(DescribeVolumesRequest) descRequest, describeHandler);
} else {
AWSTaskStatusChecker.this.taskManager.patchTaskToFailure(
new IllegalArgumentException("Invalid type " + type));
}
}
示例5: prepareRequest
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
private <Y> Request<Y> prepareRequest(Request<Y> request, ExecutionContext executionContext, boolean signRequest) {
request.setEndpoint(endpoint);
request.setTimeOffset(timeOffset);
AWSCredentials credentials = awsCredentialsProvider.getCredentials();
AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
if (originalRequest != null && originalRequest.getRequestCredentials() != null) {
credentials = originalRequest.getRequestCredentials();
}
if (signRequest) {
// expiration date is not currently supported on service side, but presignRequest method requires
// this argument so one with default value is provided.
Date expirationDate = DateTime.now(DateTimeZone.UTC)
.plusMinutes(DEFAULT_GET_REQUEST_EXPIRATION_MINUTES).toDate();
signer.presignRequest(request, credentials, expirationDate);
} else {
executionContext.setSigner(signer);
executionContext.setCredentials(credentials);
}
return request;
}
示例6: tryFindClientMethod
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
private static Method tryFindClientMethod(Object client, String name) {
// TODO: Cache me.
for (Method method : client.getClass().getMethods()) {
if (!method.getName().equals(name)) {
continue;
}
Class<?>[] parameters = method.getParameterTypes();
if (parameters.length != 1) {
continue;
}
// This is the inverse of the normal approach of findMethod() -
// we're looking for a method which will accept a specific subtype
// of AmazonWebServiceRequest, without worrying overmuch about
// what subtype it is. We'll create an object of the appropriate
// type and fill it in.
if (AmazonWebServiceRequest.class.isAssignableFrom(parameters[0])) {
return method;
}
}
return null;
}
示例7: performAction
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
/**
* Performs the given action on this resource. This always involves a
* request to the service. It may mark the cached attributes of this
* resource object dirty.
*
* @param name the name of the action to perform
* @param request the client-specified request object
* @param extractor an optional result extractor object
* @return the result of executing the action
*/
public ActionResult performAction(
String name,
AmazonWebServiceRequest request,
ResultCapture<?> extractor) {
ActionModel action = resourceModel.getAction(name);
if (action == null) {
throw new UnsupportedOperationException(
"Resource does not support the action " + name);
}
// The facade generator will ensure we only ever pass in an
// appropriately-typed extractor object.
@SuppressWarnings("unchecked")
ResultCapture<Object> erasedExtractor =
(ResultCapture<Object>) extractor;
return ActionUtils.perform(this, action, request, erasedExtractor);
}
示例8: performAction
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
public ActionResult performAction(
String name,
AmazonWebServiceRequest request,
ResultCapture<?> extractor) {
ActionModel action = model.getAction(name);
if (action == null) {
throw new UnsupportedOperationException(
"Service does not support the action " + name);
}
// The facade generator will ensure we only ever pass in an
// appropriately-typed extractor object.
@SuppressWarnings("unchecked")
ResultCapture<Object> erasedExtractor =
(ResultCapture<Object>) extractor;
return ActionUtils.perform(this, action, request, erasedExtractor);
}
示例9: callLogClientMethod
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
/**
* This is a hack to work around the problems that were introduced when the appender was compiled with AWS SDK
* version 1.9 or 1.10 but the user was running with version 1.11.
*
* The problem was that the createLogStream() method added a return object somewhere between 1.10 and 1.11 which
* broke backwards compatibility and the applications would throw NoSuchMethodError. Using reflection causes the
* linkage to be weaker and seems to work.
*/
private void callLogClientMethod(String methodName, AmazonWebServiceRequest arg) {
try {
Method method = awsLogsClient.getClass().getMethod(methodName, arg.getClass());
method.invoke(awsLogsClient, arg);
logInfo("Created: " + arg);
} catch (Exception e) {
logError("Problems creating: " + arg, e);
}
}
示例10: shouldRetry
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
@Override
public boolean shouldRetry(
AmazonWebServiceRequest originalRequest,
AmazonClientException exception,
int retriesAttempted) {
LOG.debug("Exception caught during upload, retries attempted = {} out of {}", retriesAttempted, maxErrorRetry,
exception);
return retriesAttempted <= maxErrorRetry;
}
示例11: delayBeforeNextRetry
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
@Override
public long delayBeforeNextRetry(
AmazonWebServiceRequest originalRequest,
AmazonClientException exception,
int retriesAttempted) {
long backoffDelay = retriesAttempted * errorRetryDelay;
LOG.debug("Exception caught during upload, retries attempted = {}, will retry in {} ms", retriesAttempted,
backoffDelay, exception);
return backoffDelay;
}
示例12: createRequest
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
private DefaultRequest<OrigRequest> createRequest(OperationInfo operationInfo, OrigRequest originalRequest) {
if (originalRequest instanceof AmazonWebServiceRequest) {
return new DefaultRequest<OrigRequest>((AmazonWebServiceRequest) originalRequest, operationInfo.serviceName());
} else {
return new DefaultRequest<OrigRequest>(operationInfo.serviceName());
}
}
示例13: handle
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
@Override
public T handle(HttpResponse response) throws Exception {
final AmazonWebServiceResponse<T> awsResponse = delegate.handle(response);
if (awsResponse == null) {
throw new RuntimeException("Unable to unmarshall response metadata. Response Code: "
+ response.getStatusCode() + ", Response Text: " +
response.getStatusText());
}
AmazonWebServiceRequest userRequest = request.getOriginalRequest();
if (userRequest.getCloneRoot() != null) {
userRequest = userRequest.getCloneRoot();
}
responseMetadataCache.add(userRequest, awsResponse.getResponseMetadata());
final String awsRequestId = awsResponse.getRequestId();
if (requestLog.isDebugEnabled()) {
requestLog
.debug("Received successful response: " + response.getStatusCode() +
", AWS Request ID: " + awsRequestId);
}
if (!logHeaderRequestId(response)) {
// Logs the AWS request ID extracted from the payload if
// it is not available from the response header.
logResponseRequestId(awsRequestId);
}
awsRequestMetrics.addProperty(AWSRequestMetrics.Field.AWSRequestID, awsRequestId);
return fillInResponseMetadata(awsResponse, response);
}
示例14: beforeMarshalling
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
/**
* Runs the {@code beforeMarshalling} method of any {@code RequestHandler2}s associated with
* this client.
*
* @param request the request passed in from the user
* @return The (possibly different) request to marshall
*/
@SuppressWarnings("unchecked")
protected final <T extends AmazonWebServiceRequest> T beforeMarshalling(T request) {
T local = request;
for (RequestHandler2 handler : requestHandler2s) {
local = (T) handler.beforeMarshalling(local);
}
return local;
}
示例15: inputStreamForRequest
import com.amazonaws.AmazonWebServiceRequest; //导入依赖的package包/类
/**
* Returns an input stream for request progress tracking purposes. If request/response progress
* tracking is not enabled, this method simply return the given input stream as is.
*
* @param is the request content input stream
* @deprecated
*/
@Deprecated
public static InputStream inputStreamForRequest(InputStream is,
AmazonWebServiceRequest req) {
return req == null
? is
: inputStreamForRequest(is, req.getGeneralProgressListener());
}