1
내가 CloudWatch에서 통계를 얻을 수 있지만, 다음과 같은 오류 얻기 위해 노력하고 다음과 같이jclouds와 함께 사용되는 CloudWatch API getMetricStatisticsInRegion이 UndeclaredThrowableException을 throw하는 이유는 무엇입니까?
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy85.getMetricStatisticsInRegion(Unknown Source)
at GetStats.main(GetStats.java:73)
Caused by: java.util.concurrent.ExecutionException: task submitted from the following trace
at org.jclouds.concurrent.config.ExecutorServiceModule$DescribedFuture.ensureCauseHasSubmissionTrace(ExecutorServiceModule.java:272)
at org.jclouds.concurrent.config.ExecutorServiceModule$DescribedFuture.get(ExecutorServiceModule.java:256)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:69)
at com.google.common.util.concurrent.Futures$ChainingListenableFuture.get(Futures.java:661)
at org.jclouds.concurrent.ExceptionParsingListenableFuture.get(ExceptionParsingListenableFuture.java:76)
at org.jclouds.concurrent.internal.SyncProxy.invoke(SyncProxy.java:159)
... 2 more
중요 코드를 :
ComputeServiceContext EC2context =
new ComputeServiceContextFactory().createContext("aws-ec2",
accesskeyid,
secretkey,
ImmutableSet.<Module> of(new Log4JLoggingModule(),
new SshjSshClientModule()));
ComputeService ec2 = EC2context.getComputeService();
for (ComputeMetadata c : ec2.listNodes()){
NodeMetadata w = ec2.getNodeMetadata(c.getId());
System.out.println(String.format("---node: %s(%s) status: %s---",
w.getId(), w.getName(),w.getState()));
RestContext<CloudWatchClient, CloudWatchAsyncClient> cloudWatchContext =
new RestContextFactory().createContext("aws-cloudwatch",
accesskeyid,
secretkey);
String region = w.getLocation().getParent().getId();
Date startday = new Date();
Date today = new Date();
Calendar calendar;
calendar = Calendar.getInstance();
calendar.setTime(today);
calendar.add(Calendar.DATE, -1);
startday = calendar.getTime();
System.out.println("Today : " + today.toString());
System.out.println("Startday: " + startday.toString());
System.out.println("--going to fetch Average CPU--");
CloudWatchClient client = cloudWatchContext.getApi();
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(
region,
"CPUUtilization",
"AWS/EC2",
startday,
today,
60,
Statistics.AVERAGE,
GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT));
System.out.println(String.format("---datapoint for %s---",c.getId()));
System.out.print(datapoints);
System.out.println("------end------");
}
코드를 실행하여 문제를 재현하려고 시도했지만 문제가 해결되었습니다. 나는 jclouds 1.3.2, 1.4.0 및 1.5.0-SNAPSHOT을 시도했으며 모두 효과가 있었다. jclouds 버전 및 환경에 대한 자세한 정보를 제공 할 수 있습니까? –