Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright 2010-2015, Inc. or its affiliates. All Rights Reserved.
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
  * or in the "license" file accompanying this file. This file is distributed
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
 package com.amazonaws.metrics.internal.cloudwatch.provider.transform;
 import java.util.List;
An internal service provider implementation for an DyanmoDB specific request metric transformer. This class is loaded only if there are Amazon DyanmoDB specific predefined metrics to be processed.

     public List<MetricDatumtoMetricData(MetricType metricType,
             Request<?> requestResponse<?> response) {
         try {
             return toMetricData0(metricTyperequestresponse);
         } catch (SecurityException e) {
         } catch (NoSuchMethodException e) {
         } catch (IllegalAccessException e) {
         } catch (InvocationTargetException e) {
         } catch (Exception e) {
         return null;
     private List<MetricDatumtoMetricData0(MetricType metricType,
             Request<?> reqResponse<?> responsethrows SecurityException,
             InvocationTargetException {
         if (!(metricType instanceof DynamoDBRequestMetric))
             return null;
         // Predefined metrics across all aws http clients
         DynamoDBRequestMetric predefined = (DynamoDBRequestMetricmetricType;
         switch(predefined) {
             case :
                 if (response == null)
                     return Collections.emptyList();
                 Object awsResponse = response.getAwsResponse();
                 Method method = awsResponse.getClass().getMethod("getConsumedCapacity");
                 Object value = method.invoke(awsResponse);
                 if (!(value instanceof ConsumedCapacity))
                     return Collections.emptyList();
                 ConsumedCapacity consumedCapacity = (ConsumedCapacityvalue;
                 Double units = consumedCapacity.getCapacityUnits();
                 if (units == null)
                     return Collections.emptyList();
                 String tableName = consumedCapacity.getTableName();
                 List<Dimensiondims = new ArrayList<Dimension>();
                 dims.add(new Dimension()
                 // request type specific
                 dims.add(new Dimension()
                 // table specific
                 dims.add(new Dimension()
                MetricDatum datum = new MetricDatum()
                return Collections.singletonList(datum);
                return Collections.emptyList();

Returns the name of the type of request.
    private String requestType(Request<?> req) {
        return req.getOriginalRequest().getClass().getSimpleName();
New to GrepCode? Check out our FAQ X