Changeset 37

Show
Ignore:
Timestamp:
04/17/08 00:45:03 (9 months ago)
Author:
jordi
Message:

fixed ticket#18; TimerTasks? are processed ad-hoc (see ChordNode? and SymphonyNode?)

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/conf/chord.properties

    r34 r37  
    5353 
    5454# The default initial network size 
    55 FACTORIES_NETWORKSIZE = 100 
     55FACTORIES_NETWORKSIZE = 1000 
    5656 
    5757 
     
    8686# The print level for whole network (to use by GenericApp.printNetwork() method) 
    8787# Default possible values: 0 (no print), 1 (pretty print), 2 (full print) 
    88 SIMULATOR_PRINT_LEVEL = 2 
     88SIMULATOR_PRINT_LEVEL = 0 
    8989 
    9090# The environment for the current simulation 
  • trunk/conf/master.properties

    r34 r37  
    3636 
    3737################################################################################ 
    38 SIMNETTEST = ../conf/chord.properties 
    39 #SIMNETTEST = ../conf/symphony.properties 
     38#SIMNETTEST = ../conf/chord.properties 
     39SIMNETTEST = ../conf/symphony.properties 
    4040 
    4141################################################################################ 
  • trunk/src/planet/chord/ChordNode.java

    r34 r37  
    2828import planet.util.Properties; 
    2929import planet.util.Queue; 
     30import planet.util.timer.TimerTask; 
    3031import planet.util.timer.TimerTaskImpl; 
    3132 
     
    4546public class ChordNode extends planet.generic.commonapi.NodeImpl { 
    4647         
     48        private static final long serialVersionUID = -3646239557272943682L; 
     49 
    4750        /* ******************  CONSTANTS FOR MODE OF ROUTEMESSAGE *******/ 
    4851         
     
    236239        protected NodeHandle[] temp; 
    237240         
     241        /* 
     242         * Periodic tasks 
     243         */ 
     244        /** 
     245         * Stabilization task 
     246         */ 
     247        private TimerTask stabilizeTask = new StabilizeTask(); 
     248        /** 
     249         * Stabilization period (num. of steps) 
     250         */ 
     251        private int stabPeriod = ((ChordProperties)Properties.overlayPropertiesInstance).stabilizeSteps; 
     252        /** 
     253         * FixFinger task 
     254         */ 
     255        private TimerTask fixFingerTask = new FixFingerTask(); 
     256        /** 
     257         * FixFinger period (num. of steps) 
     258         */ 
     259        private int fixFingerPeriod = ((ChordProperties)Properties.overlayPropertiesInstance).fixFingerSteps; 
     260        /** 
     261         * Step when node has joined. 
     262         */ 
     263        private int nodeHasJoinedStep = Logger.getStep(); 
     264 
    238265         
    239266        /** 
     
    250277                hasFailed = false; 
    251278                hasReceivedSucc = true;   //permits the send 
    252          
    253         //add stabilize timer 
    254         setTimer(new StabilizeTask(),  ((ChordProperties)Properties.overlayPropertiesInstance).stabilizeSteps, 
    255                 ((ChordProperties)Properties.overlayPropertiesInstance).stabilizeSteps); 
    256         // add fix finger timer 
    257         setTimer(new FixFingerTask(),  ((ChordProperties)Properties.overlayPropertiesInstance).fixFingerSteps, 
    258                 ((ChordProperties)Properties.overlayPropertiesInstance).fixFingerSteps); 
    259  
    260279        } 
    261280         
     
    838857                clearFingerChanges(); 
    839858                super.process(actualStep); 
     859                if (((actualStep - nodeHasJoinedStep)%stabPeriod)==0) 
     860                        stabilizeTask.run(); 
     861                if (((actualStep - nodeHasJoinedStep)%fixFingerPeriod)==0) 
     862                        fixFingerTask.run(); 
    840863                while (hasMoreMessages()) { 
    841864                        dispatcher(nextMessage()); 
  • trunk/src/planet/generic/commonapi/NodeImpl.java

    r11 r37  
    106106        public boolean process(int actualStep) { 
    107107                processed = 0; 
    108                 processTasks(); 
     108                if (tasks.size()>0) 
     109                        processTasks();  
    109110                return true; 
    110111        } 
  • trunk/src/planet/symphony/SymphonyNode.java

    r36 r37  
    1919import planet.generic.commonapi.behaviours.BehavioursPatternImpl; 
    2020import planet.generic.commonapi.factory.GenericFactory; 
    21 import planet.results.LinkStateResults; 
    2221import planet.simulate.Globals; 
    2322import planet.simulate.Logger; 
     
    2625import planet.symphony.messages.NeighbourMessagePool; 
    2726import planet.util.Properties; 
     27import planet.util.timer.TimerTask; 
    2828import planet.util.timer.TimerTaskImpl; 
    2929 
     
    4242        extends planet.generic.commonapi.NodeImpl  
    4343{ 
     44        private static final long serialVersionUID = 3721749298036723514L; 
    4445         
    4546        /* ******************  CONSTANTS FOR MODE OF ROUTEMESSAGE *******/ 
     
    137138    private NodeHandle estimationNH = null; 
    138139     
    139      
     140    /** 
     141         * Stabilization task 
     142         */ 
     143        private TimerTask stabilizeTask = new StabilizeTask(); 
     144        /** 
     145         * Stabilization period (num. of steps) 
     146         */ 
     147        private int stabPeriod = ((SymphonyProperties)Properties.overlayPropertiesInstance).stabilizeSteps; 
     148        /** 
     149         * Step when node has joined. 
     150         */ 
     151        private int nodeHasJoinedStep = Logger.getStep(); 
     152 
    140153    /** 
    141154     * Gets the maximum number of successors per node. 
     
    171184        statisticStabilizationSteps = SymphonyNode.getSuccessorsNumber()*24; 
    172185        behPool = GenericFactory.getDefaultBehavioursPool(); 
    173  
    174         // Stabilize Timer 
    175         setTimer(new StabilizeTask(),  ((SymphonyProperties)Properties.overlayPropertiesInstance).stabilizeSteps, 
    176                 ((SymphonyProperties)Properties.overlayPropertiesInstance).stabilizeSteps); 
    177186    } 
    178187         
     
    707716        requestedNewLongDistance = false; //permits only one QUERY_CONNECT by step 
    708717                super.process(actualStep); 
     718                if (((actualStep - nodeHasJoinedStep)%stabPeriod)==0) 
     719                        stabilizeTask.run(); 
    709720                while (hasMoreMessages()) { 
    710721                        //planet.results.LinkStateResults.updateIncoming(this.id); 
  • trunk/src/planet/util/timer/SimulationTimerImpl.java

    r34 r37  
    1515 */ 
    1616public class SimulationTimerImpl implements SimulationTimer { 
     17        private static final long serialVersionUID = 1228039166338775231L; 
    1718        private TreeSet tasks = null; 
    1819