hu.mta.sztaki.lpds.cloud.simulator
Class Timed

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.Timed
All Implemented Interfaces:
Comparable<Timed>
Direct Known Subclasses:
DeferredEvent.AggregatedEventDispatcher, EnergyMeter, MonitorConsumption, ResourceSpreader.FreqSyncer

public abstract class Timed
extends Object
implements Comparable<Timed>

This is the base class for the simulation, every class that should receive timing events should extend this and implement the function named "tick".

Author:
"Gabor Kecskemeti, Distributed and Parallel Systems Group, University of Innsbruck (c) 2013" "Gabor Kecskemeti, Laboratory of Parallel and Distributed Systems, MTA SZTAKI (c) 2012"

Field Summary
private  boolean activeSubscription
           
private  boolean backPreference
           
private static long fireCounter
           
private  long frequency
           
private  long nextEvent
           
private static PriorityQueue<Timed> timedlist
           
private static Timed underProcessing
           
 
Constructor Summary
Timed()
           
 
Method Summary
static long calcTimeJump(long jump)
           
 int compareTo(Timed o)
           
static void fire()
           
static long getFireCount()
           
 long getFrequency()
           
 long getNextEvent()
           
static long getNextFire()
           
 boolean isSubscribed()
           
static long jumpTime(long desiredJump)
           
 long nextEventDistance()
           
private  void realSubscribe(long freq)
           
static void resetTimed()
           
protected  void setBackPreference(boolean backPreference)
           
static void simulateUntil(long time)
           
static void simulateUntilLastEvent()
           
static void skipEventsTill(long desiredTime)
          Jumps the time until the time given by the user.
protected  boolean subscribe(long freq)
           
abstract  void tick(long fires)
           
 String toString()
           
protected  boolean unsubscribe()
           
private  void updateEvent(long freq)
           
protected  long updateFrequency(long freq)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timedlist

private static final PriorityQueue<Timed> timedlist

underProcessing

private static Timed underProcessing

fireCounter

private static long fireCounter

activeSubscription

private boolean activeSubscription

nextEvent

private long nextEvent

frequency

private long frequency

backPreference

private boolean backPreference
Constructor Detail

Timed

public Timed()
Method Detail

isSubscribed

public final boolean isSubscribed()

subscribe

protected final boolean subscribe(long freq)

realSubscribe

private void realSubscribe(long freq)

unsubscribe

protected final boolean unsubscribe()

updateFrequency

protected final long updateFrequency(long freq)

updateEvent

private void updateEvent(long freq)

getNextEvent

public long getNextEvent()

getFrequency

public long getFrequency()

nextEventDistance

public long nextEventDistance()

compareTo

public int compareTo(Timed o)
Specified by:
compareTo in interface Comparable<Timed>

setBackPreference

protected void setBackPreference(boolean backPreference)

fire

public static final void fire()

calcTimeJump

public static long calcTimeJump(long jump)

jumpTime

public static final long jumpTime(long desiredJump)

skipEventsTill

public static final void skipEventsTill(long desiredTime)
Jumps the time until the time given by the user. If some events supposed to happen during the jumped time period, then this function cancels them. If some events should be recurring during the period, then the first recurrence of the event will be after the given time instance. If the given time instance has already occurred then this function does nothing!

Parameters:
desiredTime - the time at which the simulation should continue after this call. If the time given here already happened then this function will have no effect.

getFireCount

public static final long getFireCount()

getNextFire

public static final long getNextFire()

simulateUntilLastEvent

public static final void simulateUntilLastEvent()

simulateUntil

public static final void simulateUntil(long time)

resetTimed

public static final void resetTimed()

toString

public String toString()
Overrides:
toString in class Object

tick

public abstract void tick(long fires)


Copyright © 2012–2015 University of Innsbruck & MTA SZTAKI. All rights reserved.