mapping
Class EndOfFailureAnnouncer

java.lang.Object
  extended by mapping.EndOfFailureAnnouncer
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class EndOfFailureAnnouncer
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable

Author:
Majd Kokaly This thread is responsible for announcing the end of an artificial failure period for an artificially down server. It keeps track of failed servers and the time when they should become up again and in turn it wakes up and announce the server up again.
See Also:
Serialized Form

Nested Class Summary
static class EndOfFailureAnnouncer.TimeNodeForServers
          This class represents the time when a server should be declared as up.
 
Constructor Summary
EndOfFailureAnnouncer(Mapper mapper)
          A default constructor.
 
Method Summary
 void add(double AfterInMinutes, Server server)
          This method is used to add nodes.
 long getCurrentSleepTime()
           
 Mapper getMapper()
           
 boolean isAlive()
           
 void print()
           
 void run()
          This thread has a list of nodes.
 void setAlive(boolean alive)
           
 void setCurrentSleepTime(long currentSleepTime)
           
 void setMapper(Mapper mapper)
           
 void startThread()
          This method starts this thread.
 void stopThread()
          This method stops this thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EndOfFailureAnnouncer

public EndOfFailureAnnouncer(Mapper mapper)
A default constructor.

Parameters:
mapper - To set the mapper field.
Method Detail

getCurrentSleepTime

public long getCurrentSleepTime()

setCurrentSleepTime

public void setCurrentSleepTime(long currentSleepTime)

isAlive

public boolean isAlive()

setAlive

public void setAlive(boolean alive)

getMapper

public Mapper getMapper()

setMapper

public void setMapper(Mapper mapper)

add

public void add(double AfterInMinutes,
                Server server)
This method is used to add nodes. Each node represents a time that this thread should wake up and announce that the server is up.

Parameters:
AfterInMinutes - The number of minutes for the server to stay down.
server - The Server object in subject.
See Also:
EndOfFailureAnnouncer.TimeNodeForServers

startThread

public void startThread()
This method starts this thread.


stopThread

public void stopThread()
This method stops this thread.


print

public void print()

run

public void run()
This thread has a list of nodes. Every node represents a time in which a server should become up again. The nodes in the link list is sorted. The first node is the node with the nearest time. This thread sleeps until it is the time to declare the server of the first node up. Then it wakes up and declare it up. If new nodes are inserted the list is modified and the sleep times of the thread are modified as well.

Specified by:
run in interface java.lang.Runnable