Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

alice.tuplemedium
Class TupleCentreVM  view TupleCentreVM download TupleCentreVM.java

java.lang.Object
  extended byalice.tuplemedium.TupleCentreVM
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
TupleCentreVMImpl

public abstract class TupleCentreVM
extends java.lang.Object
implements java.lang.Runnable

Defines the core behaviour of a tuple centre virtual machine. The behaviour reflects the operational semantic expressed in related tuple centre articles. It is abstract because it not specifies how the output events are dispatched. Note that in order to specify a concrete virtual machine, concrete object implementing TupleSet, EventSet, TRSet, Reactor, Reaction must be specified.

Version:
1.0

Field Summary
protected  long bootTime
          tuple centre boot time in ms
private  java.util.Vector eventVMListeners
          listener to observable virtual machine event (not communication event)
protected  java.util.ArrayList inputEvents
          input event queue
protected  EventSet outputEventSet
          multiset of not satisfiable pending queries Wn - W/(Wn+Wp)
protected  Tuple reactionSpec
          reactions specification (tuple centre reaction behaviour)
protected  Reactor reactor
          reactions manager
protected  TupleSet tSet
          multiset of tuples T
protected  EventSet wnSet
          multiset of not satisfiable pending queries Wn - W/(Wn+Wp)
protected  EventSet wpSet
          multiset of satisfiable pending queries Wp - predicatives (inp,rdp)
protected  EventSet wsSet
          multiset of satisfiable pending queries Ws - not predicatives (in,rd)
protected  TRSet zSet
          multiset of triggered reactions Z
 
Constructor Summary
TupleCentreVM()
           
 
Method Summary
 void acceptEvent(Event ev)
          Accepts a communication event It is the input service of the tuple centre machine, the only way to make the virtual machine aware of an external event to be processed.
 void addObservableEventListener(ObservableEventListener l)
          Registers a new listener to observable events
 void fetchTriggeredReactions(Event ev)
          Collects triggered reaction in zSet
 long getBootTime()
          gets virtual machine boot time
 long getCurrentTime()
          gets current virtual machine time
 Reactor getReactor()
          gets raective component of the vm
 TRSet getTRSet()
          gets triggered event set
 TupleSet getTSet()
          gets tuple set
 EventSet getWnSet()
          gets unsatisfied event set
private  void listen(Event ev)
          listening transition
 void notifyObservableEvent(ObservableEvent e)
          Notifies registered listeners of a new observable event
protected abstract  void notifyOutputEvents()
          Specifies how to dispatch output events (collected in outputEventSet) to related agents
private  void react()
          Reaction transition
 void removeEventsOf(AgentId id)
          Removes all events of specified agent This services is executed in paraller to the virtual machine thread of control.
 void removeObservableEventListener(ObservableEventListener l)
          Removes (if present) a listener to observable events
 void reset()
          resets the virtual machine to boot state
 void run()
          Expresses the behaviour of the thread of control of the virtual machine
private  void speak()
          speaking transition (see articles).
 void spy(java.lang.String m)
           
private  void spyState()
           
private  void waitEvents()
          blocks the current thread waiting for event incoming pre condition: zSet, wsSet, wpSet empty and inputEvents empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bootTime

protected long bootTime
tuple centre boot time in ms


tSet

protected TupleSet tSet
multiset of tuples T


wpSet

protected EventSet wpSet
multiset of satisfiable pending queries Wp - predicatives (inp,rdp)


wsSet

protected EventSet wsSet
multiset of satisfiable pending queries Ws - not predicatives (in,rd)


wnSet

protected EventSet wnSet
multiset of not satisfiable pending queries Wn - W/(Wn+Wp)


zSet

protected TRSet zSet
multiset of triggered reactions Z


inputEvents

protected java.util.ArrayList inputEvents
input event queue


outputEventSet

protected EventSet outputEventSet
multiset of not satisfiable pending queries Wn - W/(Wn+Wp)


reactionSpec

protected Tuple reactionSpec
reactions specification (tuple centre reaction behaviour)


reactor

protected Reactor reactor
reactions manager


eventVMListeners

private java.util.Vector eventVMListeners
listener to observable virtual machine event (not communication event)

Constructor Detail

TupleCentreVM

public TupleCentreVM()
Method Detail

notifyOutputEvents

protected abstract void notifyOutputEvents()
Specifies how to dispatch output events (collected in outputEventSet) to related agents


acceptEvent

public final void acceptEvent(Event ev)
Accepts a communication event It is the input service of the tuple centre machine, the only way to make the virtual machine aware of an external event to be processed. The event is placed in the satisfiable list or notSatisfiable list, according to the current tuple space state This service is executed concurrently to the thread of control of the tuple centre virtual machine, so it requires synchronization.


removeEventsOf

public final void removeEventsOf(AgentId id)
Removes all events of specified agent This services is executed in paraller to the virtual machine thread of control.


speak

private final void speak()
speaking transition (see articles).

pre condition: zSet.isEmpty && (!wsSet.isEmpty() || !wpSet.isEmpty())


react

private final void react()
Reaction transition


listen

private final void listen(Event ev)
listening transition


run

public final void run()
Expresses the behaviour of the thread of control of the virtual machine

Specified by:
run in interface java.lang.Runnable

waitEvents

private final void waitEvents()
blocks the current thread waiting for event incoming pre condition: zSet, wsSet, wpSet empty and inputEvents empty


fetchTriggeredReactions

public final void fetchTriggeredReactions(Event ev)
Collects triggered reaction in zSet


notifyObservableEvent

public final void notifyObservableEvent(ObservableEvent e)
Notifies registered listeners of a new observable event


addObservableEventListener

public final void addObservableEventListener(ObservableEventListener l)
Registers a new listener to observable events


removeObservableEventListener

public final void removeObservableEventListener(ObservableEventListener l)
Removes (if present) a listener to observable events


getBootTime

public final long getBootTime()
gets virtual machine boot time


getCurrentTime

public final long getCurrentTime()
gets current virtual machine time


getTSet

public final TupleSet getTSet()
gets tuple set


getWnSet

public final EventSet getWnSet()
gets unsatisfied event set


getTRSet

public final TRSet getTRSet()
gets triggered event set


getReactor

public final Reactor getReactor()
gets raective component of the vm


spy

public void spy(java.lang.String m)

spyState

private void spyState()

reset

public final void reset()
resets the virtual machine to boot state