incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject svn commit: r1464222 [2/3] - in /incubator/ambari/trunk: ./ ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/ ambari-agent/src/main/puppet/modules/hdp-hadoop/templates/ ambari-server/src/main/java/org/apache/ambari/eventdb/db/ ambari-server/sr...
Date Wed, 03 Apr 2013 22:35:43 GMT
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java Wed Apr  3 22:35:41 2013
@@ -24,14 +24,51 @@ import org.apache.ambari.server.state.St
 
 import javax.persistence.*;
 
-@javax.persistence.IdClass(HostComponentStateEntityPK.class)
-@javax.persistence.Table(name = "hostcomponentstate", schema = "ambari", catalog = "")
+import static org.apache.commons.lang.StringUtils.defaultString;
+
+@IdClass(HostComponentStateEntityPK.class)
+@Table(name = "hostcomponentstate")
 @Entity
 public class HostComponentStateEntity {
+
+  @Id
+  @Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
   private Long clusterId;
 
-  @javax.persistence.Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
   @Id
+  @Column(name = "service_name", nullable = false, insertable = false, updatable = false)
+  private String serviceName;
+
+  @Id
+  @Column(name = "host_name", insertable = false, updatable = false)
+  private String hostName = "";
+
+  @Id
+  @Column(name = "component_name", nullable = false, insertable = false, updatable = false)
+  private String componentName;
+
+  @Enumerated(value = EnumType.STRING)
+  @Column(name = "current_state", nullable = false, insertable = true, updatable = true)
+  private State currentState = State.INIT;
+
+  @Basic
+  @Column(name = "current_stack_version", nullable = false, insertable = true, updatable = true)
+  private String currentStackVersion;
+
+  @ManyToOne
+  @JoinColumns({
+      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+      @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false),
+      @JoinColumn(name = "component_name", referencedColumnName = "component_name", nullable = false)})
+  private ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity;
+
+  @ManyToOne
+  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
+  private HostEntity hostEntity;
+
+  @OneToMany(mappedBy = "hostComponentStateEntity", cascade = CascadeType.ALL)
+  private Collection<HostComponentConfigMappingEntity> configMappingEntities;
+
   public Long getClusterId() {
     return clusterId;
   }
@@ -40,10 +77,6 @@ public class HostComponentStateEntity {
     this.clusterId = clusterId;
   }
 
-  private String serviceName;
-
-  @javax.persistence.Column(name = "service_name", nullable = false, insertable = false, updatable = false)
-  @Id
   public String getServiceName() {
     return serviceName;
   }
@@ -52,22 +85,14 @@ public class HostComponentStateEntity {
     this.serviceName = serviceName;
   }
 
-  private String hostName = "";
-
-  @javax.persistence.Column(name = "host_name", nullable = false, insertable = false, updatable = false)
-  @Id
   public String getHostName() {
-    return hostName;
+    return defaultString(hostName);
   }
 
   public void setHostName(String hostName) {
     this.hostName = hostName;
   }
 
-  private String componentName;
-
-  @javax.persistence.Column(name = "component_name", nullable = false, insertable = false, updatable = false)
-  @Id
   public String getComponentName() {
     return componentName;
   }
@@ -76,10 +101,6 @@ public class HostComponentStateEntity {
     this.componentName = componentName;
   }
 
-  private State currentState = State.INIT;
-
-  @javax.persistence.Column(name = "current_state", nullable = false, insertable = true, updatable = true)
-  @Enumerated(value = EnumType.STRING)
   public State getCurrentState() {
     return currentState;
   }
@@ -88,10 +109,6 @@ public class HostComponentStateEntity {
     this.currentState = currentState;
   }
 
-  private String currentStackVersion;
-
-  @javax.persistence.Column(name = "current_stack_version", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getCurrentStackVersion() {
     return currentStackVersion;
   }
@@ -129,13 +146,6 @@ public class HostComponentStateEntity {
     return result;
   }
 
-  private ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity;
-
-  @ManyToOne
-  @JoinColumns({
-      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
-      @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false),
-      @JoinColumn(name = "component_name", referencedColumnName = "component_name", nullable = false)})
   public ServiceComponentDesiredStateEntity getServiceComponentDesiredStateEntity() {
     return serviceComponentDesiredStateEntity;
   }
@@ -144,10 +154,6 @@ public class HostComponentStateEntity {
     this.serviceComponentDesiredStateEntity = serviceComponentDesiredStateEntity;
   }
 
-  private HostEntity hostEntity;
-
-  @ManyToOne
-  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
   public HostEntity getHostEntity() {
     return hostEntity;
   }
@@ -156,9 +162,7 @@ public class HostComponentStateEntity {
     this.hostEntity = hostEntity;
   }
 
-  private Collection<HostComponentConfigMappingEntity> configMappingEntities;
-  @OneToMany(mappedBy = "hostComponentStateEntity", cascade = CascadeType.ALL)
-   public Collection<HostComponentConfigMappingEntity> getHostComponentConfigMappingEntities() {
+  public Collection<HostComponentConfigMappingEntity> getHostComponentConfigMappingEntities() {
     return configMappingEntities;
   }
 
@@ -167,5 +171,4 @@ public class HostComponentStateEntity {
   }
 
 
-
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java Wed Apr  3 22:35:41 2013
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -26,86 +26,90 @@ import javax.persistence.Table;
 /**
  * Entity that represents a host config mapping and override.
  */
-@Table(name = "hostconfigmapping", schema = "ambari", catalog = "")
+@Table(name = "hostconfigmapping")
 @Entity
 @IdClass(HostConfigMappingEntityPK.class)
 public class HostConfigMappingEntity {
+
+  @Id
+  @Column(name = "cluster_id", insertable = true, updatable = false, nullable = false)
   private Long clusterId;
+
+  @Id
+  @Column(name = "host_name", insertable = true, updatable = false, nullable = false)
   private String hostName;
-  private String typeName;
+
+  @Id
+  @Column(name = "type_name", insertable = true, updatable = false, nullable = false)
+  private String type;
+
+  @Id
+  @Column(name = "create_timestamp", insertable = true, updatable = false, nullable = false)
+  private Long createTimestamp;
+
+  @Column(name = "version_tag", insertable = true, updatable = false, nullable = false)
   private String versionTag;
+
+  @Column(name = "service_name", insertable = true, updatable = true)
   private String serviceName;
-  private Long createTimestamp;
-  private int selectedInd = 0;
-  
-  @Column(name = "cluster_id", insertable = true, updatable = false, nullable = false)
-  @Id
+
+  @Column(name = "selected", insertable = true, updatable = true, nullable = false)
+  private int selected = 0;
+
   public Long getClusterId() {
     return clusterId;
   }
-  
+
   public void setClusterId(Long id) {
     clusterId = id;
   }
-  
-  @Column(name = "host_name", insertable = true, updatable = false, nullable = false)
-  @Id
+
   public String getHostName() {
     return hostName;
   }
-  
+
   public void setHostName(String name) {
     hostName = name;
   }
-  
-  @Column(name = "type_name", insertable = true, updatable = false, nullable = false)
-  @Id
+
   public String getType() {
-    return typeName;
+    return type;
   }
-  
+
   public void setType(String type) {
-    typeName = type;
+    this.type = type;
   }
-  
-  @Column(name = "create_timestamp", insertable = true, updatable = false, nullable = false)
-  @Id
+
   public Long getCreateTimestamp() {
     return createTimestamp;
   }
-  
+
   public void setCreateTimestamp(Long timestamp) {
     createTimestamp = timestamp;
   }
-  
-  
-  @Column(name = "version_tag", insertable = true, updatable = false, nullable = false)
+
   public String getVersion() {
     return versionTag;
   }
-  
+
   public void setVersion(String version) {
     versionTag = version;
   }
- 
 
-  @Column(name = "selected", insertable = true, updatable = true, nullable = false)
   public int isSelected() {
-    return selectedInd;
+    return selected;
   }
 
   public void setSelected(int selected) {
-    selectedInd = selected;
-  }  
-  
-  
-  @Column(name = "service_name", insertable = true, updatable = true)
+    this.selected = selected;
+  }
+
   public String getServiceName() {
     return serviceName;
   }
-  
+
   public void setServiceName(String name) {
     serviceName = name;
   }
-  
+
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntityPK.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntityPK.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntityPK.java Wed Apr  3 22:35:41 2013
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -19,15 +19,16 @@ package org.apache.ambari.server.orm.ent
 
 import javax.persistence.Column;
 import javax.persistence.Id;
+import java.io.Serializable;
 
 /**
  * PK class for host config mappings.
  *
  */
-public class HostConfigMappingEntityPK {
+public class HostConfigMappingEntityPK implements Serializable {
   private Long clusterId;
   private String hostName;
-  private String typeName;
+  private String type;
   private Long createTimestamp;
 
   @Column(name = "cluster_id", nullable = false, insertable = true, updatable = true, length = 10)
@@ -53,11 +54,11 @@ public class HostConfigMappingEntityPK {
   @Column(name = "type_name", insertable = true, updatable = true, nullable = false)
   @Id
   public String getType() {
-    return typeName;
+    return type;
   }
   
   public void setType(String type) {
-    typeName = type;
+    this.type = type;
   }
   
   @Column(name = "create_timestamp", insertable = true, updatable = true, nullable = false)
@@ -81,7 +82,7 @@ public class HostConfigMappingEntityPK {
 
     if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
     if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
-    if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) return false;
+    if (type != null ? !type.equals(that.type) : that.type != null) return false;
     if (createTimestamp != null ? !createTimestamp.equals (that.createTimestamp) : that.createTimestamp != null) return false;
 
     return true;
@@ -90,7 +91,7 @@ public class HostConfigMappingEntityPK {
   @Override
   public int hashCode() {
     int result = clusterId !=null ? clusterId.intValue() : 0;
-    result = 31 * result + (typeName != null ? typeName.hashCode() : 0);
+    result = 31 * result + (type != null ? type.hashCode() : 0);
     result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
     result = 31 * result + createTimestamp.intValue();
     return result;

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java Wed Apr  3 22:35:41 2013
@@ -21,13 +21,101 @@ package org.apache.ambari.server.orm.ent
 import javax.persistence.*;
 import java.util.Collection;
 
-@javax.persistence.Table(name = "hosts", schema = "ambari", catalog = "")
+import static org.apache.commons.lang.StringUtils.defaultString;
+
+@javax.persistence.Table(name = "hosts")
 @Entity
 public class HostEntity {
-  private String hostName;
 
-  @javax.persistence.Column(name = "host_name", nullable = false, insertable = true, updatable = true)
   @Id
+  @Column(name = "host_name", nullable = false, insertable = true, updatable = true)
+  private String hostName;
+
+  @Column(name = "ipv4", nullable = true, insertable = true, updatable = true)
+  @Basic
+  private String ipv4;
+
+  @Column(name = "ipv6", nullable = true, insertable = true, updatable = true)
+  @Basic
+  private String ipv6;
+
+  @Column(name="public_host_name", nullable = true, insertable = true, updatable = true)
+  @Basic
+  private String publicHostName;
+
+  @Column(name = "total_mem", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private Long totalMem = 0L;
+
+  @Column(name = "cpu_count", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private Integer cpuCount = 0;
+
+  @Column(name = "ph_cpu_count", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private Integer phCpuCount = 0;
+
+  @Column(name = "cpu_info", insertable = true, updatable = true)
+  @Basic
+  private String cpuInfo = "";
+
+  @Column(name = "os_arch", insertable = true, updatable = true)
+  @Basic
+  private String osArch = "";
+
+  @Lob
+  @Column(name = "disks_info", nullable = false, insertable = true,
+      updatable = true, length = 10000)
+  @Basic
+  private String disksInfo = "";
+
+  @Column(name = "os_info", insertable = true, updatable = true,
+      length = 1000)
+  @Basic
+  private String osInfo = "";
+
+  @Column(name = "os_type", insertable = true, updatable = true)
+  @Basic
+  private String osType = "";
+
+  @Column(name = "discovery_status", insertable = true, updatable = true,
+      length = 2000)
+  @Basic
+  private String discoveryStatus = "";
+
+  @Column(name = "last_registration_time", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private Long lastRegistrationTime = 0L;
+
+  @Column(name = "rack_info", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private String rackInfo = "/default-rack";
+
+  @Column(name = "host_attributes", insertable = true, updatable = true,
+      length = 20000)
+  @Basic
+  @Lob
+  private String hostAttributes = "";
+
+  @OneToMany(mappedBy = "hostEntity")
+  private Collection<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities;
+
+  @OneToMany(mappedBy = "hostEntity")
+  private Collection<HostComponentStateEntity> hostComponentStateEntities;
+
+  @ManyToMany
+  @JoinTable(name = "ClusterHostMapping",
+      joinColumns = {@JoinColumn(name = "host_name", referencedColumnName = "host_name")},
+      inverseJoinColumns = {@JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")}
+  )
+  private Collection<ClusterEntity> clusterEntities;
+
+  @OneToOne(mappedBy = "hostEntity")
+  private HostStateEntity hostStateEntity;
+
+  @OneToMany(mappedBy = "host")
+  private Collection<HostRoleCommandEntity> hostRoleCommandEntities;
+
   public String getHostName() {
     return hostName;
   }
@@ -36,10 +124,6 @@ public class HostEntity {
     this.hostName = hostName;
   }
 
-  private String ipv4;
-
-  @javax.persistence.Column(name = "ipv4", nullable = true, insertable = true, updatable = true)
-  @Basic
   public String getIpv4() {
     return ipv4;
   }
@@ -48,10 +132,6 @@ public class HostEntity {
     this.ipv4 = ipv4;
   }
 
-  private String ipv6;
-
-  @javax.persistence.Column(name = "ipv6", nullable = true, insertable = true, updatable = true)
-  @Basic
   public String getIpv6() {
     return ipv6;
   }
@@ -59,22 +139,15 @@ public class HostEntity {
   public void setIpv6(String ipv6) {
     this.ipv6 = ipv6;
   }
-  
-  private String publicHostName;
-  @Column(name="public_host_name", nullable = true, insertable = true, updatable = true)
-  @Basic
+
   public String getPublicHostName() {
     return publicHostName;
   }
-  
+
   public void setPublicHostName(String name) {
     publicHostName = name;
   }
 
-  private Long totalMem = 0L;
-
-  @javax.persistence.Column(name = "total_mem", nullable = false, insertable = true, updatable = true, length = 10)
-  @Basic
   public Long getTotalMem() {
     return totalMem;
   }
@@ -83,10 +156,6 @@ public class HostEntity {
     this.totalMem = totalMem;
   }
 
-  private Integer cpuCount = 0;
-
-  @javax.persistence.Column(name = "cpu_count", nullable = false, insertable = true, updatable = true, length = 10)
-  @Basic
   public Integer getCpuCount() {
     return cpuCount;
   }
@@ -94,11 +163,7 @@ public class HostEntity {
   public void setCpuCount(Integer cpuCount) {
     this.cpuCount = cpuCount;
   }
-
-  private Integer phCpuCount = 0;
-
-  @javax.persistence.Column(name = "ph_cpu_count", nullable = false, insertable = true, updatable = true, length = 10)
-  @Basic
+  
   public Integer getPhCpuCount() {
     return phCpuCount;
   }
@@ -107,87 +172,54 @@ public class HostEntity {
     this.phCpuCount = phCpuCount;
   }
   
-  
-  
-  private String cpuInfo = "";
-
-  @javax.persistence.Column(name = "cpu_info", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getCpuInfo() {
-    return cpuInfo;
+    return defaultString(cpuInfo);
   }
 
   public void setCpuInfo(String cpuInfo) {
     this.cpuInfo = cpuInfo;
   }
 
-  private String osArch = "";
-
-  @javax.persistence.Column(name = "os_arch", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getOsArch() {
-    return osArch;
+    return defaultString(osArch);
   }
 
   public void setOsArch(String osArch) {
     this.osArch = osArch;
   }
 
-  private String disksInfo = "";
-
-  @javax.persistence.Column(name = "disks_info", nullable = false, insertable = true,
-		  updatable = true, length = 2000)
-  @Basic
   public String getDisksInfo() {
-    return disksInfo;
+    return defaultString(disksInfo);
   }
 
   public void setDisksInfo(String disksInfo) {
     this.disksInfo = disksInfo;
   }
 
-  private String osInfo = "";
-
-  @javax.persistence.Column(name = "os_info", nullable = false, insertable = true, updatable = true,
-      length = 1000)
-  @Basic
   public String getOsInfo() {
-    return osInfo;
+    return defaultString(osInfo);
   }
 
   public void setOsInfo(String osInfo) {
     this.osInfo = osInfo;
   }
 
-  private String osType = "";
-
-  @javax.persistence.Column(name = "os_type", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getOsType() {
-    return osType;
+    return defaultString(osType);
   }
 
   public void setOsType(String osType) {
     this.osType = osType;
   }
 
-  private String discoveryStatus = "";
-
-  @javax.persistence.Column(name = "discovery_status", nullable = false, insertable = true, updatable = true,
-      length = 2000)
-  @Basic
   public String getDiscoveryStatus() {
-    return discoveryStatus;
+    return defaultString(discoveryStatus);
   }
 
   public void setDiscoveryStatus(String discoveryStatus) {
     this.discoveryStatus = discoveryStatus;
   }
 
-  private Long lastRegistrationTime = 0L;
-
-  @javax.persistence.Column(name = "last_registration_time", nullable = false, insertable = true, updatable = true, length = 10)
-  @Basic
   public Long getLastRegistrationTime() {
     return lastRegistrationTime;
   }
@@ -196,10 +228,6 @@ public class HostEntity {
     this.lastRegistrationTime = lastRegistrationTime;
   }
 
-  private String rackInfo = "/default-rack";
-
-  @javax.persistence.Column(name = "rack_info", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getRackInfo() {
     return rackInfo;
   }
@@ -208,13 +236,8 @@ public class HostEntity {
     this.rackInfo = rackInfo;
   }
 
-  private String hostAttributes = "";
-
-  @javax.persistence.Column(name = "host_attributes", nullable = false, insertable = true, updatable = true,
-      length = 20000)
-  @Basic
   public String getHostAttributes() {
-    return hostAttributes;
+    return defaultString(hostAttributes);
   }
 
   public void setHostAttributes(String hostAttributes) {
@@ -265,9 +288,6 @@ public class HostEntity {
     return result;
   }
 
-  private Collection<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities;
-
-  @OneToMany(mappedBy = "hostEntity")
   public Collection<HostComponentDesiredStateEntity> getHostComponentDesiredStateEntities() {
     return hostComponentDesiredStateEntities;
   }
@@ -276,9 +296,6 @@ public class HostEntity {
     this.hostComponentDesiredStateEntities = hostComponentDesiredStateEntities;
   }
 
-  private Collection<HostComponentStateEntity> hostComponentStateEntities;
-
-  @OneToMany(mappedBy = "hostEntity")
   public Collection<HostComponentStateEntity> getHostComponentStateEntities() {
     return hostComponentStateEntities;
   }
@@ -287,15 +304,6 @@ public class HostEntity {
     this.hostComponentStateEntities = hostComponentStateEntities;
   }
 
-  private Collection<ClusterEntity> clusterEntities;
-
-  @ManyToMany
-//  @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")
-  @JoinTable(name = "ClusterHostMapping", catalog = "", schema = "ambari",
-          joinColumns = {@JoinColumn(name = "host_name", referencedColumnName = "host_name")},
-          inverseJoinColumns = {@JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")}
-
-  )
   public Collection<ClusterEntity> getClusterEntities() {
     return clusterEntities;
   }
@@ -304,9 +312,6 @@ public class HostEntity {
     this.clusterEntities = clusterEntities;
   }
 
-  private HostStateEntity hostStateEntity;
-
-  @OneToOne(mappedBy = "hostEntity")
   public HostStateEntity getHostStateEntity() {
     return hostStateEntity;
   }
@@ -315,9 +320,6 @@ public class HostEntity {
     this.hostStateEntity = hostStateEntity;
   }
 
-  private Collection<HostRoleCommandEntity> hostRoleCommandEntities;
-
-  @OneToMany(mappedBy = "host")
   public Collection<HostRoleCommandEntity> getHostRoleCommandEntities() {
     return hostRoleCommandEntities;
   }
@@ -326,25 +328,4 @@ public class HostEntity {
     this.hostRoleCommandEntities = hostRoleCommandEntities;
   }
 
-  //  private Collection<ServiceComponentStateEntity> serviceComponentStateEntities;
-//
-//  @OneToMany(mappedBy = "hostEntity")
-//  public Collection<ServiceComponentStateEntity> getServiceComponentStateEntities() {
-//    return serviceComponentStateEntities;
-//  }
-//
-//  public void setServiceComponentStateEntities(Collection<ServiceComponentStateEntity> serviceComponentStateEntities) {
-//    this.serviceComponentStateEntities = serviceComponentStateEntities;
-//  }
-
-//  private Collection<ServiceStateEntity> serviceStateEntities;
-//
-//  @OneToMany(mappedBy = "hostEntity")
-//  public Collection<ServiceStateEntity> getServiceStateEntities() {
-//    return serviceStateEntities;
-//  }
-//
-//  public void setServiceStateEntities(Collection<ServiceStateEntity> serviceStateEntities) {
-//    this.serviceStateEntities = serviceStateEntities;
-//  }
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java Wed Apr  3 22:35:41 2013
@@ -21,20 +21,96 @@ package org.apache.ambari.server.orm.ent
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.commons.lang.ArrayUtils;
 
 import javax.persistence.*;
 import java.util.Arrays;
 
-@Table(name = "host_role_command", schema = "ambari", catalog = "")
+import static org.apache.commons.lang.StringUtils.defaultString;
+
+@Table(name = "host_role_command")
 @Entity
 @Cacheable(false)
-@SequenceGenerator(name = "ambari.host_role_command_task_id_seq", allocationSize = 50)
+@TableGenerator(name = "host_role_command_id_generator",
+    table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "value"
+    , pkColumnValue = "host_role_command_id_seq"
+    , initialValue = 1
+    , allocationSize = 50
+)
+
 public class HostRoleCommandEntity {
-  private Long taskId;
 
   @Column(name = "task_id")
   @Id
-  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.host_role_command_task_id_seq")
+  @GeneratedValue(strategy = GenerationType.TABLE, generator = "host_role_command_id_generator")
+  private Long taskId;
+
+  @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
+  @Basic
+  private Long requestId;
+
+  @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
+  @Basic
+  private Long stageId;
+
+  @Column(name = "host_name", insertable = false, updatable = false, nullable = false)
+  @Basic
+  private String hostName;
+
+  @Column(name = "role")
+  @Enumerated(EnumType.STRING)
+  private Role role;
+
+  @Column(name = "event", length = 32000)
+  @Basic
+  @Lob
+  private String event = "";
+
+  @Column(name = "exitcode", nullable = false)
+  @Basic
+  private Integer exitcode = 0;
+
+  @Column(name = "status")
+  @Enumerated(EnumType.STRING)
+  private HostRoleStatus status;
+
+  @Column(name = "std_error")
+  @Lob
+  @Basic
+  private byte[] stdError = new byte[0];
+
+  @Column(name = "std_out")
+  @Lob
+  @Basic
+  private byte[] stdOut = new byte[0];
+
+  @Basic
+  @Column(name = "start_time", nullable = false)
+  private Long startTime = -1L;
+
+  @Basic
+  @Column(name = "last_attempt_time", nullable = false)
+  private Long lastAttemptTime = -1L;
+
+  @Basic
+  @Column(name = "attempt_count", nullable = false)
+  private Short attemptCount = 0;
+
+  @Column(name = "role_command")
+  @Enumerated(EnumType.STRING)
+  private RoleCommand roleCommand;
+
+  @OneToOne(mappedBy = "hostRoleCommand", cascade = CascadeType.REMOVE)
+  private ExecutionCommandEntity executionCommand;
+
+  @ManyToOne(cascade = {CascadeType.MERGE})
+  @JoinColumns({@JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false), @JoinColumn(name = "stage_id", referencedColumnName = "stage_id", nullable = false)})
+  private StageEntity stage;
+
+  @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
+  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
+  private HostEntity host;
+
   public Long getTaskId() {
     return taskId;
   }
@@ -43,10 +119,6 @@ public class HostRoleCommandEntity {
     this.taskId = taskId;
   }
 
-  private Long requestId;
-
-  @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
-  @Basic
   public Long getRequestId() {
     return requestId;
   }
@@ -55,10 +127,6 @@ public class HostRoleCommandEntity {
     this.requestId = requestId;
   }
 
-  private Long stageId;
-
-  @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
-  @Basic
   public Long getStageId() {
     return stageId;
   }
@@ -67,10 +135,6 @@ public class HostRoleCommandEntity {
     this.stageId = stageId;
   }
 
-  private String hostName;
-
-  @Column(name = "host_name", insertable = false, updatable = false, nullable = false)
-  @Basic
   public String getHostName() {
     return hostName;
   }
@@ -79,10 +143,6 @@ public class HostRoleCommandEntity {
     this.hostName = hostName;
   }
 
-  private Role role;
-
-  @Column(name = "role")
-  @Enumerated(EnumType.STRING)
   public Role getRole() {
     return role;
   }
@@ -91,22 +151,14 @@ public class HostRoleCommandEntity {
     this.role = role;
   }
 
-  private String event = "";
-
-  @Column(name = "event", nullable = false, length = 32000)
-  @Basic
   public String getEvent() {
-    return event;
+    return defaultString(event);
   }
 
   public void setEvent(String event) {
     this.event = event;
   }
 
-  private Integer exitcode = 0;
-
-  @Column(name = "exitcode", nullable = false)
-  @Basic
   public Integer getExitcode() {
     return exitcode;
   }
@@ -115,10 +167,6 @@ public class HostRoleCommandEntity {
     this.exitcode = exitcode;
   }
 
-  private HostRoleStatus status;
-
-  @Column(name = "status")
-  @Enumerated(EnumType.STRING)
   public HostRoleStatus getStatus() {
     return status;
   }
@@ -127,36 +175,22 @@ public class HostRoleCommandEntity {
     this.status = status;
   }
 
-  private byte[] stdError = new byte[0];
-
-  @Column(name = "std_error", nullable = false)
-  @Lob
-  @Basic
   public byte[] getStdError() {
-    return stdError;
+    return ArrayUtils.nullToEmpty(stdError);
   }
 
   public void setStdError(byte[] stdError) {
     this.stdError = stdError;
   }
 
-  private byte[] stdOut = new byte[0];
-
-  @Column(name = "std_out", nullable = false)
-  @Lob
-  @Basic
   public byte[] getStdOut() {
-    return stdOut;
+    return ArrayUtils.nullToEmpty(stdOut);
   }
 
   public void setStdOut(byte[] stdOut) {
     this.stdOut = stdOut;
   }
 
-  private Long startTime = -1L;
-
-  @Column(name = "start_time", nullable = false)
-  @Basic
   public Long getStartTime() {
     return startTime;
   }
@@ -165,10 +199,6 @@ public class HostRoleCommandEntity {
     this.startTime = startTime;
   }
 
-  private Long lastAttemptTime = -1L;
-
-  @Column(name = "last_attempt_time", nullable = false)
-  @Basic
   public Long getLastAttemptTime() {
     return lastAttemptTime;
   }
@@ -177,10 +207,6 @@ public class HostRoleCommandEntity {
     this.lastAttemptTime = lastAttemptTime;
   }
 
-  private Short attemptCount = 0;
-
-  @Column(name = "attempt_count", nullable = false)
-  @Basic
   public Short getAttemptCount() {
     return attemptCount;
   }
@@ -189,10 +215,6 @@ public class HostRoleCommandEntity {
     this.attemptCount = attemptCount;
   }
 
-  private RoleCommand roleCommand;
-
-  @Column(name = "role_command")
-  @Enumerated(EnumType.STRING)
   public RoleCommand getRoleCommand() {
     return roleCommand;
   }
@@ -244,9 +266,6 @@ public class HostRoleCommandEntity {
     return result;
   }
 
-  private ExecutionCommandEntity executionCommand;
-
-  @OneToOne(mappedBy = "hostRoleCommand", cascade = CascadeType.REMOVE)
   public ExecutionCommandEntity getExecutionCommand() {
     return executionCommand;
   }
@@ -255,10 +274,6 @@ public class HostRoleCommandEntity {
     this.executionCommand = executionCommandsByTaskId;
   }
 
-  private StageEntity stage;
-
-  @ManyToOne(cascade = {CascadeType.MERGE})
-  @JoinColumns({@JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false), @JoinColumn(name = "stage_id", referencedColumnName = "stage_id", nullable = false)})
   public StageEntity getStage() {
     return stage;
   }
@@ -267,10 +282,6 @@ public class HostRoleCommandEntity {
     this.stage = stage;
   }
 
-  private HostEntity host;
-
-  @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
-  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
   public HostEntity getHost() {
     return host;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java Wed Apr  3 22:35:41 2013
@@ -19,16 +19,44 @@
 package org.apache.ambari.server.orm.entities;
 
 import org.apache.ambari.server.state.HostState;
+import org.apache.commons.lang.StringUtils;
 
 import javax.persistence.*;
 
-@javax.persistence.Table(name = "hoststate", schema = "ambari", catalog = "")
+import static org.apache.commons.lang.StringUtils.defaultString;
+
+@javax.persistence.Table(name = "hoststate")
 @Entity
 public class HostStateEntity {
-  private String hostName;
-
+  
   @javax.persistence.Column(name = "host_name", nullable = false, insertable = false, updatable = false)
   @Id
+  private String hostName;
+
+  @Column(name = "available_mem", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private Long availableMem = 0L;
+
+  @javax.persistence.Column(name = "time_in_state", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private Long timeInState = 0L;
+
+  @Column(name = "health_status", insertable = true, updatable = true)
+  @Basic
+  private String healthStatus;
+
+  @Column(name = "agent_version", insertable = true, updatable = true)
+  @Basic
+  private String agentVersion = "";
+
+  @Column(name = "current_state", nullable = false, insertable = true, updatable = true)
+  @Enumerated(value = EnumType.STRING)
+  private HostState currentState = HostState.INIT;
+
+  @OneToOne
+  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
+  private HostEntity hostEntity;
+
   public String getHostName() {
     return hostName;
   }
@@ -37,10 +65,6 @@ public class HostStateEntity {
     this.hostName = hostName;
   }
 
-  private Long availableMem = 0L;
-
-  @Column(name = "available_mem", nullable = false, insertable = true, updatable = true)
-  @Basic
   public Long getAvailableMem() {
     return availableMem;
   }
@@ -49,10 +73,6 @@ public class HostStateEntity {
     this.availableMem = availableMem;
   }
 
-  private Long timeInState = 0L;
-
-  @javax.persistence.Column(name = "time_in_state", nullable = false, insertable = true, updatable = true, length = 10)
-  @Basic
   public Long getTimeInState() {
     return timeInState;
   }
@@ -61,10 +81,6 @@ public class HostStateEntity {
     this.timeInState = timeInState;
   }
 
-  private String healthStatus;
-
-  @Column(name = "health_status", insertable = true, updatable = true)
-  @Basic
   public String getHealthStatus() {
     return healthStatus;
   }
@@ -73,22 +89,14 @@ public class HostStateEntity {
     this.healthStatus = healthStatus;
   }
 
-  private String agentVersion = "";
-
-  @javax.persistence.Column(name = "agent_version", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getAgentVersion() {
-    return agentVersion;
+    return defaultString(agentVersion);
   }
 
   public void setAgentVersion(String agentVersion) {
     this.agentVersion = agentVersion;
   }
 
-  private HostState currentState = HostState.INIT;
-
-  @javax.persistence.Column(name = "current_state", nullable = false, insertable = true, updatable = true)
-  @Enumerated(value = EnumType.STRING)
   public HostState getCurrentState() {
     return currentState;
   }
@@ -123,22 +131,6 @@ public class HostStateEntity {
     return result;
   }
 
-//  private ClusterEntity clusterEntity;
-//
-//  @ManyToOne
-//  @javax.persistence.JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")
-//  public ClusterEntity getClusterEntity() {
-//    return clusterEntity;
-//  }
-//
-//  public void setClusterEntity(ClusterEntity clusterEntity) {
-//    this.clusterEntity = clusterEntity;
-//  }
-
-  private HostEntity hostEntity;
-
-  @OneToOne
-  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
   public HostEntity getHostEntity() {
     return hostEntity;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/KeyValueEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/KeyValueEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/KeyValueEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/KeyValueEntity.java Wed Apr  3 22:35:41 2013
@@ -19,20 +19,20 @@
 package org.apache.ambari.server.orm.entities;
 
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import javax.persistence.*;
 
-@Table(name = "key_value_store", schema = "ambari", catalog = "")
+@Table(name = "key_value_store")
 @Entity
 public class KeyValueEntity {
 
+  @Column(name = "\"key\"", length = 255)
+  @Id
   private String key;
+
+  @Column(name = "\"value\"", length = 32000)
+  @Lob
   private String value;
 
-  @Column(name = "\"key\"", length = 255)
-  @Id
   public String getKey() {
     return key;
   }
@@ -41,7 +41,6 @@ public class KeyValueEntity {
     this.key = key;
   }
 
-  @Column(name = "\"value\"", length = 32000)
   public String getValue() {
     return value;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MetainfoEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MetainfoEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MetainfoEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MetainfoEntity.java Wed Apr  3 22:35:41 2013
@@ -19,20 +19,21 @@
 package org.apache.ambari.server.orm.entities;
 
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import javax.persistence.*;
 
-@Table(name = "metainfo", schema = "ambari", catalog = "")
+@Table(name = "metainfo")
 @Entity
 public class MetainfoEntity {
 
+  @Column(name = "\"metainfo_key\"", length = 255)
+  @Id
   private String metainfoName;
+
+  @Column(name = "\"metainfo_value\"", length = 32000)
+  @Basic
+  @Lob
   private String metainfoValue;
 
-  @Column(name = "\"metainfo_key\"", length = 255)
-  @Id
   public String getMetainfoName() {
     return metainfoName;
   }
@@ -41,7 +42,6 @@ public class MetainfoEntity {
     this.metainfoName = metainfoName;
   }
 
-  @Column(name = "\"metainfo_value\"", length = 32000)
   public String getMetainfoValue() {
     return metainfoValue;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleEntity.java Wed Apr  3 22:35:41 2013
@@ -18,22 +18,23 @@
 
 package org.apache.ambari.server.orm.entities;
 
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
+import javax.persistence.*;
 import java.util.Set;
 
-@javax.persistence.Table(name = "roles", schema = "ambari", catalog = "")
+@javax.persistence.Table(name = "roles")
 @Entity
 public class RoleEntity {
 
+  @Column(name = "role_name")
+  @Id
   private String roleName;
 
-  @javax.persistence.Column(name = "role_name")
-  @Id
+  @JoinTable(name = "user_roles",
+      joinColumns = {@JoinColumn(name = "role_name", referencedColumnName = "role_name")},
+      inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")})
+  @ManyToMany(cascade = CascadeType.ALL)
+  private Set<UserEntity> userEntities;
+
   public String getRoleName() {
     return roleName;
   }
@@ -59,12 +60,6 @@ public class RoleEntity {
     return roleName != null ? roleName.hashCode() : 0;
   }
 
-  private Set<org.apache.ambari.server.orm.entities.UserEntity> userEntities;
-
-  @JoinTable(name = "user_roles", catalog = "", schema = "ambari",
-      joinColumns = {@JoinColumn(name = "role_name", referencedColumnName = "role_name")},
-      inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")})
-  @ManyToMany(cascade = CascadeType.ALL)
   public Set<org.apache.ambari.server.orm.entities.UserEntity> getUserEntities() {
     return userEntities;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java Wed Apr  3 22:35:41 2013
@@ -23,13 +23,31 @@ import org.apache.ambari.server.Role;
 import javax.persistence.*;
 
 @IdClass(org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntityPK.class)
-@Table(name = "role_success_criteria", schema = "ambari", catalog = "")
+@Table(name = "role_success_criteria")
 @Entity
 public class RoleSuccessCriteriaEntity {
-  private Long requestId;
 
+  @Id
   @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
+  private Long requestId;
+
+  @Id
+  @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
+  private Long stageId;
+
   @Id
+  @Column(name = "role")
+  @Enumerated(EnumType.STRING)
+  private Role role;
+
+  @Basic
+  @Column(name = "success_factor", nullable = false)
+  private Double successFactor = 1d;
+
+  @ManyToOne
+  @JoinColumns({@JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false), @JoinColumn(name = "stage_id", referencedColumnName = "stage_id", nullable = false)})
+  private StageEntity stage;
+
   public Long getRequestId() {
     return requestId;
   }
@@ -38,10 +56,6 @@ public class RoleSuccessCriteriaEntity {
     this.requestId = requestId;
   }
 
-  private Long stageId;
-
-  @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
-  @Id
   public Long getStageId() {
     return stageId;
   }
@@ -50,11 +64,6 @@ public class RoleSuccessCriteriaEntity {
     this.stageId = stageId;
   }
 
-  private Role role;
-
-  @Column(name = "role")
-  @Enumerated(EnumType.STRING)
-  @Id
   public Role getRole() {
     return role;
   }
@@ -63,10 +72,6 @@ public class RoleSuccessCriteriaEntity {
     this.role = role;
   }
 
-  private Double successFactor = 1d;
-
-  @Column(name = "success_factor", nullable = false)
-  @Basic
   public Double getSuccessFactor() {
     return successFactor;
   }
@@ -99,10 +104,6 @@ public class RoleSuccessCriteriaEntity {
     return result;
   }
 
-  private StageEntity stage;
-
-  @ManyToOne
-  @JoinColumns({@JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false), @JoinColumn(name = "stage_id", referencedColumnName = "stage_id", nullable = false)})
   public StageEntity getStage() {
     return stage;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java Wed Apr  3 22:35:41 2013
@@ -19,18 +19,51 @@
 package org.apache.ambari.server.orm.entities;
 
 import org.apache.ambari.server.state.State;
+import org.apache.commons.lang.StringUtils;
 
 import javax.persistence.*;
 import java.util.Collection;
 
+import static org.apache.commons.lang.StringUtils.defaultString;
+
 @javax.persistence.IdClass(ServiceComponentDesiredStateEntityPK.class)
-@javax.persistence.Table(name = "servicecomponentdesiredstate", schema = "ambari", catalog = "")
+@javax.persistence.Table(name = "servicecomponentdesiredstate")
 @Entity
 public class ServiceComponentDesiredStateEntity {
+
+  @Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
+  @Id
   private Long clusterId;
 
-  @javax.persistence.Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
+  @Column(name = "service_name", nullable = false, insertable = false, updatable = false)
   @Id
+  private String serviceName;
+
+  @Column(name = "component_name", nullable = false, insertable = true, updatable = true)
+  @Id
+  private String componentName;
+
+  @Column(name = "desired_state", nullable = false, insertable = true, updatable = true)
+  @Enumerated(EnumType.STRING)
+  private State desiredState = State.INIT;
+
+  @Column(name = "desired_stack_version", insertable = true, updatable = true)
+  @Basic
+  private String desiredStackVersion = "";
+
+  @ManyToOne
+  @JoinColumns({@javax.persistence.JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false), @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false)})
+  private ClusterServiceEntity clusterServiceEntity;
+
+  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity")
+  private Collection<HostComponentStateEntity> hostComponentStateEntities;
+
+  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity")
+  private Collection<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities;
+
+  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity", cascade = CascadeType.ALL)
+  private Collection<ComponentConfigMappingEntity> configMappingEntities;
+
   public Long getClusterId() {
     return clusterId;
   }
@@ -39,10 +72,6 @@ public class ServiceComponentDesiredStat
     this.clusterId = clusterId;
   }
 
-  private String serviceName;
-
-  @javax.persistence.Column(name = "service_name", nullable = false, insertable = false, updatable = false)
-  @Id
   public String getServiceName() {
     return serviceName;
   }
@@ -51,10 +80,6 @@ public class ServiceComponentDesiredStat
     this.serviceName = serviceName;
   }
 
-  private String componentName;
-
-  @javax.persistence.Column(name = "component_name", nullable = false, insertable = true, updatable = true)
-  @Id
   public String getComponentName() {
     return componentName;
   }
@@ -63,10 +88,6 @@ public class ServiceComponentDesiredStat
     this.componentName = componentName;
   }
 
-  private State desiredState = State.INIT;
-
-  @javax.persistence.Column(name = "desired_state", nullable = false, insertable = true, updatable = true)
-  @Enumerated(EnumType.STRING)
   public State getDesiredState() {
     return desiredState;
   }
@@ -75,12 +96,8 @@ public class ServiceComponentDesiredStat
     this.desiredState = desiredState;
   }
 
-  private String desiredStackVersion = "";
-
-  @javax.persistence.Column(name = "desired_stack_version", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getDesiredStackVersion() {
-    return desiredStackVersion;
+    return defaultString(desiredStackVersion);
   }
 
   public void setDesiredStackVersion(String desiredStackVersion) {
@@ -114,10 +131,6 @@ public class ServiceComponentDesiredStat
     return result;
   }
 
-  private ClusterServiceEntity clusterServiceEntity;
-
-  @ManyToOne
-  @javax.persistence.JoinColumns({@javax.persistence.JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false), @javax.persistence.JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false)})
   public ClusterServiceEntity getClusterServiceEntity() {
     return clusterServiceEntity;
   }
@@ -126,9 +139,6 @@ public class ServiceComponentDesiredStat
     this.clusterServiceEntity = clusterServiceEntity;
   }
 
-  private Collection<HostComponentStateEntity> hostComponentStateEntities;
-
-  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity")
   public Collection<HostComponentStateEntity> getHostComponentStateEntities() {
     return hostComponentStateEntities;
   }
@@ -137,9 +147,6 @@ public class ServiceComponentDesiredStat
     this.hostComponentStateEntities = hostComponentStateEntities;
   }
 
-  private Collection<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities;
-
-  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity")
   public Collection<HostComponentDesiredStateEntity> getHostComponentDesiredStateEntities() {
     return hostComponentDesiredStateEntities;
   }
@@ -148,8 +155,6 @@ public class ServiceComponentDesiredStat
     this.hostComponentDesiredStateEntities = hostComponentDesiredStateEntities;
   }
 
-  private Collection<ComponentConfigMappingEntity> configMappingEntities;
-  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity", cascade = CascadeType.ALL)
   public Collection<ComponentConfigMappingEntity> getComponentConfigMappingEntities() {
     return configMappingEntities;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java Wed Apr  3 22:35:41 2013
@@ -28,18 +28,41 @@ import javax.persistence.Table;
 
 @IdClass(ServiceConfigMappingEntityPK.class)
 @Entity
-@Table(name="serviceconfigmapping", schema="ambari", catalog="")
+@Table(name="serviceconfigmapping")
 public class ServiceConfigMappingEntity {
+
+  @Id
+  @Column(name = "cluster_id", nullable = false, insertable = false, updatable = false)
   private Long clusterId;
+
+  @Id
+  @Column(name = "service_name", nullable = false, insertable = false, updatable = false)
   private String serviceName;
+
+  @Id
+  @Column(name = "config_type", nullable = false, insertable = true, updatable = false)
   private String configType;
+
+  @Column(name = "config_tag", nullable = false, insertable = true, updatable = true)
   private String configVersion;
+
+  @Column(name = "timestamp", nullable = false, insertable = true, updatable = true)
   private Long timestamp;
+
+  @ManyToOne
+  @JoinColumns({
+      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+      @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false) })
   private ClusterServiceEntity serviceEntity;
+
+  @ManyToOne
+  @JoinColumns({
+      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false, insertable = false, updatable = false),
+      @JoinColumn(name = "config_type", referencedColumnName = "type_name", nullable = false, insertable = false, updatable = false),
+      @JoinColumn(name = "config_tag", referencedColumnName = "version_tag", nullable = false, insertable = false, updatable = false)
+  })
   private ClusterConfigEntity clusterConfigEntity;
 
-  @Column(name = "cluster_id", nullable = false, insertable = false, updatable = false)
-  @Id
   public Long getClusterId() {
     return clusterId;
   }
@@ -48,8 +71,6 @@ public class ServiceConfigMappingEntity 
     clusterId = id;
   }
 
-  @Column(name = "service_name", nullable = false, insertable = false, updatable = false)
-  @Id
   public String getServiceName() {
     return serviceName;
   }
@@ -58,8 +79,6 @@ public class ServiceConfigMappingEntity 
     serviceName = name;
   }
 
-  @Column(name = "config_type", nullable = false, insertable = true, updatable = false)
-  @Id
   public String getConfigType() {
     return configType;
   }
@@ -68,7 +87,6 @@ public class ServiceConfigMappingEntity 
     configType = type;
   }
 
-  @Column(name = "config_tag", nullable = false, insertable = true, updatable = true)
   public String getVersionTag() {
     return configVersion;
   }
@@ -77,7 +95,6 @@ public class ServiceConfigMappingEntity 
     configVersion = tag;
   }
 
-  @Column(name = "timestamp", nullable = false, insertable = true, updatable = true)
   public Long getTimestamp() {
     return timestamp;
   }
@@ -86,10 +103,6 @@ public class ServiceConfigMappingEntity 
     timestamp = stamp;
   }
 
-  @ManyToOne
-  @JoinColumns({
-      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
-      @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false) })
   public ClusterServiceEntity getServiceEntity() {
     return serviceEntity;
   }
@@ -98,12 +111,6 @@ public class ServiceConfigMappingEntity 
     serviceEntity = entity;
   }
 
-  @ManyToOne
-  @JoinColumns({
-      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false, insertable = false, updatable = false),
-      @JoinColumn(name = "config_type", referencedColumnName = "type_name", nullable = false, insertable = false, updatable = false),
-      @JoinColumn(name = "config_tag", referencedColumnName = "version_tag", nullable = false, insertable = false, updatable = false)
-  })
   public ClusterConfigEntity getClusterConfigEntity() {
     return clusterConfigEntity;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java Wed Apr  3 22:35:41 2013
@@ -19,17 +19,43 @@
 package org.apache.ambari.server.orm.entities;
 
 import org.apache.ambari.server.state.State;
+import org.apache.commons.lang.StringUtils;
 
 import javax.persistence.*;
 
 @javax.persistence.IdClass(ServiceDesiredStateEntityPK.class)
-@javax.persistence.Table(name = "servicedesiredstate", schema = "ambari", catalog = "")
+@javax.persistence.Table(name = "servicedesiredstate")
 @Entity
 public class ServiceDesiredStateEntity {
+
+  @Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
+  @Id
   private Long clusterId;
 
-  @javax.persistence.Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
+  @Column(name = "service_name", nullable = false, insertable = false, updatable = false)
   @Id
+  private String serviceName;
+
+  @Column(name = "desired_state", nullable = false, insertable = true, updatable = true)
+  @Enumerated(value = EnumType.STRING)
+  private State desiredState = State.INIT;
+
+  @Column(name = "desired_host_role_mapping", nullable = false, insertable = true, updatable = true, length = 10)
+  @Basic
+  private int desiredHostRoleMapping = 0;
+
+  @Column(name = "desired_stack_version", insertable = true, updatable = true)
+  @Basic
+  private String desiredStackVersion = "";
+
+  @OneToOne
+  @javax.persistence.JoinColumns(
+      {
+          @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+          @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false)
+      })
+  private ClusterServiceEntity clusterServiceEntity;
+
   public Long getClusterId() {
     return clusterId;
   }
@@ -38,10 +64,6 @@ public class ServiceDesiredStateEntity {
     this.clusterId = clusterId;
   }
 
-  private String serviceName;
-
-  @javax.persistence.Column(name = "service_name", nullable = false, insertable = false, updatable = false)
-  @Id
   public String getServiceName() {
     return serviceName;
   }
@@ -50,10 +72,6 @@ public class ServiceDesiredStateEntity {
     this.serviceName = serviceName;
   }
 
-  private State desiredState = State.INIT;
-
-  @javax.persistence.Column(name = "desired_state", nullable = false, insertable = true, updatable = true)
-  @Enumerated(value = EnumType.STRING)
   public State getDesiredState() {
     return desiredState;
   }
@@ -62,10 +80,6 @@ public class ServiceDesiredStateEntity {
     this.desiredState = desiredState;
   }
 
-  private int desiredHostRoleMapping = 0;
-
-  @javax.persistence.Column(name = "desired_host_role_mapping", nullable = false, insertable = true, updatable = true, length = 10)
-  @Basic
   public int getDesiredHostRoleMapping() {
     return desiredHostRoleMapping;
   }
@@ -74,12 +88,8 @@ public class ServiceDesiredStateEntity {
     this.desiredHostRoleMapping = desiredHostRoleMapping;
   }
 
-  private String desiredStackVersion = "";
-
-  @javax.persistence.Column(name = "desired_stack_version", nullable = false, insertable = true, updatable = true)
-  @Basic
   public String getDesiredStackVersion() {
-    return desiredStackVersion;
+    return StringUtils.defaultString(desiredStackVersion);
   }
 
   public void setDesiredStackVersion(String desiredStackVersion) {
@@ -112,14 +122,6 @@ public class ServiceDesiredStateEntity {
     return result;
   }
 
-  private ClusterServiceEntity clusterServiceEntity;
-
-  @OneToOne
-  @javax.persistence.JoinColumns(
-      {
-          @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
-          @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false)
-      })
   public ClusterServiceEntity getClusterServiceEntity() {
     return clusterServiceEntity;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java Wed Apr  3 22:35:41 2013
@@ -18,17 +18,48 @@
 
 package org.apache.ambari.server.orm.entities;
 
+import org.apache.commons.lang.StringUtils;
+
 import javax.persistence.*;
 import java.util.Collection;
 
+import static org.apache.commons.lang.StringUtils.defaultString;
+
 @IdClass(org.apache.ambari.server.orm.entities.StageEntityPK.class)
-@Table(name = "stage", schema = "ambari", catalog = "")
+@Table(name = "stage")
 @Entity
 public class StageEntity {
-  private Long clusterId;
 
   @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
   @Basic
+  private Long clusterId;
+
+  @Column(name = "request_id")
+  @Id
+  private Long requestId;
+
+  @Column(name = "stage_id", nullable = false)
+  @Id
+  private Long stageId = 0L;
+
+  @Column(name = "log_info")
+  @Basic
+  private String logInfo = "";
+
+  @Column(name = "request_context")
+  @Basic
+  private String requestContext = "";
+
+  @ManyToOne(cascade = {CascadeType.MERGE})
+  @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")
+  private ClusterEntity cluster;
+
+  @OneToMany(mappedBy = "stage", cascade = CascadeType.REMOVE)
+  private Collection<HostRoleCommandEntity> hostRoleCommands;
+
+  @OneToMany(mappedBy = "stage", cascade = CascadeType.REMOVE)
+  private Collection<RoleSuccessCriteriaEntity> roleSuccessCriterias;
+
   public Long getClusterId() {
     return clusterId;
   }
@@ -37,10 +68,6 @@ public class StageEntity {
     this.clusterId = clusterId;
   }
 
-  private Long requestId;
-
-  @Column(name = "request_id")
-  @Id
   public Long getRequestId() {
     return requestId;
   }
@@ -49,10 +76,6 @@ public class StageEntity {
     this.requestId = requestId;
   }
 
-  private Long stageId = 0L;
-
-  @Column(name = "stage_id", nullable = false)
-  @Id
   public Long getStageId() {
     return stageId;
   }
@@ -61,24 +84,16 @@ public class StageEntity {
     this.stageId = stageId;
   }
 
-  private String logInfo = "";
-
-  @Column(name = "log_info", nullable = false)
-  @Basic
   public String getLogInfo() {
-    return logInfo;
+    return defaultString(logInfo);
   }
 
   public void setLogInfo(String logInfo) {
     this.logInfo = logInfo;
   }
 
-  private String requestContext = "";
-
-  @Column(name = "request_context", nullable = true)
-  @Basic
   public String getRequestContext() {
-    return requestContext;
+    return defaultString(requestContext);
   }
 
   public void setRequestContext(String requestContext) {
@@ -112,10 +127,6 @@ public class StageEntity {
     return result;
   }
 
-  private ClusterEntity cluster;
-
-  @ManyToOne(cascade = {CascadeType.MERGE})
-  @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")
   public ClusterEntity getCluster() {
     return cluster;
   }
@@ -124,9 +135,6 @@ public class StageEntity {
     this.cluster = cluster;
   }
 
-  private Collection<HostRoleCommandEntity> hostRoleCommands;
-
-  @OneToMany(mappedBy = "stage", cascade = CascadeType.REMOVE)
   public Collection<HostRoleCommandEntity> getHostRoleCommands() {
     return hostRoleCommands;
   }
@@ -135,9 +143,6 @@ public class StageEntity {
     this.hostRoleCommands = hostRoleCommands;
   }
 
-  private Collection<RoleSuccessCriteriaEntity> roleSuccessCriterias;
-
-  @OneToMany(mappedBy = "stage", cascade = CascadeType.REMOVE)
   public Collection<RoleSuccessCriteriaEntity> getRoleSuccessCriterias() {
     return roleSuccessCriterias;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UserEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UserEntity.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UserEntity.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UserEntity.java Wed Apr  3 22:35:41 2013
@@ -22,20 +22,43 @@ import javax.persistence.*;
 import java.util.Date;
 import java.util.Set;
 
-@Table(name = "users", schema = "ambari", catalog = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"user_name", "ldap_user"})})
+@Table(name = "users", uniqueConstraints = {@UniqueConstraint(columnNames = {"user_name", "ldap_user"})})
 @Entity
 @NamedQueries({
     @NamedQuery(name = "localUserByName", query = "SELECT user FROM UserEntity user where lower(user.userName)=:username AND user.ldapUser=false"),
     @NamedQuery(name = "ldapUserByName", query = "SELECT user FROM UserEntity user where lower(user.userName)=:username AND user.ldapUser=true")
 })
-@SequenceGenerator(name = "ambari.users_user_id_seq", allocationSize = 1)
+@TableGenerator(name = "user_id_generator",
+    table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "value"
+    , pkColumnValue = "user_id_seq"
+    , initialValue = 2
+    , allocationSize = 1
+    )
 public class UserEntity {
 
-  private Integer userId;
-
   @Id
   @Column(name = "user_id")
-  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.users_user_id_seq")
+  @GeneratedValue(strategy = GenerationType.TABLE, generator = "user_id_generator")
+  private Integer userId;
+
+  @Column(name = "user_name")
+  private String userName;
+
+  @Column(name = "ldap_user")
+  private Integer ldapUser = 0;
+
+  @Column(name = "user_password")
+  @Basic
+  private String userPassword;
+
+  @Column(name = "create_time")
+  @Basic
+  @Temporal(value = TemporalType.TIMESTAMP)
+  private Date createTime = new Date();
+
+  @ManyToMany(mappedBy = "userEntities")
+  private Set<RoleEntity> roleEntities;
+
   public Integer getUserId() {
     return userId;
   }
@@ -44,9 +67,6 @@ public class UserEntity {
     this.userId = userId;
   }
 
-  private String userName;
-
-  @Column(name = "user_name")
   public String getUserName() {
     return userName;
   }
@@ -55,21 +75,18 @@ public class UserEntity {
     this.userName = userName;
   }
 
-  private Boolean ldapUser = false;
-
-  @Column(name = "ldap_user")
   public Boolean getLdapUser() {
-    return ldapUser;
+    return ldapUser == 0 ? Boolean.FALSE : Boolean.TRUE;
   }
 
   public void setLdapUser(Boolean ldapUser) {
-    this.ldapUser = ldapUser;
+    if (ldapUser == null) {
+      this.ldapUser = null;
+    } else {
+      this.ldapUser = ldapUser ? 1 : 0;
+    }
   }
 
-  private String userPassword;
-
-  @Column(name = "user_password")
-  @Basic
   public String getUserPassword() {
     return userPassword;
   }
@@ -78,11 +95,6 @@ public class UserEntity {
     this.userPassword = userPassword;
   }
 
-  private Date createTime = new Date();
-
-  @Column(name = "create_time")
-  @Basic
-  @Temporal(value = TemporalType.TIMESTAMP)
   public Date getCreateTime() {
     return createTime;
   }
@@ -117,9 +129,6 @@ public class UserEntity {
     return result;
   }
 
-  private Set<RoleEntity> roleEntities;
-
-  @ManyToMany(mappedBy = "userEntities")
   public Set<RoleEntity> getRoleEntities() {
     return roleEntities;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java Wed Apr  3 22:35:41 2013
@@ -33,10 +33,12 @@ import java.util.TreeMap;
 import javax.xml.bind.JAXBException;
 
 import com.google.gson.Gson;
+import com.google.inject.Injector;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.HostsMap;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -179,7 +181,7 @@ public class StageUtils {
   }
 
 
-  public static Map<String, List<String>> getClusterHostInfo(Cluster cluster, HostsMap hostsMap) {
+  public static Map<String, List<String>> getClusterHostInfo(Cluster cluster, HostsMap hostsMap, Injector injector) {
     Map<String, List<String>> info = new HashMap<String, List<String>>();
     if (cluster.getServices() != null) {
       for (String serviceName : cluster.getServices().keySet()) {
@@ -202,8 +204,14 @@ public class StageUtils {
               }
               info.put(clusterInfoKey, hostList);
             }
-            //Add ambari db server
-            info.put("ambari_db_server_host", Arrays.asList(hostsMap.getHostMap(getHostName())));
+            //Set up ambari-rca connection properties, is this a hack?
+//            info.put("ambari_db_server_host", Arrays.asList(hostsMap.getHostMap(getHostName())));
+            Configuration configuration = injector.getInstance(Configuration.class);
+            info.put("ambari_db_rca_url", Arrays.asList(configuration.getRcaDatabaseUrl()));
+            info.put("ambari_db_rca_driver", Arrays.asList(configuration.getRcaDatabaseDriver()));
+            info.put("ambari_db_rca_username", Arrays.asList(configuration.getRcaDatabaseUser()));
+            info.put("ambari_db_rca_password", Arrays.asList(configuration.getRcaDatabasePassword()));
+
           }
         }
       }

Modified: incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py (original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py Wed Apr  3 22:35:41 2013
@@ -37,6 +37,7 @@ import getpass
 # debug settings
 VERBOSE = False
 SILENT = False
+REMOTE_DATABASE = False
 SERVER_START_DEBUG = False
 
 # action commands
@@ -117,6 +118,20 @@ PG_DEFAULT_PASSWORD = "bigdata"
 JDBC_USER_NAME_PROPERTY = "server.jdbc.user.name"
 JDBC_PASSWORD_FILE_PROPERTY = "server.jdbc.user.passwd"
 JDBC_PASSWORD_FILENAME = "password.dat"
+JDBC_RCA_PASSWORD_FILENAME = "rca_password.dat"
+
+PERSISTENCE_TYPE_PROPERTY = "server.persistence.type"
+JDBC_DRIVER_PROPERTY = "server.jdbc.driver"
+JDBC_URL_PROPERTY = "server.jdbc.url"
+
+JDBC_RCA_DRIVER_PROPERTY = "server.jdbc.rca.driver"
+JDBC_RCA_URL_PROPERTY = "server.jdbc.rca.url"
+JDBC_RCA_USER_NAME_PROPERTY = "server.jdbc.rca.user.name"
+JDBC_RCA_PASSWORD_FILE_PROPERTY = "server.jdbc.rca.user.passwd"
+
+DRIVER_NAMES = ["org.postgresql.Driver", "oracle.jdbc.driver.OracleDriver", "com.mysql.jdbc.Driver"]
+CONNECTION_STRINGS = ["jdbc:postgresql://{0}:{1}/{2}", "jdbc:oracle:thin:@{0}:{1}/{2}", "jdbc:mysql://{0}:{1}/{2}"]
+
 
 # jdk commands
 JDK_LOCAL_FILENAME = "jdk-6u31-linux-x64.bin"
@@ -255,6 +270,95 @@ def setup_db(args):
     print errdata
   return retcode
 
+def setup_remote_db(args):
+  print "WARNING! To use MySQL/Oracle database place JDBC driver to "+ get_ambari_jars()
+  print "Table structure in remote database should be created manually in this mode."
+  (driver_name, conn_url, username, password) = get_connection_properties()
+
+  write_property(PERSISTENCE_TYPE_PROPERTY, "remote")
+  write_property(JDBC_DRIVER_PROPERTY, driver_name)
+  write_property(JDBC_URL_PROPERTY, conn_url)
+  write_property(JDBC_USER_NAME_PROPERTY, username)
+  write_property(JDBC_PASSWORD_FILE_PROPERTY, store_password_file(password, JDBC_PASSWORD_FILENAME))
+
+  ok = get_YN_input("Enter separate configuration for RCA database [y/n] (n)? ", False)
+  if ok:
+    (driver_name, conn_url, username, password) = get_connection_properties()
+
+  write_property(JDBC_RCA_DRIVER_PROPERTY, driver_name)
+  write_property(JDBC_RCA_URL_PROPERTY, conn_url)
+  write_property(JDBC_RCA_USER_NAME_PROPERTY, username)
+  write_property(JDBC_RCA_PASSWORD_FILE_PROPERTY, store_password_file(password, JDBC_RCA_PASSWORD_FILENAME))
+
+  return 0
+
+def store_password_file(password, filename):
+  conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir())
+  passFilePath = os.path.join(os.path.dirname(conf_file),
+    filename)
+
+  with open(passFilePath, 'w+') as passFile:
+    passFile.write(password)
+    pass
+  os.chmod(passFilePath, stat.S_IREAD | stat.S_IWRITE)
+
+  return passFilePath
+
+def get_connection_properties():
+  default_db_num="1"
+  default_host = "localhost"
+  default_schema = "ambari"
+
+  database_num = get_validated_string_input("Select database:\n1 - Postgres\n2 - Oracle\n3 - MySQL) \n["+str(default_db_num)+"]:",
+    default_db_num,
+    "^[123]$",
+    "Invalid number.",
+    False
+  )
+
+  db_host = get_validated_string_input("Hostname ["+default_host+"]:",
+    default_host,
+    "^[a-zA-Z0-9.\-]*$",
+    "Invalid hostname.",
+    False
+  )
+
+  default_port = None
+  if database_num == "1":
+    default_port = "5432"
+  elif database_num == "2":
+    default_port = "1521"
+  elif database_num == "3":
+    default_port = "3306"
+
+  db_port = get_validated_string_input("Port ["+ str(default_port) + "]:",
+    default_port,
+    "^[0-9]{1,5}$",
+    "Invalid port.",
+    False
+  )
+
+  if database_num == "2":
+    default_schema = "xe"
+
+  db_schema = get_validated_string_input("Database/schema/service name ["+ str(default_schema) + "]:",
+    default_schema,
+    "^[a-zA-z\-\"]+$",
+    "Invalid schema name.",
+    False
+  )
+
+  usernameDefault = 'ambari'
+  usernamePrompt = 'Username [' + usernameDefault + ']: '
+  usernamePattern = "^[a-zA-Z_][a-zA-Z0-9_\-]*$"
+  usernameDescr = "Invalid characters in username. Start with _ or alpha "\
+                  "followed by alphanumeric or _ or - characters"
+
+  username = get_validated_string_input(usernamePrompt, usernameDefault,
+    usernamePattern, usernameDescr, False)
+  password = configure_postgres_password()
+
+  return DRIVER_NAMES[int(database_num)-1], CONNECTION_STRINGS[int(database_num)-1].format(db_host, db_port, db_schema), username, password
 
 def execute_db_script(args, file):
   #password access to ambari-server and mapred
@@ -747,23 +851,32 @@ def setup(args):
     print_error_msg ('Failed to stop iptables. Exiting.')
     sys.exit(retcode)
 
-  print 'Checking PostgreSQL...'
-  retcode = check_postgre_up()
-  if not retcode == 0:
-    print_error_msg ('Unable to start PostgreSQL server. Exiting')
-    sys.exit(retcode)
+  if not REMOTE_DATABASE:
 
-  print 'Configuring database...'
-  retcode = setup_db(args)
-  if not retcode == 0:
-    print_error_msg  ('Running database init script was failed. Exiting.')
-    sys.exit(retcode)
-    
-  print 'Configuring PostgreSQL...'
-  retcode = configure_postgres()
-  if not retcode == 0:
-    print_error_msg ('Unable to configure PostgreSQL server. Exiting')
-    sys.exit(retcode)
+    print 'Checking PostgreSQL...'
+    retcode = check_postgre_up()
+    if not retcode == 0:
+      print_error_msg ('Unable to start PostgreSQL server. Exiting')
+      sys.exit(retcode)
+
+    print 'Configuring database...'
+    retcode = setup_db(args)
+    if not retcode == 0:
+      print_error_msg  ('Running database init script was failed. Exiting.')
+      sys.exit(retcode)
+
+    print 'Configuring PostgreSQL...'
+    retcode = configure_postgres()
+    if not retcode == 0:
+      print_error_msg ('Unable to configure PostgreSQL server. Exiting')
+      sys.exit(retcode)
+
+  else:
+    print 'Configuring remote database connection properties'
+    retcode = setup_remote_db(args)
+    if not retcode == 0:
+      print_error_msg ('Error while configuring connection properties. Exiting')
+      sys.exit(retcode)
   
   print 'Checking JDK...'
   retcode = download_jdk(args)
@@ -1135,6 +1248,10 @@ def main():
                   action="store_true", dest="silent", default=False,
                   help="Silently accepts default prompt values")
 
+  parser.add_option("-b", "--remote-database",
+      action="store_true", dest="remote_database", default=False,
+      help="Set up remote database instead of local")
+
   (options, args) = parser.parse_args()
 
   # set verbose
@@ -1145,6 +1262,12 @@ def main():
   global SILENT
   SILENT = options.silent
 
+  # skip local db setup
+  global REMOTE_DATABASE
+  REMOTE_DATABASE = options.remote_database
+
+
+
 
   
   if len(args) == 0:

Modified: incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql?rev=1464222&r1=1464221&r2=1464222&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql (original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql Wed Apr  3 22:35:41 2013
@@ -24,6 +24,8 @@ CREATE ROLE :username LOGIN ENCRYPTED PA
 CREATE SCHEMA ambari
   AUTHORIZATION :username;
 
+ALTER ROLE :username SET search_path to 'ambari';
+
 CREATE TABLE ambari.clusters (cluster_id BIGINT NOT NULL, cluster_info VARCHAR(255) NOT NULL, cluster_name VARCHAR(100) NOT NULL UNIQUE, desired_cluster_state VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id));
 
 GRANT ALL PRIVILEGES ON TABLE ambari.clusters TO :username;
@@ -52,9 +54,9 @@ CREATE TABLE ambari.hostcomponentconfigm
 
 GRANT ALL PRIVILEGES ON TABLE ambari.hostcomponentconfigmapping TO :username;
 
-CREATE TABLE ambari.hostcomponentdesiredconfigmapping (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, config_type VARCHAR(255) NOT NULL, timestamp BIGINT NOT NULL, config_tag VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name, config_type));
+CREATE TABLE ambari.hcdesiredconfigmapping (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, config_type VARCHAR(255) NOT NULL, timestamp BIGINT NOT NULL, config_tag VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name, config_type));
 
-GRANT ALL PRIVILEGES ON TABLE ambari.hostcomponentdesiredconfigmapping TO :username;
+GRANT ALL PRIVILEGES ON TABLE ambari.hcdesiredconfigmapping TO :username;
 
 CREATE TABLE ambari.hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
 
@@ -88,7 +90,7 @@ CREATE TABLE ambari.roles (role_name VAR
 
 GRANT ALL PRIVILEGES ON TABLE ambari.roles TO :username;
 
-CREATE TABLE ambari.users (user_id SERIAL, ldap_user BOOLEAN NOT NULL, user_name VARCHAR(255) NOT NULL, create_time TIMESTAMP DEFAULT NOW(), user_password VARCHAR(255), PRIMARY KEY (user_id), UNIQUE (ldap_user, user_name));
+CREATE TABLE ambari.users (user_id INTEGER, ldap_user INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL, create_time TIMESTAMP DEFAULT NOW(), user_password VARCHAR(255), PRIMARY KEY (user_id), UNIQUE (ldap_user, user_name));
 GRANT ALL PRIVILEGES ON TABLE ambari.users TO :username;
 
 CREATE TABLE ambari.execution_command (command bytea, task_id BIGINT NOT NULL, PRIMARY KEY (task_id));
@@ -113,11 +115,16 @@ CREATE TABLE ambari.key_value_store ("ke
 GRANT ALL PRIVILEGES ON TABLE ambari.key_value_store TO :username;
 
 CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (cluster_id, host_name, type_name, create_timestamp));
+
 GRANT ALL PRIVILEGES ON TABLE ambari.hostconfigmapping TO :username;
 
 CREATE TABLE ambari.metainfo ("metainfo_key" VARCHAR(255), "metainfo_value" VARCHAR, PRIMARY KEY("metainfo_key"));
 GRANT ALL PRIVILEGES ON TABLE ambari.metainfo TO :username;
 
+CREATE TABLE ambari.ambari_sequences (sequence_name VARCHAR(255) PRIMARY KEY, "value" BIGINT NOT NULL);
+GRANT ALL PRIVILEGES ON TABLE ambari.ambari_sequences TO :username;
+
+
 ALTER TABLE ambari.clusterconfig ADD CONSTRAINT FK_clusterconfig_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
 ALTER TABLE ambari.clusterservices ADD CONSTRAINT FK_clusterservices_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
 ALTER TABLE ambari.clusterconfigmapping ADD CONSTRAINT FK_clusterconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
@@ -126,8 +133,8 @@ ALTER TABLE ambari.componentconfigmappin
 ALTER TABLE ambari.componentconfigmapping ADD CONSTRAINT FK_componentconfigmapping_component_name FOREIGN KEY (component_name, cluster_id, service_name) REFERENCES ambari.servicecomponentdesiredstate (component_name, cluster_id, service_name);
 ALTER TABLE ambari.hostcomponentconfigmapping ADD CONSTRAINT FK_hostcomponentconfigmapping_config_tag FOREIGN KEY (config_tag, config_type, cluster_id) REFERENCES ambari.clusterconfig (version_tag, type_name, cluster_id);
 ALTER TABLE ambari.hostcomponentconfigmapping ADD CONSTRAINT FK_hostcomponentconfigmapping_cluster_id FOREIGN KEY (cluster_id, component_name, host_name, service_name) REFERENCES ambari.hostcomponentstate (cluster_id, component_name, host_name, service_name);
-ALTER TABLE ambari.hostcomponentdesiredconfigmapping ADD CONSTRAINT FK_hostcomponentdesiredconfigmapping_config_tag FOREIGN KEY (config_tag, config_type, cluster_id) REFERENCES ambari.clusterconfig (version_tag, type_name, cluster_id);
-ALTER TABLE ambari.hostcomponentdesiredconfigmapping ADD CONSTRAINT FK_hostcomponentdesiredconfigmapping_cluster_id FOREIGN KEY (cluster_id, component_name, host_name, service_name) REFERENCES ambari.hostcomponentdesiredstate (cluster_id, component_name, host_name, service_name);
+ALTER TABLE ambari.hcdesiredconfigmapping ADD CONSTRAINT FK_hostcomponentdesiredconfigmapping_config_tag FOREIGN KEY (config_tag, config_type, cluster_id) REFERENCES ambari.clusterconfig (version_tag, type_name, cluster_id);
+ALTER TABLE ambari.hcdesiredconfigmapping ADD CONSTRAINT FK_hostcomponentdesiredconfigmapping_cluster_id FOREIGN KEY (cluster_id, component_name, host_name, service_name) REFERENCES ambari.hostcomponentdesiredstate (cluster_id, component_name, host_name, service_name);
 ALTER TABLE ambari.hostcomponentdesiredstate ADD CONSTRAINT FK_hostcomponentdesiredstate_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
 ALTER TABLE ambari.hostcomponentdesiredstate ADD CONSTRAINT FK_hostcomponentdesiredstate_component_name FOREIGN KEY (component_name, cluster_id, service_name) REFERENCES ambari.servicecomponentdesiredstate (component_name, cluster_id, service_name);
 ALTER TABLE ambari.hostcomponentstate ADD CONSTRAINT FK_hostcomponentstate_component_name FOREIGN KEY (component_name, cluster_id, service_name) REFERENCES ambari.servicecomponentdesiredstate (component_name, cluster_id, service_name);
@@ -149,28 +156,25 @@ ALTER TABLE ambari.user_roles ADD CONSTR
 ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
 ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
 
-CREATE SEQUENCE ambari.host_role_command_task_id_seq INCREMENT BY 50 START WITH 51;
-
-GRANT ALL PRIVILEGES ON TABLE ambari.host_role_command_task_id_seq TO :username;
-
-GRANT ALL PRIVILEGES ON TABLE ambari.users_user_id_seq TO :username;
-
-CREATE SEQUENCE ambari.clusters_cluster_id_seq START WITH 1;
-
-GRANT ALL PRIVILEGES ON TABLE ambari.clusters_cluster_id_seq TO :username;
-
 BEGIN;
 
+insert into ambari.ambari_sequences(sequence_name, "value")
+select 'cluster_id_seq', 1
+union all
+select 'user_id_seq', 2
+union all
+select 'host_role_command_id_seq', 1;
+
 insert into ambari.Roles(role_name)
 select 'admin'
 union all
 select 'user';
 
-insert into ambari.Users(user_name, user_password, ldap_user)
-select 'admin','538916f8943ec225d97a9a86a2c6ec0818c1cd400e09e03b660fdaaec4af29ddbb6f2b1033b81b00', FALSE;
+insert into ambari.Users(user_id, user_name, user_password)
+select 1,'admin','538916f8943ec225d97a9a86a2c6ec0818c1cd400e09e03b660fdaaec4af29ddbb6f2b1033b81b00';
 
 insert into ambari.user_roles(role_name, user_id)
-select 'admin',(select user_id from ambari.users where user_name='admin' and ldap_user=false);
+select 'admin',1;
 
 insert into ambari.metainfo(metainfo_key, metainfo_value)
 select 'version','1.3.0';



Mime
View raw message