소스 검색

AMBARI-5749. Store cluster installed state as part of the Cluster resource - 2 (Jonathan Hurley via ncole)

Nate Cole 11 년 전
부모
커밋
73538ee1fe

+ 1 - 2
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -1041,10 +1041,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     
     // set the provisioning state of the cluster
     if (null != request.getProvisioningState()) {
-      State provisioningState;
       State oldProvisioningState = cluster.getProvisioningState();
+      State provisioningState = State.valueOf(request.getProvisioningState());
 
-      provisioningState = State.valueOf(request.getProvisioningState());
       if (provisioningState != State.INIT
           && provisioningState != State.INSTALLED) {
         LOG.warn(

+ 5 - 11
ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterStateEntity.java

@@ -23,17 +23,12 @@ import static org.apache.commons.lang.StringUtils.defaultString;
 import javax.persistence.Basic;
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
-import javax.persistence.Table;
-
-import org.apache.ambari.server.state.State;
 
+@javax.persistence.Table(name = "clusterstate")
 @Entity
-@Table(name = "clusterstate")
 public class ClusterStateEntity {
 
   @Id
@@ -41,9 +36,8 @@ public class ClusterStateEntity {
   private Long clusterId;
 
   @Basic
-  @Enumerated(value = EnumType.STRING)
   @Column(name = "current_cluster_state", insertable = true, updatable = true)
-  private State currentClusterState = State.INIT; 
+  private String currentClusterState = "";
 
   @Basic
   @Column(name = "current_stack_version", insertable = true, updatable = true)
@@ -61,11 +55,11 @@ public class ClusterStateEntity {
     this.clusterId = clusterId;
   }
 
-  public State getCurrentClusterState() {
-    return currentClusterState;
+  public String getCurrentClusterState() {
+    return defaultString(currentClusterState);
   }
 
-  public void setCurrentClusterState(State currentClusterState) {
+  public void setCurrentClusterState(String currentClusterState) {
     this.currentClusterState = currentClusterState;
   }