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/07 17:11:13 UTC
svn commit: r1382059 [1/2] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-server/ ambari-server/conf/
ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/
ambari-server/src/main/java/org/apache/ambari/server/ ambari-server/sr...
Author: hitesh
Date: Fri Sep 7 15:11:12 2012
New Revision: 1382059
URL: http://svn.apache.org/viewvc?rev=1382059&view=rev
Log:
AMBARI-705. Initial work on Node FSM. (Contributed by hitesh)
Added:
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/AbstractEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/Event.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/EventHandler.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeState.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeVerifiedEvent.java (with props)
Removed:
incubator/ambari/branches/AMBARI-666/ambari-server/conf/auth.conf
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/AbstractEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/Event.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/EventHandler.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Node.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/NodeEvent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/NodeEventType.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/NodeHealthStatus.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/NodeImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/NodeState.java
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.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/state/ConfigVersion.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/fsm/StateMachine.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachineFactory.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/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
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/ServiceComponentNodeEventType.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/ServiceComponentNodeState.java
incubator/ambari/branches/AMBARI-666/pom.xml
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=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Fri Sep 7 15:11:12 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
NEW FEATURES
+ AMBARI-705. Initial work on Node FSM. (hitesh)
+
AMBARI-703. Heartbeat handler classes. (jitendra)
AMBARI-702. Add skeleton for Ambari agent that talks to the server and
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml Fri Sep 7 15:11:12 2012
@@ -42,44 +42,15 @@
</execution>
</executions>
</plugin>
- <!--
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>1.6</version>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
<configuration>
- <createDependencyReducedPom>true
- </createDependencyReducedPom>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
</configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.apache.ambari.server.controller.AmbariController
- </mainClass>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
</plugin>
- -->
</plugins>
</build>
<profiles>
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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.controller.rest.resources;
import javax.ws.rs.GET;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
import java.io.IOException;
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.ambari.server;
//This enumerates all the roles that the server can handle.
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigVersion.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigVersion.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigVersion.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigVersion.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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 interface ConfigVersion {
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -19,6 +19,7 @@
package org.apache.ambari.server.state.fsm;
// TODO
+@SuppressWarnings("serial")
public class InvalidStateTransitonException extends Exception {
private Enum<?> currentState;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachine.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachine.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachine.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachine.java Fri Sep 7 15:11:12 2012
@@ -22,6 +22,7 @@ public interface StateMachine
<STATE extends Enum<STATE>,
EVENTTYPE extends Enum<EVENTTYPE>, EVENT> {
public STATE getCurrentState();
+ public void setCurrentState(STATE state);
public STATE doTransition(EVENTTYPE eventType, EVENT event)
throws InvalidStateTransitonException;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachineFactory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachineFactory.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachineFactory.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/StateMachineFactory.java Fri Sep 7 15:11:12 2012
@@ -441,6 +441,12 @@ final public class StateMachineFactory
(operand, currentState, eventType, event);
return currentState;
}
+
+ @Override
+ public synchronized void setCurrentState(STATE state) {
+ currentState = state;
+ }
+
}
/*
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/AbstractEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/AbstractEvent.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/AbstractEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/AbstractEvent.java Fri Sep 7 15:11:12 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.state.fsm.event;
+
+/**
+ * parent class of all the events. All events extend this class.
+ */
+public abstract class AbstractEvent<TYPE extends Enum<TYPE>>
+ implements Event<TYPE> {
+
+ private final TYPE type;
+ private final long timestamp;
+
+ // use this if you DON'T care about the timestamp
+ public AbstractEvent(TYPE type) {
+ this.type = type;
+ // We're not generating a real timestamp here. It's too expensive.
+ timestamp = -1L;
+ }
+
+ // use this if you care about the timestamp
+ public AbstractEvent(TYPE type, long timestamp) {
+ this.type = type;
+ this.timestamp = timestamp;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public TYPE getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return "EventType: " + getType();
+ }
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/AbstractEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/Event.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/Event.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/Event.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/Event.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,30 @@
+/**
+* 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.fsm.event;
+
+/**
+ * Interface defining events api.
+ *
+ */
+public interface Event<TYPE extends Enum<TYPE>> {
+
+ TYPE getType();
+ long getTimestamp();
+ String toString();
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/Event.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/EventHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/EventHandler.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/EventHandler.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/EventHandler.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,30 @@
+/**
+* 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.fsm.event;
+
+/**
+ * Interface for handling events of type T
+ *
+ * @param <T> paremeterized event of type T
+ */
+public interface EventHandler<T extends Event<?> > {
+
+ void handle(T event);
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/event/EventHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
// TODO
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,6 +1,26 @@
+/**
+ * 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;
import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
+import org.apache.ambari.server.state.live.node.NodeEvent;
+import org.apache.ambari.server.state.live.node.NodeState;
public interface Cluster {
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+* 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;
public interface Clusters {
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
/**
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/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.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java Fri Sep 7 15:11:12 2012
@@ -1,6 +1,24 @@
+/**
+ * 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;
-import org.apache.ambari.server.fsm.event.AbstractEvent;
+import org.apache.ambari.server.state.fsm.event.AbstractEvent;
public class JobEvent extends AbstractEvent<JobEventType> {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEventType.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEventType.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEventType.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
public enum JobEventType {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobId.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobId.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobId.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobId.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
// TODO
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobImpl.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobImpl.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobState.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobState.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobState.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
public enum JobState {
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
import java.util.List;
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,6 +1,24 @@
+/**
+ * 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;
-import org.apache.ambari.server.fsm.event.AbstractEvent;
+import org.apache.ambari.server.state.fsm.event.AbstractEvent;
public class ServiceComponentNodeEvent
extends AbstractEvent<ServiceComponentNodeEventType> {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEventType.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEventType.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEventType.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
public enum ServiceComponentNodeEventType {
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=1382059&r1=1382058&r2=1382059&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 Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
import java.util.List;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeState.java?rev=1382059&r1=1382058&r2=1382059&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeState.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeState.java Fri Sep 7 15:11:12 2012
@@ -1,3 +1,21 @@
+/**
+ * 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;
public enum ServiceComponentNodeState {
Added: 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=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,239 @@
+/**
+ * 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.node;
+
+import java.util.List;
+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;
+
+public interface Node {
+
+ /**
+ * @return the hostName
+ */
+ public String getHostName();
+
+ /**
+ * @param hostName the hostName to set
+ */
+ public void setHostName(String hostName);
+
+ /**
+ * IPv4 assigned to the Node
+ * @return the ip or null if no IPv4 interface
+ */
+ public String getIPv4();
+
+ /**
+ * @param ip the ip to set
+ */
+ public void setIPv4(String ip);
+
+ /**
+ * IPv6 assigned to the Node
+ * @return the ip or null if no IPv6 interface
+ */
+ public String getIPv6();
+
+ /**
+ * @param ip the ip to set
+ */
+ public void setIPv6(String ip);
+
+ /**
+ * @return the cpuCount
+ */
+ public int getCpuCount();
+
+ /**
+ * @param cpuCount the cpuCount to set
+ */
+ public void setCpuCount(int cpuCount);
+
+ /**
+ * Get the Amount of physical memory for the Node.
+ * @return the totalMemBytes
+ */
+ public long getTotalMemBytes();
+
+ /**
+ * Set the Amount of physical memory for the Node.
+ * @param totalMemBytes the totalMemBytes to set
+ */
+ public void setTotalMemBytes(long totalMemBytes);
+
+ /**
+ * Get the Amount of available memory for the Node.
+ * In most cases, available should be same as total unless
+ * the agent on the node is configured to not use all
+ * available memory
+ * @return the availableMemBytes
+ */
+ public long getAvailableMemBytes();
+
+ /**
+ * Set the Amount of available memory for the Node.
+ * @param availableMemBytes the availableMemBytes to set
+ */
+ public void setAvailableMemBytes(long availableMemBytes);
+
+ /**
+ * Get the OS Architecture.
+ * i386, x86_64, etc.
+ * @return the osArch
+ */
+ public String getOsArch();
+
+ /**
+ * @param osArch the osArch to set
+ */
+ public void setOsArch(String osArch);
+
+ /**
+ * Get the General OS information.
+ * uname -a, /etc/*-release dump
+ * @return the osInfo
+ */
+ public String getOsInfo();
+
+ /**
+ * @param osInfo the osInfo to set
+ */
+ public void setOsInfo(String osInfo);
+
+ /**
+ * Get the OS Type: RHEL5/RHEL6/CentOS5/...
+ * Defined and match-able OS type
+ * @return the osType
+ */
+ public String getOsType();
+
+ /**
+ * @param osType the osType to set
+ */
+ public void setOsType(String osType);
+
+ /**
+ * Get information on disks available on the node.
+ * @return the disksInfo
+ */
+ public List<DiskInfo> getDisksInfo();
+
+ /**
+ * @param disksInfo the disksInfo to set
+ */
+ public void setDisksInfo(List<DiskInfo> disksInfo);
+
+ /**
+ * @return the healthStatus
+ */
+ public NodeHealthStatus getHealthStatus();
+
+ /**
+ * @param healthStatus the healthStatus to set
+ */
+ public void setHealthStatus(NodeHealthStatus healthStatus);
+
+ /**
+ * Get additional host attributes
+ * For example, public/hostname/IP for AWS
+ * @return the hostAttributes
+ */
+ public Map<String, String> getHostAttributes();
+
+ /**
+ * @param hostAttributes the hostAttributes to set
+ */
+ public void setHostAttributes(Map<String, String> hostAttributes);
+ /**
+ * @return the rackInfo
+ */
+ public String getRackInfo();
+
+ /**
+ * @param rackInfo the rackInfo to set
+ */
+ public void setRackInfo(String rackInfo);
+
+ /**
+ * Last time the node registered with the Ambari Server
+ * ( Unix timestamp )
+ * @return the lastRegistrationTime
+ */
+ public long getLastRegistrationTime();
+
+ /**
+ * @param lastRegistrationTime the lastRegistrationTime to set
+ */
+ public void setLastRegistrationTime(long lastRegistrationTime);
+
+ /**
+ * Last time the Ambari Server received a heartbeat from the Node
+ * ( Unix timestamp )
+ * @return the lastHeartbeatTime
+ */
+ public long getLastHeartbeatTime();
+
+ /**
+ * @param lastHeartbeatTime the lastHeartbeatTime to set
+ */
+ public void setLastHeartbeatTime(long lastHeartbeatTime);
+
+ /**
+ * Version of the Ambari Agent running on the node
+ * @return the agentVersion
+ */
+ public AgentVersion getAgentVersion();
+
+ /**
+ * @param agentVersion the agentVersion to set
+ */
+ public void setAgentVersion(AgentVersion agentVersion);
+
+ /**
+ * Get the list of Jobs that are currently being tracked at the
+ * Node level
+ * @return List of Jobs
+ */
+ public List<Job> getJobs();
+
+ /**
+ * Get Current Node State
+ * @return NodeState
+ */
+ public NodeState getState();
+
+ /**
+ * Set the State of the Node
+ * @param state Node State
+ */
+ public void setState(NodeState state);
+
+ /**
+ * Send an event to the Node's StateMachine
+ * @param event NodeEvent
+ * @throws InvalidStateTransitonException
+ */
+ public void handleEvent(NodeEvent event)
+ throws InvalidStateTransitonException;
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,34 @@
+/**
+ * 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.node;
+
+import org.apache.ambari.server.state.fsm.event.AbstractEvent;
+
+public class NodeEvent extends AbstractEvent<NodeEventType> {
+
+ final String nodeName;
+
+ // TODO
+ // this should have some node identifier
+ public NodeEvent(String nodeName, NodeEventType type) {
+ super(type);
+ this.nodeName = nodeName;
+ }
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,42 @@
+/**
+* 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.node;
+
+public enum NodeEventType {
+ /**
+ * Event to denote when a registration request is received from a Node
+ */
+ NODE_REGISTRATION_REQUEST,
+ /**
+ * Node authenticated/verified.
+ */
+ NODE_VERIFIED,
+ /**
+ * A healthy heartbeat event received from the Node.
+ */
+ NODE_HEARTBEAT_HEALTHY,
+ /**
+ * No heartbeat received from the Node within the defined expiry interval.
+ */
+ NODE_HEARTBEAT_TIMED_OUT,
+ /**
+ * A non-healthy heartbeat event received from the Node.
+ */
+ NODE_HEARTBEAT_UNHEALTHY
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,24 @@
+/**
+ * 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.node;
+
+public interface NodeHealthStatus {
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java Fri Sep 7 15:11:12 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.node;
+
+public class NodeHealthyHeartbeatEvent extends NodeEvent {
+
+ private final long heartbeatTime;
+
+ public NodeHealthyHeartbeatEvent(String nodeName, long heartbeatTime) {
+ super(nodeName, NodeEventType.NODE_HEARTBEAT_HEALTHY);
+ this.heartbeatTime = heartbeatTime;
+ }
+
+ /**
+ * @return the heartbeatTime
+ */
+ public long getHeartbeatTime() {
+ return heartbeatTime;
+ }
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,28 @@
+/**
+ * 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.node;
+
+public class NodeHeartbeatTimedOutEvent extends NodeEvent {
+
+ public NodeHeartbeatTimedOutEvent(String nodeName) {
+ super(nodeName, NodeEventType.NODE_HEARTBEAT_TIMED_OUT);
+ }
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,734 @@
+/**
+ * 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.node;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+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.ambari.server.state.live.AgentVersion;
+import org.apache.ambari.server.state.live.DiskInfo;
+import org.apache.ambari.server.state.live.Job;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class NodeImpl implements Node {
+
+ private static final Log LOG = LogFactory.getLog(NodeImpl.class);
+
+ private final Lock readLock;
+ private final Lock writeLock;
+
+ /**
+ * Node hostname
+ */
+ private String hostName;
+
+ /**
+ * Node IP if ipv4 interface available
+ */
+ private String ipv4;
+
+ /**
+ * Node IP if ipv6 interface available
+ */
+ private String ipv6;
+
+ /**
+ * Count of cores on Node
+ */
+ private int cpuCount;
+
+ /**
+ * Os Architecture
+ */
+ private String osArch;
+
+ /**
+ * OS Type
+ */
+ private String osType;
+
+ /**
+ * OS Information
+ */
+ private String osInfo;
+
+ /**
+ * Amount of available memory for the Node
+ */
+ private long availableMemBytes;
+
+ /**
+ * Amount of physical memory for the Node
+ */
+ private long totalMemBytes;
+
+ /**
+ * Disks mounted on the Node
+ */
+ private List<DiskInfo> disksInfo;
+
+ /**
+ * Last heartbeat timestamp from the Node
+ */
+ private long lastHeartbeatTime;
+
+ /**
+ * Last registration timestamp for the Node
+ */
+ private long lastRegistrationTime;
+
+ /**
+ * Rack to which the Node belongs to
+ */
+ private String rackInfo;
+
+ /**
+ * Additional Node attributes
+ */
+ private Map<String, String> hostAttributes;
+
+ /**
+ * 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
+ = new StateMachineFactory<NodeImpl, NodeState, NodeEventType, NodeEvent>
+ (NodeState.INIT)
+
+ // define the state machine of a Node
+
+ // Transition from INIT state
+ // 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
+ .addTransition(NodeState.WAITING_FOR_VERIFICATION, NodeState.VERIFIED,
+ NodeEventType.NODE_VERIFIED, new NodeVerifiedTransition())
+
+ // Transitions from VERIFIED state
+ // when a normal heartbeat is received
+ .addTransition(NodeState.VERIFIED, NodeState.HEALTHY,
+ NodeEventType.NODE_HEARTBEAT_HEALTHY,
+ new NodeBecameHealthyTransition())
+ // when a heartbeat is not received within the configured timeout period
+ .addTransition(NodeState.VERIFIED, NodeState.HEARTBEAT_LOST,
+ NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
+ new NodeHeartbeatTimedOutTransition())
+ // when a heartbeart denoting node as unhealthy is received
+ .addTransition(NodeState.VERIFIED, NodeState.UNHEALTHY,
+ NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
+ new NodeBecameUnhealthyTransition())
+
+ // Transitions from HEALTHY state
+ // when a normal heartbeat is received
+ .addTransition(NodeState.HEALTHY, NodeState.HEALTHY,
+ NodeEventType.NODE_HEARTBEAT_HEALTHY,
+ new NodeHeartbeatReceivedTransition())
+ // when a heartbeat is not received within the configured timeout period
+ .addTransition(NodeState.HEALTHY, NodeState.HEARTBEAT_LOST,
+ NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
+ new NodeHeartbeatTimedOutTransition())
+ // 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
+ .addTransition(NodeState.UNHEALTHY, NodeState.HEALTHY,
+ NodeEventType.NODE_HEARTBEAT_HEALTHY,
+ new NodeBecameHealthyTransition())
+ // when a heartbeart denoting node as unhealthy is received
+ .addTransition(NodeState.UNHEALTHY, NodeState.UNHEALTHY,
+ NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
+ new NodeHeartbeatReceivedTransition())
+ // when a heartbeat is not received within the configured timeout period
+ .addTransition(NodeState.UNHEALTHY, NodeState.HEARTBEAT_LOST,
+ NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
+ new NodeHeartbeatTimedOutTransition())
+
+ // Transitions from HEARTBEAT_LOST state
+ // 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
+ .addTransition(NodeState.HEARTBEAT_LOST, NodeState.UNHEALTHY,
+ NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
+ new NodeBecameUnhealthyTransition())
+ // when a heartbeat is not received within the configured timeout period
+ .addTransition(NodeState.HEARTBEAT_LOST, NodeState.HEARTBEAT_LOST,
+ NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
+ .installTopology();
+
+ private final StateMachine<NodeState, NodeEventType, NodeEvent> stateMachine;
+
+ public NodeImpl() {
+ super();
+ this.stateMachine = stateMachineFactory.make(this);
+ ReadWriteLock rwLock = new ReentrantReadWriteLock();
+ this.readLock = rwLock.readLock();
+ this.writeLock = rwLock.writeLock();
+ }
+
+ static class NodeRegistrationReceived
+ implements SingleArcTransition<NodeImpl, NodeEvent> {
+
+ @Override
+ public void transition(NodeImpl node, NodeEvent event) {
+ NodeRegistrationRequestEvent e = (NodeRegistrationRequestEvent) event;
+ node.importNodeInfo(e.nodeInfo);
+ node.setLastRegistrationTime(e.registrationTime);
+ node.setAgentVersion(e.agentVersion);
+ }
+ }
+
+ static class NodeVerifiedTransition
+ implements SingleArcTransition<NodeImpl, NodeEvent> {
+
+ @Override
+ public void transition(NodeImpl node, NodeEvent event) {
+ // TODO Auto-generated method stub
+ }
+ }
+
+ static class NodeHeartbeatReceivedTransition
+ implements SingleArcTransition<NodeImpl, NodeEvent> {
+
+ @Override
+ public void transition(NodeImpl node, NodeEvent event) {
+ long heartbeatTime = 0;
+ switch (event.getType()) {
+ case NODE_HEARTBEAT_HEALTHY:
+ heartbeatTime = ((NodeHealthyHeartbeatEvent)event).getHeartbeatTime();
+ break;
+ case NODE_HEARTBEAT_UNHEALTHY:
+ heartbeatTime = ((NodeUnhealthyHeartbeatEvent)event).getHeartbeatTime();
+ break;
+ default:
+ break;
+ }
+ if (0 == heartbeatTime) {
+ // TODO handle error
+ }
+ node.setLastHeartbeatTime(heartbeatTime);
+ }
+ }
+
+ static class NodeBecameHealthyTransition
+ implements SingleArcTransition<NodeImpl, NodeEvent> {
+
+ @Override
+ public void transition(NodeImpl node, NodeEvent event) {
+ NodeHealthyHeartbeatEvent e = (NodeHealthyHeartbeatEvent) event;
+ // TODO Audit logs
+ LOG.info("Node transitioned to a healthy state"
+ + ", node=" + e.nodeName
+ + ", heartbeatTime=" + e.getHeartbeatTime());
+ // TODO update health status to healthy
+ }
+ }
+
+ static class NodeBecameUnhealthyTransition
+ implements SingleArcTransition<NodeImpl, NodeEvent> {
+
+ @Override
+ public void transition(NodeImpl node, NodeEvent event) {
+ NodeUnhealthyHeartbeatEvent e = (NodeUnhealthyHeartbeatEvent) event;
+ // TODO Audit logs
+ LOG.info("Node transitioned to an unhealthy state"
+ + ", node=" + e.nodeName
+ + ", heartbeatTime=" + e.getHeartbeatTime()
+ + ", healthStatis=" + e.getHealthStatus());
+ node.setHealthStatus(e.getHealthStatus());
+ }
+ }
+
+ static class NodeHeartbeatTimedOutTransition
+ implements SingleArcTransition<NodeImpl, NodeEvent> {
+
+ @Override
+ public void transition(NodeImpl node, NodeEvent event) {
+ NodeHeartbeatTimedOutEvent e = (NodeHeartbeatTimedOutEvent) event;
+ // TODO Audit logs
+ LOG.info("Node transitioned to heartbeat timed out state"
+ + ", node=" + e.nodeName
+ + ", lastHeartbeatTime=" + node.getLastHeartbeatTime());
+ // TODO update health status to ???
+ }
+ }
+
+ private void importNodeInfo(NodeInfo nodeInfo) {
+ try {
+ writeLock.lock();
+ this.hostName = nodeInfo.hostName;
+ this.ipv4 = nodeInfo.ipv4;
+ this.ipv6 = nodeInfo.ipv6;
+ this.availableMemBytes = nodeInfo.availableMemBytes;
+ this.totalMemBytes = nodeInfo.totalMemBytes;
+ this.cpuCount = nodeInfo.cpuCount;
+ this.osArch = nodeInfo.osArch;
+ this.osType = nodeInfo.osType;
+ this.osInfo = nodeInfo.osInfo;
+ this.disksInfo = nodeInfo.disksInfo;
+ this.rackInfo = nodeInfo.rackInfo;
+ this.hostAttributes = nodeInfo.hostAttributes;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public NodeState getState() {
+ try {
+ readLock.lock();
+ return stateMachine.getCurrentState();
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setState(NodeState state) {
+ try {
+ writeLock.lock();
+ stateMachine.setCurrentState(state);
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public void handleEvent(NodeEvent event)
+ throws InvalidStateTransitonException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Handling Node event, eventType=" + event.getType().name()
+ + ", event=" + event.toString());
+ }
+ NodeState oldState = getState();
+ try {
+ writeLock.lock();
+ try {
+ stateMachine.doTransition(event.getType(), event);
+ } catch (InvalidStateTransitonException e) {
+ LOG.error("Can't handle Node event at current state"
+ + ", node=" + this.getHostName()
+ + ", currentState=" + oldState
+ + ", eventType=" + event.getType()
+ + ", event=" + event);
+ throw e;
+ }
+ }
+ finally {
+ writeLock.unlock();
+ }
+ if (oldState != getState()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Node transitioned to a new state"
+ + ", node=" + this.getHostName()
+ + ", oldState=" + oldState
+ + ", currentState=" + getState()
+ + ", eventType=" + event.getType().name()
+ + ", event=" + event);
+ }
+ }
+ }
+
+ @Override
+ public String getHostName() {
+ try {
+ readLock.lock();
+ return hostName;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setHostName(String hostName) {
+ try {
+ writeLock.lock();
+ this.hostName = hostName;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public String getIPv4() {
+ try {
+ readLock.lock();
+ return ipv4;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setIPv4(String ip) {
+ try {
+ writeLock.lock();
+ this.ipv4 = ip;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public String getIPv6() {
+ try {
+ readLock.lock();
+ return ipv6;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setIPv6(String ip) {
+ try {
+ writeLock.lock();
+ this.ipv6 = ip;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public int getCpuCount() {
+ try {
+ readLock.lock();
+ return cpuCount;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setCpuCount(int cpuCount) {
+ try {
+ writeLock.lock();
+ this.cpuCount = cpuCount;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public long getTotalMemBytes() {
+ try {
+ readLock.lock();
+ return totalMemBytes;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setTotalMemBytes(long totalMemBytes) {
+ try {
+ writeLock.lock();
+ this.totalMemBytes = totalMemBytes;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public long getAvailableMemBytes() {
+ try {
+ readLock.lock();
+ return availableMemBytes;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setAvailableMemBytes(long availableMemBytes) {
+ try {
+ writeLock.lock();
+ this.availableMemBytes = availableMemBytes;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public String getOsArch() {
+ try {
+ readLock.lock();
+ return osArch;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setOsArch(String osArch) {
+ try {
+ writeLock.lock();
+ this.osArch = osArch;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public String getOsInfo() {
+ try {
+ readLock.lock();
+ return osInfo;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setOsInfo(String osInfo) {
+ try {
+ writeLock.lock();
+ this.osInfo = osInfo;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public String getOsType() {
+ try {
+ readLock.lock();
+ return osType;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setOsType(String osType) {
+ try {
+ writeLock.lock();
+ this.osType = osType;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public List<DiskInfo> getDisksInfo() {
+ try {
+ readLock.lock();
+ return Collections.unmodifiableList(disksInfo);
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setDisksInfo(List<DiskInfo> disksInfo) {
+ try {
+ writeLock.lock();
+ this.disksInfo = disksInfo;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public NodeHealthStatus getHealthStatus() {
+ try {
+ readLock.lock();
+ return healthStatus;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setHealthStatus(NodeHealthStatus healthStatus) {
+ try {
+ writeLock.lock();
+ this.healthStatus = healthStatus;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public Map<String, String> getHostAttributes() {
+ try {
+ readLock.lock();
+ return Collections.unmodifiableMap(hostAttributes);
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setHostAttributes(Map<String, String> hostAttributes) {
+ try {
+ writeLock.lock();
+ this.hostAttributes = hostAttributes;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public String getRackInfo() {
+ try {
+ readLock.lock();
+ return rackInfo;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setRackInfo(String rackInfo) {
+ try {
+ writeLock.lock();
+ this.rackInfo = rackInfo;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public long getLastRegistrationTime() {
+ try {
+ readLock.lock();
+ return lastRegistrationTime;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setLastRegistrationTime(long lastRegistrationTime) {
+ try {
+ writeLock.lock();
+ this.lastRegistrationTime = lastRegistrationTime;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public long getLastHeartbeatTime() {
+ try {
+ readLock.lock();
+ return lastHeartbeatTime;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setLastHeartbeatTime(long lastHeartbeatTime) {
+ try {
+ writeLock.lock();
+ this.lastHeartbeatTime = lastHeartbeatTime;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public AgentVersion getAgentVersion() {
+ try {
+ readLock.lock();
+ return agentVersion;
+ }
+ finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setAgentVersion(AgentVersion agentVersion) {
+ try {
+ writeLock.lock();
+ this.agentVersion = agentVersion;
+ }
+ finally {
+ writeLock.unlock();
+ }
+ }
+
+ @Override
+ public List<Job> getJobs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java?rev=1382059&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java Fri Sep 7 15:11:12 2012
@@ -0,0 +1,40 @@
+/**
+ * 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.node;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ambari.server.state.live.DiskInfo;
+
+public class NodeInfo {
+ public String hostName;
+ public String ipv4;
+ public String ipv6;
+ public int cpuCount;
+ public String osArch;
+ public String osType;
+ public String osInfo;
+ public long availableMemBytes;
+ public long totalMemBytes;
+ public List<DiskInfo> disksInfo;
+ public String rackInfo;
+ public Map<String, String> hostAttributes;
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java
------------------------------------------------------------------------------
svn:eol-style = native