Java 类com.amazonaws.services.cloudwatch.AmazonCloudWatch 实例源码

项目:lumber-mill    文件:KinesisConsumerBootstrap.java   
public void start()  {
    int mb = 1024 * 1024;

    LOG.info("Max memory:           {} mb", Runtime.getRuntime().maxMemory() / mb);
    LOG.info("Starting up Kinesis Consumer... (may take a few seconds)");
    AmazonKinesisClient kinesisClient = new AmazonKinesisClient(kinesisCfg.getKinesisCredentialsProvider(),
            kinesisCfg.getKinesisClientConfiguration());
    AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(kinesisCfg.getDynamoDBCredentialsProvider(),
            kinesisCfg.getDynamoDBClientConfiguration());
    AmazonCloudWatch cloudWatchClient = new AmazonCloudWatchClient(kinesisCfg.getCloudWatchCredentialsProvider(),
            kinesisCfg.getCloudWatchClientConfiguration());

    Worker worker = new Worker.Builder()
            .recordProcessorFactory(() -> new RecordProcessor(unitOfWorkListener, exceptionStrategy, metricsCallback, dry))
            .config(kinesisCfg)
            .kinesisClient(kinesisClient)
            .dynamoDBClient(dynamoDBClient)
            .cloudWatchClient(cloudWatchClient)
            .build();

    worker.run();

}
项目:aem-orchestrator    文件:AwsConfig.java   
@Bean
public AmazonCloudWatch amazonCloudWatchClient(final AWSCredentialsProvider awsCredentialsProvider, 
    final ClientConfiguration awsClientConfig, final Region awsRegion) {
    return AmazonCloudWatchClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .withRegion(awsRegion.getName())
        .build();
}
项目:aws-doc-sdk-examples    文件:DisableAlarmActions.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply an alarm name\n" +
            "Ex: DisableAlarmActions <alarm-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alarmName = args[0];

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        DisableAlarmActionsRequest request = new DisableAlarmActionsRequest()
            .withAlarmNames(alarmName);

        DisableAlarmActionsResult response = cw.disableAlarmActions(request);

        System.out.printf(
            "Successfully disabled actions on alarm %s", alarmName);
    }
项目:aws-doc-sdk-examples    文件:DeleteAlarm.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply an alarm name\n" +
            "Ex: DeleteAlarm <alarm-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alarm_name = args[0];

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        DeleteAlarmsRequest request = new DeleteAlarmsRequest()
            .withAlarmNames(alarm_name);

        DeleteAlarmsResult response = cw.deleteAlarms(request);

        System.out.printf("Successfully deleted alarm %s", alarm_name);
    }
项目:aws-doc-sdk-examples    文件:EnableAlarmActions.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply an alarm name\n" +
            "Ex: EnableAlarmActions <alarm-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alarm = args[0];

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        EnableAlarmActionsRequest request = new EnableAlarmActionsRequest()
            .withAlarmNames(alarm);

        EnableAlarmActionsResult response = cw.enableAlarmActions(request);

        System.out.printf(
            "Successfully enabled actions on alarm %s", alarm);
    }
项目:aws-doc-sdk-examples    文件:DescribeAlarms.java   
public static void main(String[] args) {

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        boolean done = false;
        DescribeAlarmsRequest request = new DescribeAlarmsRequest();

        while(!done) {

            DescribeAlarmsResult response = cw.describeAlarms(request);

            for(MetricAlarm alarm : response.getMetricAlarms()) {
                System.out.printf("Retrieved alarm %s", alarm.getAlarmName());
            }

            request.setNextToken(response.getNextToken());

            if(response.getNextToken() == null) {
                done = true;
            }
        }
    }
项目:javamelody    文件:CloudWatch.java   
CloudWatch(AmazonCloudWatch cloudWatch, String cloudWatchNamespace, String prefix,
        String application, String hostName) {
    super();
    assert cloudWatch != null;
    assert cloudWatchNamespace != null && !cloudWatchNamespace.startsWith("AWS/")
            && cloudWatchNamespace.length() > 0 && cloudWatchNamespace.length() <= 255;
    assert prefix != null;
    assert application.length() >= 1 && application.length() <= 255;
    assert hostName.length() >= 1 && hostName.length() <= 255;

    this.awsCloudWatch = cloudWatch;
    this.cloudWatchNamespace = cloudWatchNamespace;
    this.prefix = prefix;
    // A dimension is like a tag which can be used to filter metrics in the CloudWatch UI.
    // Name and value of dimensions have min length 1 and max length 255.
    dimensions.add(new Dimension().withName("application").withValue(application));
    dimensions.add(new Dimension().withName("hostname").withValue(hostName));
    // note: to add other dimensions (max 10), we could call
    // new URL("http://instance-data/latest/meta-data/instance-id").openStream(),
    // or /ami-id, /placement/availability-zone, /instance-type, /local-hostname, /local-ipv4, /public-hostname, /public-ipv4
    // see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
    // except that it would not work from the collector server
}
项目:cloudwatch-tomcat-valve    文件:ElapsedTimeAggregatorTest.java   
/**
 * Default constructor
 */
public ElapsedTimeAggregatorTest() {
    AmazonEC2 ec2Client = mock(AmazonEC2.class);
    AmazonCloudWatch cloudWatchClient = mock(AmazonCloudWatch.class);
    Region region = Region.getRegion(Regions.US_WEST_1);

    when(ec2Client.describeTags(any(DescribeTagsRequest.class))).
            thenReturn(new DescribeTagsResult());

    instanceOnlyAggregator = new ElapsedTimeAggregator("TEST", region, "i-500f6ca6", null, ec2Client, cloudWatchClient);

    when(ec2Client.describeTags(any(DescribeTagsRequest.class))).
            thenReturn(new DescribeTagsResult().withTags(
                    new TagDescription().
                            withKey("aws:autoscaling:groupName").
                            withValue("TEST")
            ));
    asgAggregator = new ElapsedTimeAggregator("TEST", region, "i-500f6ca6", null, ec2Client, cloudWatchClient);
}
项目:swage    文件:CloudWatchRecorder.java   
/**
 * Create a new recorder instance.
 * This recorder will periodically send aggregated metric events to CloudWatch
 * via the provided client. Requests will be queued and sent using a
 * single-threaded ScheduledExecutorService every publishFrequency (in seconds).
 * The initial submission to CloudWatch will be delayed by a random amount
 * on top of the publish frequency, bounded by maxJitter.
 *
 * The {@link #shutdown} method must be called when the application is done
 * with the recorder in order to flush and stop the reporting thread.
 *
 * @param client Client to use for connecting to CloudWatch
 * @param namespace CloudWatch namespace to publish under
 * @param maxJitter Maximum delay before counting publish frequency for
 *                  initial request, in seconds.
 *                  A value of 0 will provide no jitter.
 * @param publishFrequency Batch up and publish at this interval, in seconds.
 *                         Suggested value of 60, for one minute aggregation.
 * @param dimensionMapper Configuration specifying which dimensions to sent
 *                        to CloudWatch for each metric event.
 */
public CloudWatchRecorder(
        final AmazonCloudWatch client,
        final String namespace,
        final int maxJitter,
        final int publishFrequency,
        final DimensionMapper dimensionMapper)
{
    if (client == null) {
        throw new IllegalArgumentException("AmazonCloudWatch must be provided");
    }
    if (namespace == null || namespace.isEmpty()) {
        throw new IllegalArgumentException("namespace must be provided");
    }
    if (dimensionMapper == null) {
        throw new IllegalArgumentException("DimensionMapper must be provided");
    }

    this.metricsClient = client;
    this.namespace = namespace;

    //TODO: is there value in injecting this? Yes, but then how to handle lifecycle?
    this.publishExecutor = Executors.newSingleThreadScheduledExecutor();

    this.aggregator = new MetricDataAggregator(dimensionMapper);

    start(maxJitter, publishFrequency);
}
项目:swage    文件:CloudWatchRecorderTest.java   
@Test
public void record_and_shutdown() throws Exception {
    final DimensionMapper mapper = new DimensionMapper.Builder()
            .addGlobalDimension(ContextData.ID)
            .build();

    final String namespace = "spacename";

    final String id = UUID.randomUUID().toString();
    final TypedMap data = ContextData.withId(id).build();
    final double time = 123.45;

    final AmazonCloudWatch client = mock(AmazonCloudWatch.class);

    final CloudWatchRecorder recorder = new CloudWatchRecorder(client, namespace, 60, 120, mapper);

    final MetricRecorder.Context context = recorder.context(data);
    context.record(M_TIME, time, Unit.MILLISECOND, Instant.now());
    context.close();

    // shutdown right away, before first scheduled publish
    recorder.shutdown();

    final List<MetricDatum> expected = new ArrayList<>(1);
    expected.add(makeDatum(id, M_TIME.toString(), time, time, time, 1, StandardUnit.Milliseconds));

    verify(client).putMetricData(argThat(new RequestMatcher(namespace, expected)));
}
项目:emodb    文件:ScanUploadModule.java   
@Provides
@Singleton
protected AmazonCloudWatch provideAmazonCloudWatch(Region region, AWSCredentialsProvider credentialsProvider) {
    AmazonCloudWatch cloudWatch = new AmazonCloudWatchClient(credentialsProvider);
    cloudWatch.setRegion(region);
    return cloudWatch;
}
项目:aws-doc-sdk-examples    文件:ListMetrics.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a metric name and metric namespace\n" +
            "Ex: ListMetrics <metric-name> <metric-namespace>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String name = args[0];
        String namespace = args[1];

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        ListMetricsRequest request = new ListMetricsRequest()
                .withMetricName(name)
                .withNamespace(namespace);

        boolean done = false;

        while(!done) {
            ListMetricsResult response = cw.listMetrics(request);

            for(Metric metric : response.getMetrics()) {
                System.out.printf(
                    "Retrieved metric %s", metric.getMetricName());
            }

            request.setNextToken(response.getNextToken());

            if(response.getNextToken() == null) {
                done = true;
            }
        }
    }
项目:aws-doc-sdk-examples    文件:PutMetricData.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a data point:\n" +
            "Ex: PutMetricData <data_point>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        Double data_point = Double.parseDouble(args[0]);

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        Dimension dimension = new Dimension()
            .withName("UNIQUE_PAGES")
            .withValue("URLS");

        MetricDatum datum = new MetricDatum()
            .withMetricName("PAGES_VISITED")
            .withUnit(StandardUnit.None)
            .withValue(data_point)
            .withDimensions(dimension);

        PutMetricDataRequest request = new PutMetricDataRequest()
            .withNamespace("SITE/TRAFFIC")
            .withMetricData(datum);

        PutMetricDataResult response = cw.putMetricData(request);

        System.out.printf("Successfully put data point %f", data_point);
    }
项目:beam    文件:KinesisIO.java   
@Override
public AmazonCloudWatch getCloudWatchClient() {
  AmazonCloudWatchClientBuilder clientBuilder =
      AmazonCloudWatchClientBuilder.standard().withCredentials(getCredentialsProvider());
  if (serviceEndpoint == null) {
    clientBuilder.withRegion(region);
  } else {
    clientBuilder.withEndpointConfiguration(
        new AwsClientBuilder.EndpointConfiguration(serviceEndpoint, region.getName()));
  }
  return clientBuilder.build();
}
项目:chassis    文件:CloudWatchReporterTest.java   
/**
 * A metric is not fully filtered, but some stats within the metric are
 */
@Test
public void testPublishFilteredMetrics_metricStatFiltered() throws InterruptedException {
    MetricRegistry metricRegistry = new MetricRegistry();

    metricRegistry.meter("UnitTestMeter1").mark();
    metricRegistry.meter("UnitTestMeter2").mark();

    final AmazonCloudWatch amazonCloudWatch = Mockito.mock(AmazonCloudWatch.class);

    reporter =
            new MetricsCloudWatchReporter(
                    APP_NAME,
                    APP_VERSION,
                    APP_ENVIRONMENT,
                    "utm1=UnitTestMeter1,utm2=UnitTestMeter2:1m:5m:15m",
                    2,
                    TimeUnit.SECONDS,
                    metricRegistry,
                    createCloudWatchFactory(amazonCloudWatch));
    reporter.start();

    //give the reporter a chance to publish
    Thread.sleep(3000);

    PutMetricDataRequestMatcher matcher = new PutMetricDataRequestMatcher(
            new MetricDatumValidator("utm1.1m", APP_ENVIRONMENT, 0d),
            new MetricDatumValidator("utm1.5m", APP_ENVIRONMENT, 0d),
            new MetricDatumValidator("utm1.15m", APP_ENVIRONMENT, 0d),
            new MetricDatumValidator("utm1.mean", APP_ENVIRONMENT, null),
            new MetricDatumValidator("utm2.1m", APP_ENVIRONMENT, 0d),
            new MetricDatumValidator("utm2.5m", APP_ENVIRONMENT, 0d),
            new MetricDatumValidator("utm2.15m", APP_ENVIRONMENT, 0d));

    Mockito.verify(amazonCloudWatch, Mockito.times(1)).putMetricData(Mockito.argThat(matcher));
}
项目:chassis    文件:CloudWatchReporterTest.java   
/**
 * Ensure all metrics are published event when the max number of cloudwatch metrics (per request) is exceeded.
 */
@Test
public void testPublishInMultipleCloudWatchRequests() throws InterruptedException {
    MetricRegistry metricRegistry = new MetricRegistry();

    StringBuilder filter = new StringBuilder();
    for (int i = 0; i < MetricsCloudWatchReporter.MAX_CLOUDWATCH_DATUM_PER_REQUEST + 1; i++) {
        String metric = "UnitTestCounter" + i;
        metricRegistry.counter(metric).inc();
        if (i > 0) {
            filter.append(",");
        }
        filter.append(metric).append("=").append(metric);
    }

    final AmazonCloudWatch amazonCloudWatch = Mockito.mock(AmazonCloudWatch.class);

    reporter =
            new MetricsCloudWatchReporter(
                    APP_NAME,
                    APP_VERSION,
                    APP_ENVIRONMENT,
                    filter.toString(),
                    2,
                    TimeUnit.SECONDS,
                    metricRegistry,
                    createCloudWatchFactory(amazonCloudWatch));

    reporter.start();

    Mockito.verify(amazonCloudWatch, Mockito.never()).putMetricData(Mockito.any(PutMetricDataRequest.class));

    Thread.sleep(3000);

    Mockito.verify(amazonCloudWatch, Mockito.times(2)).putMetricData(Mockito.any(PutMetricDataRequest.class));
}
项目:chassis    文件:CloudWatchReporterTest.java   
private CloudWatchFactory createCloudWatchFactory(final AmazonCloudWatch amazonCloudWatch) {
    return new CloudWatchFactory() {
        @Override
        public AmazonCloudWatch getCloudWatchClient() {
            return amazonCloudWatch;
        }
    };
}
项目:swage    文件:CloudWatchRecorderTest.java   
@Test
public void no_aggregation() throws Exception {
    final DimensionMapper mapper = new DimensionMapper.Builder()
            .addGlobalDimension(ContextData.ID)
            .build();

    final String namespace = "testytesttest";
    final String id = UUID.randomUUID().toString();
    final Integer time = Integer.valueOf(23);
    final Integer load = Integer.valueOf(87);

    final AmazonCloudWatch client = mock(AmazonCloudWatch.class);

    CloudWatchRecorder recorder = null;
    try {
        // no jitter, publish soon
        recorder = new CloudWatchRecorder(client, namespace, 0, 1, mapper);

        final TypedMap data = ContextData.withId(id).build();
        final MetricRecorder.Context context = recorder.context(data);

        final Instant timestamp = Instant.now();

        context.record(M_TIME, time, Unit.MILLISECOND, timestamp);
        context.count(M_FAIL, 1);
        context.record(M_PERC, load, Unit.PERCENT, timestamp);
        context.close();

        // allow time for one publish
        Thread.sleep(1024);
    } finally {
        recorder.shutdown();
    }

    final List<MetricDatum> expected = new ArrayList<>(2);
    expected.add(makeDatum(id, M_TIME.toString(), time, time, time, 1, StandardUnit.Milliseconds));
    expected.add(makeDatum(id, M_PERC.toString(), load, load, load, 1, StandardUnit.Percent));
    expected.add(makeDatum(id, M_FAIL.toString(), 1, 1, 1, 1, StandardUnit.Count));

    verify(client).putMetricData(argThat(new RequestMatcher(namespace, expected)));
}
项目:swage    文件:CloudWatchRecorderTest.java   
@Test
public void aggregation() throws Exception {
    final DimensionMapper mapper = new DimensionMapper.Builder()
            .addGlobalDimension(ContextData.ID)
            .build();

    final String namespace = "testytesttest";
    final String id = UUID.randomUUID().toString();

    final double[] timeVals = {867, 5309};
    final double[] percVals = {0.01, 97.3, 3.1415};
    final int[] failCnts = {1, 3, 0, 42};

    final List<MetricDatum> expected = new ArrayList<>(3);
    expected.add(makeDatum(id,
                           M_TIME.toString(),
                           Arrays.stream(timeVals).sum(),
                           Arrays.stream(timeVals).min().getAsDouble(),
                           Arrays.stream(timeVals).max().getAsDouble(),
                           timeVals.length,
                           StandardUnit.Milliseconds));
    expected.add(makeDatum(id,
                           M_PERC.toString(),
                           Arrays.stream(percVals).sum(),
                           Arrays.stream(percVals).min().getAsDouble(),
                           Arrays.stream(percVals).max().getAsDouble(),
                           percVals.length,
                           StandardUnit.Percent));
    expected.add(makeDatum(id,
                           M_FAIL.toString(),
                           Arrays.stream(failCnts).sum(),
                           Arrays.stream(failCnts).min().getAsInt(),
                           Arrays.stream(failCnts).max().getAsInt(),
                           failCnts.length,
                           StandardUnit.Count));


    final AmazonCloudWatch client = mock(AmazonCloudWatch.class);

    CloudWatchRecorder recorder = null;
    try {
        // no jitter, publish soon
        recorder = new CloudWatchRecorder(client, namespace, 0, 1, mapper);

        final TypedMap data = ContextData.withId(id).build();
        final MetricRecorder.Context context = recorder.context(data);

        context.count(M_FAIL, failCnts[0]);
        context.record(M_PERC, percVals[0], Unit.PERCENT, Instant.now());
        context.record(M_TIME, timeVals[0], Unit.MILLISECOND, Instant.now());
        context.count(M_FAIL, failCnts[1]);
        context.record(M_PERC, percVals[1], Unit.PERCENT, Instant.now());
        context.record(M_TIME, timeVals[1], Unit.MILLISECOND, Instant.now());
        context.count(M_FAIL, failCnts[2]);
        context.record(M_PERC, percVals[2], Unit.PERCENT, Instant.now());
        context.count(M_FAIL, failCnts[3]);
        context.close();

        // allow time for one publish
        Thread.sleep(1024);
    } finally {
        recorder.shutdown();
    }

    verify(client).putMetricData(argThat(new RequestMatcher(namespace, expected)));
}
项目:emodb    文件:CloudWatchScanCountListener.java   
@Inject
public CloudWatchScanCountListener(AmazonCloudWatch cloudWatch, List<Dimension> dimensions, LifeCycleRegistry lifecycle) {
    _cloudWatch = cloudWatch;
    _dimensions = dimensions;
    lifecycle.manage(new ManagedGuavaService(this));
}
项目:aws-doc-sdk-examples    文件:PutMetricAlarm.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply an alarm name and instance id\n" +
            "Ex: DeleteAlarm <alarm-name> <instance-id>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alarmName = args[0];
        String instanceId = args[1];

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        Dimension dimension = new Dimension()
            .withName("InstanceId")
            .withValue(instanceId);

        PutMetricAlarmRequest request = new PutMetricAlarmRequest()
            .withAlarmName(alarmName)
            .withComparisonOperator(
                ComparisonOperator.GreaterThanThreshold)
            .withEvaluationPeriods(1)
            .withMetricName("CPUUtilization")
            .withNamespace("AWS/EC2")
            .withPeriod(60)
            .withStatistic(Statistic.Average)
            .withThreshold(70.0)
            .withActionsEnabled(false)
            .withAlarmDescription(
                "Alarm when server CPU utilization exceeds 70%")
            .withUnit(StandardUnit.Seconds)
            .withDimensions(dimension);

        PutMetricAlarmResult response = cw.putMetricAlarm(request);

        System.out.printf(
            "Successfully created alarm with name %s", alarmName);

    }
项目:beam    文件:SimplifiedKinesisClient.java   
public SimplifiedKinesisClient(AmazonKinesis kinesis, AmazonCloudWatch cloudWatch) {
  this.kinesis = checkNotNull(kinesis, "kinesis");
  this.cloudWatch = checkNotNull(cloudWatch, "cloudWatch");
}
项目:beam    文件:AmazonKinesisMock.java   
@Override
public AmazonCloudWatch getCloudWatchClient() {
  return Mockito.mock(AmazonCloudWatch.class);
}
项目:Camel    文件:CwConfiguration.java   
public AmazonCloudWatch getAmazonCwClient() {
    return amazonCwClient;
}
项目:Camel    文件:CwConfiguration.java   
/**
 * To use the AmazonCloudWatch as the client
 */
public void setAmazonCwClient(AmazonCloudWatch amazonCwClient) {
    this.amazonCwClient = amazonCwClient;
}
项目:Camel    文件:CwEndpoint.java   
public void setCloudWatchClient(AmazonCloudWatch cloudWatchClient) {
    this.cloudWatchClient = cloudWatchClient;
}
项目:Camel    文件:CwEndpoint.java   
public AmazonCloudWatch getCloudWatchClient() {
    return cloudWatchClient;
}
项目:simplemetrics    文件:CloudWatchMetricsPersister.java   
/**
 * Set the client to use to publish the metrics.
 */
// @NotRequired("Default is create one in initialize() with the credentials")
public void setCloudWatchClient(AmazonCloudWatch cloudWatchClient) {
    this.cloudWatchClient = cloudWatchClient;
}
项目:chassis    文件:CloudWatchReporterTest.java   
/**
 * Ensure that a failed publication does not prevent subsequent attempts
 */
@Test
@Ignore("Fix the thread sleeps.")
public void testRecoverAfterFailedPublication() throws InterruptedException {
    MetricRegistry metricRegistry = new MetricRegistry();

    metricRegistry.counter("UnitTestCounter").inc();

    final AmazonCloudWatch amazonCloudWatch = Mockito.mock(AmazonCloudWatch.class);

    reporter =
            new MetricsCloudWatchReporter(
                    APP_NAME,
                    APP_VERSION,
                    APP_ENVIRONMENT,
                    "utc=UnitTestCounter",
                    2,
                    TimeUnit.SECONDS,
                    metricRegistry,
                    createCloudWatchFactory(amazonCloudWatch));

    Mockito.doThrow(new RuntimeException("CloudWatch request error")).when(amazonCloudWatch).putMetricData(Mockito.any(PutMetricDataRequest.class));

    reporter.start();

    //give the reporter a chance to publish
    Thread.sleep(3000);

    //verify that
    Mockito.verify(amazonCloudWatch, Mockito.times(1)).putMetricData(Mockito.any(PutMetricDataRequest.class));

    Mockito.reset(amazonCloudWatch);

    metricRegistry.counter("UnitTestCounter").inc();

    Thread.sleep(3000);

    PutMetricDataRequestMatcher matcher = new PutMetricDataRequestMatcher(
            new MetricDatumValidator("utc", APP_ENVIRONMENT, 2d));

    Mockito.verify(amazonCloudWatch, Mockito.times(2)).putMetricData(Mockito.argThat(matcher));
}
项目:swage    文件:CloudWatchRecorder.java   
/**
 * Create a new recorder instance.
 * This recorder will periodically send aggregated metric events to CloudWatch
 * via the provided client.
 *
 * The {@link #shutdown} method must be called when the application is done
 * with the recorder in order to flush and stop the reporting thread.
 *
 * This is equivalent to constructing a CloudWatch recorder with a
 * maxJitter of 60, a publish frequency of 60, and a default dimension
 * mapping that includes just the metric context ID.
 *
 * @param client Client to use for connecting to CloudWatch
 * @param namespace CloudWatch namespace to publish under
 */
public CloudWatchRecorder(
        final AmazonCloudWatch client,
        final String namespace)
{
    this(client, namespace, DEFAULT_JITTER, DEFAULT_PUBLISH_FREQ, DEFAULT_DIMENSIONS);
}
项目:chassis    文件:CloudWatchFactory.java   
/**
 * get an AmazonCloudWatch
 * @return AmazonCloudWatch
 */
public AmazonCloudWatch getCloudWatchClient();
项目:beam    文件:AWSClientsProvider.java   
AmazonCloudWatch getCloudWatchClient();