@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getStateChangeReason() == null) ? 0 : getStateChangeReason().hashCode()); hashCode = prime * hashCode + ((getTimeline() == null) ? 0 : getTimeline().hashCode()); return hashCode; }
private co.cask.cdap.runtime.spi.provisioner.ClusterStatus convertStatus(ClusterStatus status) { switch (ClusterState.fromValue(status.getState())) { case BOOTSTRAPPING: case STARTING: return co.cask.cdap.runtime.spi.provisioner.ClusterStatus.CREATING; case WAITING: case RUNNING: return co.cask.cdap.runtime.spi.provisioner.ClusterStatus.RUNNING; case TERMINATING: return co.cask.cdap.runtime.spi.provisioner.ClusterStatus.DELETING; case TERMINATED: case TERMINATED_WITH_ERRORS: // we don't returned FAILED, because then that means we will attempt to delete it return co.cask.cdap.runtime.spi.provisioner.ClusterStatus.NOT_EXISTS; default: // unrecognized and unknown return co.cask.cdap.runtime.spi.provisioner.ClusterStatus.ORPHANED; } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ClusterStatus == false) return false; ClusterStatus other = (ClusterStatus) obj; if (other.getState() == null ^ this.getState() == null) return false; if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getStateChangeReason() == null ^ this.getStateChangeReason() == null) return false; if (other.getStateChangeReason() != null && other.getStateChangeReason().equals(this.getStateChangeReason()) == false) return false; if (other.getTimeline() == null ^ this.getTimeline() == null) return false; if (other.getTimeline() != null && other.getTimeline().equals(this.getTimeline()) == false) return false; return true; }
Optional<ClusterSummary> getUnterminatedClusterByName(String name) { List<ClusterSummary> clusters = client.listClusters().getClusters(); List<ClusterSummary> clustersWithSameName = clusters.stream() .filter(clusterSummary -> name.equals(clusterSummary.getName())) .filter(clusterSummary -> UNTERMINATED_STATES.contains( ClusterState.fromValue(clusterSummary.getStatus().getState()))) .collect(Collectors.toList()); if (clustersWithSameName.size() == 0) { return Optional.empty(); } else if (clustersWithSameName.size() == 1) { return Optional.of(Iterables.getOnlyElement(clustersWithSameName)); } throw new IllegalStateException("Multiple clusters with the name '" + name + "': " + clustersWithSameName); }
/** * 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 (getState() != null) sb.append("State: ").append(getState()).append(","); if (getStateChangeReason() != null) sb.append("StateChangeReason: ").append(getStateChangeReason()).append(","); if (getTimeline() != null) sb.append("Timeline: ").append(getTimeline()); sb.append("}"); return sb.toString(); }
@Override public String getEmrClusterStatusById(String clusterId, AwsParamsDto awsParams) { Cluster cluster = getEmrClusterById(clusterId, awsParams); return ((cluster == null) ? null : cluster.getStatus().getState()); }
/** * Marshall the given parameter object. */ public void marshall(ClusterStatus clusterStatus, ProtocolMarshaller protocolMarshaller) { if (clusterStatus == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(clusterStatus.getState(), STATE_BINDING); protocolMarshaller.marshall(clusterStatus.getStateChangeReason(), STATECHANGEREASON_BINDING); protocolMarshaller.marshall(clusterStatus.getTimeline(), TIMELINE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
@Override public String getEmrClusterStatusById(String clusterId, AwsParamsDto awsParams) { Cluster cluster = getEmrClusterById(clusterId, awsParams); return ((cluster == null) ? null : cluster.getStatus().getState()); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getStateChangeReason() == null) ? 0 : getStateChangeReason().hashCode()); hashCode = prime * hashCode + ((getTimeline() == null) ? 0 : getTimeline().hashCode()); return hashCode; }
String emrClusterState = cluster.getStatus().getState(); Assert.isTrue(isActiveEmrState(emrClusterState), String .format("The cluster with ID \"%s\" is not active. The cluster state must be in one of %s. Current state is \"%s\"", emrClusterIdTrimmed,
/** * 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 (getState() != null) sb.append("State: ").append(getState()).append(","); if (getStateChangeReason() != null) sb.append("StateChangeReason: ").append(getStateChangeReason()).append(","); if (getTimeline() != null) sb.append("Timeline: ").append(getTimeline()); sb.append("}"); return sb.toString(); }
String emrClusterState = cluster.getStatus().getState(); Assert.isTrue(isActiveEmrState(emrClusterState), String .format("The cluster with ID \"%s\" is not active. The cluster state must be in one of %s. Current state is \"%s\"", emrClusterIdTrimmed,
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ClusterStatus == false) return false; ClusterStatus other = (ClusterStatus) obj; if (other.getState() == null ^ this.getState() == null) return false; if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getStateChangeReason() == null ^ this.getStateChangeReason() == null) return false; if (other.getStateChangeReason() != null && other.getStateChangeReason().equals(this.getStateChangeReason()) == false) return false; if (other.getTimeline() == null ^ this.getTimeline() == null) return false; if (other.getTimeline() != null && other.getTimeline().equals(this.getTimeline()) == false) return false; return true; }
private String getActualClusterState() { String clusterState = null; DescribeClusterRequest describeClusterRequest = new DescribeClusterRequest(); describeClusterRequest.setClusterId( hadoopJobFlowId ); DescribeClusterResult describeClusterResult = emrClient.describeCluster( describeClusterRequest ); if ( describeClusterResult != null ) { clusterState = describeClusterResult.getCluster().getStatus().getState(); } return clusterState; }
/** * Marshall the given parameter object. */ public void marshall(ClusterStatus clusterStatus, ProtocolMarshaller protocolMarshaller) { if (clusterStatus == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(clusterStatus.getState(), STATE_BINDING); protocolMarshaller.marshall(clusterStatus.getStateChangeReason(), STATECHANGEREASON_BINDING); protocolMarshaller.marshall(clusterStatus.getTimeline(), TIMELINE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
String clusterState = clusterStatus.getState();
/** * Updates EMR cluster model object with the specified EMR cluster status information. * * @param emrCluster the EMR cluster * @param clusterStatus the EMR cluster status information */ private void setEmrClusterStatus(EmrCluster emrCluster, ClusterStatus clusterStatus) { // Log cluster status information. LOGGER.info("emrClusterId=\"{}\" emrClusterStatus={}", emrCluster.getId(), jsonHelper.objectToJson(clusterStatus)); // Update the EMR cluster with the status information. emrCluster.setStatus(clusterStatus.getState()); emrCluster .setStatusChangeReason(new StatusChangeReason(clusterStatus.getStateChangeReason().getCode(), clusterStatus.getStateChangeReason().getMessage())); emrCluster.setStatusTimeline(new StatusTimeline(toXmlGregorianCalendar(clusterStatus.getTimeline().getCreationDateTime()), toXmlGregorianCalendar(clusterStatus.getTimeline().getReadyDateTime()), toXmlGregorianCalendar(clusterStatus.getTimeline().getEndDateTime()))); } }
/** * Updates EMR cluster model object with the specified EMR cluster status information. * * @param emrCluster the EMR cluster * @param clusterStatus the EMR cluster status information */ private void setEmrClusterStatus(EmrCluster emrCluster, ClusterStatus clusterStatus) { // Log cluster status information. LOGGER.info("emrClusterId=\"{}\" emrClusterStatus={}", emrCluster.getId(), jsonHelper.objectToJson(clusterStatus)); // Update the EMR cluster with the status information. emrCluster.setStatus(clusterStatus.getState()); emrCluster .setStatusChangeReason(new StatusChangeReason(clusterStatus.getStateChangeReason().getCode(), clusterStatus.getStateChangeReason().getMessage())); emrCluster.setStatusTimeline(new StatusTimeline(toXmlGregorianCalendar(clusterStatus.getTimeline().getCreationDateTime()), toXmlGregorianCalendar(clusterStatus.getTimeline().getReadyDateTime()), toXmlGregorianCalendar(clusterStatus.getTimeline().getEndDateTime()))); } }