2017-07-28 1 views
2

Je tente de soumettre un travail d'étincelle à AWS EMR via les API AWS EMR SDK. Je souhaite que le processus soumette le travail, puis attend que le travail soit terminé/échoué et obtienne le statut correspondant.Soumettre un travail d'étincelle à AWS EMR avec du code Java et attendre l'exécution et obtenir l'état final

code:

AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); 
AmazonElasticMapReduce emr = 
     AmazonElasticMapReduceClientBuilder 
       .standard() 
       .withCredentials(new AWSStaticCredentialsProvider(credentials)) 
       .build(); 

HadoopJarStepConfig sparkStepConf = 
     new HadoopJarStepConfig() 
       .withJar("command-runner.jar") 
       .withArgs("spark-submit") 
       .withArgs("--master", "yarn") 
       .withArgs(sparkJarPath) 
       .withArgs(args); 

StepConfig sparkStep = 
     new StepConfig().withName("Spark Step").withActionOnFailure(ActionOnFailure.CONTINUE).withHadoopJarStep(
       sparkStepConf); 

AddJobFlowStepsRequest req = 
     new AddJobFlowStepsRequest().withJobFlowId(clusterId).withSteps(Collections.singletonList(sparkStep)); 
emr.addJobFlowSteps(req); 

Impossible de trouver quelque chose pour aller chercher l'état des travaux soumis

Répondre

1

Voici un exemple (s'il vous plaît vérifier le vide dans certains domaines de code):

ListStepsResult stepsResult = emr.listSteps(new ListStepsRequest().withClusterId(clusterId).withStepIds(req.getStepIds())); 
List<StepSummary> stepsList = stepsResult.getSteps(); 
StepSummary stepSummary = stepsList.get(0); 
StepStatus stepSummaryStatus = stepSummary.getStatus(); 
String stepStatus = stepSummaryStatus.getState(); 
StepExecutionState stepState = StepExecutionState.valueOf(stepStatus); 

stepState aura ce que vous voulez.