/** * <p> * The filtered list of steps for the cluster. * </p> * * @param steps * The filtered list of steps for the cluster. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsResult withSteps(java.util.Collection<StepSummary> steps) { setSteps(steps); return this; }
/** * <p> * The pagination token that indicates the next set of results to retrieve. * </p> * * @param marker * The pagination token that indicates the next set of results to retrieve. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsResult withMarker(String marker) { setMarker(marker); return this; }
@Override public ListStepsResult answer(InvocationOnMock invocation) throws Throwable { ListStepsRequest listStepsRequest = invocation.getArgument(1); assertEquals(clusterId, listStepsRequest.getClusterId()); assertEquals(1, listStepsRequest.getStepStates().size()); assertEquals(StepState.RUNNING.toString(), listStepsRequest.getStepStates().get(0)); ListStepsResult listStepsResult = new ListStepsResult(); listStepsResult.setSteps(new ArrayList<>()); listStepsResult.getSteps().add(expectedStepSummary); return listStepsResult; } });
private List<StepSummary> getSteps() { ListStepsRequest listStepsRequest = new ListStepsRequest(); listStepsRequest.setClusterId( hadoopJobFlowId ); ListStepsResult listStepsResult = emrClient.listSteps( listStepsRequest ); List<StepSummary> stepSummaries = listStepsResult.getSteps(); if ( stepSummaries.isEmpty() ) { return null; } return stepSummaries; }
public ListStepsResult unmarshall(JsonUnmarshallerContext context) throws Exception { ListStepsResult listStepsResult = new ListStepsResult(); if (context.testExpression("Steps", targetDepth)) { context.nextToken(); listStepsResult.setSteps(new ListUnmarshaller<StepSummary>(StepSummaryJsonUnmarshaller.getInstance()).unmarshall(context)); listStepsResult.setMarker(context.getUnmarshaller(String.class).unmarshall(context));
@Test public void getClusterActiveStepAssertReturnFirstWhenStepListSizeGt1() throws Exception { String clusterId = "clusterId"; StepSummary expectedStepSummary = new StepSummary(); expectedStepSummary.setId("expected"); ListStepsResult listStepsResult = new ListStepsResult(); listStepsResult.setSteps(Arrays.asList(expectedStepSummary, new StepSummary())); when(mockEmrOperations.listStepsRequest(any(), any())).thenReturn(listStepsResult); assertEquals(expectedStepSummary, emrDao.getClusterActiveStep(clusterId, getAwsParamsDto())); }
@Override public ListStepsResult listStepsRequest(AmazonElasticMapReduceClient emrClient, ListStepsRequest listStepsRequest) { MockEmrJobFlow cluster = getClusterById(listStepsRequest.getClusterId()); if (cluster == null) { throw new AmazonServiceException("No cluster found with jobFlowId: " + listStepsRequest.getClusterId()); } List<StepSummary> steps = new ArrayList<>(); // Add steps that are in these states for (MockEmrJobFlow step : cluster.getSteps()) { if ((listStepsRequest.getStepStates() == null || listStepsRequest.getStepStates().isEmpty()) || listStepsRequest.getStepStates().contains(step.getStatus())) { StepSummary stepSummary = new StepSummary().withId(step.getJobFlowId()).withName(step.getJobFlowName()).withStatus(new StepStatus().withState(step.getStatus())) .withConfig(new HadoopStepConfig().withJar(step.getJarLocation())); steps.add(stepSummary); } } return new ListStepsResult().withSteps(steps); }
@Test public void getClusterActiveStepAssertReturnNullWhenStepListIsEmpty() throws Exception { String clusterId = "clusterId"; when(mockEmrOperations.listStepsRequest(any(), any())).thenReturn(new ListStepsResult()); assertNull(emrDao.getClusterActiveStep(clusterId, getAwsParamsDto())); }
@Override public StepSummary getClusterActiveStep(String clusterId, AwsParamsDto awsParamsDto) { ListStepsRequest listStepsRequest = new ListStepsRequest().withClusterId(clusterId).withStepStates(StepState.RUNNING); List<StepSummary> stepSummaryList = emrOperations.listStepsRequest(getEmrClient(awsParamsDto), listStepsRequest).getSteps(); return !stepSummaryList.isEmpty() ? stepSummaryList.get(0) : null; }
public ListStepsResult unmarshall(JsonUnmarshallerContext context) throws Exception { ListStepsResult listStepsResult = new ListStepsResult(); if (context.testExpression("Steps", targetDepth)) { context.nextToken(); listStepsResult.setSteps(new ListUnmarshaller<StepSummary>(StepSummaryJsonUnmarshaller.getInstance()).unmarshall(context)); listStepsResult.setMarker(context.getUnmarshaller(String.class).unmarshall(context));
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListStepsResult == false) return false; ListStepsResult other = (ListStepsResult) obj; if (other.getSteps() == null ^ this.getSteps() == null) return false; if (other.getSteps() != null && other.getSteps().equals(this.getSteps()) == false) return false; if (other.getMarker() == null ^ this.getMarker() == null) return false; if (other.getMarker() != null && other.getMarker().equals(this.getMarker()) == false) return false; return true; }
@Override public StepSummary getClusterActiveStep(String clusterId, AwsParamsDto awsParamsDto) { ListStepsRequest listStepsRequest = new ListStepsRequest().withClusterId(clusterId).withStepStates(StepState.RUNNING); List<StepSummary> stepSummaryList = emrOperations.listStepsRequest(getEmrClient(awsParamsDto), listStepsRequest).getSteps(); return !stepSummaryList.isEmpty() ? stepSummaryList.get(0) : null; }
/** * <p> * The filtered list of steps for the cluster. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setSteps(java.util.Collection)} or {@link #withSteps(java.util.Collection)} if you want to override the * existing values. * </p> * * @param steps * The filtered list of steps for the cluster. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsResult withSteps(StepSummary... steps) { if (this.steps == null) { setSteps(new com.amazonaws.internal.SdkInternalList<StepSummary>(steps.length)); } for (StepSummary ele : steps) { this.steps.add(ele); } return this; }
/** * <p> * The pagination token that indicates the next set of results to retrieve. * </p> * * @param marker * The pagination token that indicates the next set of results to retrieve. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsResult withMarker(String marker) { setMarker(marker); return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSteps() != null) sb.append("Steps: ").append(getSteps()).append(","); if (getMarker() != null) sb.append("Marker: ").append(getMarker()); sb.append("}"); return sb.toString(); }
.withStepStates("RUNNING")); runningSteps.getSteps().stream().findFirst() .ifPresent(step -> { int stepIndex = submission.stepIds().indexOf(step.getId()); .flatMap(ids -> emr.listSteps(new ListStepsRequest() .withClusterId(submission.clusterId()) .withStepIds(ids)).getSteps().stream()) .collect(toList());
/** * <p> * The filtered list of steps for the cluster. * </p> * * @param steps * The filtered list of steps for the cluster. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsResult withSteps(java.util.Collection<StepSummary> steps) { setSteps(steps); return this; }
List<StepSummary> addedSteps = listStepsResult.getSteps();