2
GUI 화면을 통해 EMR 클러스터를 가동했습니다. 클러스터가 가동되면 ID를 볼 수 있습니다. 그 ID를 가진 클러스터를 나타내는 Cluster 클래스의 객체를 얻는 방법은 무엇입니까? EMR과 상호 작용하기 위해 Java를 사용하고 있습니다.ID에서 클러스터 개체 가져 오기 Amazon EMR
GUI 화면을 통해 EMR 클러스터를 가동했습니다. 클러스터가 가동되면 ID를 볼 수 있습니다. 그 ID를 가진 클러스터를 나타내는 Cluster 클래스의 객체를 얻는 방법은 무엇입니까? EMR과 상호 작용하기 위해 Java를 사용하고 있습니다.ID에서 클러스터 개체 가져 오기 Amazon EMR
클러스터의 ID를 얻기 위해 단일 명령을 실행할 수는 없습니다. 다음은 실패한 모든 클러스터의 ID를 읽는 알고리즘의 작동 예입니다.
AWSCredentials credentials;
credentials = new BasicAWSCredentials("myAccessKey", "mySecretKey");
AmazonElasticMapReduceClient emrClient;
emrClient = new AmazonElasticMapReduceClient(credentials);
emrClient.setEndpoint("elasticmapreduce.eu-west-1.amazonaws.com");
ListClustersRequest req;
req = new ListClustersRequest().withClusterStates(ClusterState.TERMINATED_WITH_ERRORS);
ListClustersResult res;
res = emrClient.listClusters(req);
int size = res.getClusters().size();
System.out.println("***************** CLUSTER LIST ***************");
System.out.println("*** Size: " + size);
for(int i = 0 ; i < size; i++){
String clusterID = res.getClusters().get(i).getId();
System.out.println(">>> Cluster: " + clusterID);
}
참고 다음 단계 :
귀하의 특정 질문을 언급 한대로 클러스터의 실제 개체를 가져올 수 없습니다. 대신 API는 구체적인 클러스터의 정보 요약을 가져올 수 있습니다 (위의 제공된 코드에서 사용됨). 그러나 클러스터 종료와 같은 명령을 계속 실행할 수 있습니다 (예 :
clusterId //Defined in the code above
TerminateJobFlowsRequest terminate;
terminate = new TerminateJobFlowsRequest().withJobFlowIds(Arrays.asList(new String[] {clusterId});
emrClient.terminateJobFlows(terminate);
).