Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-2015 Amazon.com, 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
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.util;
 
 import java.util.List;
 import java.util.Map;
 
In contrast to TimingInfo, which is intended to be a minimal support of the timing info, this class is the full support of timing info including features related to sub-measurements and counters.

This class is instantiated instead of TimingInfo when request metric collection is required during a particular service request/response cycle.

 
 class TimingInfoFullSupport extends TimingInfo {
     private final Map<StringList<TimingInfo>> subMeasurementsByName = new HashMap<StringList<TimingInfo>>();
     private final Map<StringNumbercountersByName = new HashMap<StringNumber>();

    
A private ctor to facilitate the deprecation of using millisecond and migration to using nanosecond for timing measurement.

Parameters:
startEpochTimeMilli start time since epoch in millisecond
startTimeNano start time in nanosecond
endTimeNano end time in nanosecond; or null if not known
See also:
TimingInfo.startTimingFullSupport()
TimingInfo.startTimingFullSupport(long)
TimingInfo.newTimingInfoFullSupport(long,long)
TimingInfo.newTimingInfoFullSupport(long,long,long)
 
     TimingInfoFullSupport(Long startEpochTimeMillilong startTimeNanoLong endTimeNano) {
         super(startEpochTimeMillistartTimeNanoendTimeNano);
     }
 
     @Override
     public void addSubMeasurement(String subMeasurementNameTimingInfo ti) {
         List<TimingInfotimings = .get(subMeasurementName);
         if (timings == null) {
             timings = new ArrayList<TimingInfo>();
             .put(subMeasurementNametimings);
         }
         if (ti.isEndTimeKnown()) {
             timings.add(ti);
         } else {
             LogFactory.getLog(getClass()).debug(
                 "Skip submeasurement timing info with no end time for "
                 + subMeasurementName);
         }
     }
 
     @Override
     public TimingInfo getSubMeasurement(String subMeasurementName) {
         return getSubMeasurement(subMeasurementName, 0);
     }
 
     @Override
     public TimingInfo getSubMeasurement(String subMesurementNameint index) {
 
         List<TimingInfotimings = .get(subMesurementName);
         if (index < 0 || timings == null || timings.size() == 0
                 || index >= timings.size()) {
             return null;
         }
 
         return timings.get(index);
     }
 
     @Override
     public TimingInfo getLastSubMeasurement(String subMeasurementName) {
 
         if ( == null || .size() == 0) {
             return null;
         }
 
         List<TimingInfotimings = .get(subMeasurementName);
         if (timings == null || timings.size() == 0) {
             return null;
         }
        return timings.get(timings.size() - 1);
    }
    @Override
    public List<TimingInfogetAllSubMeasurements(String subMeasurementName) {
        return .get(subMeasurementName);
    }
    @Override
        return ;
    }
    @Override
    public Number getCounter(String key) {
        return .get(key);
    }
    @Override
    public Map<StringNumbergetAllCounters() {
        return ;
    }
    @Override
    public void setCounter(String keylong count) {
        .put(keycount);
    }
    @Override
    public void incrementCounter(String key) {
        int count = 0;
        Number counter = getCounter(key);
        if (counter != null) {
            count = counter.intValue();
        }
        setCounter(key, ++count);
    }
New to GrepCode? Check out our FAQ X