发布到CloudWatch失败:运行child时出错:java.lang.NoSuchMethodError:

时间:2017-06-20 17:51:56

标签: java amazon-web-services emr amazon-emr amazon-cloudwatch

我正试图从我的EMR作业发布到Cloudwatch,但我一直从stderr得到错误:

  

错误:com.amazonaws.auth.DefaultAWSCredentialsProviderChain.getInstance()Lcom / amazonaws / auth / DefaultAWSCredentialsProviderChain;   ApplicationMaster杀死的容器。   根据要求杀死容器。退出代码是143   容器以非零退出代码143退出

来自syslog:

  

2017-06-20 16:58:23,078致命[main] org.apache.hadoop.mapred.YarnChild:运行child时出错:java.lang.NoSuchMethodError:com.amazonaws.auth.DefaultAWSCredentialsProviderChain.getInstance()Lcom / amazonaws / AUTH / DefaultAWSCredentialsProviderChain;       在com.amazonaws.client.builder.AwsClientBuilder.resolveCredentials(AwsClientBuilder.java:125)       在com.amazonaws.client.builder.AwsClientBuilder.access $ 100(AwsClientBuilder.java:52)       在com.amazonaws.client.builder.AwsClientBuilder $ SyncBuilderParams。(AwsClientBuilder.java:412)       在com.amazonaws.client.builder.AwsClientBuilder.getSyncClientParams(AwsClientBuilder.java:354)       在com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)       在MapJoltSpec.cleanup(MapJoltSpec.java:186)       在org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:149)       在org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:796)       在org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)       在org.apache.hadoop.mapred.YarnChild $ 2.run(YarnChild.java:164)       at java.security.AccessController.doPrivileged(Native Method)       在javax.security.auth.Subject.doAs(Subject.java:422)       在org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)       在org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

我已将角色CloudWatchFullAccess附加到EC2实例上并添加到pom.xml中:

<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.11.151</version>
    </dependency>

最后,我的代码试图在mapreduce作业的清理方法中发布:

    final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

    Dimension dimension = new Dimension()
            .withName("POST_COUNT")
            .withValue("SUCCESFUL_POST_COUNT");

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

    PutMetricDataRequest request = new PutMetricDataRequest()
            .withNamespace("test-ElasticMapReduce")
            .withMetricData(datum);

    PutMetricDataResult response = cw.putMetricData(request);
    System.out.println(response);

0 个答案:

没有答案