Author: degenaro
Date: Fri Sep 16 21:12:51 2016
New Revision: 1761090

URL: http://svn.apache.org/viewvc?rev=1761090&view=rev
Log:
UIMA-5110 DUCC Job Driver (JD) employ enums for EventType and StateType

Modified:
    
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Event.java
    
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Fsm.java
    
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/State.java
    
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IEvent.java
    
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IState.java

Modified: 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Event.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Event.java?rev=1761090&r1=1761089&r2=1761090&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Event.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Event.java
 Fri Sep 16 21:12:51 2016
@@ -22,19 +22,20 @@ import org.apache.uima.ducc.container.co
 
 public class Event implements IEvent {
 
-       private String name = null;
+       private EventType eventType = null;
        
-       public Event(String name) throws FsmException {
-               if(name == null) {
-                       throw new FsmException("event name is null");
+       public Event(EventType eventType) throws FsmException {
+               if(eventType == null) {
+                       throw new FsmException("event type is null");
                }
-               setName(name);
+               setEventType(eventType);
        }
        
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
+               String name = getEventName();
                result = prime * result + ((name == null) ? 0 : 
name.hashCode());
                return result;
        }
@@ -45,8 +46,8 @@ public class Event implements IEvent {
                if(o != null) {
                        if(o instanceof IEvent) {
                                IEvent that = (IEvent)o;
-                               String thisName = this.getName();
-                               String thatName = that.getName();
+                               String thisName = this.getEventName();
+                               String thatName = that.getEventName();
                                retVal = thisName.compareTo(thatName) == 0;
                        }
                }
@@ -56,12 +57,12 @@ public class Event implements IEvent {
        @Override
        public int compareTo(Object o) {
                int retVal = 0;
-               if(name != null) {
+               if(eventType != null) {
                        if(o != null) {
                                if(o instanceof IEvent) {
                                        IEvent that = (IEvent)o;
-                                       String thisName = this.getName();
-                                       String thatName = that.getName();
+                                       String thisName = this.getEventName();
+                                       String thatName = that.getEventName();
                                        retVal = thisName.compareTo(thatName);
                                }
                        }
@@ -70,11 +71,16 @@ public class Event implements IEvent {
        }
 
        @Override
-       public String getName() {
-               return name;
+       public String getEventName() {
+               return eventType.name();
        }
        
-       private void setName(String value) {
-               name = value;
+       @Override
+       public EventType getEventType() {
+               return eventType;
+       }
+       
+       private void setEventType(EventType value) {
+               eventType = value;
        }
 }

Modified: 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Fsm.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Fsm.java?rev=1761090&r1=1761089&r2=1761090&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Fsm.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/Fsm.java
 Fri Sep 16 21:12:51 2016
@@ -51,13 +51,13 @@ public class Fsm implements IFsmBuilder
                if(result != null) {
                        MessageBuffer mb = new MessageBuffer();
                        mb.append("duplicate");
-                       
mb.append(Standardize.Label.state.get()+current.getName());
-                       
mb.append(Standardize.Label.event.get()+event.getName());
+                       
mb.append(Standardize.Label.state.get()+current.getStateName());
+                       
mb.append(Standardize.Label.event.get()+event.getEventName());
                        throw new FsmException(mb.toString());
                }
                MessageBuffer mb = new MessageBuffer();
-               mb.append(Standardize.Label.state.get()+current.getName());
-               mb.append(Standardize.Label.event.get()+event.getName());
+               mb.append(Standardize.Label.state.get()+current.getStateName());
+               mb.append(Standardize.Label.event.get()+event.getEventName());
                logger.trace(location, ILogger.null_id, mb.toString());
        }
 
@@ -80,8 +80,8 @@ public class Fsm implements IFsmBuilder
                IState s1 = getStateCurrent();
                if(s0 != null) {
                        if(s1 != null) {
-                               String n0 = s0.getName();
-                               String n1 = s1.getName();
+                               String n0 = s0.getStateName();
+                               String n1 = s1.getStateName();
                                if(n0 != null) {
                                        if(n1 != null) {
                                                retVal = n0.equals(n1);
@@ -121,8 +121,8 @@ public class Fsm implements IFsmBuilder
        private IStateEventValue putIfAbsent(IStateEventKey key, 
IStateEventValue value) {
                String location = "putIfAbsent";
                MessageBuffer mb = new MessageBuffer();
-               
mb.append(Standardize.Label.state.get()+key.getState().getName());
-               
mb.append(Standardize.Label.event.get()+key.getEvent().getName());
+               
mb.append(Standardize.Label.state.get()+key.getState().getStateName());
+               
mb.append(Standardize.Label.event.get()+key.getEvent().getEventName());
                mb.append(Standardize.Label.hash.get()+key.hashCode());
                logger.trace(location, ILogger.null_id, mb.toString());
                return map.putIfAbsent(key, value);
@@ -131,8 +131,8 @@ public class Fsm implements IFsmBuilder
        private IStateEventValue get(IStateEventKey key) {
                String location = "get";
                MessageBuffer mb = new MessageBuffer();
-               
mb.append(Standardize.Label.state.get()+key.getState().getName());
-               
mb.append(Standardize.Label.event.get()+key.getEvent().getName());
+               
mb.append(Standardize.Label.state.get()+key.getState().getStateName());
+               
mb.append(Standardize.Label.event.get()+key.getEvent().getEventName());
                mb.append(Standardize.Label.hash.get()+key.hashCode());
                logger.trace(location, ILogger.null_id, mb.toString());
                IStateEventValue value = map.get(key);
@@ -143,9 +143,9 @@ public class Fsm implements IFsmBuilder
        public void transitionLog(IEvent event, Object actionData) {
                String location = "transition";
                MessageBuffer mb = new MessageBuffer();
-               
mb.append(Standardize.Label.curr.get()+getStateCurrent().getName());
-               
mb.append(Standardize.Label.prev.get()+getStatePrevious().getName());
-               mb.append(Standardize.Label.event.get()+event.getName());
+               
mb.append(Standardize.Label.curr.get()+getStateCurrent().getStateName());
+               
mb.append(Standardize.Label.prev.get()+getStatePrevious().getStateName());
+               mb.append(Standardize.Label.event.get()+event.getEventName());
                logger.trace(location, ILogger.null_id, mb.toString());
        }
        
@@ -159,8 +159,8 @@ public class Fsm implements IFsmBuilder
                                if(value == null) {
                                        MessageBuffer mb = new MessageBuffer();
                                        mb.append("undefined");
-                                       
mb.append(Standardize.Label.state.get()+_stateCurrent.getName());
-                                       
mb.append(Standardize.Label.event.get()+event.getName());
+                                       
mb.append(Standardize.Label.state.get()+_stateCurrent.getStateName());
+                                       
mb.append(Standardize.Label.event.get()+event.getEventName());
                                        throw new FsmException(mb.toString());
                                }
                                IState _statePrevious = _stateCurrent;
@@ -186,8 +186,8 @@ public class Fsm implements IFsmBuilder
                                IState _statePrevious = getStateCurrent();
                                if(!_stateCurrent.equals(_statePrevious)) {
                                        MessageBuffer mb = new MessageBuffer();
-                                       
mb.append(Standardize.Label.curr.get()+_stateCurrent.getName());
-                                       
mb.append(Standardize.Label.prev.get()+_statePrevious.getName());
+                                       
mb.append(Standardize.Label.curr.get()+_stateCurrent.getStateName());
+                                       
mb.append(Standardize.Label.prev.get()+_statePrevious.getStateName());
                                        logger.info(location, ILogger.null_id, 
mb.toString());
                                }
                        }

Modified: 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/State.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/State.java?rev=1761090&r1=1761089&r2=1761090&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/State.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/State.java
 Fri Sep 16 21:12:51 2016
@@ -22,19 +22,20 @@ import org.apache.uima.ducc.container.co
 
 public class State implements IState {
 
-       private String name = null;
+       private StateType stateType = null;
        
-       public State(String name) throws FsmException {
-               if(name == null) {
-                       throw new FsmException("state name is null");
+       public State(StateType stateType) throws FsmException {
+               if(stateType == null) {
+                       throw new FsmException("state type is null");
                }
-               setName(name);
+               setStateType(stateType);
        }
        
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
+               String name = getStateName();
                result = prime * result + ((name == null) ? 0 : 
name.hashCode());
                return result;
        }
@@ -45,8 +46,8 @@ public class State implements IState {
                if(o != null) {
                        if(o instanceof IState) {
                                IState that = (IState)o;
-                               String thisName = this.getName();
-                               String thatName = that.getName();
+                               String thisName = this.getStateName();
+                               String thatName = that.getStateName();
                                retVal = thisName.compareTo(thatName) == 0;
                        }
                }
@@ -56,12 +57,12 @@ public class State implements IState {
        @Override
        public int compareTo(Object o) {
                int retVal = 0;
-               if(name != null) {
+               if(stateType != null) {
                        if(o != null) {
                                if(o instanceof IState) {
                                        IState that = (IState)o;
-                                       String thisName = this.getName();
-                                       String thatName = that.getName();
+                                       String thisName = this.getStateName();
+                                       String thatName = that.getStateName();
                                        retVal = thisName.compareTo(thatName);
                                }
                        }
@@ -70,11 +71,16 @@ public class State implements IState {
        }
        
        @Override
-       public String getName() {
-               return name;
+       public String getStateName() {
+               return stateType.name();
        }
        
-       private void setName(String value) {
-               name = value;
+       @Override
+       public StateType getStateType() {
+               return stateType;
+       }
+       
+       private void setStateType(StateType value) {
+               stateType = value;
        }
 }

Modified: 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IEvent.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IEvent.java?rev=1761090&r1=1761089&r2=1761090&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IEvent.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IEvent.java
 Fri Sep 16 21:12:51 2016
@@ -20,5 +20,23 @@ package org.apache.uima.ducc.container.c
 
 public interface IEvent extends Comparable<Object> {
 
-       public String getName();
+       public enum EventType {
+               Get_Request,
+               CAS_Available,
+               CAS_Unavailable,
+               Ack_Request,
+               Send_Failure,
+               Ack_Timer_Pop,
+               End_Request,
+               End_Timer_Pop,
+               Host_Failure,
+               Process_Failure,
+               Process_Premept,
+               Process_Volunteered,
+               Investment_Reset,
+               ;
+       }
+       
+       public String getEventName();
+       public EventType getEventType();
 }

Modified: 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IState.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IState.java?rev=1761090&r1=1761089&r2=1761090&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IState.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/common/fsm/iface/IState.java
 Fri Sep 16 21:12:51 2016
@@ -20,5 +20,14 @@ package org.apache.uima.ducc.container.c
 
 public interface IState extends Comparable<Object> {
 
-       public String getName();
+       public enum StateType {
+               Start,
+               Get_Pending,
+               CAS_Send,
+               CAS_Active,
+               ;
+       }
+       
+       public String getStateName();
+       public StateType getStateType();
 }


Reply via email to