org.universAAL.middleware.ui.impl.generic
Class CoordinatedStrategy

Package class diagram package CoordinatedStrategy
java.lang.Object
  extended by java.lang.Thread
      extended by org.universAAL.middleware.bus.model.BusStrategy
          extended by org.universAAL.middleware.ui.impl.generic.EventBasedStrategy
              extended by org.universAAL.middleware.ui.impl.generic.CallBasedStrategy
                  extended by org.universAAL.middleware.ui.impl.generic.CoordinatedStrategy
All Implemented Interfaces:
Runnable, SharedObjectListener, AALSpaceListener
Direct Known Subclasses:
CoordinatedRegistrationManagement

public class CoordinatedStrategy
extends CallBasedStrategy
implements AALSpaceListener, SharedObjectListener

Strategy stack dedicated only to manage Coordination of the bus.
This strategy consists of 3 basic events:

  1. Coordinator_Broadcast : used to announce coordinator and respond to coordinator requests
  2. Coordinator_Request: used to request a coordinator when there is not one yet
  3. Coordinator_Resign: used by the coordinator instance to resign from being a coordinator.
UIStrategy messages
The strategy subscribes to the AALSpaceManager to listen to lost peers, in case they are the coordinator; or if the Coordinator has left the coordinated space, it automatically surrenders coordination. Also new Peers joining the space will proactively be informed about who is the coordinator.

Author:
amedrano

Nested Class Summary
static class CoordinatedStrategy.CoordinatorAlreadyExistsException
          Exception indicating there is already a Coordinator.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String TYPE_uAAL_UI_BUS_COORDINATOR_BROADCAST
           
static String TYPE_uAAL_UI_BUS_COORDINATOR_REQUEST
           
static String TYPE_uAAL_UI_BUS_COORDINATOR_RESIGN
           
 
Fields inherited from class org.universAAL.middleware.bus.model.BusStrategy
bus, busModule, commModule
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CoordinatedStrategy(CommunicationModule commModule)
           
CoordinatedStrategy(CommunicationModule commModule, String name)
           
 
Method Summary
 void aalSpaceJoined(AALSpaceDescriptor spaceDescriptor)
          
 void aalSpaceLost(AALSpaceDescriptor spaceDescriptor)
          
 void aalSpaceStatusChanged(AALSpaceStatus status)
          
 void close()
          Tearing down
 PeerCard getCoordinator()
           
protected  boolean iAmCoordinator()
           
protected  void lostCoordinator()
          Extending classes may override this method to perform any opertation needed when the coordinator is lost.
 void newPeerJoined(PeerCard peer)
          
 void peerLost(PeerCard peer)
          
protected  void requestBecomeACoordinator()
          Check the conditions and announce this Peer as coordinator.
protected  void resignFromCoordinator()
          Check and announce this Peer is no longer the coordinator.
 void sharedObjectAdded(Object sharedObj, Object removeHook)
          
 void sharedObjectRemoved(Object removeHook)
          
 void start()
          
 
Methods inherited from class org.universAAL.middleware.ui.impl.generic.CallBasedStrategy
abortAll, abortCall, handle, placeAsynchronousRequest, placeAsynchronousRequest, placeSynchronousRequest, placeSynchronousRequest, sendAsynchronousResponse, sendAsynchronousResponse, sendSynchronousResponse
 
Methods inherited from class org.universAAL.middleware.ui.impl.generic.EventBasedStrategy
sendEventToRemoteBusMember, sendEventToRemoteBusMember, sendEventToRemoteBusMember, sendEventToRemoteBusMember, sendEventToRemoteBusMember
 
Methods inherited from class org.universAAL.middleware.bus.model.BusStrategy
buildChannelMessage, getBusMember, getLocalBusByName, handleMessage, run, send, setBus, stopThread
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_uAAL_UI_BUS_COORDINATOR_BROADCAST

public static final String TYPE_uAAL_UI_BUS_COORDINATOR_BROADCAST
See Also:
Constant Field Values

TYPE_uAAL_UI_BUS_COORDINATOR_REQUEST

public static final String TYPE_uAAL_UI_BUS_COORDINATOR_REQUEST
See Also:
Constant Field Values

TYPE_uAAL_UI_BUS_COORDINATOR_RESIGN

public static final String TYPE_uAAL_UI_BUS_COORDINATOR_RESIGN
See Also:
Constant Field Values
Constructor Detail

CoordinatedStrategy

public CoordinatedStrategy(CommunicationModule commModule)
Parameters:
commModule -

CoordinatedStrategy

public CoordinatedStrategy(CommunicationModule commModule,
                           String name)
Parameters:
commModule -
name -
Method Detail

lostCoordinator

protected void lostCoordinator()
Extending classes may override this method to perform any opertation needed when the coordinator is lost.


start

public void start()

Overrides:
start in class Thread

iAmCoordinator

protected final boolean iAmCoordinator()

requestBecomeACoordinator

protected final void requestBecomeACoordinator()
                                        throws CoordinatedStrategy.CoordinatorAlreadyExistsException
Check the conditions and announce this Peer as coordinator.

Throws:
CoordinatedStrategy.CoordinatorAlreadyExistsException

resignFromCoordinator

protected final void resignFromCoordinator()
                                    throws CoordinatedStrategy.CoordinatorAlreadyExistsException
Check and announce this Peer is no longer the coordinator.

Throws:
CoordinatedStrategy.CoordinatorAlreadyExistsException - in case this peer is not the coordinator.

getCoordinator

public final PeerCard getCoordinator()

aalSpaceJoined

public void aalSpaceJoined(AALSpaceDescriptor spaceDescriptor)

Specified by:
aalSpaceJoined in interface AALSpaceListener
Parameters:
spaceDescriptor - Space desce

aalSpaceLost

public void aalSpaceLost(AALSpaceDescriptor spaceDescriptor)

Specified by:
aalSpaceLost in interface AALSpaceListener
Parameters:
spaceDescriptor - Space desce

newPeerJoined

public void newPeerJoined(PeerCard peer)

Specified by:
newPeerJoined in interface AALSpaceListener
Parameters:
peer - PeerCard

peerLost

public void peerLost(PeerCard peer)

Specified by:
peerLost in interface AALSpaceListener

aalSpaceStatusChanged

public void aalSpaceStatusChanged(AALSpaceStatus status)

Specified by:
aalSpaceStatusChanged in interface AALSpaceListener

sharedObjectAdded

public void sharedObjectAdded(Object sharedObj,
                              Object removeHook)

Specified by:
sharedObjectAdded in interface SharedObjectListener

sharedObjectRemoved

public void sharedObjectRemoved(Object removeHook)

Specified by:
sharedObjectRemoved in interface SharedObjectListener

close

public void close()
Tearing down



Copyright © 2014 universAAL Consortium. All Rights Reserved.