hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1145791 - in /hadoop/common/branches/MR-279/mapreduce: CHANGES.txt yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/state/StateMachineFactory.java
Date Tue, 12 Jul 2011 22:03:15 GMT
Author: mahadev
Date: Tue Jul 12 22:03:14 2011
New Revision: 1145791

URL: http://svn.apache.org/viewvc?rev=1145791&view=rev
Log:
MAPREDUCE-2663. Refactoring StateMachineFactory inner classes. (ahmed radwan via mahadev)

Modified:
    hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/state/StateMachineFactory.java

Modified: hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/CHANGES.txt?rev=1145791&r1=1145790&r2=1145791&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/CHANGES.txt (original)
+++ hadoop/common/branches/MR-279/mapreduce/CHANGES.txt Tue Jul 12 22:03:14 2011
@@ -5,6 +5,9 @@ Trunk (unreleased changes)
 
     MAPREDUCE-279
 
+    MAPREDUCE-2663. Refactoring StateMachineFactory inner classes. (ahmed 
+    radwan via mahadev)
+
     MAPREDUCE-2400. Remove Cluster's dependency on JobTracker via a 
     ServiceProvider for the actual implementation. (tomwhite via acmurthy) 
  

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/state/StateMachineFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/state/StateMachineFactory.java?rev=1145791&r1=1145790&r2=1145791&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/state/StateMachineFactory.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/state/StateMachineFactory.java
Tue Jul 12 22:03:14 2011
@@ -102,7 +102,7 @@ final public class StateMachineFactory
     }
   }
 
-  static private class ApplicableSingleTransition
+  static private class ApplicableSingleOrMultipleTransition
              <OPERAND, STATE extends Enum<STATE>,
               EVENTTYPE extends Enum<EVENTTYPE>, EVENT>
           implements ApplicableTransition<OPERAND, STATE, EVENTTYPE, EVENT> {
@@ -110,7 +110,7 @@ final public class StateMachineFactory
     final EVENTTYPE eventType;
     final Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition;
 
-    ApplicableSingleTransition
+    ApplicableSingleOrMultipleTransition
         (STATE preState, EVENTTYPE eventType,
          Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition) {
       this.preState = preState;
@@ -135,42 +135,6 @@ final public class StateMachineFactory
     }
   }
 
-  static private class ApplicableMultipleTransition
-             <OPERAND, STATE extends Enum<STATE>,
-              EVENTTYPE extends Enum<EVENTTYPE>, EVENT>
-          implements ApplicableTransition<OPERAND, STATE, EVENTTYPE, EVENT> {
-    final STATE preState;
-    final Set<STATE> postStates;
-    final EVENTTYPE eventType;
-    final Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition;
-
-    ApplicableMultipleTransition
-        (STATE preState, Set<STATE> postStates, EVENTTYPE eventType,
-         Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition) {
-      this.preState = preState;
-      this.postStates = postStates;
-      this.eventType = eventType;
-      this.transition = transition;
-    }
-
-    @Override
-    public void apply
-             (StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> subject) {
-
-      Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>> transitionMap
-        = subject.stateMachineTable.get(preState);
-      if (transitionMap == null) {
-        // I use HashMap here because I would expect most EVENTTYPE's to not
-        //  apply out of a particular state, so FSM sizes would be 
-        //  quadratic if I use EnumMap's here as I do at the top level.
-        transitionMap = new HashMap<EVENTTYPE,
-          Transition<OPERAND, STATE, EVENTTYPE, EVENT>>();
-        subject.stateMachineTable.put(preState, transitionMap);
-      }
-      transitionMap.put(eventType, transition);
-    }
-  }
-
   /**
    * @return a NEW StateMachineFactory just like {@code this} with the current
    *          transition added as a new legal transition.  This overload
@@ -258,7 +222,7 @@ final public class StateMachineFactory
                         EVENTTYPE eventType,
                         SingleArcTransition<OPERAND, EVENT> hook){
     return new StateMachineFactory
-        (this, new ApplicableSingleTransition
+        (this, new ApplicableSingleOrMultipleTransition
            (preState, eventType, new SingleInternalArc(postState, hook)));
   }
 
@@ -282,9 +246,8 @@ final public class StateMachineFactory
                         MultipleArcTransition<OPERAND, EVENT, STATE> hook){
     return new StateMachineFactory
         (this,
-         new ApplicableMultipleTransition
-           (preState, postStates,
-            eventType, new MultipleInternalArc(postStates, hook)));
+         new ApplicableSingleOrMultipleTransition
+           (preState, eventType, new MultipleInternalArc(postStates, hook)));
   }
 
   /**



Mime
View raw message