本文整理了Java中com.amazonaws.Request.getServiceName
方法的一些代码示例,展示了Request.getServiceName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getServiceName
方法的具体详情如下:
包路径:com.amazonaws.Request
类名称:Request
方法名:getServiceName
暂无
代码示例来源:origin: aws/aws-sdk-java
/**
* Returned the best-guessed throughput metric type for the given request,
* or null if there is none or if metric is disabled.
*/
public static ThroughputMetricType guessThroughputMetricType(
final Request<?> req,
final String metricNameSuffix,
final String byteCountMetricNameSuffix)
{
if (!AwsSdkMetrics.isMetricsEnabled())
return null; // metric disabled
Object orig = req.getOriginalRequestObject();
if (orig.getClass().getName().startsWith("com.amazonaws.services.s3")) {
return new SimpleThroughputMetricType(
"S3" + metricNameSuffix,
req.getServiceName(),
"S3" + byteCountMetricNameSuffix);
}
return null;
}
}
代码示例来源:origin: aws/aws-sdk-java
private void collectMetrics0(Request<?> request, Response<?> response) {
AWSRequestMetrics arm = request.getAWSRequestMetrics();
if (arm == null || !arm.isEnabled()) {
return;
}
for (MetricType type: AwsSdkMetrics.getPredefinedMetrics()) {
if (!(type instanceof RequestMetricType))
continue;
PredefinedMetricTransformer transformer = getTransformer();
for (MetricDatum datum : transformer.toMetricData(type, request, response)) {
try {
if (!addMetricsToQueue(datum)) {
if (log.isDebugEnabled()) {
log.debug("Failed to add to the metrics queue (due to no space available) for "
+ type.name()
+ ":"
+ request.getServiceName());
}
}
} catch(RuntimeException ex) {
log.warn("Failed to add to the metrics queue for "
+ type.name() + ":" + request.getServiceName(),
ex);
}
}
}
}
代码示例来源:origin: aws/aws-sdk-java
} else {
return Collections.singletonList(new MetricDatum()
.withMetricName(req.getServiceName())
.withDimensions(new Dimension()
.withName(Dimensions.MetricType.name())
代码示例来源:origin: aws/aws-sdk-java
.withValue(tableName));
MetricDatum datum = new MetricDatum()
.withMetricName(req.getServiceName())
.withDimensions(dims)
.withUnit(StandardUnit.Count)
代码示例来源:origin: aws/aws-sdk-java
protected List<MetricDatum> metricOfCount(
Field metricType, Request<?> req, Object resp) {
AWSRequestMetrics m = req.getAWSRequestMetrics();
TimingInfo ti = m.getTimingInfo();
Number counter = ti.getCounter(metricType.name());
if (counter == null) {
return Collections.emptyList();
}
final double count = counter.doubleValue();
if (count < 1) {
return Collections.emptyList();
} else {
return Collections.singletonList(new MetricDatum()
.withMetricName(req.getServiceName())
.withDimensions(new Dimension()
.withName(Dimensions.MetricType.name())
.withValue(metricType.name()))
.withUnit(StandardUnit.Count)
.withValue(Double.valueOf(count))
.withTimestamp(endTimestamp(ti)))
;
}
}
代码示例来源:origin: aws/aws-sdk-java
.withMetricName(req.getServiceName())
.withDimensions(metricDimension)
.withUnit(StandardUnit.Count)
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns a request type specific metrics for
* {@link Field#ClientExecuteTime} which is special in the sense that it
* makes a more accurate measurement by taking the {@link TimingInfo} at the
* root into account.
*/
protected List<MetricDatum> latencyOfClientExecuteTime(Request<?> req, Object response) {
AWSRequestMetrics m = req.getAWSRequestMetrics();
TimingInfo root = m.getTimingInfo();
final String metricName = Field.ClientExecuteTime.name();
if (root.isEndTimeKnown()) { // being defensive
List<Dimension> dims = new ArrayList<Dimension>();
dims.add(new Dimension()
.withName(Dimensions.MetricType.name())
.withValue(metricName));
// request type specific
dims.add(new Dimension()
.withName(Dimensions.RequestType.name())
.withValue(requestType(req)));
MetricDatum datum = new MetricDatum()
.withMetricName(req.getServiceName())
.withDimensions(dims)
.withUnit(StandardUnit.Milliseconds)
.withValue(root.getTimeTakenMillisIfKnown());
return Collections.singletonList(datum);
}
return Collections.emptyList();
}
代码示例来源:origin: aws/aws-sdk-java
.withMetricName(req.getServiceName())
.withDimensions(dims)
.withUnit(StandardUnit.Milliseconds)
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
final AmazonServiceException ase = handleAse(response);
ase.setStatusCode(response.getStatusCode());
ase.setServiceName(response.getRequest().getServiceName());
awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
.addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
.addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
return ase;
}
代码示例来源:origin: aws/aws-sdk-java
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: aws/aws-sdk-java
.addPropertyWith(Field.ServiceName, request.getServiceName())
.addPropertyWith(Field.ServiceEndpoint, request.getEndpoint());
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Returned the best-guessed throughput metric type for the given request,
* or null if there is none or if metric is disabled.
*/
public static ThroughputMetricType guessThroughputMetricType(
final Request<?> req,
final String metricNameSuffix,
final String byteCountMetricNameSuffix)
{
if (!AwsSdkMetrics.isMetricsEnabled())
return null; // metric disabled
AmazonWebServiceRequest orig = req.getOriginalRequest();
if (orig.getClass().getName().startsWith("com.amazonaws.services.s3")) {
return new SimpleThroughputMetricType(
"S3" + metricNameSuffix,
req.getServiceName(),
"S3" + byteCountMetricNameSuffix);
}
return null;
}
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* Returned the best-guessed throughput metric type for the given request,
* or null if there is none or if metric is disabled.
*/
public static ThroughputMetricType guessThroughputMetricType(
final Request<?> req,
final String metricNameSuffix,
final String byteCountMetricNameSuffix)
{
if (!AwsSdkMetrics.isMetricsEnabled())
return null; // metric disabled
Object orig = req.getOriginalRequestObject();
if (orig.getClass().getName().startsWith("com.amazonaws.services.s3")) {
return new SimpleThroughputMetricType(
"S3" + metricNameSuffix,
req.getServiceName(),
"S3" + byteCountMetricNameSuffix);
}
return null;
}
}
代码示例来源:origin: aws/aws-sdk-java
ase.setRequestId(requestId);
ase.setExtendedRequestId(hostId);
ase.setServiceName(request.getServiceName());
ase.setStatusCode(200);
代码示例来源:origin: aws/aws-sdk-java
ase.setRequestId(requestId);
ase.setExtendedRequestId(hostId);
ase.setServiceName(request.getServiceName());
ase.setStatusCode(200);
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
final AmazonServiceException ase = handleAse(response);
ase.setStatusCode(response.getStatusCode());
ase.setServiceName(response.getRequest().getServiceName());
awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
.addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
.addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
return ase;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
assertSame(response, httpResponse);
AmazonServiceException ase = new AmazonServiceException("Test");
ase.setErrorCode("TestError");
ase.setErrorType(ErrorType.Service);
ase.setServiceName(request.getServiceName());
ase.setStatusCode(response.getStatusCode());
return ase;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
内容来源于网络,如有侵权,请联系作者删除!