You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by hi...@apache.org on 2012/09/10 22:51:12 UTC
svn commit: r1383107 [1/2] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/
ambari-server/src/main/java/org/apache/ambari/controller/api/rest/
ambari-server/src/main/java/org/apache/amb...
Author: hitesh
Date: Mon Sep 10 20:51:10 2012
New Revision: 1383107
URL: http://svn.apache.org/viewvc?rev=1383107&view=rev
Log:
AMBARI-713. Initial work on Job FSM. (Contributed by hitesh)
Added:
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobCompletedEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEventType.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobFailedEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobId.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobImpl.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobProgressUpdateEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobState.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobType.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/NewJobEvent.java (with props)
Removed:
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEventType.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobId.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobState.java
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Role.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostAction.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ActionQueue.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/AgentCommand.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/NodeStatus.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/JobRequest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/Request.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigurationRequest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Clusters.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/DiskInfo.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNode.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java
Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Mon Sep 10 20:51:10 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
NEW FEATURES
+ AMBARI-713. Initial work on Job FSM. (hitesh)
+
AMBARI-712. Action manager skeleton. (jitendra)
AMBARI-710. Basic registration and heartbeat protocol implementation between
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java Mon Sep 10 20:51:10 2012
@@ -33,10 +33,10 @@ import org.apache.commons.logging.LogFac
import com.google.inject.Inject;
-/**
+/**
* Agent Resource represents Ambari agent controller.
* It provides API for Ambari agents to get the cluster configuration changes
- * as well as report the node attributes and state of services running the on
+ * as well as report the node attributes and state of services running the on
* the cluster nodes
*/
@Path("/")
@@ -50,7 +50,7 @@ public class AgentResource {
}
/**
- * Register information about the host (Internal API to be used for
+ * Register information about the host (Internal API to be used for
* Ambari Agent)
* @response.representation.200.doc This API is invoked by Ambari agent running
* on a cluster to register with the server.
@@ -58,37 +58,37 @@ public class AgentResource {
* @response.representation.406.doc Error in register message format
* @response.representation.408.doc Request Timed out
* @param message Register message
- * @throws Exception
+ * @throws Exception
*/
@Path("register/{hostName}")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public RegistrationResponse register(Register message,
- @Context HttpServletRequest req)
+ public RegistrationResponse register(Register message,
+ @Context HttpServletRequest req)
throws WebApplicationException {
LOG.info("Post input = " + req.toString());
RegistrationResponse response = new RegistrationResponse();
LOG.info("Received message from agent " + message.toString());
return response;
}
-
- /**
+
+ /**
* Update state of the node (Internal API to be used by Ambari agent).
- *
+ *
* @response.representation.200.doc This API is invoked by Ambari agent running
* on a cluster to update the state of various services running on the node.
* @response.representation.200.mediaType application/json
* @response.representation.406.doc Error in heartbeat message format
* @response.representation.408.doc Request Timed out
* @param message Heartbeat message
- * @throws Exception
+ * @throws Exception
*/
@Path("heartbeat/{hostname}")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public HeartBeatResponse heartbeat(HeartBeat message)
+ public HeartBeatResponse heartbeat(HeartBeat message)
throws WebApplicationException {
HeartBeatResponse heartBeatResponse = new HeartBeatResponse();
try {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java Mon Sep 10 20:51:10 2012
@@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlRoot
import javax.xml.bind.annotation.XmlType;
/**
- *
+ *
* Data model for Ambari Agent to send hardware profile to Ambari Server.
*
*/
@@ -114,16 +114,16 @@ public class HardwareProfile {
@XmlElement
private long uptime_days;
@XmlElement
- private long uptime_hours;
-
+ private long uptime_hours;
+
public long getUpTimeDays() {
return this.uptime_days;
}
-
+
public void setUpTimeDays(long uptime_days) {
this.uptime_days = uptime_days;
}
-
+
public String toString() {
return "memory=" + this.memorytotal + "\n" +
"uptime_hours=" + this.uptime_hours;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java Mon Sep 10 20:51:10 2012
@@ -26,13 +26,13 @@ import javax.xml.bind.annotation.XmlType
/**
- *
+ *
* Data model for Ambari Agent to send heartbeat to Ambari Controller.
*
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {"responseId","timestamp",
+@XmlType(name = "", propOrder = {"responseId","timestamp",
"hostname", "hardwareProfile", "installedRoleStates", "installScriptHash",
"actionResults", "firstContact", "idle"})
public class HeartBeat {
@@ -50,61 +50,61 @@ public class HeartBeat {
private boolean firstContact;
@XmlElement
private boolean idle;
-
+
public short getResponseId() {
return responseId;
}
-
+
public void setResponseId(short responseId) {
this.responseId=responseId;
}
-
+
public long getTimestamp() {
return timestamp;
}
-
+
public String getHostname() {
return hostname;
}
-
+
public boolean getFirstContact() {
return firstContact;
}
-
+
public boolean getIdle() {
return idle;
}
-
+
public HardwareProfile getHardwareProfile() {
return hardwareProfile;
}
-
-
+
+
public int getInstallScriptHash() {
return installScriptHash;
}
-
+
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
-
+
public void setHostname(String hostname) {
this.hostname = hostname;
}
-
+
public void setHardwareProfile(HardwareProfile hardwareProfile) {
- this.hardwareProfile = hardwareProfile;
+ this.hardwareProfile = hardwareProfile;
}
-
-
+
+
public void setFirstContact(boolean firstContact) {
this.firstContact = firstContact;
}
-
+
public void setIdle(boolean idle) {
this.idle = idle;
}
-
+
public void setInstallScriptHash(int hash) {
this.installScriptHash = hash;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java Mon Sep 10 20:51:10 2012
@@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlRoot
import javax.xml.bind.annotation.XmlType;
/**
- *
+ *
* Controller to Agent response data model.
*
*/
@@ -37,22 +37,22 @@ public class HeartBeatResponse {
public short responseId;
@XmlElement
public String clusterId;
-
+
public short getResponseId() {
return responseId;
}
-
+
public void setResponseId(short responseId) {
this.responseId=responseId;
}
-
+
public String getClusterId() {
return clusterId;
}
-
+
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
-
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java Mon Sep 10 20:51:10 2012
@@ -26,13 +26,13 @@ import javax.xml.bind.annotation.XmlType
/**
- *
+ *
* Data model for Ambari Agent to send heartbeat to Ambari Controller.
*
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {"responseId","timestamp",
+@XmlType(name = "", propOrder = {"responseId","timestamp",
"hostname", "hardwareProfile"})
public class Register {
@XmlElement
@@ -43,39 +43,39 @@ public class Register {
private String hostname;
@XmlElement
private HardwareProfile hardwareProfile;
-
+
public short getResponseId() {
return responseId;
}
-
+
public void setResponseId(short responseId) {
this.responseId=responseId;
}
-
+
public long getTimestamp() {
return timestamp;
}
-
+
public String getHostname() {
return hostname;
}
-
+
public HardwareProfile getHardwareProfile() {
return hardwareProfile;
}
-
+
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
-
+
public void setHostname(String hostname) {
this.hostname = hostname;
}
-
+
public void setHardwareProfile(HardwareProfile hardwareProfile) {
- this.hardwareProfile = hardwareProfile;
+ this.hardwareProfile = hardwareProfile;
}
-
+
@Override
public String toString() {
return "responseId=" + responseId + "\n" +
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java Mon Sep 10 20:51:10 2012
@@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlRoot
import javax.xml.bind.annotation.XmlType;
/**
- *
+ *
* Controller to Agent response data model.
*
*/
@@ -35,12 +35,12 @@ import javax.xml.bind.annotation.XmlType
public class RegistrationResponse {
@XmlElement
public short responseId;
-
+
public short getResponseId() {
return responseId;
}
-
+
public void setResponseId(short responseId) {
this.responseId=responseId;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java Mon Sep 10 20:51:10 2012
@@ -52,5 +52,5 @@ public class HealthCheck {
return "<html> " + "<title>" + "Status" + "</title>"
+ "<body><h1>" + status + "</body></h1>" + "</html> ";
}
-}
+}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Role.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Role.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Role.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Role.java Mon Sep 10 20:51:10 2012
@@ -19,7 +19,7 @@
package org.apache.ambari.server;
//This enumerates all the roles that the server can handle.
-//Each component or a job maps to a particular role.
+//Each component or a job maps to a particular role.
public enum Role {
ZOOKEEPER_SERVER,
ZOOKEEPER_CLIENT,
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostAction.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostAction.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostAction.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostAction.java Mon Sep 10 20:51:10 2012
@@ -25,7 +25,7 @@ public class HostAction {
private Map<String, String> params = null;
private String manifest = null;
private List<HostRoleCommand> roles;
-
+
public HostAction(String host) {
this.host = host;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java Mon Sep 10 20:51:10 2012
@@ -22,7 +22,7 @@ import java.util.Map;
import org.apache.ambari.server.Role;
import org.apache.ambari.server.RoleCommand;
-/**
+/**
* This class encapsulates all the information for an action
* on a host for a particular role. This class will be used to schedule, persist and track
* an action.
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java Mon Sep 10 20:51:10 2012
@@ -20,12 +20,12 @@ package org.apache.ambari.server.actionm
import java.util.List;
import java.util.Map;
-//This class encapsulates the stage. The stage encapsulates all the information
+//This class encapsulates the stage. The stage encapsulates all the information
//required to persist an action.
public class Stage {
private long requestId;
private long stageId = -1;
-
+
//Map of host to host-roles
private Map<String, HostAction> action;
private String logDir;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ActionQueue.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ActionQueue.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ActionQueue.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ActionQueue.java Mon Sep 10 20:51:10 2012
@@ -47,7 +47,7 @@ public class ActionQueue {
return q.remove();
}
}
-
+
public List<AgentCommand> dequeueAll(String hostname) {
Queue<AgentCommand> q = getQueue(hostname);
List<AgentCommand> l = new ArrayList<AgentCommand>();
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/AgentCommand.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/AgentCommand.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/AgentCommand.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/AgentCommand.java Mon Sep 10 20:51:10 2012
@@ -18,5 +18,5 @@
package org.apache.ambari.server.agentprotocol;
public class AgentCommand {
- private String commandId;
+ private String commandId;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java Mon Sep 10 20:51:10 2012
@@ -26,8 +26,8 @@ public class Heartbeat {
List<ComponentStatus> componentStatus;
NodeInfo nodeInfo;
NodeStatus nodeStatus;
-
+
public class NodeInfo {
-
+
}
-}
\ No newline at end of file
+}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/NodeStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/NodeStatus.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/NodeStatus.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/NodeStatus.java Mon Sep 10 20:51:10 2012
@@ -22,7 +22,7 @@ public class NodeStatus {
HEALTHY,
UNHEALTHY
}
-
+
Status status;
- String cause;
+ String cause;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java Mon Sep 10 20:51:10 2012
@@ -39,7 +39,7 @@ public class AmbariServer {
public static int CLIENT_PORT = 4080;
private Server server = null;
public volatile boolean running = true; // true while controller runs
-
+
public void run() {
server = new Server(CLIENT_PORT);
@@ -47,25 +47,25 @@ public class AmbariServer {
Context root = new Context(server, "/", Context.SESSIONS);
ServletHolder rootServlet = root.addServlet(DefaultServlet.class, "/");
rootServlet.setInitOrder(1);
-
+
ServletHolder sh = new ServletHolder(ServletContainer.class);
- sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
+ sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
- sh.setInitParameter("com.sun.jersey.config.property.packages",
+ sh.setInitParameter("com.sun.jersey.config.property.packages",
"org.apache.ambari.controller.api.rest");
root.addServlet(sh, "/api/*");
sh.setInitOrder(2);
ServletHolder agent = new ServletHolder(ServletContainer.class);
- agent.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
+ agent.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
- agent.setInitParameter("com.sun.jersey.config.property.packages",
+ agent.setInitParameter("com.sun.jersey.config.property.packages",
"org.apache.ambari.controller.agent.rest");
root.addServlet(agent, "/agent/*");
agent.setInitOrder(3);
-
+
server.setStopAtShutdown(true);
-
+
/*
* Start the server after controller state is recovered.
*/
@@ -75,10 +75,10 @@ public class AmbariServer {
LOG.info("Joined the Server");
} catch (Exception e) {
LOG.error("Error in the server", e);
-
+
}
}
-
+
public void stop() throws Exception {
try {
server.stop();
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java Mon Sep 10 20:51:10 2012
@@ -26,10 +26,10 @@ import java.util.Map;
*/
public class HostRequest extends Request {
private List<String> hosts;
-
- public HostRequest(long requestId, Request.Method m, List<String> hostList,
+
+ public HostRequest(long requestId, Request.Method m, List<String> hostList,
Map<String, String> params) {
super(requestId, m, params);
hosts = hostList;
- }
+ }
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/JobRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/JobRequest.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/JobRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/JobRequest.java Mon Sep 10 20:51:10 2012
@@ -29,7 +29,7 @@ public class JobRequest extends Request
final private String job;
final private String serviceName; //can be null if action is at host level
- final private List<String> hosts;
+ final private List<String> hosts;
public JobRequest(long requestId, Request.Method m, String job, String serviceName,
List<String> hosts, Map<String, String> params) {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/Request.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/Request.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/Request.java Mon Sep 10 20:51:10 2012
@@ -20,19 +20,19 @@ package org.apache.ambari.server.control
import java.util.Map;
public class Request {
-
+
public enum Method {
GET,
PUT,
POST,
DELETE
}
-
+
private long requestId;
private Map<String, String> params;
private Method method;
-
-
+
+
public Request(long requestId, Method m) {
this(requestId, m, null);
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigurationRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigurationRequest.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigurationRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigurationRequest.java Mon Sep 10 20:51:10 2012
@@ -27,9 +27,9 @@ import java.util.Map;
public class ServiceConfigurationRequest extends Request {
final private String clusterName;
final private String serviceName;
-
+
//The complete set of desired configurations can be derived as
- //properties corresponding to baseConfigVersion overridden with
+ //properties corresponding to baseConfigVersion overridden with
//desiredProperties.
final private String baseConfigVersion;
private Map<String, String> desiredProperties = null;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java Mon Sep 10 20:51:10 2012
@@ -31,16 +31,16 @@ public class ServiceRequest extends Requ
private String service;
private String configVersion;
private String hostComponentMapVersion;
-
+
public class ComponentRequest {
private String componentName;
private Map<String, String> params = new HashMap<String, String>();
}
-
+
public void addComponentRequest(ComponentRequest c) {
components.add(c);
}
-
+
public ServiceRequest(long requestId, Request.Method m, String clusterName,
String service, String configVersion, String hostComponentMapVersion) {
super(requestId, m);
@@ -49,6 +49,6 @@ public class ServiceRequest extends Requ
this.configVersion = configVersion;
this.hostComponentMapVersion = hostComponentMapVersion;
}
-
+
private List<ComponentRequest> components = new ArrayList<ComponentRequest>();
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java Mon Sep 10 20:51:10 2012
@@ -19,7 +19,7 @@
package org.apache.ambari.server.state.fsm;
/**
- * Exception thrown when a StateMachine encounters an invalid
+ * Exception thrown when a StateMachine encounters an invalid
* event at its current state.
*/
@SuppressWarnings("serial")
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java Mon Sep 10 20:51:10 2012
@@ -24,7 +24,7 @@ package org.apache.ambari.server.state.l
public class AgentVersion {
private final String version;
-
+
public AgentVersion(String version) {
this.version = version;
}
@@ -35,5 +35,5 @@ public class AgentVersion {
public String getVersion() {
return version;
}
-
-}
+
+}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java Mon Sep 10 20:51:10 2012
@@ -30,14 +30,14 @@ public interface Cluster {
* @return
*/
public NodeState getNodeState(String nodeName);
-
+
/**
* Set the State for a given Node
* @param nodeName Node's hostname for which state is to be set
* @param state NodeState to set
*/
public void setNodeState(String nodeName, NodeState state);
-
+
/**
* Send event to the given Node
* @param nodeName Node's hostname
@@ -45,7 +45,7 @@ public interface Cluster {
*/
public void handleNodeEvent(String nodeName, NodeEvent event)
throws InvalidStateTransitonException;
-
+
/**
* Get the State for a given ServiceComponentNode
* @param service Service name
@@ -77,5 +77,5 @@ public interface Cluster {
public void handleServiceComponentNodeEvent(String service,
String serviceComponent, String nodeName,
ServiceComponentNodeEvent event) throws InvalidStateTransitonException;
-
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Clusters.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Clusters.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Clusters.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Clusters.java Mon Sep 10 20:51:10 2012
@@ -26,5 +26,5 @@ public interface Clusters {
* @return
*/
public Cluster getCluster(String clusterName);
-
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/DiskInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/DiskInfo.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/DiskInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/DiskInfo.java Mon Sep 10 20:51:10 2012
@@ -44,7 +44,7 @@ public class DiskInfo {
* Capacity of the disk in bytes
*/
long totalCapacityBytes;
-
+
/**
* Current capacity in bytes
*/
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNode.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNode.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNode.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNode.java Mon Sep 10 20:51:10 2012
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.ambari.server.state.ConfigVersion;
import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
+import org.apache.ambari.server.state.live.job.Job;
public interface ServiceComponentNode {
@@ -31,14 +32,14 @@ public interface ServiceComponentNode {
* @return Name of the ServiceComponent
*/
public String getServiceComponentName();
-
+
/**
* Get the Node this object maps to
* @return Node's hostname
*/
public String getNodeName();
-
-
+
+
/**
* Get the Config Version
* @return ConfigVersion
@@ -51,8 +52,8 @@ public interface ServiceComponentNode {
* @return List of Jobs
*/
public List<Job> getJobs();
-
-
+
+
/**
* Get ServiceComponent-Node State
* @return ServiceComponentNodeState
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java Mon Sep 10 20:51:10 2012
@@ -35,7 +35,7 @@ public class ServiceComponentNodeEvent
* Hostname of the Node that this event relates to
*/
final String nodeName;
-
+
public ServiceComponentNodeEvent(ServiceComponentNodeEventType type,
String serviceComponentName, String nodeName) {
super(type);
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java Mon Sep 10 20:51:10 2012
@@ -24,6 +24,7 @@ import org.apache.ambari.server.state.Co
import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
import org.apache.ambari.server.state.fsm.StateMachine;
import org.apache.ambari.server.state.fsm.StateMachineFactory;
+import org.apache.ambari.server.state.live.job.Job;
public class ServiceComponentNodeImpl implements ServiceComponentNode {
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,75 @@
+/**
+ * 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.live.job;
+
+import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
+
+public interface Job {
+
+ /**
+ * Get the Job ID for the action
+ * @return JobId
+ */
+ public JobId getId();
+
+ // TODO requires some form of JobType to ensure only one running
+ // job per job type
+ // There may be gotchas such as de-commissioning should be allowed to happen
+ // on more than one node at a time
+
+
+ /**
+ * Get Start Time of the job
+ * @return Start time as a unix timestamp
+ */
+ public long getStartTime();
+
+ /**
+ * Get the last update time of the Job when its progress status
+ * was updated
+ * @return Last Update Time as a unix timestamp
+ */
+ public long getLastUpdateTime();
+
+ /**
+ * Time when the Job completed
+ * @return Completion Time as a unix timestamp
+ */
+ public long getCompletionTime();
+
+ /**
+ * Get the current state of the Job
+ * @return JobState
+ */
+ public JobState getState();
+
+ /**
+ * Set the State of the Job
+ * @param state JobState
+ */
+ public void setState(JobState state);
+
+ /**
+ * Send a JobEvent to the Job's StateMachine
+ * @param event JobEvent
+ * @throws InvalidStateTransitonException
+ */
+ public void handleEvent(JobEvent event)
+ throws InvalidStateTransitonException;
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobCompletedEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobCompletedEvent.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobCompletedEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobCompletedEvent.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,18 @@
+package org.apache.ambari.server.state.live.job;
+
+public class JobCompletedEvent extends JobEvent {
+
+ private final long completionTime;
+
+ public JobCompletedEvent(JobId jobId, long completionTime) {
+ super(JobEventType.JOB_COMPLETED, jobId);
+ this.completionTime = completionTime;
+ }
+
+ /**
+ * @return the completionTime
+ */
+ public long getCompletionTime() {
+ return completionTime;
+ }
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobCompletedEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.live.job;
+
+import org.apache.ambari.server.state.fsm.event.AbstractEvent;
+
+/**
+ * Base class for all events that affect the Job FSM
+ */
+public class JobEvent extends AbstractEvent<JobEventType> {
+
+ /**
+ * JobId identifying the job
+ */
+ private final JobId jobId;
+
+ public JobEvent(JobEventType type, JobId jobId) {
+ super(type);
+ this.jobId = jobId;
+ }
+
+ /**
+ * @return the jobId
+ */
+ public JobId getJobId() {
+ return jobId;
+ }
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEventType.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEventType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEventType.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.live.job;
+
+public enum JobEventType {
+ /**
+ * Initial state for the job when triggered.
+ */
+ JOB_INIT,
+ /**
+ * Job still in progress.
+ */
+ JOB_IN_PROGRESS,
+ /**
+ * Job completed successfully.
+ */
+ JOB_COMPLETED,
+ /**
+ * Job failed to complete successfully.
+ */
+ JOB_FAILED
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEventType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobFailedEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobFailedEvent.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobFailedEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobFailedEvent.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,21 @@
+package org.apache.ambari.server.state.live.job;
+
+public class JobFailedEvent extends JobEvent {
+
+ private final long completionTime;
+
+ // TODO
+ // need to add job failed reason
+
+ public JobFailedEvent(JobId jobId, long completionTime) {
+ super(JobEventType.JOB_FAILED, jobId);
+ this.completionTime = completionTime;
+ }
+
+ /**
+ * @return the completionTime
+ */
+ public long getCompletionTime() {
+ return completionTime;
+ }
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobFailedEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobId.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobId.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobId.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobId.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,35 @@
+/**
+ * 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.live.job;
+
+// TODO
+public class JobId {
+
+ final long jobId;
+
+ final JobType jobType;
+
+ public JobId(long jobId, JobType jobType) {
+ super();
+ this.jobId = jobId;
+ this.jobType = jobType;
+ }
+
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobId.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobImpl.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobImpl.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,295 @@
+/**
+ * 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.live.job;
+
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
+import org.apache.ambari.server.state.fsm.SingleArcTransition;
+import org.apache.ambari.server.state.fsm.StateMachine;
+import org.apache.ambari.server.state.fsm.StateMachineFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class JobImpl implements Job {
+
+ private static final Log LOG = LogFactory.getLog(JobImpl.class);
+
+ private final Lock readLock;
+ private final Lock writeLock;
+
+ private JobId id;
+
+ private long startTime;
+ private long lastUpdateTime;
+ private long completionTime;
+
+ // TODO
+ // need to add job failed reason
+
+ private static final StateMachineFactory
+ <JobImpl, JobState, JobEventType, JobEvent>
+ stateMachineFactory
+ = new StateMachineFactory<JobImpl, JobState,
+ JobEventType, JobEvent>
+ (JobState.INIT)
+
+ // define the state machine of a Job
+
+ .addTransition(JobState.INIT, JobState.IN_PROGRESS,
+ JobEventType.JOB_IN_PROGRESS, new JobProgressUpdateTransition())
+ .addTransition(JobState.IN_PROGRESS, JobState.IN_PROGRESS,
+ JobEventType.JOB_IN_PROGRESS, new JobProgressUpdateTransition())
+ .addTransition(JobState.IN_PROGRESS, JobState.COMPLETED,
+ JobEventType.JOB_COMPLETED, new JobCompletedTransition())
+ .addTransition(JobState.IN_PROGRESS, JobState.FAILED,
+ JobEventType.JOB_FAILED, new JobFailedTransition())
+ .addTransition(JobState.COMPLETED, JobState.INIT,
+ JobEventType.JOB_INIT, new NewJobTransition())
+ .addTransition(JobState.FAILED, JobState.INIT,
+ JobEventType.JOB_INIT, new NewJobTransition())
+ .installTopology();
+
+ private final StateMachine<JobState, JobEventType, JobEvent>
+ stateMachine;
+
+ public JobImpl(JobId id) {
+ super();
+ this.id = id;
+ this.stateMachine = stateMachineFactory.make(this);
+ ReadWriteLock rwLock = new ReentrantReadWriteLock();
+ this.readLock = rwLock.readLock();
+ this.writeLock = rwLock.writeLock();
+ startTime = -1;
+ lastUpdateTime = -1;
+ completionTime = -1;
+ }
+
+ static class NewJobTransition
+ implements SingleArcTransition<JobImpl, JobEvent> {
+
+ @Override
+ public void transition(JobImpl job, JobEvent event) {
+ NewJobEvent e = (NewJobEvent) event;
+ // TODO audit logs
+ job.setId(e.getJobId());
+ job.setStartTime(e.getStartTime());
+ LOG.info("Launching a new Job"
+ + ", jobId=" + job.getId()
+ + ", startTime=" + job.getStartTime());
+ }
+ }
+
+ static class JobProgressUpdateTransition
+ implements SingleArcTransition<JobImpl, JobEvent> {
+
+ @Override
+ public void transition(JobImpl job, JobEvent event) {
+ JobProgressUpdateEvent e = (JobProgressUpdateEvent) event;
+ job.setLastUpdateTime(e.getProgressUpdateTime());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Progress update for Job"
+ + ", jobId=" + job.getId()
+ + ", startTime=" + job.getStartTime()
+ + ", lastUpdateTime=" + job.getLastUpdateTime());
+ }
+ }
+ }
+
+ static class JobCompletedTransition
+ implements SingleArcTransition<JobImpl, JobEvent> {
+
+ @Override
+ public void transition(JobImpl job, JobEvent event) {
+ // TODO audit logs
+ JobCompletedEvent e = (JobCompletedEvent) event;
+ job.setCompletionTime(e.getCompletionTime());
+ job.setLastUpdateTime(e.getCompletionTime());
+
+ LOG.info("Job completed successfully"
+ + ", jobId=" + job.getId()
+ + ", startTime=" + job.getStartTime()
+ + ", completionTime=" + job.getCompletionTime());
+ }
+ }
+
+ static class JobFailedTransition
+ implements SingleArcTransition<JobImpl, JobEvent> {
+
+ @Override
+ public void transition(JobImpl job, JobEvent event) {
+ // TODO audit logs
+ JobFailedEvent e = (JobFailedEvent) event;
+ job.setCompletionTime(e.getCompletionTime());
+ job.setLastUpdateTime(e.getCompletionTime());
+ LOG.info("Job failed to complete"
+ + ", jobId=" + job.getId()
+ + ", startTime=" + job.getStartTime()
+ + ", completionTime=" + job.getCompletionTime());
+ }
+ }
+
+
+ @Override
+ public JobState getState() {
+ try {
+ readLock.lock();
+ return stateMachine.getCurrentState();
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setState(JobState state) {
+ try {
+ writeLock.lock();
+ stateMachine.setCurrentState(state);
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public void handleEvent(JobEvent event)
+ throws InvalidStateTransitonException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Handling Job event, eventType=" + event.getType().name()
+ + ", event=" + event.toString());
+ }
+ JobState oldState = getState();
+ try {
+ writeLock.lock();
+ try {
+ stateMachine.doTransition(event.getType(), event);
+ } catch (InvalidStateTransitonException e) {
+ LOG.error("Can't handle Job event at current state"
+ + ", jobId=" + this.getId()
+ + ", currentState=" + oldState
+ + ", eventType=" + event.getType()
+ + ", event=" + event);
+ throw e;
+ }
+ }
+ finally {
+ writeLock.unlock();
+ }
+ if (oldState != getState()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Job transitioned to a new state"
+ + ", jobId=" + this.getId()
+ + ", oldState=" + oldState
+ + ", currentState=" + getState()
+ + ", eventType=" + event.getType().name()
+ + ", event=" + event);
+ }
+ }
+ }
+
+ @Override
+ public JobId getId() {
+ try {
+ readLock.lock();
+ return id;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ private void setId(JobId id) {
+ try {
+ writeLock.lock();
+ this.id = id;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public long getStartTime() {
+ try {
+ readLock.lock();
+ return startTime;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ public void setStartTime(long startTime) {
+ try {
+ writeLock.lock();
+ this.startTime = startTime;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public long getLastUpdateTime() {
+ try {
+ readLock.lock();
+ return lastUpdateTime;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ public void setLastUpdateTime(long lastUpdateTime) {
+ try {
+ writeLock.lock();
+ this.lastUpdateTime = lastUpdateTime;
+ }
+ finally {
+ writeLock.unlock();
+ }
+
+ }
+
+ @Override
+ public long getCompletionTime() {
+ try {
+ readLock.lock();
+ return completionTime;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ public void setCompletionTime(long completionTime) {
+ try {
+ writeLock.lock();
+ this.completionTime = completionTime;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobProgressUpdateEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobProgressUpdateEvent.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobProgressUpdateEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobProgressUpdateEvent.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,19 @@
+package org.apache.ambari.server.state.live.job;
+
+public class JobProgressUpdateEvent extends JobEvent {
+
+ private final long progressUpdateTime;
+
+ public JobProgressUpdateEvent(JobId jobId, long progressUpdateTime) {
+ super(JobEventType.JOB_IN_PROGRESS, jobId);
+ this.progressUpdateTime = progressUpdateTime;
+ }
+
+ /**
+ * @return the progressUpdateTime
+ */
+ public long getProgressUpdateTime() {
+ return progressUpdateTime;
+ }
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobProgressUpdateEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobState.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobState.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobState.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,39 @@
+/**
+ * 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.live.job;
+
+public enum JobState {
+ /**
+ * Initial state for the Job.
+ * When a new action is triggered or set in motion.
+ */
+ INIT,
+ /**
+ * State when the job is triggered on the cluster,
+ */
+ IN_PROGRESS,
+ /**
+ * State of successful completion
+ */
+ COMPLETED,
+ /**
+ * Job failed to complete successfully
+ */
+ FAILED
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobType.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobType.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,7 @@
+package org.apache.ambari.server.state.live.job;
+
+public class JobType {
+
+ public String jobName;
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/NewJobEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/NewJobEvent.java?rev=1383107&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/NewJobEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/NewJobEvent.java Mon Sep 10 20:51:10 2012
@@ -0,0 +1,19 @@
+package org.apache.ambari.server.state.live.job;
+
+public class NewJobEvent extends JobEvent {
+
+ private final long startTime;
+
+ public NewJobEvent(JobId jobId, long creationTime) {
+ super(JobEventType.JOB_INIT, jobId);
+ this.startTime = creationTime;
+ }
+
+ /**
+ * @return the start time of the Job
+ */
+ public long getStartTime() {
+ return startTime;
+ }
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/NewJobEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java Mon Sep 10 20:51:10 2012
@@ -24,7 +24,7 @@ import java.util.Map;
import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
import org.apache.ambari.server.state.live.AgentVersion;
import org.apache.ambari.server.state.live.DiskInfo;
-import org.apache.ambari.server.state.live.Job;
+import org.apache.ambari.server.state.live.job.Job;
public interface Node {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java Mon Sep 10 20:51:10 2012
@@ -29,7 +29,7 @@ public class NodeEvent extends AbstractE
* Hostname of the Node
*/
final String nodeName;
-
+
public NodeEvent(String nodeName, NodeEventType type) {
super(type);
this.nodeName = nodeName;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java Mon Sep 10 20:51:10 2012
@@ -21,9 +21,9 @@ package org.apache.ambari.server.state.l
public class NodeHealthStatus {
private HealthStatus healthStatus;
-
+
private String healthReport;
-
+
public NodeHealthStatus(HealthStatus healthStatus, String healthReport) {
super();
this.healthStatus = healthStatus;
@@ -33,11 +33,11 @@ public class NodeHealthStatus {
public synchronized HealthStatus getHealthStatus() {
return healthStatus;
}
-
+
public synchronized void setHealthStatus(HealthStatus healthStatus) {
this.healthStatus = healthStatus;
}
-
+
public synchronized void setHealthReport(String healthReport) {
this.healthReport = healthReport;
}
@@ -45,11 +45,11 @@ public class NodeHealthStatus {
public synchronized String getHealthReport() {
return healthReport;
}
-
+
public static enum HealthStatus {
UNKNOWN,
HEALTHY,
UNHEALTHY
}
-
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java Mon Sep 10 20:51:10 2012
@@ -32,7 +32,7 @@ import org.apache.ambari.server.state.fs
import org.apache.ambari.server.state.fsm.StateMachineFactory;
import org.apache.ambari.server.state.live.AgentVersion;
import org.apache.ambari.server.state.live.DiskInfo;
-import org.apache.ambari.server.state.live.Job;
+import org.apache.ambari.server.state.live.job.Job;
import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,7 +43,7 @@ public class NodeImpl implements Node {
private final Lock readLock;
private final Lock writeLock;
-
+
/**
* Node hostname
*/
@@ -58,17 +58,17 @@ public class NodeImpl implements Node {
* Node IP if ipv6 interface available
*/
private String ipv6;
-
+
/**
* Count of cores on Node
*/
private int cpuCount;
-
+
/**
* Os Architecture
*/
private String osArch;
-
+
/**
* OS Type
*/
@@ -83,7 +83,7 @@ public class NodeImpl implements Node {
* Amount of available memory for the Node
*/
private long availableMemBytes;
-
+
/**
* Amount of physical memory for the Node
*/
@@ -108,7 +108,7 @@ public class NodeImpl implements Node {
* Rack to which the Node belongs to
*/
private String rackInfo;
-
+
/**
* Additional Node attributes
*/
@@ -118,12 +118,12 @@ public class NodeImpl implements Node {
* Version of agent running on the Node
*/
private AgentVersion agentVersion;
-
+
/**
* Node Health Status
*/
private NodeHealthStatus healthStatus;
-
+
private static final StateMachineFactory
<NodeImpl, NodeState, NodeEventType, NodeEvent>
stateMachineFactory
@@ -133,17 +133,17 @@ public class NodeImpl implements Node {
// define the state machine of a Node
// Transition from INIT state
- // when the initial registration request is received
+ // when the initial registration request is received
.addTransition(NodeState.INIT, NodeState.WAITING_FOR_VERIFICATION,
NodeEventType.NODE_REGISTRATION_REQUEST, new NodeRegistrationReceived())
// Transition from WAITING_FOR_VERIFICATION state
- // when the node is authenticated
+ // when the node is authenticated
.addTransition(NodeState.WAITING_FOR_VERIFICATION, NodeState.VERIFIED,
NodeEventType.NODE_VERIFIED, new NodeVerifiedTransition())
// Transitions from VERIFIED state
- // when a normal heartbeat is received
+ // when a normal heartbeat is received
.addTransition(NodeState.VERIFIED, NodeState.HEALTHY,
NodeEventType.NODE_HEARTBEAT_HEALTHY,
new NodeBecameHealthyTransition())
@@ -151,13 +151,13 @@ public class NodeImpl implements Node {
.addTransition(NodeState.VERIFIED, NodeState.HEARTBEAT_LOST,
NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
new NodeHeartbeatTimedOutTransition())
- // when a heartbeart denoting node as unhealthy is received
+ // when a heartbeart denoting node as unhealthy is received
.addTransition(NodeState.VERIFIED, NodeState.UNHEALTHY,
NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
- new NodeBecameUnhealthyTransition())
-
+ new NodeBecameUnhealthyTransition())
+
// Transitions from HEALTHY state
- // when a normal heartbeat is received
+ // when a normal heartbeat is received
.addTransition(NodeState.HEALTHY, NodeState.HEALTHY,
NodeEventType.NODE_HEARTBEAT_HEALTHY,
new NodeHeartbeatReceivedTransition())
@@ -165,17 +165,17 @@ public class NodeImpl implements Node {
.addTransition(NodeState.HEALTHY, NodeState.HEARTBEAT_LOST,
NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
new NodeHeartbeatTimedOutTransition())
- // when a heartbeart denoting node as unhealthy is received
+ // when a heartbeart denoting node as unhealthy is received
.addTransition(NodeState.HEALTHY, NodeState.UNHEALTHY,
NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
new NodeBecameUnhealthyTransition())
// Transitions from UNHEALTHY state
- // when a normal heartbeat is received
+ // when a normal heartbeat is received
.addTransition(NodeState.UNHEALTHY, NodeState.HEALTHY,
NodeEventType.NODE_HEARTBEAT_HEALTHY,
new NodeBecameHealthyTransition())
- // when a heartbeart denoting node as unhealthy is received
+ // when a heartbeart denoting node as unhealthy is received
.addTransition(NodeState.UNHEALTHY, NodeState.UNHEALTHY,
NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
new NodeHeartbeatReceivedTransition())
@@ -185,11 +185,11 @@ public class NodeImpl implements Node {
new NodeHeartbeatTimedOutTransition())
// Transitions from HEARTBEAT_LOST state
- // when a normal heartbeat is received
+ // when a normal heartbeat is received
.addTransition(NodeState.HEARTBEAT_LOST, NodeState.HEALTHY,
NodeEventType.NODE_HEARTBEAT_HEALTHY,
new NodeBecameHealthyTransition())
- // when a heartbeart denoting node as unhealthy is received
+ // when a heartbeart denoting node as unhealthy is received
.addTransition(NodeState.HEARTBEAT_LOST, NodeState.UNHEALTHY,
NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
new NodeBecameUnhealthyTransition())
@@ -220,7 +220,7 @@ public class NodeImpl implements Node {
node.setAgentVersion(e.agentVersion);
}
}
-
+
static class NodeVerifiedTransition
implements SingleArcTransition<NodeImpl, NodeEvent> {
@@ -229,7 +229,7 @@ public class NodeImpl implements Node {
// TODO Auto-generated method stub
}
}
-
+
static class NodeHeartbeatReceivedTransition
implements SingleArcTransition<NodeImpl, NodeEvent> {
@@ -247,12 +247,12 @@ public class NodeImpl implements Node {
break;
}
if (0 == heartbeatTime) {
- // TODO handle error
+ // TODO handle error
}
node.setLastHeartbeatTime(heartbeatTime);
}
- }
-
+ }
+
static class NodeBecameHealthyTransition
implements SingleArcTransition<NodeImpl, NodeEvent> {
@@ -264,7 +264,7 @@ public class NodeImpl implements Node {
LOG.info("Node transitioned to a healthy state"
+ ", node=" + e.nodeName
+ ", heartbeatTime=" + e.getHeartbeatTime());
- node.getHealthStatus().setHealthStatus(HealthStatus.HEALTHY);
+ node.getHealthStatus().setHealthStatus(HealthStatus.HEALTHY);
}
}
@@ -296,7 +296,7 @@ public class NodeImpl implements Node {
+ ", lastHeartbeatTime=" + node.getLastHeartbeatTime());
node.getHealthStatus().setHealthStatus(HealthStatus.UNKNOWN);
}
- }
+ }
void importNodeInfo(NodeInfo nodeInfo) {
try {
@@ -315,10 +315,10 @@ public class NodeImpl implements Node {
this.hostAttributes = nodeInfo.hostAttributes;
}
finally {
- writeLock.unlock();
+ writeLock.unlock();
}
}
-
+
@Override
public NodeState getState() {
try {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java Mon Sep 10 20:51:10 2012
@@ -23,11 +23,11 @@ import org.apache.ambari.server.state.li
public class NodeRegistrationRequestEvent extends NodeEvent {
final long registrationTime;
-
+
final NodeInfo nodeInfo;
-
+
final AgentVersion agentVersion;
-
+
public NodeRegistrationRequestEvent(String nodeName,
AgentVersion agentVersion, long registrationTime, NodeInfo nodeInfo) {
super(nodeName, NodeEventType.NODE_REGISTRATION_REQUEST);
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java?rev=1383107&r1=1383106&r2=1383107&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java Mon Sep 10 20:51:10 2012
@@ -21,7 +21,7 @@ package org.apache.ambari.server.state.l
public class NodeUnhealthyHeartbeatEvent extends NodeEvent {
private final long heartbeatTime;
-
+
private final NodeHealthStatus healthStatus;
public NodeUnhealthyHeartbeatEvent(String nodeName, long heartbeatTime,