incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1398669 [1/5] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-project/ ambari-server/ ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ ambari-server/src/main/java/org/apache/ambari/server/agent/ ambari-server/src/m...
Date Tue, 16 Oct 2012 06:38:26 GMT
Author: mahadev
Date: Tue Oct 16 06:38:23 2012
New Revision: 1398669

URL: http://svn.apache.org/viewvc?rev=1398669&view=rev
Log:
AMBARI-866. Add ORM layer for the FSM's in the server. (mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/PersistenceType.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentDesiredStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentFactory.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostFactory.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceFactory.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostFactory.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/security/SslExecutionTest.java
Removed:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ComponentHostDesiredStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentHostDesiredStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentHostDesiredStateEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentStateEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceStateEntityPK.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBInMemoryImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ActionStatusDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentMappingDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentConfigDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentHostConfigDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceDesiredStateDAO.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentMappingEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentMappingEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentConfigEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentHostConfigEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UserEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/resources/api/rest/GetResource.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SecurityFilter.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SignCertResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/CertificateDownload.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/CertificateSign.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/META-INF/persistence.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostImplTest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImplTest.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Tue Oct 16 06:38:23 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-866. Add ORM layer for the FSM's in the server. (mahadev)
+
   AMBARI-853. Add more complete JMX metrics. (Tom Beerbower via mahadev)
 
   AMBARI-852. Improve REST API functionality regarding query and partial

Modified: incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml Tue Oct 16 06:38:23 2012
@@ -120,6 +120,11 @@
         <version>3.0</version>
       </dependency>
       <dependency>
+        <groupId>com.google.code.gson</groupId>
+        <artifactId>gson</artifactId>
+        <version>2.2.2</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.derby</groupId>
         <artifactId>derby</artifactId>
         <version>10.9.1.0</version>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml Tue Oct 16 06:38:23 2012
@@ -78,6 +78,10 @@
       <artifactId>guice-servlet</artifactId>
     </dependency>
     <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.derby</groupId>
       <artifactId>derby</artifactId>
     </dependency>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBInMemoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBInMemoryImpl.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBInMemoryImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBInMemoryImpl.java Tue Oct 16 06:38:23 2012
@@ -49,6 +49,7 @@ public class ActionDBInMemoryImpl implem
   public synchronized List<Stage> getAllStages(long requestId) {
     List<Stage> l = new ArrayList<Stage>();
     for (Stage s: stageList) {
+      System.err.println(s.getRequestId());
       if (s.getRequestId() == requestId) {
         l.add(s);
       }
@@ -98,6 +99,7 @@ public class ActionDBInMemoryImpl implem
   @Override
   public synchronized void persistActions(List<Stage> stages) {
     for (Stage s: stages) {
+      System.err.println("adding stage "+s.getRequestId()+" "+s.getStageId());
       stageList.add(s);
     }
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java Tue Oct 16 06:38:23 2012
@@ -135,7 +135,7 @@ public class HeartBeatHandler {
     Set<Cluster> clusters = clusterFsm.getClustersForHost(hostname);
     for (Cluster cl : clusters) {
       for (ComponentStatus status : heartbeat.componentStatus) {
-        if (status.getClusterName() == cl.getClusterName()) {
+        if (status.getClusterName().equals(cl.getClusterName())) {
           Service svc = cl.getService(status.getServiceName());
           ServiceComponent svcComp = svc.getServiceComponent(
               status.getComponentName());

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java Tue Oct 16 06:38:23 2012
@@ -51,7 +51,7 @@ public class AgentResource {
   private static Log LOG = LogFactory.getLog(AgentResource.class);
 
   @Inject
-  static void init(HeartBeatHandler instance) {
+  public static void init(HeartBeatHandler instance) {
     hh = instance;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java Tue Oct 16 06:38:23 2012
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.ambari.server.orm.PersistenceType;
 import org.apache.ambari.server.security.ClientSecurityType;
 import org.apache.ambari.server.security.authorization.LdapServerProperties;
 import org.apache.commons.io.FileUtils;
@@ -78,6 +79,9 @@ public class Configuration {
   public static final String LDAP_USER_DEFAULT_ROLE_KEY =
       "authorization.ldap.userDefaultRole";
 
+  public static final String PERSISTENCE_IN_MEMORY_KEY =
+      "server.persistence.inMemory";
+
   private static final String SRVR_KSTR_DIR_DEFAULT = ".";
   public static final String SRVR_CRT_NAME_DEFAULT = "ca.crt";
   public static final String SRVR_KEY_NAME_DEFAULT = "ca.key";
@@ -90,16 +94,16 @@ public class Configuration {
 
   private static final String CLIENT_SECURITY_DEFAULT = "local";
 
-  private static final String LDAP_USER_SEARCH_FILTER_DEFAULT = "({attribute}={0})";
   private static final String LDAP_USER_DEFAULT_ROLE_DEFAULT = "user";
   private static final String LDAP_BIND_ANONYMOUSLY_DEFAULT = "true";
 
-  //For embedded server only - should be removed later
+  //TODO For embedded server only - should be removed later
   private static final String LDAP_PRIMARY_URL_DEFAULT = "localhost:33389";
   private static final String LDAP_BASE_DN_DEFAULT = "dc=ambari,dc=apache,dc=org";
   private static final String LDAP_USERNAME_ATTRIBUTE_DEFAULT = "uid";
 
-
+  //TODO for development purposes only, should be changed to 'false'
+  private static final String PERSISTENCE_IN_MEMORY_DEFAULT = "true";
 
 
   private static final Log LOG = LogFactory.getLog(Configuration.class);
@@ -111,7 +115,7 @@ public class Configuration {
   private Map<String, String> configsMap;
 
 
-  Configuration() {
+  public Configuration() {
     this(readConfigFile());
   }
 
@@ -135,7 +139,7 @@ public class Configuration {
     configsMap.put(KSTR_NAME_KEY, properties.getProperty(
         KSTR_NAME_KEY, KSTR_NAME_DEFAULT));
     configsMap.put(SRVR_CRT_PASS_FILE_KEY, properties.getProperty(
-    	SRVR_CRT_PASS_FILE_KEY, SRVR_CRT_PASS_FILE_DEFAULT));
+     SRVR_CRT_PASS_FILE_KEY, SRVR_CRT_PASS_FILE_DEFAULT));
     configsMap.put(PASSPHRASE_ENV_KEY, properties.getProperty(
         PASSPHRASE_ENV_KEY, PASSPHRASE_ENV_DEFAULT));
     configsMap.put(PASSPHRASE_KEY, System.getenv(configsMap.get(
@@ -147,23 +151,36 @@ public class Configuration {
     configsMap.put(RESOURCES_DIR_KEY, properties.getProperty(
         RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT));
     configsMap.put(SRVR_CRT_PASS_LEN_KEY, properties.getProperty(
-    	SRVR_CRT_PASS_LEN_KEY, SRVR_CRT_PASS_LEN_DEFAULT));
+     SRVR_CRT_PASS_LEN_KEY, SRVR_CRT_PASS_LEN_DEFAULT));
     
-    try {
-      
-  	  String randStr = RandomStringUtils.randomAlphanumeric(Integer.parseInt(configsMap.get(SRVR_CRT_PASS_LEN_KEY)));
-
-      File passFile = new File(configsMap.get(SRVR_KSTR_DIR_KEY) + File.separator
-          + configsMap.get(SRVR_CRT_PASS_FILE_KEY));
-      FileUtils.writeStringToFile(passFile, randStr);
-      configsMap.put(SRVR_CRT_PASS_KEY, randStr);
-      
-    } catch (IOException e) {
-      e.printStackTrace();
-      throw new RuntimeException("Error reading certificate password from file");
+    File passFile = new File(configsMap.get(SRVR_KSTR_DIR_KEY) + File.separator
+        + configsMap.get(SRVR_CRT_PASS_FILE_KEY));
+    String randStr = null;
+
+    if (!passFile.exists()) {
+      LOG.info("Generation of file with password");
+      try {
+        randStr = RandomStringUtils.randomAlphanumeric(Integer
+            .parseInt(configsMap.get(SRVR_CRT_PASS_LEN_KEY)));
+        FileUtils.writeStringToFile(passFile, randStr);
+
+      } catch (IOException e) {
+          e.printStackTrace();
+          throw new RuntimeException(
+            "Error reading certificate password from file");
+      }
+    } else {
+        LOG.info("Reading password from existing file");
+      try {
+        randStr = FileUtils.readFileToString(passFile);
+      } catch (IOException e) {
+      		  LOG.error(e.getStackTrace());
+      }
     }
+    configsMap.put(SRVR_CRT_PASS_KEY, randStr);
   }
 
+
   /**
    * Find, read, and parse the configuration file.
    * @return the properties that were found or empty if no file was found
@@ -175,8 +192,8 @@ public class Configuration {
     InputStream inputStream = Configuration.class.getClassLoader().getResourceAsStream(CONFIG_FILE);
     
     if (inputStream == null)
-      LOG.info(CONFIG_FILE + " not found in classpath");
-    		
+      throw new RuntimeException(CONFIG_FILE + " not found in classpath");
+      
     
     // load the properties
     try {
@@ -185,7 +202,7 @@ public class Configuration {
       LOG.info("No configuration file " + CONFIG_FILE + " found in classpath.", fnf);
     } catch (IOException ie) {
       throw new IllegalArgumentException("Can't read configuration file " +
-    		 CONFIG_FILE, ie);
+       CONFIG_FILE, ie);
     }
     
     return properties;
@@ -228,6 +245,15 @@ public class Configuration {
     properties.setProperty(CLIENT_SECURITY_KEY, type.toString());
   }
 
+  public PersistenceType getPersistenceType() {
+    String value = properties.getProperty(PERSISTENCE_IN_MEMORY_KEY, PERSISTENCE_IN_MEMORY_DEFAULT);
+    if ("true".equalsIgnoreCase(value)) {
+      return PersistenceType.IN_MEMORY;
+    } else {
+      return PersistenceType.POSTGRES;
+    }
+  }
+
   /**
    * Gets parameters of LDAP server to connect to
    * @return LdapServerProperties object representing connection parameters

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Tue Oct 16 06:38:23 2012
@@ -18,26 +18,15 @@
 
 package org.apache.ambari.server.controller;
 
+import com.google.inject.Injector;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.HostNotFoundException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.ActionManager;
-import org.apache.ambari.server.actionmanager.HostAction;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.Config;
-import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentHost;
-import org.apache.ambari.server.state.ServiceComponentImpl;
-import org.apache.ambari.server.state.StackVersion;
-import org.apache.ambari.server.state.State;
-import org.apache.ambari.server.state.ServiceImpl;
-import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
+import org.apache.ambari.server.state.*;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -66,11 +55,21 @@ public class AmbariManagementControllerI
 
   private final ActionManager actionManager;
 
+  private final Injector injector;
+  @Inject
+  private ServiceFactory serviceFactory;
+  @Inject
+  private ServiceComponentFactory serviceComponentFactory;
+  @Inject
+  private ServiceComponentHostFactory serviceComponentHostFactory;
+
   @Inject
   public AmbariManagementControllerImpl(ActionManager actionManager,
-      Clusters clusters) {
+      Clusters clusters, Injector injector) {
     this.clusters = clusters;
     this.actionManager = actionManager;
+    this.injector = injector;
+    injector.injectMembers(this);
     LOG.info("Initializing the AmbariManagementControllerImpl");
   }
 
@@ -144,7 +143,7 @@ public class AmbariManagementControllerI
     Map<String, Config> configs = new HashMap<String, Config>();
 
     // Assuming service does not exist
-    s = new ServiceImpl(cluster, request.getServiceName());
+    s = serviceFactory.createNew(cluster, request.getServiceName());
 
     // TODO validate correct desired state
     // TODO take action based on desired state
@@ -164,6 +163,7 @@ public class AmbariManagementControllerI
     s.updateConfigs(configs);
     s.setDesiredStackVersion(cluster.getDesiredStackVersion());
     cluster.addService(s);
+    s.persist();
 
     // TODO
     return null;
@@ -208,7 +208,7 @@ public class AmbariManagementControllerI
       // Expected
     }
 
-    sc = new ServiceComponentImpl(s, request.getComponentName());
+    sc = serviceComponentFactory.createNew(s, request.getComponentName());
     sc.setDesiredStackVersion(s.getDesiredStackVersion());
 
     // TODO validate correct desired state
@@ -234,6 +234,7 @@ public class AmbariManagementControllerI
 
     sc.updateDesiredConfigs(configs);
     s.addServiceComponent(sc);
+    sc.persist();
 
     // TODO
     return null;
@@ -337,7 +338,7 @@ public class AmbariManagementControllerI
       isClient = false;
     }
 
-    sch = new ServiceComponentHostImpl(sc, request.getHostname(), isClient);
+    sch = serviceComponentHostFactory.createNew(sc, request.getHostname(), isClient);
 
     // TODO validate correct desired state
     if (request.getDesiredState() != null
@@ -365,6 +366,8 @@ public class AmbariManagementControllerI
     sch.updateDesiredConfigs(configs);
     sc.addServiceComponentHost(sch);
 
+    sch.persist();
+
     // TODO handle action if desired state is something other than INIT
     if (State.INIT == sch.getDesiredState()) {
       // TODO fix

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java Tue Oct 16 06:38:23 2012
@@ -24,9 +24,15 @@ import java.io.IOException;
 import java.util.Map;
 
 import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.agent.HeartBeatHandler;
+import org.apache.ambari.server.agent.rest.AgentResource;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.resources.ResourceManager;
+import org.apache.ambari.server.resources.api.rest.GetResource;
 import org.apache.ambari.server.security.CertificateManager;
+import org.apache.ambari.server.security.unsecured.rest.CertificateDownload;
+import org.apache.ambari.server.security.unsecured.rest.CertificateSign;
 import org.apache.ambari.server.state.Clusters;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.ResourceHandler;
@@ -46,12 +52,10 @@ import com.google.inject.Guice;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.Singleton;
-import com.google.inject.persist.jpa.JpaPersistModule;
 import com.sun.jersey.spi.container.servlet.ServletContainer;
 
 @Singleton
 public class AmbariServer {
-  public static final String PERSISTENCE_PROVIDER = "ambari-postgres";
   private static Logger LOG = LoggerFactory.getLogger(AmbariServer.class);
   public static int CLIENT_ONE_WAY = 4080;
   public static int CLIENT_TWO_WAY = 8443;
@@ -84,6 +88,7 @@ public class AmbariServer {
   }
 
   public void run() {
+    performStaticInjection();
     server = new Server(CLIENT_API_PORT);
     serverForAgent = new Server();
 
@@ -246,15 +251,25 @@ public class AmbariServer {
     }
   }
 
+  /**
+   * Static injection replacement to wait Persistence Service start
+   */
+  public void performStaticInjection() {
+    AgentResource.init(injector.getInstance(HeartBeatHandler.class));
+    CertificateDownload.init(injector.getInstance(CertificateManager.class));
+    CertificateSign.init(injector.getInstance(CertificateManager.class));
+    GetResource.init(injector.getInstance(ResourceManager.class));
+  }
+
   public static void main(String[] args) throws IOException {
-    Injector injector = Guice.createInjector(new ControllerModule(),
-        new JpaPersistModule(PERSISTENCE_PROVIDER));
 
+    Injector injector = Guice.createInjector(new ControllerModule());
+    
     try {
       LOG.info("Getting the controller");
+      injector.getInstance(GuiceJpaInitializer.class);
       AmbariServer server = injector.getInstance(AmbariServer.class);
       CertificateManager certMan = injector.getInstance(CertificateManager.class);
-      injector.getInstance(GuiceJpaInitializer.class);
       certMan.initRootCert();
       if (server != null) {
         server.run();

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java Tue Oct 16 06:38:23 2012
@@ -17,19 +17,25 @@
  */
 
 package org.apache.ambari.server.controller;
-
+import com.google.gson.Gson;
+import com.google.inject.Scopes;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.persist.jpa.JpaPersistModule;
 import org.apache.ambari.server.actionmanager.ActionDBAccessor;
 import org.apache.ambari.server.actionmanager.ActionDBInMemoryImpl;
-import org.apache.ambari.server.agent.rest.AgentResource;
-import org.apache.ambari.server.resources.api.rest.GetResource;
-import org.apache.ambari.server.security.unsecured.rest.CertificateDownload;
-import org.apache.ambari.server.security.unsecured.rest.CertificateSign;
-import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.state.*;
+import org.apache.ambari.server.state.cluster.ClusterFactory;
+import org.apache.ambari.server.state.cluster.ClusterImpl;
 import org.apache.ambari.server.state.cluster.ClustersImpl;
+import org.apache.ambari.server.state.host.HostFactory;
+import org.apache.ambari.server.state.host.HostImpl;
 
 import com.google.inject.AbstractModule;
-import com.google.inject.Injector;
 import com.google.inject.name.Names;
+import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
+
+import java.util.Properties;
 
 /**
  * Used for injection purposes.
@@ -37,13 +43,29 @@ import com.google.inject.name.Names;
  */
 public class ControllerModule extends AbstractModule {
 
+  private final Configuration configuration;
+
+  public ControllerModule() {
+    configuration = new Configuration();
+  }
+
+  public ControllerModule(Properties properties) {
+    configuration = new Configuration(properties);
+  }
+
   @Override
   protected void configure() {
+    bind(Configuration.class).toInstance(configuration);
+
+    install(new JpaPersistModule(configuration.getPersistenceType().getUnitName()));
+
+    install(new FactoryModuleBuilder().implement(Cluster.class, ClusterImpl.class).build(ClusterFactory.class));
+    install(new FactoryModuleBuilder().implement(Host.class, HostImpl.class).build(HostFactory.class));
+    install(new FactoryModuleBuilder().implement(Service.class, ServiceImpl.class).build(ServiceFactory.class));
+    install(new FactoryModuleBuilder().implement(ServiceComponent.class, ServiceComponentImpl.class).build(ServiceComponentFactory.class));
+    install(new FactoryModuleBuilder().implement(ServiceComponentHost.class, ServiceComponentHostImpl.class).build(ServiceComponentHostFactory.class));
 
-    requestStaticInjection(AgentResource.class);
-    requestStaticInjection(CertificateDownload.class);
-    requestStaticInjection(CertificateSign.class);
-    requestStaticInjection(GetResource.class);
+    bind(Gson.class).in(Scopes.SINGLETON);
     bind(Clusters.class).to(ClustersImpl.class);
     bind(ActionDBAccessor.class).to(ActionDBInMemoryImpl.class);
     bindConstant().annotatedWith(Names.named("schedulerSleeptime")).to(10000L);

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/PersistenceType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/PersistenceType.java?rev=1398669&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/PersistenceType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/PersistenceType.java Tue Oct 16 06:38:23 2012
@@ -0,0 +1,33 @@
+/**
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.orm;
+
+public enum PersistenceType {
+  IN_MEMORY("ambari-javadb"),
+  POSTGRES("ambari-postgres");
+
+  String unitName;
+
+  PersistenceType(String unitName) {
+    this.unitName = unitName;
+  }
+
+  public String getUnitName() {
+    return unitName;
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ActionStatusDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ActionStatusDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ActionStatusDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ActionStatusDAO.java Tue Oct 16 06:38:23 2012
@@ -34,6 +34,10 @@ public class ActionStatusDAO {
     return entityManagerProvider.get().find(ActionStatusEntity.class, actionStatusEntityPK);
   }
 
+  public void refresh(ActionStatusEntity actionStatusEntity) {
+    entityManagerProvider.get().refresh(actionStatusEntity);
+  }
+
   @Transactional
   public void create(ActionStatusEntity actionStatusEntity) {
     entityManagerProvider.get().persist(actionStatusEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java Tue Oct 16 06:38:23 2012
@@ -24,8 +24,13 @@ import com.google.inject.persist.Transac
 import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 
 import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.TypedQuery;
+import java.util.List;
+import java.util.Set;
 
 public class ClusterDAO {
   private static final Log log = LogFactory.getLog(ClusterDAO.class);
@@ -33,15 +38,51 @@ public class ClusterDAO {
   @Inject
   Provider<EntityManager> entityManagerProvider;
 
+  /**
+   * Looks for Cluster by ID
+   * @param id ID of Cluster
+   * @return Found entity or NULL
+   */
+  public ClusterEntity findById(long id) {
+    return entityManagerProvider.get().find(ClusterEntity.class, id);
+  }
+
   public ClusterEntity findByName(String clusterName) {
-    return entityManagerProvider.get().find(ClusterEntity.class, clusterName);
+    TypedQuery<ClusterEntity> query = entityManagerProvider.get().createNamedQuery("clusterByName", ClusterEntity.class);
+    query.setParameter("clusterName", clusterName);
+    try {
+      return query.getSingleResult();
+    } catch (NoResultException ignored) {
+      return null;
+    }
   }
 
+  public List<ClusterEntity> findAll() {
+    TypedQuery<ClusterEntity> query = entityManagerProvider.get().createNamedQuery("allClusters", ClusterEntity.class);
+    try {
+      return query.getResultList();
+    } catch (NoResultException ignored) {
+    }
+    return null;
+  }
+
+  /**
+   * Create Cluster entity in Database
+   * @param clusterEntity entity to create
+   */
   @Transactional
   public void create(ClusterEntity clusterEntity) {
     entityManagerProvider.get().persist(clusterEntity);
   }
 
+  /**
+   * Retrieve entity data from DB
+   * @param clusterEntity entity to refresh
+   */
+  public void refresh(ClusterEntity clusterEntity) {
+    entityManagerProvider.get().refresh(clusterEntity);
+  }
+
   @Transactional
   public ClusterEntity merge(ClusterEntity clusterEntity) {
     return entityManagerProvider.get().merge(clusterEntity);
@@ -57,4 +98,13 @@ public class ClusterDAO {
     remove(findByName(clusterName));
   }
 
+  @Transactional
+  public void rename(ClusterEntity clusterEntity, String newName) {
+    entityManagerProvider.get().unwrap(JpaEntityManager.class).getUnitOfWork().setShouldPerformDeletesFirst(true);
+    remove(clusterEntity);
+    entityManagerProvider.get().detach(clusterEntity);
+    clusterEntity.setClusterName(newName);
+    create(clusterEntity);
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java Tue Oct 16 06:38:23 2012
@@ -21,10 +21,13 @@ package org.apache.ambari.server.orm.dao
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.persist.Transactional;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntityPK;
 
 import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.TypedQuery;
 
 public class ClusterServiceDAO {
   @Inject
@@ -34,11 +37,21 @@ public class ClusterServiceDAO {
     return entityManagerProvider.get().find(ClusterServiceEntity.class, clusterServiceEntityPK);
   }
 
-  public ClusterServiceEntity findByClusterAndServiceNames(String clusterName, String serviceName) {
-    ClusterServiceEntityPK pk = new ClusterServiceEntityPK();
-    pk.setClusterName(clusterName);
-    pk.setServiceName(serviceName);
-    return findByPK(pk);
+  public ClusterServiceEntity findByClusterAndServiceNames(String  clusterName, String serviceName) {
+    TypedQuery<ClusterServiceEntity> query = entityManagerProvider.get()
+            .createNamedQuery("clusterServiceByClusterAndServiceNames", ClusterServiceEntity.class);
+    query.setParameter("clusterName", clusterName);
+    query.setParameter("serviceName", serviceName);
+
+    try {
+      return query.getSingleResult();
+    } catch (NoResultException ignored) {
+      return null;
+    }
+  }
+
+  public void refresh(ClusterServiceEntity clusterServiceEntity) {
+    entityManagerProvider.get().refresh(clusterServiceEntity);
   }
 
   @Transactional

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterStateDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterStateDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterStateDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterStateDAO.java Tue Oct 16 06:38:23 2012
@@ -33,6 +33,10 @@ public class ClusterStateDAO {
     return entityManagerProvider.get().find(ClusterStateEntity.class, clusterName);
   }
 
+  public void refresh(ClusterStateEntity clusterStateEntity) {
+    entityManagerProvider.get().refresh(clusterStateEntity);
+  }
+
   @Transactional
   public void create(ClusterStateEntity clusterStateEntity) {
     entityManagerProvider.get().persist(clusterStateEntity);

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java?rev=1398669&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java Tue Oct 16 06:38:23 2012
@@ -0,0 +1,61 @@
+/**
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.orm.dao;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.persist.Transactional;
+import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
+import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntityPK;
+
+import javax.persistence.EntityManager;
+
+public class HostComponentDesiredStateDAO {
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+
+  public HostComponentDesiredStateEntity findByPK(HostComponentDesiredStateEntityPK primaryKey) {
+    return entityManagerProvider.get().find(HostComponentDesiredStateEntity.class, primaryKey);
+  }
+
+  public void refresh(HostComponentDesiredStateEntity hostComponentDesiredStateEntity) {
+    entityManagerProvider.get().refresh(hostComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public void create(HostComponentDesiredStateEntity hostComponentDesiredStateEntity) {
+    entityManagerProvider.get().persist(hostComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public HostComponentDesiredStateEntity merge(HostComponentDesiredStateEntity hostComponentDesiredStateEntity) {
+    return entityManagerProvider.get().merge(hostComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public void remove(HostComponentDesiredStateEntity hostComponentDesiredStateEntity) {
+    entityManagerProvider.get().remove(hostComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public void removeByPK(HostComponentDesiredStateEntityPK primaryKey) {
+    remove(findByPK(primaryKey));
+  }
+
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentMappingDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentMappingDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentMappingDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentMappingDAO.java Tue Oct 16 06:38:23 2012
@@ -34,6 +34,10 @@ public class HostComponentMappingDAO {
     return entityManagerProvider.get().find(HostComponentMappingEntity.class, primaryKey);
   }
 
+  public void refresh(HostComponentMappingEntity hostComponentMappingEntity) {
+    entityManagerProvider.get().refresh(hostComponentMappingEntity);
+  }
+
   @Transactional
   public void create(HostComponentMappingEntity hostComponentMappingEntity) {
     entityManagerProvider.get().persist(hostComponentMappingEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentStateDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentStateDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentStateDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentStateDAO.java Tue Oct 16 06:38:23 2012
@@ -34,6 +34,10 @@ public class HostComponentStateDAO {
     return entityManagerProvider.get().find(HostComponentStateEntity.class, primaryKey);
   }
 
+  public void refresh(HostComponentStateEntity hostComponentStateEntity) {
+    entityManagerProvider.get().refresh(hostComponentStateEntity);
+  }
+
   @Transactional
   public void create(HostComponentStateEntity hostComponentStateEntity) {
     entityManagerProvider.get().persist(hostComponentStateEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostDAO.java Tue Oct 16 06:38:23 2012
@@ -21,9 +21,13 @@ package org.apache.ambari.server.orm.dao
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.persist.Transactional;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
 
 import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.TypedQuery;
+import java.util.List;
 
 public class HostDAO {
 
@@ -34,6 +38,19 @@ public class HostDAO {
     return entityManagerProvider.get().find(HostEntity.class, hostName);
   }
 
+  public List<HostEntity> findAll() {
+    TypedQuery<HostEntity> query = entityManagerProvider.get().createQuery("SELECT host FROM HostEntity host", HostEntity.class);
+    return query.getResultList();
+  }
+
+  /**
+   * Refreshes entity state from database
+   * @param hostEntity entity to refresh
+   */
+  public void refresh(HostEntity hostEntity) {
+    entityManagerProvider.get().refresh(hostEntity);
+  }
+
   @Transactional
   public void create(HostEntity hostEntity) {
     entityManagerProvider.get().persist(hostEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostStateDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostStateDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostStateDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostStateDAO.java Tue Oct 16 06:38:23 2012
@@ -33,6 +33,10 @@ public class HostStateDAO {
     return entityManagerProvider.get().find(HostStateEntity.class, hostName);
   }
 
+  public void refresh(HostStateEntity hostStateEntity) {
+    entityManagerProvider.get().refresh(hostStateEntity);
+  }
+
   @Transactional
   public void create(HostStateEntity hostStateEntity) {
     entityManagerProvider.get().persist(hostStateEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentConfigDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentConfigDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentConfigDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentConfigDAO.java Tue Oct 16 06:38:23 2012
@@ -33,6 +33,10 @@ public class ServiceComponentConfigDAO {
     return entityManagerProvider.get().find(ServiceComponentConfigEntity.class, primaryKey);
   }
 
+  public void refresh(ServiceComponentConfigEntity serviceComponentConfigEntity) {
+    entityManagerProvider.get().refresh(serviceComponentConfigEntity);
+  }
+
   @Transactional
   public void create(ServiceComponentConfigEntity serviceComponentConfigEntity) {
     entityManagerProvider.get().persist(serviceComponentConfigEntity);

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentDesiredStateDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentDesiredStateDAO.java?rev=1398669&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentDesiredStateDAO.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentDesiredStateDAO.java Tue Oct 16 06:38:23 2012
@@ -0,0 +1,61 @@
+/**
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.orm.dao;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.persist.Transactional;
+import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntityPK;
+import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity;
+
+import javax.persistence.EntityManager;
+
+public class ServiceComponentDesiredStateDAO {
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+
+  public ServiceComponentDesiredStateEntity findByPK(ServiceComponentDesiredStateEntityPK primaryKey) {
+    return entityManagerProvider.get().find(ServiceComponentDesiredStateEntity.class, primaryKey);
+  }
+
+  public void refresh(ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
+    entityManagerProvider.get().refresh(serviceComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public void create(ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
+    entityManagerProvider.get().persist(serviceComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public ServiceComponentDesiredStateEntity merge(ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
+    return entityManagerProvider.get().merge(serviceComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public void remove(ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
+    entityManagerProvider.get().remove(serviceComponentDesiredStateEntity);
+  }
+
+  @Transactional
+  public void removeByPK(ServiceComponentDesiredStateEntityPK primaryKey) {
+    remove(findByPK(primaryKey));
+  }
+
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentHostConfigDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentHostConfigDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentHostConfigDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceComponentHostConfigDAO.java Tue Oct 16 06:38:23 2012
@@ -33,6 +33,10 @@ public class ServiceComponentHostConfigD
     return entityManagerProvider.get().find(ServiceComponentHostConfigEntity.class, primaryKey);
   }
 
+  public void refresh(ServiceComponentHostConfigEntity serviceComponentHostConfigEntity) {
+    entityManagerProvider.get().refresh(serviceComponentHostConfigEntity);
+  }
+
   @Transactional
   public void create(ServiceComponentHostConfigEntity serviceComponentHostConfigEntity) {
     entityManagerProvider.get().persist(serviceComponentHostConfigEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java Tue Oct 16 06:38:23 2012
@@ -51,6 +51,10 @@ public class ServiceConfigDAO {
     return query.getResultList();
   }
 
+  public void refresh(ServiceConfigEntity serviceConfigEntity) {
+    entityManagerProvider.get().refresh(serviceConfigEntity);
+  }
+
   @Transactional
   public void create(ServiceConfigEntity serviceConfigEntity) {
     entityManagerProvider.get().persist(serviceConfigEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceDesiredStateDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceDesiredStateDAO.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceDesiredStateDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceDesiredStateDAO.java Tue Oct 16 06:38:23 2012
@@ -34,6 +34,10 @@ public class ServiceDesiredStateDAO {
     return entityManagerProvider.get().find(ServiceDesiredStateEntity.class, primaryKey);
   }
 
+  public void refresh(ServiceDesiredStateEntity serviceDesiredStateEntity) {
+    entityManagerProvider.get().refresh(serviceDesiredStateEntity);
+  }
+
   @Transactional
   public void create(ServiceDesiredStateEntity serviceDesiredStateEntity) {
     entityManagerProvider.get().persist(serviceDesiredStateEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntity.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntity.java Tue Oct 16 06:38:23 2012
@@ -15,27 +15,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.ambari.server.orm.entities;
 
-import javax.persistence.*;
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
 import java.util.Arrays;
 
 @javax.persistence.IdClass(ActionStatusEntityPK.class)
 @javax.persistence.Table(name = "actionstatus", schema = "ambari", catalog = "")
 @Entity
 public class ActionStatusEntity {
+  private Long clusterId;
 
-  private String clusterName = "";
-
-  @javax.persistence.Column(name = "cluster_name", nullable = true, insertable = false, updatable = false)
+  @javax.persistence.Column(name = "cluster_id", nullable = false, insertable = false, updatable = false, length = 10)
   @Id
-  public String getClusterName() {
-    return clusterName;
+  public Long getClusterId() {
+    return clusterId;
   }
 
-  public void setClusterName(String clusterName) {
-    this.clusterName = clusterName;
+  public void setClusterId(Long clusterId) {
+    this.clusterId = clusterId;
   }
 
   private String hostName = "";
@@ -52,7 +53,7 @@ public class ActionStatusEntity {
 
   private String role = "";
 
-  @javax.persistence.Column(name = "role", nullable = false)
+  @javax.persistence.Column(name = "role", nullable = false, insertable = true, updatable = true)
   @Id
   public String getRole() {
     return role;
@@ -64,31 +65,31 @@ public class ActionStatusEntity {
 
   private Integer requestId = 0;
 
-  @javax.persistence.Column(name = "request_id", nullable = false)
+  @javax.persistence.Column(name = "request_id", nullable = false, insertable = true, updatable = true, length = 10)
   @Id
-  public Integer getRequestId() {
+  public int getRequestId() {
     return requestId;
   }
 
-  public void setRequestId(Integer requestId) {
+  public void setRequestId(int requestId) {
     this.requestId = requestId;
   }
 
   private Integer stageId = 0;
 
-  @javax.persistence.Column(name = "stage_id", nullable = false)
+  @javax.persistence.Column(name = "stage_id", nullable = false, insertable = true, updatable = true, length = 10)
   @Id
-  public Integer getStageId() {
+  public int getStageId() {
     return stageId;
   }
 
-  public void setStageId(Integer stageId) {
+  public void setStageId(int stageId) {
     this.stageId = stageId;
   }
 
   private String event = "";
 
-  @javax.persistence.Column(name = "event", nullable = false)
+  @javax.persistence.Column(name = "event", nullable = false, insertable = true, updatable = true)
   @Basic
   public String getEvent() {
     return event;
@@ -100,19 +101,19 @@ public class ActionStatusEntity {
 
   private Integer taskId = 0;
 
-  @javax.persistence.Column(name = "task_id", nullable = false)
+  @javax.persistence.Column(name = "task_id", nullable = false, insertable = true, updatable = true, length = 10)
   @Basic
-  public Integer getTaskId() {
+  public int getTaskId() {
     return taskId;
   }
 
-  public void setTaskId(Integer taskId) {
+  public void setTaskId(int taskId) {
     this.taskId = taskId;
   }
 
   private String status = "";
 
-  @javax.persistence.Column(name = "status", nullable = false)
+  @javax.persistence.Column(name = "status", nullable = false, insertable = true, updatable = true)
   @Basic
   public String getStatus() {
     return status;
@@ -124,7 +125,7 @@ public class ActionStatusEntity {
 
   private String logInfo;
 
-  @javax.persistence.Column(name = "log_info")
+  @javax.persistence.Column(name = "log_info", nullable = false, insertable = true, updatable = true)
   @Basic
   public String getLogInfo() {
     return logInfo;
@@ -136,7 +137,7 @@ public class ActionStatusEntity {
 
   private byte[] continueCriteria;
 
-  @javax.persistence.Column(name = "continue_criteria")
+  @javax.persistence.Column(name = "continue_criteria", nullable = false, insertable = true, updatable = true)
   @Basic
   public byte[] getContinueCriteria() {
     return continueCriteria;
@@ -146,30 +147,6 @@ public class ActionStatusEntity {
     this.continueCriteria = continueCriteria;
   }
 
-  private ClusterEntity clusterEntity;
-
-  @ManyToOne
-  @JoinColumn(name = "cluster_name")
-  public ClusterEntity getClusterEntity() {
-    return clusterEntity;
-  }
-
-  public void setClusterEntity(ClusterEntity clusterEntity) {
-    this.clusterEntity = clusterEntity;
-  }
-
-  private HostEntity hostEntity;
-
-  @ManyToOne
-  @JoinColumn(name = "host_name")
-  public HostEntity getHostEntity() {
-    return hostEntity;
-  }
-
-  public void setHostEntity(HostEntity hostEntity) {
-    this.hostEntity = hostEntity;
-  }
-
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;
@@ -177,32 +154,56 @@ public class ActionStatusEntity {
 
     ActionStatusEntity that = (ActionStatusEntity) o;
 
-    if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false;
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false;
+    if (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
+    if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
     if (!Arrays.equals(continueCriteria, that.continueCriteria)) return false;
     if (event != null ? !event.equals(that.event) : that.event != null) return false;
     if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
     if (logInfo != null ? !logInfo.equals(that.logInfo) : that.logInfo != null) return false;
-    if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false;
     if (role != null ? !role.equals(that.role) : that.role != null) return false;
-    if (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
     if (status != null ? !status.equals(that.status) : that.status != null) return false;
-    if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
 
     return true;
   }
 
   @Override
   public int hashCode() {
-    int result = clusterName != null ? clusterName.hashCode() : 0;
+    int result = clusterId != null ? clusterId.intValue() : 0;
     result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
     result = 31 * result + (role != null ? role.hashCode() : 0);
-    result = 31 * result + (requestId != null ? requestId.hashCode() : 0);
-    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    result = 31 * result + (requestId !=null ? requestId : 0);
+    result = 31 * result + (stageId !=null ? stageId : 0);
     result = 31 * result + (event != null ? event.hashCode() : 0);
-    result = 31 * result + (taskId != null ? taskId.hashCode() : 0);
+    result = 31 * result + (taskId !=null ? taskId : 0);
     result = 31 * result + (status != null ? status.hashCode() : 0);
     result = 31 * result + (logInfo != null ? logInfo.hashCode() : 0);
     result = 31 * result + (continueCriteria != null ? Arrays.hashCode(continueCriteria) : 0);
     return result;
   }
+
+  private ClusterEntity clusterEntity;
+
+  @ManyToOne
+  @javax.persistence.JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false)
+  public ClusterEntity getClusterEntity() {
+    return clusterEntity;
+  }
+
+  public void setClusterEntity(ClusterEntity clusterEntity) {
+    this.clusterEntity = clusterEntity;
+  }
+
+  private HostEntity hostEntity;
+
+  @ManyToOne
+  @javax.persistence.JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
+  public HostEntity getHostEntity() {
+    return hostEntity;
+  }
+
+  public void setHostEntity(HostEntity hostEntity) {
+    this.hostEntity = hostEntity;
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntityPK.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntityPK.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ActionStatusEntityPK.java Tue Oct 16 06:38:23 2012
@@ -15,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.ambari.server.orm.entities;
 
 import javax.persistence.Column;
@@ -23,23 +22,22 @@ import javax.persistence.Id;
 import java.io.Serializable;
 
 public class ActionStatusEntityPK implements Serializable {
-
-  private String clusterName;
+  private Long clusterId;
 
   @Id
-  @Column(name = "cluster_name")
-  public String getClusterName() {
-    return clusterName;
+  @Column(name = "cluster_id", nullable = false, insertable = true, updatable = true, length = 10)
+  public Long getClusterId() {
+    return clusterId;
   }
 
-  public void setClusterName(String clusterName) {
-    this.clusterName = clusterName;
+  public void setClusterId(Long clusterId) {
+    this.clusterId = clusterId;
   }
 
   private String hostName;
 
   @Id
-  @Column(name = "host_name")
+  @Column(name = "host_name", nullable = false, insertable = true, updatable = true)
   public String getHostName() {
     return hostName;
   }
@@ -51,7 +49,7 @@ public class ActionStatusEntityPK implem
   private String role;
 
   @Id
-  @Column(name = "role")
+  @Column(name = "role", nullable = false, insertable = true, updatable = true)
   public String getRole() {
     return role;
   }
@@ -63,7 +61,7 @@ public class ActionStatusEntityPK implem
   private Integer requestId;
 
   @Id
-  @Column(name = "request_id")
+  @Column(name = "request_id", nullable = false, insertable = true, updatable = true, length = 10)
   public Integer getRequestId() {
     return requestId;
   }
@@ -75,7 +73,7 @@ public class ActionStatusEntityPK implem
   private Integer stageId;
 
   @Id
-  @Column(name = "stage_id")
+  @Column(name = "stage_id", nullable = false, insertable = true, updatable = true, length = 10)
   public Integer getStageId() {
     return stageId;
   }
@@ -91,22 +89,22 @@ public class ActionStatusEntityPK implem
 
     ActionStatusEntityPK that = (ActionStatusEntityPK) o;
 
-    if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false;
-    if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
     if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false;
-    if (role != null ? !role.equals(that.role) : that.role != null) return false;
     if (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
+    if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
+    if (role != null ? !role.equals(that.role) : that.role != null) return false;
 
     return true;
   }
 
   @Override
   public int hashCode() {
-    int result = clusterName != null ? clusterName.hashCode() : 0;
+    int result = clusterId != null ? clusterId.intValue() : 0;
     result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
     result = 31 * result + (role != null ? role.hashCode() : 0);
-    result = 31 * result + (requestId != null ? requestId.hashCode() : 0);
-    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    result = 31 * result + (requestId !=null ? requestId : 0);
+    result = 31 * result + (stageId !=null ? stageId : 0);
     return result;
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java?rev=1398669&r1=1398668&r2=1398669&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java Tue Oct 16 06:38:23 2012
@@ -18,22 +18,38 @@
 
 package org.apache.ambari.server.orm.entities;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import javax.persistence.*;
-import java.util.List;
+import java.util.Collection;
 
-@Table(name = "clusters", schema = "ambari", catalog = "")
+@javax.persistence.Table(name = "clusters", schema = "ambari", catalog = "")
+@NamedQueries({
+    @NamedQuery(name = "clusterByName", query =
+        "SELECT cluster " +
+            "FROM ClusterEntity cluster " +
+            "WHERE cluster.clusterName=:clusterName"),
+    @NamedQuery(name = "allClusters", query =
+        "SELECT clusters " +
+            "FROM ClusterEntity clusters")
+})
 @Entity
 public class ClusterEntity {
+  private Long clusterId;
 
-  private static final Log log = LogFactory.getLog(ClusterEntity.class);
+  @javax.persistence.Column(name = "cluster_id", nullable = false, insertable = true, updatable = true)
+  @Id
+  @GeneratedValue(strategy = GenerationType.AUTO)
+  public Long getClusterId() {
+    return clusterId;
+  }
+
+  public void setClusterId(Long clusterId) {
+    this.clusterId = clusterId;
+  }
 
   private String clusterName;
 
-  @Column(name = "cluster_name")
-  @Id
+  @javax.persistence.Column(name = "cluster_name", nullable = false, insertable = true, updatable = true, unique = true)
+  @Basic
   public String getClusterName() {
     return clusterName;
   }
@@ -44,7 +60,7 @@ public class ClusterEntity {
 
   private String desiredClusterState = "";
 
-  @Column(name = "desired_cluster_state", nullable = false)
+  @javax.persistence.Column(name = "desired_cluster_state", nullable = false, insertable = true, updatable = true)
   @Basic
   public String getDesiredClusterState() {
     return desiredClusterState;
@@ -56,7 +72,7 @@ public class ClusterEntity {
 
   private String clusterInfo = "";
 
-  @Column(name = "cluster_info", nullable = false)
+  @javax.persistence.Column(name = "cluster_info", nullable = false, insertable = true, updatable = true)
   @Basic
   public String getClusterInfo() {
     return clusterInfo;
@@ -66,48 +82,51 @@ public class ClusterEntity {
     this.clusterInfo = clusterInfo;
   }
 
-  List<HostEntity> hostEntities;
-
-  @OneToMany(cascade = CascadeType.ALL, mappedBy = "clusterEntity")
-  public List<HostEntity> getHostEntities() {
-    return hostEntities;
-  }
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
 
-  public void setHostEntities(List<HostEntity> hostEntities) {
-    this.hostEntities = hostEntities;
-  }
+    ClusterEntity that = (ClusterEntity) o;
 
-  List<ClusterServiceEntity> clusterServiceEntities;
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (clusterInfo != null ? !clusterInfo.equals(that.clusterInfo) : that.clusterInfo != null) return false;
+    if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false;
+    if (desiredClusterState != null ? !desiredClusterState.equals(that.desiredClusterState) : that.desiredClusterState != null)
+      return false;
 
-  @OneToMany(cascade = CascadeType.ALL, mappedBy = "clusterEntity")
-  public List<ClusterServiceEntity> getClusterServiceEntities() {
-    return clusterServiceEntities;
+    return true;
   }
 
-  public void setClusterServiceEntities(List<ClusterServiceEntity> clusterServiceEntities) {
-    this.clusterServiceEntities = clusterServiceEntities;
+  @Override
+  public int hashCode() {
+    int result = clusterId != null ? clusterId.intValue() : 0;
+    result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0);
+    result = 31 * result + (desiredClusterState != null ? desiredClusterState.hashCode() : 0);
+    result = 31 * result + (clusterInfo != null ? clusterInfo.hashCode() : 0);
+    return result;
   }
 
-  List<ActionStatusEntity> actionStatusEntities;
+  private Collection<ActionStatusEntity> actionStatusEntities;
 
   @OneToMany(mappedBy = "clusterEntity")
-  public List<ActionStatusEntity> getActionStatusEntities() {
+  public Collection<ActionStatusEntity> getActionStatusEntities() {
     return actionStatusEntities;
   }
 
-  public void setActionStatusEntities(List<ActionStatusEntity> actionStatusEntities) {
+  public void setActionStatusEntities(Collection<ActionStatusEntity> actionStatusEntities) {
     this.actionStatusEntities = actionStatusEntities;
   }
 
-  List<ComponentHostDesiredStateEntity> componentHostDesiredStateEntities;
+  private Collection<ClusterServiceEntity> clusterServiceEntities;
 
   @OneToMany(mappedBy = "clusterEntity")
-  public List<ComponentHostDesiredStateEntity> getComponentHostDesiredStateEntities() {
-    return componentHostDesiredStateEntities;
+  public Collection<ClusterServiceEntity> getClusterServiceEntities() {
+    return clusterServiceEntities;
   }
 
-  public void setComponentHostDesiredStateEntities(List<ComponentHostDesiredStateEntity> componentHostDesiredStateEntities) {
-    this.componentHostDesiredStateEntities = componentHostDesiredStateEntities;
+  public void setClusterServiceEntities(Collection<ClusterServiceEntity> clusterServiceEntities) {
+    this.clusterServiceEntities = clusterServiceEntities;
   }
 
   private ClusterStateEntity clusterStateEntity;
@@ -121,60 +140,14 @@ public class ClusterEntity {
     this.clusterStateEntity = clusterStateEntity;
   }
 
-  private List<HostStateEntity> hostStateEntities;
+  private Collection<HostEntity> hostEntities;
 
-  @OneToMany(mappedBy = "clusterEntity")
-  public List<HostStateEntity> getHostStateEntities() {
-    return hostStateEntities;
-  }
-
-  public void setHostStateEntities(List<HostStateEntity> hostStateEntities) {
-    this.hostStateEntities = hostStateEntities;
-  }
-
-  private List<HostComponentStateEntity> hostComponentStateEntities;
-
-  @OneToMany(mappedBy = "clusterEntity")
-  public List<HostComponentStateEntity> getHostComponentStateEntities() {
-    return hostComponentStateEntities;
-  }
-
-  public void setHostComponentStateEntities(List<HostComponentStateEntity> hostComponentStateEntities) {
-    this.hostComponentStateEntities = hostComponentStateEntities;
-  }
-
-  private List<ServiceComponentStateEntity> serviceComponentStateEntities;
-
-  @OneToMany(mappedBy = "clusterEntity")
-  public List<ServiceComponentStateEntity> getServiceComponentStateEntities() {
-    return serviceComponentStateEntities;
-  }
-
-  public void setServiceComponentStateEntities(List<ServiceComponentStateEntity> serviceComponentStateEntities) {
-    this.serviceComponentStateEntities = serviceComponentStateEntities;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-
-    ClusterEntity that = (ClusterEntity) o;
-
-    if (clusterInfo != null ? !clusterInfo.equals(that.clusterInfo) : that.clusterInfo != null) return false;
-    if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false;
-    if (desiredClusterState != null ? !desiredClusterState.equals(that.desiredClusterState) : that.desiredClusterState != null)
-      return false;
-
-    return true;
+  @ManyToMany(mappedBy = "clusterEntities")
+  public Collection<HostEntity> getHostEntities() {
+    return hostEntities;
   }
 
-  @Override
-  public int hashCode() {
-    int result = clusterName != null ? clusterName.hashCode() : 0;
-    result = 31 * result + (desiredClusterState != null ? desiredClusterState.hashCode() : 0);
-    result = 31 * result + (clusterInfo != null ? clusterInfo.hashCode() : 0);
-    return result;
+  public void setHostEntities(Collection<HostEntity> hostEntities) {
+    this.hostEntities = hostEntities;
   }
-
 }



Mime
View raw message