@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getClusterId() == null) ? 0 : getClusterId().hashCode()); hashCode = prime * hashCode + ((getStepStates() == null) ? 0 : getStepStates().hashCode()); hashCode = prime * hashCode + ((getStepIds() == null) ? 0 : getStepIds().hashCode()); hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); return hashCode; }
/** * <p> * The identifier of the cluster for which to list the steps. * </p> * * @param clusterId * The identifier of the cluster for which to list the steps. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsRequest withClusterId(String clusterId) { setClusterId(clusterId); 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 ListStepsRequest withMarker(String marker) { setMarker(marker); return this; }
/** * <p> * The filter to limit the step list based on certain states. * </p> * * @param stepStates * The filter to limit the step list based on certain states. * @return Returns a reference to this object so that method calls can be chained together. * @see StepState */ public ListStepsRequest withStepStates(StepState... stepStates) { com.amazonaws.internal.SdkInternalList<String> stepStatesCopy = new com.amazonaws.internal.SdkInternalList<String>(stepStates.length); for (StepState value : stepStates) { stepStatesCopy.add(value.toString()); } if (getStepStates() == null) { setStepStates(stepStatesCopy); } else { getStepStates().addAll(stepStatesCopy); } return this; }
@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; }
.run(s -> { ListStepsResult runningSteps = emr.listSteps(new ListStepsRequest() .withClusterId(submission.clusterId()) .withStepStates("RUNNING")); .flatMap(ids -> emr.listSteps(new ListStepsRequest() .withClusterId(submission.clusterId()) .withStepIds(ids)).getSteps().stream()) .collect(toList());
private List<StepSummary> listSubmittedSteps(AmazonElasticMapReduce emr, String tag, NewCluster cluster) { List<StepSummary> steps = new ArrayList<>(); ListStepsRequest request = new ListStepsRequest().withClusterId(cluster.id()); while (steps.size() < cluster.steps()) { ListStepsResult result = emr.listSteps(request); for (StepSummary step : result.getSteps()) { if (step.getName().contains(tag)) { steps.add(step); } } if (result.getMarker() == null) { break; } request.setMarker(result.getMarker()); } // The ListSteps api returns steps in reverse order. So reverse them to submission order. Collections.reverse(steps); return steps; }
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; }
ListStepsRequest listStepsRequest = (new ListStepsRequest()).withClusterId(emrCluster.getId());
@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; } });
@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; }
@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); }
/** * <p> * The filter to limit the step list based on certain states. * </p> * * @param stepStates * The filter to limit the step list based on certain states. * @return Returns a reference to this object so that method calls can be chained together. * @see StepState */ public ListStepsRequest withStepStates(StepState... stepStates) { com.amazonaws.internal.SdkInternalList<String> stepStatesCopy = new com.amazonaws.internal.SdkInternalList<String>(stepStates.length); for (StepState value : stepStates) { stepStatesCopy.add(value.toString()); } if (getStepStates() == null) { setStepStates(stepStatesCopy); } else { getStepStates().addAll(stepStatesCopy); } return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListStepsRequest == false) return false; ListStepsRequest other = (ListStepsRequest) obj; if (other.getClusterId() == null ^ this.getClusterId() == null) return false; if (other.getClusterId() != null && other.getClusterId().equals(this.getClusterId()) == false) return false; if (other.getStepStates() == null ^ this.getStepStates() == null) return false; if (other.getStepStates() != null && other.getStepStates().equals(this.getStepStates()) == false) return false; if (other.getStepIds() == null ^ this.getStepIds() == null) return false; if (other.getStepIds() != null && other.getStepIds().equals(this.getStepIds()) == 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; }
/** * <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 ListStepsRequest withMarker(String marker) { setMarker(marker); return this; }
/** * <p> * The identifier of the cluster for which to list the steps. * </p> * * @param clusterId * The identifier of the cluster for which to list the steps. * @return Returns a reference to this object so that method calls can be chained together. */ public ListStepsRequest withClusterId(String clusterId) { setClusterId(clusterId); 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 (getClusterId() != null) sb.append("ClusterId: ").append(getClusterId()).append(","); if (getStepStates() != null) sb.append("StepStates: ").append(getStepStates()).append(","); if (getStepIds() != null) sb.append("StepIds: ").append(getStepIds()).append(","); if (getMarker() != null) sb.append("Marker: ").append(getMarker()); sb.append("}"); return sb.toString(); }
/** * Marshall the given parameter object. */ public void marshall(ListStepsRequest listStepsRequest, ProtocolMarshaller protocolMarshaller) { if (listStepsRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(listStepsRequest.getClusterId(), CLUSTERID_BINDING); protocolMarshaller.marshall(listStepsRequest.getStepStates(), STEPSTATES_BINDING); protocolMarshaller.marshall(listStepsRequest.getStepIds(), STEPIDS_BINDING); protocolMarshaller.marshall(listStepsRequest.getMarker(), MARKER_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getClusterId() == null) ? 0 : getClusterId().hashCode()); hashCode = prime * hashCode + ((getStepStates() == null) ? 0 : getStepStates().hashCode()); hashCode = prime * hashCode + ((getStepIds() == null) ? 0 : getStepIds().hashCode()); hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListStepsRequest == false) return false; ListStepsRequest other = (ListStepsRequest) obj; if (other.getClusterId() == null ^ this.getClusterId() == null) return false; if (other.getClusterId() != null && other.getClusterId().equals(this.getClusterId()) == false) return false; if (other.getStepStates() == null ^ this.getStepStates() == null) return false; if (other.getStepStates() != null && other.getStepStates().equals(this.getStepStates()) == false) return false; if (other.getStepIds() == null ^ this.getStepIds() == null) return false; if (other.getStepIds() != null && other.getStepIds().equals(this.getStepIds()) == 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; }