incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1400792 [2/2] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/src/main/puppet/modules/configgenerator/manifests/ ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/ ambari-agent/src/main/puppet/modules/hdp/manifests/lib/...
Date Mon, 22 Oct 2012 08:09:16 GMT
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java Mon Oct 22 08:09:14 2012
@@ -21,19 +21,55 @@ 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.Role;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.orm.entities.HostEntity;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
+import org.apache.ambari.server.orm.entities.StageEntity;
 
 import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import java.util.Collection;
+import java.util.List;
 
 public class HostRoleCommandDAO {
 
   @Inject
   Provider<EntityManager> entityManagerProvider;
+  @Inject
+  DaoUtils daoUtils;
 
   public HostRoleCommandEntity findByPK(int taskId) {
     return entityManagerProvider.get().find(HostRoleCommandEntity.class, taskId);
   }
 
+  public List<HostRoleCommandEntity> findSortedCommandsByStageAndHost(StageEntity stageEntity, HostEntity hostEntity) {
+    TypedQuery<HostRoleCommandEntity> query = entityManagerProvider.get().createQuery("SELECT hostRoleCommand " +
+        "FROM HostRoleCommandEntity hostRoleCommand " +
+        "WHERE hostRoleCommand.stage=?1 AND hostRoleCommand.host=?2 " +
+        "ORDER BY hostRoleCommand.taskId", HostRoleCommandEntity.class);
+    return daoUtils.selectList(query, stageEntity, hostEntity);
+  }
+
+  public List<HostRoleCommandEntity> findByHostRole(String hostName, long requestId, long stageId, Role role) {
+    TypedQuery<HostRoleCommandEntity> query = entityManagerProvider.get().createQuery("SELECT command " +
+        "FROM HostRoleCommandEntity command " +
+        "WHERE command.hostName=?1 AND command.requestId=?2 " +
+        "AND command.stageId=?3 AND command.role=?4", HostRoleCommandEntity.class);
+
+    return daoUtils.selectList(query, hostName, requestId, stageId, role);
+  }
+
+  @Transactional
+  public int updateStatusByRequestId(long requestId, HostRoleStatus target, Collection<HostRoleStatus> sources) {
+    Query query = entityManagerProvider.get().createQuery("UPDATE HostRoleCommandEntity command " +
+        "SET command.status=?1 " +
+        "WHERE command.requestId=?2 AND command.status IN ?3");
+
+    return daoUtils.executeUpdate(query, target, requestId, sources);
+  }
+
   @Transactional
   public void create(HostRoleCommandEntity stageEntity) {
     entityManagerProvider.get().persist(stageEntity);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java Mon Oct 22 08:09:14 2012
@@ -21,20 +21,59 @@ 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.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.orm.entities.StageEntity;
 import org.apache.ambari.server.orm.entities.StageEntityPK;
+import org.apache.ambari.server.utils.StageUtils;
 
 import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import java.util.Collection;
+import java.util.List;
 
 public class StageDAO {
 
   @Inject
   Provider<EntityManager> entityManagerProvider;
+  @Inject
+  DaoUtils daoUtils;
 
   public StageEntity findByPK(StageEntityPK stageEntityPK) {
     return entityManagerProvider.get().find(StageEntity.class, stageEntityPK);
   }
 
+  public long getLastRequestId() {
+    TypedQuery<Long> query = entityManagerProvider.get().createQuery("SELECT stage.requestId " +
+        "FROM StageEntity stage" +
+        " WHERE stage.requestId = (SELECT max(stage.requestId) FROM StageEntity stage)", Long.class);
+    Long result = daoUtils.selectSingle(query);
+    if (result != null) {
+      return result;
+    } else {
+      return -1;
+    }
+  }
+
+  public StageEntity findByActionId(String actionId) {
+    long[] ids = StageUtils.getRequestStage(actionId);
+    StageEntityPK pk = new StageEntityPK();
+    pk.setRequestId(ids[0]);
+    pk.setStageId(ids[1]);
+    return findByPK(pk);
+  }
+
+  public List<StageEntity> findByRequestId(long requestId) {
+    TypedQuery<StageEntity> query = entityManagerProvider.get().createQuery("SELECT stage FROM StageEntity stage WHERE stage.requestId=?1", StageEntity.class);
+    return daoUtils.selectList(query, requestId);
+  }
+
+  public List<StageEntity> findByCommandStatuses(Collection<HostRoleStatus> statuses) {
+    TypedQuery<StageEntity> query = entityManagerProvider.get().createQuery("SELECT stage " +
+        "FROM StageEntity stage JOIN stage.hostRoleCommands command " +
+        "WHERE command.status IN ?1", StageEntity.class);
+    return daoUtils.selectList(query, statuses);
+  }
+
   @Transactional
   public void create(StageEntity stageEntity) {
     entityManagerProvider.get().persist(stageEntity);

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=1400792&r1=1400791&r2=1400792&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 Mon Oct 22 08:09:14 2012
@@ -32,12 +32,13 @@ import java.util.Collection;
             "FROM ClusterEntity clusters")
 })
 @Entity
+@SequenceGenerator(name = "ambari.clusters_cluster_id_seq", allocationSize = 1)
 public class ClusterEntity {
   private Long clusterId;
 
   @javax.persistence.Column(name = "cluster_id", nullable = false, insertable = true, updatable = true)
   @Id
-  @GeneratedValue(strategy = GenerationType.AUTO)
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.clusters_cluster_id_seq")
   public Long getClusterId() {
     return clusterId;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java Mon Oct 22 08:09:14 2012
@@ -19,7 +19,6 @@
 package org.apache.ambari.server.orm.entities;
 
 import javax.persistence.*;
-import java.util.Arrays;
 
 @Table(name = "execution_command", schema = "ambari", catalog = "")
 @Entity
@@ -36,15 +35,15 @@ public class ExecutionCommandEntity {
     this.taskId = taskId;
   }
 
-  private byte[] command;
+  private String command;
 
-  @Column(name = "command")
+  @Column(name = "command", length = 32000)
   @Basic
-  public byte[] getCommand() {
+  public String getCommand() {
     return command;
   }
 
-  public void setCommand(byte[] command) {
+  public void setCommand(String command) {
     this.command = command;
   }
 
@@ -55,7 +54,7 @@ public class ExecutionCommandEntity {
 
     ExecutionCommandEntity that = (ExecutionCommandEntity) o;
 
-    if (!Arrays.equals(command, that.command)) return false;
+    if (command != null ? !command.equals(that.command) : that.command != null) return false;
     if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
 
     return true;
@@ -64,7 +63,7 @@ public class ExecutionCommandEntity {
   @Override
   public int hashCode() {
     int result = taskId != null ? taskId.hashCode() : 0;
-    result = 31 * result + (command != null ? Arrays.hashCode(command) : 0);
+    result = 31 * result + (command != null ? command.hashCode() : 0);
     return result;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentMappingEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentMappingEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentMappingEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentMappingEntity.java Mon Oct 22 08:09:14 2012
@@ -23,6 +23,7 @@ import javax.persistence.*;
 @javax.persistence.IdClass(HostComponentMappingEntityPK.class)
 @javax.persistence.Table(name = "hostcomponentmapping", schema = "ambari", catalog = "")
 @Entity
+@SequenceGenerator(name = "ambari.hostcomponentmapping_host_component_mapping_id_seq", allocationSize = 1)
 public class HostComponentMappingEntity {
   private Long clusterId;
 
@@ -52,7 +53,7 @@ public class HostComponentMappingEntity 
 
   @javax.persistence.Column(name = "host_component_mapping_id", nullable = false, insertable = true, updatable = true, length = 10)
   @Id
-  @GeneratedValue(strategy = GenerationType.AUTO)
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.hostcomponentmapping_host_component_mapping_id_seq")
   public Integer getHostComponentMappingId() {
     return hostComponentMappingId;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java Mon Oct 22 08:09:14 2012
@@ -110,7 +110,8 @@ public class HostEntity {
 
   private String disksInfo = "";
 
-  @javax.persistence.Column(name = "disks_info", nullable = false, insertable = true, updatable = true)
+  @javax.persistence.Column(name = "disks_info", nullable = false, insertable = true, 
+		  updatable = true, length = 2000)
   @Basic
   public String getDisksInfo() {
     return disksInfo;
@@ -199,9 +200,9 @@ public class HostEntity {
 
     HostEntity that = (HostEntity) o;
 
-    if (cpuCount != that.cpuCount) return false;
-    if (lastRegistrationTime != that.lastRegistrationTime) return false;
-    if (totalMem != that.totalMem) return false;
+    if (cpuCount != null ? !cpuCount.equals(that.cpuCount) : that.cpuCount != null) return false;
+    if (lastRegistrationTime != null ? !lastRegistrationTime.equals(that.lastRegistrationTime) : that.lastRegistrationTime != null) return false;
+    if (totalMem != null ? !totalMem.equals(that.totalMem) : that.totalMem != null) return false;
     if (cpuInfo != null ? !cpuInfo.equals(that.cpuInfo) : that.cpuInfo != null) return false;
     if (discoveryStatus != null ? !discoveryStatus.equals(that.discoveryStatus) : that.discoveryStatus != null)
       return false;
@@ -297,7 +298,18 @@ public class HostEntity {
     this.serviceComponentHostConfigEntities = serviceComponentHostConfigEntities;
   }
 
-//  private Collection<ServiceComponentStateEntity> serviceComponentStateEntities;
+  private Collection<HostRoleCommandEntity> hostRoleCommandEntities;
+
+  @OneToMany(mappedBy = "host")
+  public Collection<HostRoleCommandEntity> getHostRoleCommandEntities() {
+    return hostRoleCommandEntities;
+  }
+
+  public void setHostRoleCommandEntities(Collection<HostRoleCommandEntity> hostRoleCommandEntities) {
+    this.hostRoleCommandEntities = hostRoleCommandEntities;
+  }
+
+  //  private Collection<ServiceComponentStateEntity> serviceComponentStateEntities;
 //
 //  @OneToMany(mappedBy = "hostEntity")
 //  public Collection<ServiceComponentStateEntity> getServiceComponentStateEntities() {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java Mon Oct 22 08:09:14 2012
@@ -18,15 +18,20 @@
 
 package org.apache.ambari.server.orm.entities;
 
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+
 import javax.persistence.*;
 
 @Table(name = "host_role_command", schema = "ambari", catalog = "")
 @Entity
+@SequenceGenerator(name = "ambari.host_role_command_task_id_seq", allocationSize = 1)
 public class HostRoleCommandEntity {
   private Integer taskId;
 
   @Column(name = "task_id")
   @Id
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.host_role_command_task_id_seq")
   public Integer getTaskId() {
     return taskId;
   }
@@ -35,27 +40,27 @@ public class HostRoleCommandEntity {
     this.taskId = taskId;
   }
 
-  private Integer requestId;
+  private Long requestId;
 
   @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
   @Basic
-  public Integer getRequestId() {
+  public Long getRequestId() {
     return requestId;
   }
 
-  public void setRequestId(Integer requestId) {
+  public void setRequestId(Long requestId) {
     this.requestId = requestId;
   }
 
-  private Integer stageId;
+  private Long stageId;
 
   @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
   @Basic
-  public Integer getStageId() {
+  public Long getStageId() {
     return stageId;
   }
 
-  public void setStageId(Integer stageId) {
+  public void setStageId(Long stageId) {
     this.stageId = stageId;
   }
 
@@ -71,15 +76,15 @@ public class HostRoleCommandEntity {
     this.hostName = hostName;
   }
 
-  private String role = "";
+  private Role role;
 
-  @Column(name = "role", nullable = false)
-  @Basic
-  public String getRole() {
+  @Column(name = "role")
+  @Enumerated(EnumType.STRING)
+  public Role getRole() {
     return role;
   }
 
-  public void setRole(String role) {
+  public void setRole(Role role) {
     this.role = role;
   }
 
@@ -119,15 +124,15 @@ public class HostRoleCommandEntity {
     this.exitcode = exitcode;
   }
 
-  private String status = "";
+  private HostRoleStatus status;
 
-  @Column(name = "status", nullable = false)
-  @Basic
-  public String getStatus() {
+  @Column(name = "status")
+  @Enumerated(EnumType.STRING)
+  public HostRoleStatus getStatus() {
     return status;
   }
 
-  public void setStatus(String status) {
+  public void setStatus(HostRoleStatus status) {
     this.status = status;
   }
 
@@ -179,15 +184,15 @@ public class HostRoleCommandEntity {
     this.lastAttemptTime = lastAttemptTime;
   }
 
-  private Integer attemptCount = 0;
+  private Short attemptCount = 0;
 
   @Column(name = "attempt_count", nullable = false)
   @Basic
-  public Integer getAttemptCount() {
+  public Short getAttemptCount() {
     return attemptCount;
   }
 
-  public void setAttemptCount(Integer attemptCount) {
+  public void setAttemptCount(Short attemptCount) {
     this.attemptCount = attemptCount;
   }
 
@@ -270,4 +275,4 @@ public class HostRoleCommandEntity {
   public void setHost(HostEntity host) {
     this.host = host;
   }
-}
+}
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java Mon Oct 22 08:09:14 2012
@@ -18,45 +18,48 @@
 
 package org.apache.ambari.server.orm.entities;
 
+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 = "")
 @Entity
 public class RoleSuccessCriteriaEntity {
-  private Integer requestId;
+  private Long requestId;
 
   @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
   @Id
-  public Integer getRequestId() {
+  public Long getRequestId() {
     return requestId;
   }
 
-  public void setRequestId(Integer requestId) {
+  public void setRequestId(Long requestId) {
     this.requestId = requestId;
   }
 
-  private Integer stageId;
+  private Long stageId;
 
   @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
   @Id
-  public Integer getStageId() {
+  public Long getStageId() {
     return stageId;
   }
 
-  public void setStageId(Integer stageId) {
+  public void setStageId(Long stageId) {
     this.stageId = stageId;
   }
 
-  private String role;
+  private Role role;
 
   @Column(name = "role")
+  @Enumerated(EnumType.STRING)
   @Id
-  public String getRole() {
+  public Role getRole() {
     return role;
   }
 
-  public void setRole(String role) {
+  public void setRole(Role role) {
     this.role = role;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntityPK.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntityPK.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntityPK.java Mon Oct 22 08:09:14 2012
@@ -18,44 +18,49 @@
 
 package org.apache.ambari.server.orm.entities;
 
+import org.apache.ambari.server.Role;
+
 import javax.persistence.Column;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import java.io.Serializable;
 
 public class RoleSuccessCriteriaEntityPK implements Serializable {
-  private Integer requestId;
+  private Long requestId;
 
   @Id
   @Column(name = "request_id")
-  public Integer getRequestId() {
+  public Long getRequestId() {
     return requestId;
   }
 
-  public void setRequestId(Integer requestId) {
+  public void setRequestId(Long requestId) {
     this.requestId = requestId;
   }
 
-  private Integer stageId;
+  private Long stageId;
 
   @Id
   @Column(name = "stage_id")
-  public Integer getStageId() {
+  public Long getStageId() {
     return stageId;
   }
 
-  public void setStageId(Integer stageId) {
+  public void setStageId(Long stageId) {
     this.stageId = stageId;
   }
 
-  private String role;
+  private Role role;
 
-  @Id
   @Column(name = "role")
-  public String getRole() {
+  @Enumerated(EnumType.STRING)
+  @Id
+  public Role getRole() {
     return role;
   }
 
-  public void setRole(String role) {
+  public void setRole(Role role) {
     this.role = role;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentConfigEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentConfigEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentConfigEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentConfigEntity.java Mon Oct 22 08:09:14 2012
@@ -23,12 +23,13 @@ import java.util.Date;
 
 @javax.persistence.Table(name = "servicecomponentconfig", schema = "ambari", catalog = "")
 @Entity
+@SequenceGenerator(name = "ambari.servicecomponentconfig_config_version_seq", allocationSize = 1)
 public class ServiceComponentConfigEntity {
   private Integer configVersion;
 
   @javax.persistence.Column(name = "config_version", nullable = false, insertable = true, updatable = true, length = 10)
   @Id
-  @GeneratedValue(strategy = GenerationType.AUTO)
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.servicecomponentconfig_config_version_seq")
   public Integer getConfigVersion() {
     return configVersion;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentHostConfigEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentHostConfigEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentHostConfigEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentHostConfigEntity.java Mon Oct 22 08:09:14 2012
@@ -23,12 +23,13 @@ import java.util.Date;
 
 @javax.persistence.Table(name = "servicecomponenthostconfig", schema = "ambari", catalog = "")
 @Entity
+@SequenceGenerator(name = "ambari.servicecomponenthostconfig_config_version_seq", allocationSize = 1)
 public class ServiceComponentHostConfigEntity {
   private Integer configVersion;
 
   @javax.persistence.Column(name = "config_version", nullable = false, insertable = true, updatable = true, length = 10)
   @Id
-  @GeneratedValue(strategy = GenerationType.AUTO)
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.servicecomponenthostconfig_config_version_seq")
   public Integer getConfigVersion() {
     return configVersion;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java Mon Oct 22 08:09:14 2012
@@ -23,12 +23,13 @@ import java.util.Date;
 
 @javax.persistence.Table(name = "serviceconfig", schema = "ambari", catalog = "")
 @Entity
+@SequenceGenerator(name = "ambari.serviceconfig_config_version_seq", allocationSize = 1)
 public class ServiceConfigEntity {
   private Integer configVersion;
 
   @javax.persistence.Column(name = "config_version", nullable = false, insertable = true, updatable = true, length = 10)
   @Id
-  @GeneratedValue(strategy = GenerationType.AUTO)
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ambari.serviceconfig_config_version_seq")
   public Integer getConfigVersion() {
     return configVersion;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java Mon Oct 22 08:09:14 2012
@@ -25,40 +25,39 @@ import java.util.Collection;
 @Table(name = "stage", schema = "ambari", catalog = "")
 @Entity
 public class StageEntity {
-  private Integer clusterId;
+  private Long clusterId;
 
   @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
   @Basic
-  public Integer getClusterId() {
+  public Long getClusterId() {
     return clusterId;
   }
 
-  public void setClusterId(Integer clusterId) {
+  public void setClusterId(Long clusterId) {
     this.clusterId = clusterId;
   }
 
-  private Integer requestId;
+  private Long requestId;
 
   @Column(name = "request_id")
   @Id
-  //TODO auto generated? @GeneratedValue(strategy = GenerationType.AUTO)
-  public Integer getRequestId() {
+  public Long getRequestId() {
     return requestId;
   }
 
-  public void setRequestId(Integer requestId) {
+  public void setRequestId(Long requestId) {
     this.requestId = requestId;
   }
 
-  private Integer stageId = 0;
+  private Long stageId = 0L;
 
   @Column(name = "stage_id", nullable = false)
   @Id
-  public Integer getStageId() {
+  public Long getStageId() {
     return stageId;
   }
 
-  public void setStageId(Integer stageId) {
+  public void setStageId(Long stageId) {
     this.stageId = stageId;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java Mon Oct 22 08:09:14 2012
@@ -23,27 +23,27 @@ import javax.persistence.Id;
 import java.io.Serializable;
 
 public class StageEntityPK implements Serializable {
-  private Integer requestId;
+  private Long requestId;
 
   @Id
   @Column(name = "request_id")
-  public Integer getRequestId() {
+  public Long getRequestId() {
     return requestId;
   }
 
-  public void setRequestId(Integer requestId) {
+  public void setRequestId(Long requestId) {
     this.requestId = requestId;
   }
 
-  private Integer stageId;
+  private Long stageId;
 
   @Id
   @Column(name = "stage_id")
-  public Integer getStageId() {
+  public Long getStageId() {
     return stageId;
   }
 
-  public void setStageId(Integer stageId) {
+  public void setStageId(Long stageId) {
     this.stageId = stageId;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java Mon Oct 22 08:09:14 2012
@@ -181,8 +181,8 @@ public class CertificateManager {
     String passphraseSrvr = configs.getConfigsMap().get(Configuration.
         PASSPHRASE_KEY);
 
-    System.out.println(passphraseSrvr);
-    System.out.println(passphraseAgent);
+    LOG.info("Pass phrase Server " + passphraseSrvr);
+    LOG.info("Pass Phrase Agent" + passphraseAgent);
 
     if (!passphraseSrvr.equals(passphraseAgent)) {
       LOG.warn("Incorrect passphrase from agent");

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java Mon Oct 22 08:09:14 2012
@@ -19,6 +19,9 @@
 package org.apache.ambari.server.state;
 
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
+import org.apache.ambari.server.state.svccomphost.*;
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
 
 /**
  * Base class for all events that affect the ServiceComponentHost FSM
@@ -70,4 +73,31 @@ public abstract class ServiceComponentHo
     return opTimestamp;
   }
 
+  @JsonCreator
+  public static ServiceComponentHostEvent create(@JsonProperty("type") ServiceComponentHostEventType type,
+                                                 @JsonProperty("serviceComponentName") String serviceComponentName,
+                                                 @JsonProperty("hostName") String hostName, @JsonProperty("opTimestamp") long opTimestamp) {
+    switch (type) {
+      case HOST_SVCCOMP_INSTALL:
+        return new ServiceComponentHostInstallEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_OP_FAILED:
+        return new ServiceComponentHostOpFailedEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_OP_IN_PROGRESS:
+        return new ServiceComponentHostOpInProgressEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_OP_RESTART:
+        return new ServiceComponentHostOpRestartedEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_OP_SUCCEEDED:
+        return new ServiceComponentHostOpSucceededEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_START:
+        return new ServiceComponentHostStartEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_STOP:
+        return new ServiceComponentHostStopEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_UNINSTALL:
+        return new ServiceComponentHostUninstallEvent(serviceComponentName, hostName, opTimestamp);
+      case HOST_SVCCOMP_WIPEOUT:
+        return new ServiceComponentHostWipeoutEvent(serviceComponentName, hostName, opTimestamp);
+    }
+    return null;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java Mon Oct 22 08:09:14 2012
@@ -23,9 +23,9 @@ import java.util.List;
 
 public class ServiceInfo {
   private String name;
-  private String version;
-  private String user;
-  private String comment;
+    private String version;
+    private String user;
+    private String comment;
   private List<PropertyInfo> properties;
 
   public String getName() {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java Mon Oct 22 08:09:14 2012
@@ -116,4 +116,12 @@ public class StageUtils {
     InputStream is = new ByteArrayInputStream(json.getBytes());
     return mapper.readValue(is, ExecutionCommand.class);
   }
+
+  public static <T> T fromJson(String json, Class<T> clazz) throws IOException {
+    ObjectMapper mapper = new ObjectMapper();
+    mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+    mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
+    InputStream is = new ByteArrayInputStream(json.getBytes());
+    return mapper.readValue(is, clazz);
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/python/ambari-server-state/core-site.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/python/ambari-server-state/core-site.xml?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/python/ambari-server-state/core-site.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/python/ambari-server-state/core-site.xml Mon Oct 22 08:09:14 2012
@@ -60,7 +60,7 @@
     <property>
         <name>fs.default.name</name>
         <!-- cluster variant -->
-        <value>hdfs://hdp1.cybervisiontech.com.ua:8020</value>
+        <value>hdfs://hdp1:8020</value>
         <description>The name of the default file system. Either the
             literal string "local" or a host:port for NDFS.
         </description>
@@ -240,7 +240,7 @@
 
     <property>
         <name>hadoop.proxyuser.oozie.hosts</name>
-        <value>hdp1.cybervisiontech.com.ua</value>
+        <value>hdp1</value>
         <description>
             Proxy host for Hadoop.
         </description>
@@ -256,7 +256,7 @@
 
     <property>
         <name>hadoop.proxyuser.templeton.hosts</name>
-        <value>hdp1.cybervisiontech.com.ua</value>
+        <value>hdp1</value>
         <description>
             Proxy host for templeton.
         </description>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/Ambari-DDL.sql
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/Ambari-DDL.sql?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/Ambari-DDL.sql (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/Ambari-DDL.sql Mon Oct 22 08:09:14 2012
@@ -60,7 +60,7 @@ FOREIGN KEY(user_name, ldap_user) REFERE
 /* Overall clusters table - all created/managed clusters */
 CREATE TABLE Clusters
 (
-cluster_id SERIAL,
+cluster_id BIGSERIAL,
 cluster_name VARCHAR UNIQUE NOT NULL,
 desired_cluster_state VARCHAR DEFAULT '' NOT NULL,
 cluster_info VARCHAR DEFAULT '' NOT NULL,
@@ -90,14 +90,14 @@ PRIMARY KEY (host_name)
 /* Cluster Hosts mapping table */
 CREATE TABLE ClusterHostMapping
 (
-  cluster_id INTEGER references Clusters(cluster_id),
+  cluster_id BIGINT references Clusters(cluster_id),
   host_name VARCHAR references Hosts(host_name),
   PRIMARY KEY(cluster_id, host_name)
 );
 
 CREATE TABLE ClusterServices
 (
-cluster_id INTEGER NOT NULL references Clusters(cluster_id),
+cluster_id BIGINT NOT NULL references Clusters(cluster_id),
 service_name VARCHAR,
 service_enabled INTEGER DEFAULT '0' NOT NULL,
 PRIMARY KEY (cluster_id,service_name)
@@ -110,7 +110,7 @@ PRIMARY KEY (cluster_id,service_name)
 CREATE TABLE ServiceConfig
 (
 config_version SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
-cluster_id INTEGER NOT NULL,
+cluster_id BIGINT NOT NULL,
 service_name VARCHAR NOT NULL,
 config_snapshot VARCHAR DEFAULT '' NOT NULL,
 config_snapshot_time timestamp NOT NULL,
@@ -125,7 +125,7 @@ FOREIGN KEY (cluster_id, service_name) R
 CREATE TABLE ServiceComponentConfig
 (
 config_version SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
-cluster_id INTEGER NOT NULL,
+cluster_id BIGINT NOT NULL,
 service_name VARCHAR NOT NULL,
 component_name VARCHAR NOT NULL,
 config_snapshot VARCHAR DEFAULT '' NOT NULL,
@@ -138,7 +138,7 @@ FOREIGN KEY (cluster_id, service_name) R
 CREATE TABLE ServiceComponentHostConfig
 (
 config_version SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
-cluster_id INTEGER NOT NULL,
+cluster_id BIGINT NOT NULL,
 service_name VARCHAR NOT NULL,
 component_name VARCHAR NOT NULL,
 host_name VARCHAR NOT NULL references Hosts(host_name),
@@ -150,7 +150,7 @@ FOREIGN KEY (cluster_id, service_name) R
 
 CREATE TABLE ServiceDesiredState
 (
-cluster_id INTEGER,
+cluster_id BIGINT,
 service_name VARCHAR DEFAULT '' NOT NULL,
 desired_state VARCHAR DEFAULT '' NOT NULL,
 desired_host_role_mapping INTEGER DEFAULT '0' NOT NULL,
@@ -161,7 +161,7 @@ FOREIGN KEY (cluster_id, service_name) R
 
 CREATE TABLE HostComponentMapping /*HostRoleMapping*/
 (
-cluster_id INTEGER,
+cluster_id BIGINT,
 service_name VARCHAR DEFAULT '' NOT NULL,
 host_component_mapping_id SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
 host_component_mapping_snapshot VARCHAR DEFAULT '' NOT NULL,
@@ -172,7 +172,7 @@ FOREIGN KEY (cluster_id, service_name) R
 
 CREATE TABLE ClusterState
 (
-cluster_id INTEGER NOT NULL references Clusters(cluster_id),
+cluster_id BIGINT NOT NULL references Clusters(cluster_id),
 current_cluster_state VARCHAR DEFAULT '' NOT NULL,
 PRIMARY KEY (cluster_id)
 );
@@ -192,7 +192,7 @@ PRIMARY KEY (host_name)
 
 CREATE TABLE ServiceComponentDesiredState
 (
-cluster_id INTEGER references Clusters(cluster_id),
+cluster_id BIGINT references Clusters(cluster_id),
 service_name VARCHAR DEFAULT '' NOT NULL,
 component_name VARCHAR DEFAULT '' NOT NULL,
 desired_state VARCHAR DEFAULT '' NOT NULL,
@@ -204,7 +204,7 @@ FOREIGN KEY (cluster_id, service_name) R
 
 CREATE TABLE HostComponentState
 (
-cluster_id INTEGER,
+cluster_id BIGINT,
 service_name VARCHAR DEFAULT '' NOT NULL,
 host_name VARCHAR DEFAULT '' NOT NULL references Hosts(host_name),
 component_name VARCHAR DEFAULT '' NOT NULL,
@@ -217,7 +217,7 @@ FOREIGN KEY (cluster_id, service_name, c
 
 CREATE TABLE HostComponentDesiredState
 (
-cluster_id INTEGER,
+cluster_id BIGINT,
 service_name VARCHAR DEFAULT '' NOT NULL,
 host_name VARCHAR NOT NULL references Hosts(host_name),
 component_name VARCHAR DEFAULT '' NOT NULL,
@@ -230,18 +230,18 @@ FOREIGN KEY (cluster_id, service_name, c
 
 CREATE TABLE STAGE
 (
-   cluster_id INTEGER references Clusters(cluster_id),
-   request_id SERIAL,
-   stage_id INTEGER DEFAULT '0' NOT NULL,
+   cluster_id BIGINT references Clusters(cluster_id),
+   request_id BIGINT DEFAULT '0',
+   stage_id BIGINT DEFAULT '0' NOT NULL,
    log_info VARCHAR DEFAULT '' NOT NULL,
    PRIMARY KEY (request_id, stage_id)
 );
 
 CREATE TABLE HOST_ROLE_COMMAND
 (
-   task_id INTEGER DEFAULT '0' NOT NULL,
-   request_id INTEGER NOT NULL,
-   stage_id INTEGER NOT NULL,
+   task_id SERIAL NOT NULL,
+   request_id BIGINT NOT NULL,
+   stage_id BIGINT NOT NULL,
    host_name VARCHAR DEFAULT '' NOT NULL references Hosts(host_name),
    role VARCHAR DEFAULT '' NOT NULL,
    command VARCHAR DEFAULT '' NOT NULL,
@@ -252,7 +252,7 @@ CREATE TABLE HOST_ROLE_COMMAND
    std_out VARCHAR DEFAULT '' NOT NULL,
    start_time BIGINT DEFAULT -1 NOT NULL,
    last_attempt_time BIGINT DEFAULT -1 NOT NULL,
-   attempt_count INTEGER DEFAULT 0 NOT NULL,
+   attempt_count SMALLINT DEFAULT 0 NOT NULL,
    PRIMARY KEY (task_id),
    FOREIGN KEY (request_id, stage_id) REFERENCES STAGE(request_id, stage_id)
 );
@@ -260,15 +260,15 @@ CREATE TABLE HOST_ROLE_COMMAND
 CREATE TABLE EXECUTION_COMMAND
 (
    task_id INTEGER DEFAULT '0' NOT NULL references HOST_ROLE_COMMAND(task_id),
-   command bytea NOT NULL, /** Serialized ExecutionCommand **/
+   command VARCHAR NOT NULL, /** Serialized ExecutionCommand **/
    PRIMARY KEY(task_id)
 );
 
 
 CREATE TABLE ROLE_SUCCESS_CRITERIA
 (
-   request_id INTEGER NOT NULL,
-   stage_id INTEGER NOT NULL,
+   request_id BIGINT NOT NULL,
+   stage_id BIGINT NOT NULL,
    role VARCHAR DEFAULT '' NOT NULL,
    success_factor FLOAT DEFAULT 1,
    PRIMARY KEY(role, request_id, stage_id),
@@ -292,6 +292,7 @@ CREATE TABLE ROLE_SUCCESS_CRITERIA
 
 
 GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA ambari TO "ambari-server";
+GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA ambari TO "ambari-server";
 
 BEGIN;
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/META-INF/persistence.xml?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/META-INF/persistence.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/META-INF/persistence.xml Mon Oct 22 08:09:14 2012
@@ -77,8 +77,7 @@
       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
       <!--<property name="javax.persistence.jdbc.user" value="ambari-server"/>-->
       <!--<property name="javax.persistence.jdbc.password" value="bigdata"/>-->
+      <property name="eclipselink.orm.throw.exceptions" value="true"/>
     </properties>
   </persistence-unit>
-
-
 </persistence>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/db/newcerts/.gitignore
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/db/newcerts/.gitignore?rev=1400792&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/db/newcerts/.gitignore (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/db/newcerts/.gitignore Mon Oct 22 08:09:14 2012
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/repos/repoinfo.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/repos/repoinfo.xml?rev=1400792&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/repos/repoinfo.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/repos/repoinfo.xml Mon Oct 22 08:09:14 2012
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<reposinfo>
+    <repo>
+        <url>url</url>
+        <os>Centos 5</os>
+        <description>...</description>
+    </repo>
+    <repo>
+        <url>url</url>
+        <os>Centos 6</os>
+    </repo>
+</reposinfo>
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml?rev=1400792&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml Mon Oct 22 08:09:14 2012
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<metainfo>
+    <user>root</user>
+    <comment>This is comment for HDFS service</comment>
+    <version>1.0</version>
+</metainfo>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java?rev=1400792&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java Mon Oct 22 08:09:14 2012
@@ -0,0 +1,144 @@
+/**
+ * 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.actionmanager;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.agent.ActionQueue;
+import org.apache.ambari.server.agent.CommandReport;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.ExecutionCommandDAO;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
+import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
+import org.apache.ambari.server.utils.StageUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestActionDBAccessorImpl {
+  private static final Logger log = LoggerFactory.getLogger(TestActionDBAccessorImpl.class);
+
+  private long requestId = 23;
+  private long stageId = 31;
+  private String hostName = "host1";
+  private String clusterName = "cluster1";
+  private Injector injector;
+  ActionDBAccessor db;
+  ActionManager am;
+
+  @Inject
+  private Clusters clusters;
+  @Inject
+  private ExecutionCommandDAO executionCommandDAO;
+  @Inject
+  private HostRoleCommandDAO hostRoleCommandDAO;
+
+  @Before
+  public void setup() throws AmbariException {
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    injector.getInstance(GuiceJpaInitializer.class);
+    injector.injectMembers(this);
+    clusters.addHost(hostName);
+    clusters.getHost(hostName).persist();
+    clusters.addCluster(clusterName);
+    db = injector.getInstance(ActionDBAccessorImpl.class);
+    am = new ActionManager(5000, 1200000, new ActionQueue(), clusters, db);
+  }
+
+  @After
+  public void tearDown() throws AmbariException {
+    injector.getInstance(PersistService.class).stop();
+  }
+
+  @Test
+  public void testActionResponse() {
+    String hostname = "host1";
+    populateActionDB(db, hostname);
+    List<CommandReport> reports = new ArrayList<CommandReport>();
+    CommandReport cr = new CommandReport();
+    cr.setActionId(StageUtils.getActionId(requestId, stageId));
+    cr.setRole("HBASE_MASTER");
+    cr.setStatus("COMPLETED");
+    cr.setStdErr("");
+    cr.setStdOut("");
+    cr.setExitCode(215);
+    reports.add(cr);
+    am.actionResponse(hostname, reports);
+    assertEquals(215,
+        am.getAction(requestId, stageId).getExitCode(hostname, "HBASE_MASTER"));
+    assertEquals(HostRoleStatus.COMPLETED, am.getAction(requestId, stageId)
+        .getHostRoleStatus(hostname, "HBASE_MASTER"));
+  }
+
+  @Test
+  public void testPersistActions() {
+    populateActionDB(db, hostName);
+    for (Stage stage : db.getAllStages(requestId)) {
+      log.info("taskId={}", stage.getExecutionCommands(hostName).get(0).getTaskId());
+      assertTrue(stage.getExecutionCommands(hostName).get(0).getTaskId() != -1);
+      log.info(executionCommandDAO.findByPK(stage.getExecutionCommands(hostName).get(0).getTaskId()).getCommand());
+    }
+  }
+
+  @Test
+  public void testHostRoleScheduled() {
+    populateActionDB(db, hostName);
+    Stage stage = db.getAction(StageUtils.getActionId(requestId, stageId));
+    assertEquals(HostRoleStatus.PENDING, stage.getHostRoleStatus(hostName, Role.HBASE_MASTER.toString()));
+    List<HostRoleCommandEntity> entities=
+        hostRoleCommandDAO.findByHostRole(hostName, requestId, stageId, Role.HBASE_MASTER);
+
+    assertEquals(HostRoleStatus.PENDING, entities.get(0).getStatus());
+    stage.setHostRoleStatus(hostName, Role.HBASE_MASTER.toString(), HostRoleStatus.QUEUED);
+
+    entities = hostRoleCommandDAO.findByHostRole(hostName, requestId, stageId, Role.HBASE_MASTER);
+    assertEquals(HostRoleStatus.QUEUED, stage.getHostRoleStatus(hostName, Role.HBASE_MASTER.toString()));
+    assertEquals(HostRoleStatus.PENDING, entities.get(0).getStatus());
+    db.hostRoleScheduled(stage, hostName, Role.HBASE_MASTER.toString());
+
+    entities = hostRoleCommandDAO.findByHostRole(hostName, requestId, stageId, Role.HBASE_MASTER);
+    assertEquals(HostRoleStatus.QUEUED, entities.get(0).getStatus());
+  }
+
+  private void populateActionDB(ActionDBAccessor db, String hostname) {
+    Stage s = new Stage(requestId, "/a/b", "cluster1");
+    s.setStageId(stageId);
+    s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
+        RoleCommand.START,
+        new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
+            hostname, System.currentTimeMillis()), "cluster1", "HBASE");
+    List<Stage> stages = new ArrayList<Stage>();
+    stages.add(s);
+    db.persistActions(stages);
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java Mon Oct 22 08:09:14 2012
@@ -23,15 +23,14 @@ import com.google.inject.Injector;
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
 import com.google.inject.persist.Transactional;
-import org.apache.ambari.server.orm.dao.ClusterDAO;
-import org.apache.ambari.server.orm.dao.RoleDAO;
-import org.apache.ambari.server.orm.dao.UserDAO;
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.orm.dao.*;
 import org.apache.ambari.server.orm.entities.*;
 import org.apache.ambari.server.state.HostState;
 import org.springframework.security.crypto.password.PasswordEncoder;
 
 import javax.persistence.EntityManager;
-import javax.persistence.Query;
 import java.util.*;
 
 @Singleton
@@ -143,15 +142,54 @@ public class OrmTestHelper {
     getEntityManager().getTransaction().setRollbackOnly();
   }
 
-  public int getClusterSizeByHostName(String hostName) {
-
-    Query query = getEntityManager().createQuery(
-            "SELECT host2 from HostEntity host join host.clusterEntities clusters join clusters.hostEntities host2 where host.hostName=:hostName");
-    query.setParameter("hostName", hostName);
-
-    Collection hosts = query.getResultList();
+  @Transactional
+  public void createStageCommands() {
+    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
+    StageDAO stageDAO = injector.getInstance(StageDAO.class);
+    HostRoleCommandDAO hostRoleCommandDAO = injector.getInstance(HostRoleCommandDAO.class);
+    HostDAO hostDAO = injector.getInstance(HostDAO.class);
+    StageEntity stageEntity = new StageEntity();
+    stageEntity.setCluster(clusterDAO.findByName("test_cluster1"));
+    stageEntity.setRequestId(0L);
+    stageEntity.setStageId(0L);
+
+    HostRoleCommandEntity commandEntity = new HostRoleCommandEntity();
+    HostRoleCommandEntity commandEntity2 = new HostRoleCommandEntity();
+    HostRoleCommandEntity commandEntity3 = new HostRoleCommandEntity();
+    HostEntity host1 = hostDAO.findByName("test_host1");
+    HostEntity host2 = hostDAO.findByName("test_host2");
+    commandEntity.setHost(host1);
+    host1.getHostRoleCommandEntities().add(commandEntity);
+    commandEntity.setHostName("test_host1");
+    commandEntity.setCommand("cmd1");
+    commandEntity.setStatus(HostRoleStatus.QUEUED);
+    commandEntity.setRole(Role.DATANODE);
+    commandEntity2.setHost(host2);
+    host2.getHostRoleCommandEntities().add(commandEntity2);
+    commandEntity2.setCommand("cmd2");
+    commandEntity2.setRole(Role.NAMENODE);
+    commandEntity2.setStatus(HostRoleStatus.COMPLETED);
+    commandEntity3.setHost(host1);
+    host1.getHostRoleCommandEntities().add(commandEntity3);
+    commandEntity3.setCommand("cmd3");
+    commandEntity3.setRole(Role.SECONDARY_NAMENODE);
+    commandEntity3.setStatus(HostRoleStatus.IN_PROGRESS);
+    commandEntity.setStage(stageEntity);
+    commandEntity2.setStage(stageEntity);
+    commandEntity3.setStage(stageEntity);
+
+    stageEntity.setHostRoleCommands(new ArrayList<HostRoleCommandEntity>());
+    stageEntity.getHostRoleCommands().add(commandEntity);
+    stageEntity.getHostRoleCommands().add(commandEntity2);
+    stageEntity.getHostRoleCommands().add(commandEntity3);
+
+    stageDAO.create(stageEntity);
+    hostRoleCommandDAO.create(commandEntity3);
+    hostRoleCommandDAO.create(commandEntity);
+    hostRoleCommandDAO.create(commandEntity2);
+    hostDAO.merge(host1);
+    hostDAO.merge(host2);
 
-    return hosts.size();
   }
 
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java?rev=1400792&r1=1400791&r2=1400792&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java Mon Oct 22 08:09:14 2012
@@ -20,38 +20,39 @@ package org.apache.ambari.server.orm;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
-import com.google.inject.persist.jpa.JpaPersistModule;
-import org.apache.ambari.server.orm.dao.ClusterDAO;
-import org.apache.ambari.server.orm.dao.ClusterServiceDAO;
-import org.apache.ambari.server.orm.dao.ServiceConfigDAO;
-import org.apache.ambari.server.orm.entities.ClusterEntity;
-import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
-import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import com.google.inject.persist.PersistService;
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.orm.dao.*;
+import org.apache.ambari.server.orm.entities.*;
+import org.junit.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
 import javax.persistence.RollbackException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
 public class TestOrmImpl extends Assert {
-  private final static Log log = LogFactory.getLog(TestOrmImpl.class);
+  private static final Logger log = LoggerFactory.getLogger(TestOrmImpl.class);
 
   private static Injector injector;
 
-  @BeforeClass
-  public static void setUpClass() throws Exception {
-    injector = Guice.createInjector(new JpaPersistModule("ambari-javadb")); //used for injecting in-memory DB EntityManager
-//    injector = Guice.createInjector(new JpaPersistModule("ambari-postgres")); //for injecting
-    injector.getInstance(GuiceJpaInitializer.class); //needed by Guice-persist to work
+  @Before
+  public void setup() {
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    injector.getInstance(GuiceJpaInitializer.class);
     injector.getInstance(OrmTestHelper.class).createDefaultData();
   }
 
+  @After
+  public void teardown() {
+    injector.getInstance(PersistService.class).stop();
+  }
+
   /**
    * persistence provider is responsible for returning empty collection if relation doesn't exists
    */
@@ -184,4 +185,53 @@ public class TestOrmImpl extends Assert 
     clusterServiceDAO.remove(clusterServiceEntity);
   }
 
+  @Test
+  public void testSortedCommands() {
+    injector.getInstance(OrmTestHelper.class).createStageCommands();
+    HostRoleCommandDAO hostRoleCommandDAO = injector.getInstance(HostRoleCommandDAO.class);
+    HostDAO hostDAO = injector.getInstance(HostDAO.class);
+    StageDAO stageDAO = injector.getInstance(StageDAO.class);
+
+    List<HostRoleCommandEntity> list =
+        hostRoleCommandDAO.findSortedCommandsByStageAndHost(
+            stageDAO.findByActionId("0-0"), hostDAO.findByName("test_host1"));
+    log.info("command '{}' - taskId '{}'", list.get(0).getCommand(), list.get(0).getTaskId());
+    log.info("command '{}' - taskId '{}'", list.get(1).getCommand(), list.get(1).getTaskId());
+    assertTrue(list.get(0).getTaskId() < list.get(1).getTaskId());
+  }
+
+  @Test
+  public void testFindHostsByStage() {
+    injector.getInstance(OrmTestHelper.class).createStageCommands();
+    HostDAO hostDAO = injector.getInstance(HostDAO.class);
+    StageDAO stageDAO = injector.getInstance(StageDAO.class);
+    StageEntity stageEntity = stageDAO.findByActionId("0-0");
+    log.info("StageEntity {} {}", stageEntity.getRequestId(), stageEntity.getStageId());
+    List<HostEntity> hosts = hostDAO.findByStage(stageEntity);
+    assertEquals(2, hosts.size());
+  }
+
+  @Test
+  public void testAbortHostRoleCommands() {
+    injector.getInstance(OrmTestHelper.class).createStageCommands();
+    HostRoleCommandDAO hostRoleCommandDAO = injector.getInstance(HostRoleCommandDAO.class);
+    int result = hostRoleCommandDAO.updateStatusByRequestId(0L, HostRoleStatus.ABORTED, Arrays.asList(HostRoleStatus.QUEUED, HostRoleStatus.IN_PROGRESS, HostRoleStatus.PENDING));
+    assertEquals(2, result);
+  }
+
+  @Test
+  public void testFindStageByHostRole() {
+    injector.getInstance(OrmTestHelper.class).createStageCommands();
+    HostRoleCommandDAO hostRoleCommandDAO = injector.getInstance(HostRoleCommandDAO.class);
+    List<HostRoleCommandEntity> list = hostRoleCommandDAO.findByHostRole("test_host1", 0L, 0L, Role.DATANODE);
+    assertEquals(1, list.size());
+  }
+
+  @Test
+  public void testLastRequestId() {
+    injector.getInstance(OrmTestHelper.class).createStageCommands();
+    StageDAO stageDAO = injector.getInstance(StageDAO.class);
+    assertEquals(0L, stageDAO.getLastRequestId());
+  }
+
 }



Mime
View raw message