You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/10/22 09:44:07 UTC

svn commit: r1400790 [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-hcat-old/manif...

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,56 @@
+/*
+ * 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.HostRoleCommandEntity;
+
+import javax.persistence.EntityManager;
+
+public class HostRoleCommandDAO {
+
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+
+  public HostRoleCommandEntity findByPK(int taskId) {
+    return entityManagerProvider.get().find(HostRoleCommandEntity.class, taskId);
+  }
+
+  @Transactional
+  public void create(HostRoleCommandEntity stageEntity) {
+    entityManagerProvider.get().persist(stageEntity);
+  }
+
+  @Transactional
+  public HostRoleCommandEntity merge(HostRoleCommandEntity stageEntity) {
+    return entityManagerProvider.get().merge(stageEntity);
+  }
+
+  @Transactional
+  public void remove(HostRoleCommandEntity stageEntity) {
+    entityManagerProvider.get().remove(stageEntity);
+  }
+
+  @Transactional
+  public void removeByPK(int taskId) {
+    remove(findByPK(taskId));
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RoleSuccessCriteriaDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RoleSuccessCriteriaDAO.java?rev=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RoleSuccessCriteriaDAO.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RoleSuccessCriteriaDAO.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.RoleSuccessCriteriaEntity;
+import org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntityPK;
+
+import javax.persistence.EntityManager;
+
+public class RoleSuccessCriteriaDAO {
+
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+
+  public RoleSuccessCriteriaEntity findByPK(RoleSuccessCriteriaEntityPK roleSuccessCriteriaEntityPK) {
+    return entityManagerProvider.get().find(RoleSuccessCriteriaEntity.class, roleSuccessCriteriaEntityPK);
+  }
+
+  @Transactional
+  public void create(RoleSuccessCriteriaEntity stageEntity) {
+    entityManagerProvider.get().persist(stageEntity);
+  }
+
+  @Transactional
+  public RoleSuccessCriteriaEntity merge(RoleSuccessCriteriaEntity stageEntity) {
+    return entityManagerProvider.get().merge(stageEntity);
+  }
+
+  @Transactional
+  public void remove(RoleSuccessCriteriaEntity stageEntity) {
+    entityManagerProvider.get().remove(stageEntity);
+  }
+
+  @Transactional
+  public void removeByPK(RoleSuccessCriteriaEntityPK roleSuccessCriteriaEntityPK) {
+    remove(findByPK(roleSuccessCriteriaEntityPK));
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,58 @@
+/*
+ * 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.StageEntity;
+import org.apache.ambari.server.orm.entities.StageEntityPK;
+
+import javax.persistence.EntityManager;
+
+public class StageDAO {
+
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+
+  public StageEntity findByPK(StageEntityPK stageEntityPK) {
+    return entityManagerProvider.get().find(StageEntity.class, stageEntityPK);
+  }
+
+  @Transactional
+  public void create(StageEntity stageEntity) {
+    entityManagerProvider.get().persist(stageEntity);
+  }
+
+  @Transactional
+  public StageEntity merge(StageEntity stageEntity) {
+    return entityManagerProvider.get().merge(stageEntity);
+  }
+
+  @Transactional
+  public void remove(StageEntity stageEntity) {
+    entityManagerProvider.get().remove(stageEntity);
+  }
+
+  @Transactional
+  public void removeByPK(StageEntityPK stageEntityPK) {
+    remove(findByPK(stageEntityPK));
+  }
+
+}

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=1400790&r1=1400789&r2=1400790&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 07:44:06 2012
@@ -107,17 +107,6 @@ public class ClusterEntity {
     return result;
   }
 
-  private Collection<ActionStatusEntity> actionStatusEntities;
-
-  @OneToMany(mappedBy = "clusterEntity")
-  public Collection<ActionStatusEntity> getActionStatusEntities() {
-    return actionStatusEntities;
-  }
-
-  public void setActionStatusEntities(Collection<ActionStatusEntity> actionStatusEntities) {
-    this.actionStatusEntities = actionStatusEntities;
-  }
-
   private Collection<ClusterServiceEntity> clusterServiceEntities;
 
   @OneToMany(mappedBy = "clusterEntity")
@@ -150,4 +139,15 @@ public class ClusterEntity {
   public void setHostEntities(Collection<HostEntity> hostEntities) {
     this.hostEntities = hostEntities;
   }
+
+  private Collection<StageEntity> stages;
+
+  @OneToMany(mappedBy = "cluster")
+  public Collection<StageEntity> getStages() {
+    return stages;
+  }
+
+  public void setStages(Collection<StageEntity> stages) {
+    this.stages = stages;
+  }
 }

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,82 @@
+/*
+ * 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.entities;
+
+import javax.persistence.*;
+import java.util.Arrays;
+
+@Table(name = "execution_command", schema = "ambari", catalog = "")
+@Entity
+public class ExecutionCommandEntity {
+  private Integer taskId;
+
+  @Column(name = "task_id", insertable = false, updatable = false, nullable = false)
+  @Id
+  public Integer getTaskId() {
+    return taskId;
+  }
+
+  public void setTaskId(Integer taskId) {
+    this.taskId = taskId;
+  }
+
+  private byte[] command;
+
+  @Column(name = "command")
+  @Basic
+  public byte[] getCommand() {
+    return command;
+  }
+
+  public void setCommand(byte[] command) {
+    this.command = command;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ExecutionCommandEntity that = (ExecutionCommandEntity) o;
+
+    if (!Arrays.equals(command, that.command)) return false;
+    if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = taskId != null ? taskId.hashCode() : 0;
+    result = 31 * result + (command != null ? Arrays.hashCode(command) : 0);
+    return result;
+  }
+
+  private HostRoleCommandEntity hostRoleCommand;
+
+  @OneToOne
+  @JoinColumn(name = "task_id", referencedColumnName = "task_id", nullable = false)
+  public HostRoleCommandEntity getHostRoleCommand() {
+    return hostRoleCommand;
+  }
+
+  public void setHostRoleCommand(HostRoleCommandEntity hostRoleCommandByTaskId) {
+    this.hostRoleCommand = hostRoleCommandByTaskId;
+  }
+}

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=1400790&r1=1400789&r2=1400790&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 07:44:06 2012
@@ -236,17 +236,6 @@ public class HostEntity {
     return result;
   }
 
-  private Collection<ActionStatusEntity> actionStatusEntities;
-
-  @OneToMany(mappedBy = "hostEntity")
-  public Collection<ActionStatusEntity> getActionStatusEntities() {
-    return actionStatusEntities;
-  }
-
-  public void setActionStatusEntities(Collection<ActionStatusEntity> actionStatusEntities) {
-    this.actionStatusEntities = actionStatusEntities;
-  }
-
   private Collection<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities;
 
   @OneToMany(mappedBy = "hostEntity")

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,273 @@
+/*
+ * 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.entities;
+
+import javax.persistence.*;
+
+@Table(name = "host_role_command", schema = "ambari", catalog = "")
+@Entity
+public class HostRoleCommandEntity {
+  private Integer taskId;
+
+  @Column(name = "task_id")
+  @Id
+  public Integer getTaskId() {
+    return taskId;
+  }
+
+  public void setTaskId(Integer taskId) {
+    this.taskId = taskId;
+  }
+
+  private Integer requestId;
+
+  @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
+  @Basic
+  public Integer getRequestId() {
+    return requestId;
+  }
+
+  public void setRequestId(Integer requestId) {
+    this.requestId = requestId;
+  }
+
+  private Integer stageId;
+
+  @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
+  @Basic
+  public Integer getStageId() {
+    return stageId;
+  }
+
+  public void setStageId(Integer stageId) {
+    this.stageId = stageId;
+  }
+
+  private String hostName;
+
+  @Column(name = "host_name", insertable = false, updatable = false, nullable = false)
+  @Basic
+  public String getHostName() {
+    return hostName;
+  }
+
+  public void setHostName(String hostName) {
+    this.hostName = hostName;
+  }
+
+  private String role = "";
+
+  @Column(name = "role", nullable = false)
+  @Basic
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole(String role) {
+    this.role = role;
+  }
+
+  private String command = "";
+
+  @Column(name = "command", nullable = false)
+  @Basic
+  public String getCommand() {
+    return command;
+  }
+
+  public void setCommand(String command) {
+    this.command = command;
+  }
+
+  private String event = "";
+
+  @Column(name = "event", nullable = false)
+  @Basic
+  public String getEvent() {
+    return event;
+  }
+
+  public void setEvent(String event) {
+    this.event = event;
+  }
+
+  private Integer exitcode = 0;
+
+  @Column(name = "exitcode", nullable = false)
+  @Basic
+  public Integer getExitcode() {
+    return exitcode;
+  }
+
+  public void setExitcode(Integer exitcode) {
+    this.exitcode = exitcode;
+  }
+
+  private String status = "";
+
+  @Column(name = "status", nullable = false)
+  @Basic
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  private String stdError = "";
+
+  @Column(name = "std_error", nullable = false)
+  @Basic
+  public String getStdError() {
+    return stdError;
+  }
+
+  public void setStdError(String stdError) {
+    this.stdError = stdError;
+  }
+
+  private String stdOut = "";
+
+  @Column(name = "std_out", nullable = false)
+  @Basic
+  public String getStdOut() {
+    return stdOut;
+  }
+
+  public void setStdOut(String stdOut) {
+    this.stdOut = stdOut;
+  }
+
+  private Long startTime = -1L;
+
+  @Column(name = "start_time", nullable = false)
+  @Basic
+  public Long getStartTime() {
+    return startTime;
+  }
+
+  public void setStartTime(Long startTime) {
+    this.startTime = startTime;
+  }
+
+  private Long lastAttemptTime = -1L;
+
+  @Column(name = "last_attempt_time", nullable = false)
+  @Basic
+  public Long getLastAttemptTime() {
+    return lastAttemptTime;
+  }
+
+  public void setLastAttemptTime(Long lastAttemptTime) {
+    this.lastAttemptTime = lastAttemptTime;
+  }
+
+  private Integer attemptCount = 0;
+
+  @Column(name = "attempt_count", nullable = false)
+  @Basic
+  public Integer getAttemptCount() {
+    return attemptCount;
+  }
+
+  public void setAttemptCount(Integer attemptCount) {
+    this.attemptCount = attemptCount;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    HostRoleCommandEntity that = (HostRoleCommandEntity) o;
+
+    if (attemptCount != null ? !attemptCount.equals(that.attemptCount) : that.attemptCount != null) return false;
+    if (command != null ? !command.equals(that.command) : that.command != null) return false;
+    if (event != null ? !event.equals(that.event) : that.event != null) return false;
+    if (exitcode != null ? !exitcode.equals(that.exitcode) : that.exitcode != null) return false;
+    if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
+    if (lastAttemptTime != null ? !lastAttemptTime.equals(that.lastAttemptTime) : that.lastAttemptTime != 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 (startTime != null ? !startTime.equals(that.startTime) : that.startTime != null) return false;
+    if (status != null ? !status.equals(that.status) : that.status != null) return false;
+    if (stdError != null ? !stdError.equals(that.stdError) : that.stdError != null) return false;
+    if (stdOut != null ? !stdOut.equals(that.stdOut) : that.stdOut != null) return false;
+    if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = taskId != null ? taskId.hashCode() : 0;
+    result = 31 * result + (requestId != null ? requestId.hashCode() : 0);
+    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
+    result = 31 * result + (role != null ? role.hashCode() : 0);
+    result = 31 * result + (command != null ? command.hashCode() : 0);
+    result = 31 * result + (event != null ? event.hashCode() : 0);
+    result = 31 * result + (exitcode != null ? exitcode.hashCode() : 0);
+    result = 31 * result + (status != null ? status.hashCode() : 0);
+    result = 31 * result + (stdError != null ? stdError.hashCode() : 0);
+    result = 31 * result + (stdOut != null ? stdOut.hashCode() : 0);
+    result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
+    result = 31 * result + (lastAttemptTime != null ? lastAttemptTime.hashCode() : 0);
+    result = 31 * result + (attemptCount != null ? attemptCount.hashCode() : 0);
+    return result;
+  }
+
+  private ExecutionCommandEntity executionCommand;
+
+  @OneToOne(mappedBy = "hostRoleCommand")
+  public ExecutionCommandEntity getExecutionCommand() {
+    return executionCommand;
+  }
+
+  public void setExecutionCommand(ExecutionCommandEntity executionCommandsByTaskId) {
+    this.executionCommand = executionCommandsByTaskId;
+  }
+
+  private StageEntity stage;
+
+  @ManyToOne
+  @JoinColumns({@JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false), @JoinColumn(name = "stage_id", referencedColumnName = "stage_id", nullable = false)})
+  public StageEntity getStage() {
+    return stage;
+  }
+
+  public void setStage(StageEntity stage) {
+    this.stage = stage;
+  }
+
+  private HostEntity host;
+
+  @ManyToOne
+  @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false)
+  public HostEntity getHost() {
+    return host;
+  }
+
+  public void setHost(HostEntity host) {
+    this.host = host;
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntity.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,110 @@
+/*
+ * 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.entities;
+
+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;
+
+  @Column(name = "request_id", insertable = false, updatable = false, nullable = false)
+  @Id
+  public Integer getRequestId() {
+    return requestId;
+  }
+
+  public void setRequestId(Integer requestId) {
+    this.requestId = requestId;
+  }
+
+  private Integer stageId;
+
+  @Column(name = "stage_id", insertable = false, updatable = false, nullable = false)
+  @Id
+  public Integer getStageId() {
+    return stageId;
+  }
+
+  public void setStageId(Integer stageId) {
+    this.stageId = stageId;
+  }
+
+  private String role;
+
+  @Column(name = "role")
+  @Id
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole(String role) {
+    this.role = role;
+  }
+
+  private Double successFactor = 1d;
+
+  @Column(name = "success_factor", nullable = false)
+  @Basic
+  public Double getSuccessFactor() {
+    return successFactor;
+  }
+
+  public void setSuccessFactor(Double successFactor) {
+    this.successFactor = successFactor;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    RoleSuccessCriteriaEntity that = (RoleSuccessCriteriaEntity) o;
+
+    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 (successFactor != null ? !successFactor.equals(that.successFactor) : that.successFactor != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = requestId != null ? requestId.hashCode() : 0;
+    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    result = 31 * result + (role != null ? role.hashCode() : 0);
+    result = 31 * result + (successFactor != null ? successFactor.hashCode() : 0);
+    return result;
+  }
+
+  private StageEntity stage;
+
+  @ManyToOne
+  @JoinColumns({@JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false), @JoinColumn(name = "stage_id", referencedColumnName = "stage_id", nullable = false)})
+  public StageEntity getStage() {
+    return stage;
+  }
+
+  public void setStage(StageEntity stage) {
+    this.stage = stage;
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntityPK.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RoleSuccessCriteriaEntityPK.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,83 @@
+/*
+ * 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.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class RoleSuccessCriteriaEntityPK implements Serializable {
+  private Integer requestId;
+
+  @Id
+  @Column(name = "request_id")
+  public Integer getRequestId() {
+    return requestId;
+  }
+
+  public void setRequestId(Integer requestId) {
+    this.requestId = requestId;
+  }
+
+  private Integer stageId;
+
+  @Id
+  @Column(name = "stage_id")
+  public Integer getStageId() {
+    return stageId;
+  }
+
+  public void setStageId(Integer stageId) {
+    this.stageId = stageId;
+  }
+
+  private String role;
+
+  @Id
+  @Column(name = "role")
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole(String role) {
+    this.role = role;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    RoleSuccessCriteriaEntityPK that = (RoleSuccessCriteriaEntityPK) o;
+
+    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;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = requestId != null ? requestId.hashCode() : 0;
+    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    result = 31 * result + (role != null ? role.hashCode() : 0);
+    return result;
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,134 @@
+/*
+ * 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.entities;
+
+import javax.persistence.*;
+import java.util.Collection;
+
+@IdClass(org.apache.ambari.server.orm.entities.StageEntityPK.class)
+@Table(name = "stage", schema = "ambari", catalog = "")
+@Entity
+public class StageEntity {
+  private Integer clusterId;
+
+  @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
+  @Basic
+  public Integer getClusterId() {
+    return clusterId;
+  }
+
+  public void setClusterId(Integer clusterId) {
+    this.clusterId = clusterId;
+  }
+
+  private Integer requestId;
+
+  @Column(name = "request_id")
+  @Id
+  //TODO auto generated? @GeneratedValue(strategy = GenerationType.AUTO)
+  public Integer getRequestId() {
+    return requestId;
+  }
+
+  public void setRequestId(Integer requestId) {
+    this.requestId = requestId;
+  }
+
+  private Integer stageId = 0;
+
+  @Column(name = "stage_id", nullable = false)
+  @Id
+  public Integer getStageId() {
+    return stageId;
+  }
+
+  public void setStageId(Integer stageId) {
+    this.stageId = stageId;
+  }
+
+  private String logInfo = "";
+
+  @Column(name = "log_info", nullable = false)
+  @Basic
+  public String getLogInfo() {
+    return logInfo;
+  }
+
+  public void setLogInfo(String logInfo) {
+    this.logInfo = logInfo;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    StageEntity that = (StageEntity) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != 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 (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId != null ? clusterId.hashCode() : 0;
+    result = 31 * result + (requestId != null ? requestId.hashCode() : 0);
+    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    result = 31 * result + (logInfo != null ? logInfo.hashCode() : 0);
+    return result;
+  }
+
+  private ClusterEntity cluster;
+
+  @ManyToOne
+  @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")
+  public ClusterEntity getCluster() {
+    return cluster;
+  }
+
+  public void setCluster(ClusterEntity cluster) {
+    this.cluster = cluster;
+  }
+
+  private Collection<HostRoleCommandEntity> hostRoleCommands;
+
+  @OneToMany(mappedBy = "stage")
+  public Collection<HostRoleCommandEntity> getHostRoleCommands() {
+    return hostRoleCommands;
+  }
+
+  public void setHostRoleCommands(Collection<HostRoleCommandEntity> hostRoleCommands) {
+    this.hostRoleCommands = hostRoleCommands;
+  }
+
+  private Collection<RoleSuccessCriteriaEntity> roleSuccessCriterias;
+
+  @OneToMany(mappedBy = "stage")
+  public Collection<RoleSuccessCriteriaEntity> getRoleSuccessCriterias() {
+    return roleSuccessCriterias;
+  }
+
+  public void setRoleSuccessCriterias(Collection<RoleSuccessCriteriaEntity> roleSuccessCriterias) {
+    this.roleSuccessCriterias = roleSuccessCriterias;
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,69 @@
+/*
+ * 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.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class StageEntityPK implements Serializable {
+  private Integer requestId;
+
+  @Id
+  @Column(name = "request_id")
+  public Integer getRequestId() {
+    return requestId;
+  }
+
+  public void setRequestId(Integer requestId) {
+    this.requestId = requestId;
+  }
+
+  private Integer stageId;
+
+  @Id
+  @Column(name = "stage_id")
+  public Integer getStageId() {
+    return stageId;
+  }
+
+  public void setStageId(Integer stageId) {
+    this.stageId = stageId;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    StageEntityPK that = (StageEntityPK) o;
+
+    if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false;
+    if (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = requestId != null ? requestId.hashCode() : 0;
+    result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
+    return result;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java?rev=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.state;
+
+public class PropertyInfo {
+  private String name;
+  private String value;
+  private String description;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getValue() {
+    return value;
+  }
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java?rev=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,64 @@
+/**
+ * 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.state;
+
+public class RepositoryInfo {
+  private String url;
+  private String os;
+  private String description;
+//  private String gpgKey;
+
+  public String getUrl() {
+    return url;
+  }
+
+  public void setUrl(String url) {
+    this.url = url;
+  }
+
+//  public String getGpgKey() {
+//    return gpgKey;
+//  }
+//
+//  public void setGpgKey(String gpgKey) {
+//    this.gpgKey = gpgKey;
+//  }
+
+
+  public String getOs() {
+    return os;
+  }
+
+  public void setOs(String os) {
+    this.os = os;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  @Override
+  public String toString() {
+    return "url="+ url + "\tos="+os+"\tdescription="+ description;
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,83 @@
+/**
+ * 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.state;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ServiceInfo {
+  private String name;
+  private String version;
+  private String user;
+  private String comment;
+  private List<PropertyInfo> properties;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  public String getUser() {
+    return user;
+  }
+
+  public void setUser(String user) {
+    this.user = user;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+
+  public synchronized List<PropertyInfo> getProperties() {
+    if (properties == null) properties = new ArrayList<PropertyInfo>();
+    return properties;
+  }
+
+  public void setProperties(List<PropertyInfo> properties) {
+    this.properties = properties;
+  }
+
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append("Service name:" + name + "\nversion:" + version + "\nuser:" + user + "\ncomment:" + comment);
+//    if(properties != null)
+//    for (PropertyInfo property : properties) {
+//      sb.append("\tProperty name=" + property.getName() + "\nproperty value=" + property.getValue() + "\ndescription=" + property.getDescription());
+//    }
+    return sb.toString();
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java?rev=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java Mon Oct 22 07:44:06 2012
@@ -0,0 +1,83 @@
+/**
+ * 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.state;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class StackInfo {
+  private String name;
+  private String version;
+  private List<RepositoryInfo> repositories;
+  private List<ServiceInfo> services;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  public List<RepositoryInfo> getRepositories() {
+    if( repositories == null ) repositories = new ArrayList<RepositoryInfo>();
+    return repositories;
+  }
+
+  public void setRepositories(List<RepositoryInfo> repositories) {
+    this.repositories = repositories;
+  }
+
+  public synchronized List<ServiceInfo> getServices() {
+    if (services == null) services = new ArrayList<ServiceInfo>();
+    return services;
+  }
+
+  public void setServices(List<ServiceInfo> services) {
+    this.services = services;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Stack name:" + name + "\nversion:" + version );//TODO add repository
+    if (services != null) {
+      sb.append("\n\t\tService:");
+      for (ServiceInfo service : services) {
+        sb.append("\t\t" + service.toString());
+      }
+    }
+
+    if (repositories != null) {
+      sb.append("\n\t\tRepositories:");
+      for (RepositoryInfo repository : repositories) {
+        sb.append("\t\t" + repository.toString());
+      }
+    }
+
+    return sb.toString();
+  }
+}

Added: 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=1400790&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/Ambari-DDL.sql (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/Ambari-DDL.sql Mon Oct 22 07:44:06 2012
@@ -0,0 +1,313 @@
+/**
+ * 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.
+ */
+-- Schema: ambari
+
+DROP SCHEMA IF EXISTS ambari CASCADE;
+
+DROP ROLE IF EXISTS "ambari-server";
+
+CREATE ROLE "ambari-server" LOGIN ENCRYPTED PASSWORD 'bigdata';
+
+CREATE SCHEMA ambari
+  AUTHORIZATION "ambari-server";
+
+COMMENT ON SCHEMA ambari
+  IS 'test schema';
+
+SET search_path TO ambari;
+
+/* Table for storing user information*/
+CREATE TABLE Users
+(
+user_name VARCHAR,
+user_password VARCHAR,
+ldap_user boolean DEFAULT FALSE NOT NULL,
+create_time TIMESTAMP DEFAULT now() NOT NULL,
+PRIMARY KEY(user_name, ldap_user)
+);
+
+/*Table for storing roles list - can be dropped out if list of roles is predefined and limited on upper layer*/
+CREATE TABLE Roles
+(
+role_name VARCHAR PRIMARY KEY
+);
+
+/*Users - Roles mapping table*/
+CREATE TABLE user_roles
+(
+user_name VARCHAR,
+ldap_user boolean default false,
+role_name VARCHAR references Roles(role_name),
+PRIMARY KEY(user_name, ldap_user, role_name),
+FOREIGN KEY(user_name, ldap_user) REFERENCES Users(user_name, ldap_user)
+);
+
+/* Overall clusters table - all created/managed clusters */
+CREATE TABLE Clusters
+(
+cluster_id SERIAL,
+cluster_name VARCHAR UNIQUE NOT NULL,
+desired_cluster_state VARCHAR DEFAULT '' NOT NULL,
+cluster_info VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id)
+);
+
+/* All hosts for all clusters */
+CREATE TABLE Hosts
+(
+host_name VARCHAR NOT NULL,
+ipv4 VARCHAR UNIQUE,
+ipv6 VARCHAR UNIQUE,
+total_mem INTEGER DEFAULT '0' NOT NULL,
+cpu_count INTEGER DEFAULT '0' NOT NULL,
+cpu_info VARCHAR DEFAULT '' NOT NULL,
+os_arch VARCHAR DEFAULT '' NOT NULL,
+disks_info VARCHAR DEFAULT '' NOT NULL,
+os_info VARCHAR DEFAULT '' NOT NULL,
+os_type VARCHAR DEFAULT '' NOT NULL,
+discovery_status VARCHAR DEFAULT '' NOT NULL,
+last_registration_time INTEGER DEFAULT '0' NOT NULL,
+rack_info VARCHAR DEFAULT '/default-rack' NOT NULL,
+host_attributes VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (host_name)
+);
+
+/* Cluster Hosts mapping table */
+CREATE TABLE ClusterHostMapping
+(
+  cluster_id INTEGER 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),
+service_name VARCHAR,
+service_enabled INTEGER DEFAULT '0' NOT NULL,
+PRIMARY KEY (cluster_id,service_name)
+);
+
+/* Configs at a service level */
+/* This will be used in most scenarios for homogenous clusters */
+/* Snapshot is a blob for all properties and their values. There is no separate row for each property */
+/* A special service called AMBARI or GLOBAL can be leveraged for global level configs */
+CREATE TABLE ServiceConfig
+(
+config_version SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
+cluster_id INTEGER NOT NULL,
+service_name VARCHAR NOT NULL,
+config_snapshot VARCHAR DEFAULT '' NOT NULL,
+config_snapshot_time timestamp NOT NULL,
+PRIMARY KEY (config_version),
+FOREIGN KEY (cluster_id, service_name) REFERENCES ClusterServices(cluster_id, service_name)
+);
+
+/* Configs that are overridden at the component level */
+/* Combination of serviceconfig and servicecomponentconfig table 
+    defines the config for a given component. 
+    Absence of an entry implies the component’s configs are same as that of the overall service config */
+CREATE TABLE ServiceComponentConfig
+(
+config_version SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
+cluster_id INTEGER NOT NULL,
+service_name VARCHAR NOT NULL,
+component_name VARCHAR NOT NULL,
+config_snapshot VARCHAR DEFAULT '' NOT NULL,
+config_snapshot_time timestamp NOT NULL,
+PRIMARY KEY (config_version),
+FOREIGN KEY (cluster_id, service_name) REFERENCES ClusterServices(cluster_id, service_name)
+);
+
+/* For overridding configs on a per host level for heterogenous clusters */
+CREATE TABLE ServiceComponentHostConfig
+(
+config_version SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
+cluster_id INTEGER NOT NULL,
+service_name VARCHAR NOT NULL,
+component_name VARCHAR NOT NULL,
+host_name VARCHAR NOT NULL references Hosts(host_name),
+config_snapshot VARCHAR DEFAULT '' NOT NULL,
+config_snapshot_time timestamp NOT NULL,
+PRIMARY KEY (config_version),
+FOREIGN KEY (cluster_id, service_name) REFERENCES ClusterServices(cluster_id, service_name)
+);
+
+CREATE TABLE ServiceDesiredState
+(
+cluster_id INTEGER,
+service_name VARCHAR DEFAULT '' NOT NULL,
+desired_state VARCHAR DEFAULT '' NOT NULL,
+desired_host_role_mapping INTEGER DEFAULT '0' NOT NULL,
+desired_stack_version VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id, service_name),
+FOREIGN KEY (cluster_id, service_name) REFERENCES ClusterServices(cluster_id, service_name)
+);
+
+CREATE TABLE HostComponentMapping /*HostRoleMapping*/
+(
+cluster_id INTEGER,
+service_name VARCHAR DEFAULT '' NOT NULL,
+host_component_mapping_id SERIAL /*INTEGER NOT NULL AUTO_INCREMENT*/,
+host_component_mapping_snapshot VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id, service_name, host_component_mapping_id),
+FOREIGN KEY (cluster_id, service_name) REFERENCES ClusterServices(cluster_id, service_name)
+);
+
+
+CREATE TABLE ClusterState
+(
+cluster_id INTEGER NOT NULL references Clusters(cluster_id),
+current_cluster_state VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id)
+);
+
+CREATE TABLE HostState
+(
+/*cluster_id INTEGER references Clusters(cluster_id),*/
+host_name VARCHAR NOT NULL references Hosts(host_name),
+available_mem INTEGER DEFAULT '0' NOT NULL,
+last_heartbeat_time INTEGER DEFAULT '0' NOT NULL,
+agent_version VARCHAR DEFAULT '' NOT NULL,
+health_status VARCHAR,
+current_state VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (host_name)
+);
+
+
+CREATE TABLE ServiceComponentDesiredState
+(
+cluster_id INTEGER references Clusters(cluster_id),
+service_name VARCHAR DEFAULT '' NOT NULL,
+component_name VARCHAR DEFAULT '' NOT NULL,
+desired_state VARCHAR DEFAULT '' NOT NULL,
+desired_stack_version VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id,service_name,component_name),
+FOREIGN KEY (cluster_id, service_name) REFERENCES ClusterServices(cluster_id, service_name)
+);
+
+
+CREATE TABLE HostComponentState
+(
+cluster_id INTEGER,
+service_name VARCHAR DEFAULT '' NOT NULL,
+host_name VARCHAR DEFAULT '' NOT NULL references Hosts(host_name),
+component_name VARCHAR DEFAULT '' NOT NULL,
+current_state VARCHAR DEFAULT '' NOT NULL,
+current_config_version VARCHAR DEFAULT '' NOT NULL,
+current_stack_version VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id, service_name, host_name, component_name),
+FOREIGN KEY (cluster_id, service_name, component_name) REFERENCES ServiceComponentDesiredState(cluster_id, service_name, component_name)
+);
+
+CREATE TABLE HostComponentDesiredState
+(
+cluster_id INTEGER,
+service_name VARCHAR DEFAULT '' NOT NULL,
+host_name VARCHAR NOT NULL references Hosts(host_name),
+component_name VARCHAR DEFAULT '' NOT NULL,
+desired_state VARCHAR DEFAULT '' NOT NULL,
+desired_config_version VARCHAR DEFAULT '' NOT NULL, /* desired config version defines a combined version of service/component/node-component config versions */
+desired_stack_version VARCHAR DEFAULT '' NOT NULL,
+PRIMARY KEY (cluster_id,host_name,component_name),
+FOREIGN KEY (cluster_id, service_name, component_name) REFERENCES ServiceComponentDesiredState(cluster_id, service_name, component_name)
+);
+
+CREATE TABLE STAGE
+(
+   cluster_id INTEGER references Clusters(cluster_id),
+   request_id SERIAL,
+   stage_id INTEGER 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,
+   host_name VARCHAR DEFAULT '' NOT NULL references Hosts(host_name),
+   role VARCHAR DEFAULT '' NOT NULL,
+   command VARCHAR DEFAULT '' NOT NULL,
+   event VARCHAR DEFAULT '' NOT NULL, /** Refer to ServiceComponentHostEventType.java */
+   exitCode INTEGER DEFAULT '0' NOT NULL,
+   status VARCHAR DEFAULT '' NOT NULL, /** PENDING, QUEUED, IN_PROGRESS, COMPLETED, FAILED, TIMEDOUT, ABORTED **/
+   std_error VARCHAR DEFAULT '' NOT NULL,
+   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,
+   PRIMARY KEY (task_id),
+   FOREIGN KEY (request_id, stage_id) REFERENCES STAGE(request_id, stage_id)
+);
+
+CREATE TABLE EXECUTION_COMMAND
+(
+   task_id INTEGER DEFAULT '0' NOT NULL references HOST_ROLE_COMMAND(task_id),
+   command bytea NOT NULL, /** Serialized ExecutionCommand **/
+   PRIMARY KEY(task_id)
+);
+
+
+CREATE TABLE ROLE_SUCCESS_CRITERIA
+(
+   request_id INTEGER NOT NULL,
+   stage_id INTEGER NOT NULL,
+   role VARCHAR DEFAULT '' NOT NULL,
+   success_factor FLOAT DEFAULT 1,
+   PRIMARY KEY(role, request_id, stage_id),
+   FOREIGN KEY (request_id, stage_id) REFERENCES STAGE(request_id, stage_id)
+);
+
+--CREATE TABLE ActionStatus 
+--(
+--cluster_id INTEGER references Clusters(cluster_id),
+--host_name VARCHAR DEFAULT '' NOT NULL references Hosts(host_name),
+--role VARCHAR DEFAULT '' NOT NULL,
+--request_id INTEGER DEFAULT '0' NOT NULL,
+--stage_id INTEGER DEFAULT '0' NOT NULL,
+--event VARCHAR DEFAULT '' NOT NULL,
+--task_id INTEGER DEFAULT '0' NOT NULL,
+--status VARCHAR DEFAULT '' NOT NULL, /* PENDING, QUEUED, COMPLETED, FAILED,, ABORTED */ 
+--log_info VARCHAR DEFAULT '' NOT NULL,
+--continue_criteria bytea /*BLOB*/ DEFAULT '' NOT NULL, /* Define continuation criteria for moving to next stage */
+--PRIMARY KEY (cluster_id, host_name, role, request_id, stage_id)
+--);
+
+
+GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA ambari TO "ambari-server";
+
+BEGIN;
+
+insert into Roles(role_name) 
+select 'admin'
+union all
+select 'user';
+
+insert into Users(user_name, user_password)
+select 'administrator','538916f8943ec225d97a9a86a2c6ec0818c1cd400e09e03b660fdaaec4af29ddbb6f2b1033b81b00'
+union all
+select 'test','d2f5da28bf8353e836fbae0a7f586b9cbda03f590910998957383371fbacba7e4088394991305ef8';
+
+insert into user_roles(user_name,role_name)
+select 'test','user'
+union all
+select 'administrator','admin';
+
+COMMIT;
\ No newline at end of file

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=1400790&r1=1400789&r2=1400790&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 07:44:06 2012
@@ -34,6 +34,10 @@
     <class>org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity</class>
     <class>org.apache.ambari.server.orm.entities.RoleEntity</class>
     <class>org.apache.ambari.server.orm.entities.UserEntity</class>
+    <class>org.apache.ambari.server.orm.entities.ExecutionCommandEntity</class>
+    <class>org.apache.ambari.server.orm.entities.HostRoleCommandEntity</class>
+    <class>org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntity</class>
+    <class>org.apache.ambari.server.orm.entities.StageEntity</class>
 
     <properties>
       <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/postgres"/>
@@ -60,6 +64,10 @@
     <class>org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity</class>
     <class>org.apache.ambari.server.orm.entities.RoleEntity</class>
     <class>org.apache.ambari.server.orm.entities.UserEntity</class>
+    <class>org.apache.ambari.server.orm.entities.ExecutionCommandEntity</class>
+    <class>org.apache.ambari.server.orm.entities.HostRoleCommandEntity</class>
+    <class>org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntity</class>
+    <class>org.apache.ambari.server.orm.entities.StageEntity</class>
 
     <properties>
       <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:myDB;create=true"/>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java?rev=1400790&r1=1400789&r2=1400790&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java Mon Oct 22 07:44:06 2012
@@ -36,6 +36,7 @@ import org.easymock.IArgumentMatcher;
 import org.junit.Assert;
 import org.junit.Test;
 
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
@@ -263,7 +264,9 @@ public class ResourceProviderImplTest {
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     TrackActionResponse response = createNiceMock(TrackActionResponse.class);
 
-    managementController.createService(Matchers.serviceRequest("Cluster100", "Service100", null, "DEPLOYED"));
+//    Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
+//    requests.add(Matchers.serviceRequest("Cluster100", "Service100", null, "DEPLOYED"));
+    managementController.createServices(anyObject(Set.class));
 
     // replay
     replay(managementController, response);
@@ -390,7 +393,7 @@ public class ResourceProviderImplTest {
     TrackActionResponse response = createNiceMock(TrackActionResponse.class);
 
     // set expectations
-    expect(managementController.updateService(Matchers.serviceRequest("Cluster100", "Service102", null, "DEPLOYED"))).andReturn(response).once();
+    expect(managementController.updateServices(anyObject(Set.class))).andReturn(response).once();
 
     // replay
     replay(managementController, response);