|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.harvard.syrah.pyxida.nc.lib.NCClient<T>
T
- the type of the unique identifier of a host
A note about time: Try to not use System.currentTimeMillis or
similar references to the system's time in this code. This code
should be able to run in simulation, where arbitrary times are
passed in as parameters.public class NCClient<T>
A class that is responsible for updating the local Vivaldi coordinates, both at the system and application level, and also maintaining the state of remote hosts that support Vivaldi.
Field Summary | |
---|---|
static double |
COORD_CONTROL
|
static double |
COORD_ERROR
|
static byte |
CURRENT_VERSION
|
static boolean |
DEBUG
|
protected double |
error
|
static double |
GRAVITY_DIAMETER
|
protected java.util.Set<T> |
hosts
|
static boolean |
KEEP_STATS
|
protected T |
local_addr
|
protected static edu.harvard.syrah.prp.Log |
logger
|
static long |
MAINTENANCE_PERIOD
|
static double |
MAX_DIST_FROM_ORIGIN
|
static double |
MAX_ERROR
|
static int |
MAX_NEIGHBORS
|
static long |
MAX_PING_RESPONSE_TIME
|
static int |
MAX_RS_MAP_SIZE
|
static long |
MIN_UPDATE_TIME_TO_PING
|
protected java.util.List<RemoteState<T>> |
neighbors
|
protected static java.text.NumberFormat |
nf
|
protected static int |
NFDigits
|
protected int |
num_dims
|
protected ObserverList |
obs_list
|
static double |
OUTRAGEOUSLY_LARGE_RTT
|
static java.util.Random |
random
|
static long |
RS_EXPIRATION
|
protected java.util.HashMap<T,RemoteState<T>> |
rs_map
|
static int |
RUNNING_STAT_HISTORY
|
protected EWMAStatistic |
running_sys_dd
|
protected WindowStatistic |
running_sys_error
|
protected EWMAStatistic |
running_sys_update_frequency
|
static boolean |
SIM
|
protected Coordinate |
sys_coord
|
protected long |
time_of_last_sys_update
|
static boolean |
USE_HEIGHT
|
static boolean |
VERBOSE
|
static byte |
VERSION_04
|
Constructor Summary | |
---|---|
NCClient(int _num_dims)
Creates a new instance. |
Method Summary | |
---|---|
boolean |
addHost(T addr)
Notifies this VivaldiClient object that a host that supports
Vivaldi has joined the system. |
boolean |
addHost(T addr,
Coordinate _r_coord,
double r_error,
long curr_time,
boolean can_update)
Notifies this VivaldiClient object that a host that supports
Vivaldi and has the provided coordinates and error has joined the system. |
protected boolean |
addNeighbor(RemoteState<T> guy)
|
boolean |
containsHost(T addr)
Returns whether the given host has been registered with this VivaldiClient object. |
long |
getAge(long curr_time)
Returns the age of our coordinate Note that this does not require clock-synchronization because it is relative to our coordinate |
double |
getDistanceDelta()
|
java.util.Set<T> |
getHosts()
Returns all hosts that support Vivaldi and have been registered with this VivaldiClient object. |
protected int |
getIdFromAddr(T addr)
|
T |
getNeighborToPing(long curr_time)
|
int |
getNumDimensions()
Returns the dimension of the Euclidian space coordinates are embedded in. |
ObserverList |
getObserverList()
Returns the list of observers, to which observers for the application-level coordinate can be added, removed, and so forth. |
java.util.Hashtable<java.lang.String,java.lang.Double> |
getStatistics()
|
Coordinate |
getSystemCoords()
Returns the system-level Vivaldi coordinates. |
double |
getSystemError()
Returns the system-level error, which denotes the accuracy of the system-level coordinates. |
boolean |
hasAllNeighbors()
|
protected void |
performMaintenance(long curr_time)
|
java.lang.String |
printNeighbors()
|
boolean |
processSample(T addr,
Coordinate _r_coord,
double r_error,
double sample_rtt,
long sample_age,
long curr_time,
boolean can_add)
This method is invoked when a new RTT sample is made to a host that supports Vivaldi. |
boolean |
removeHost(T addr)
Notifies this VivaldiClient object that a host that supports
Vivaldi has left the system. |
protected boolean |
removeNeighbor(RemoteState<T> guy)
|
void |
reset()
|
void |
setLocalID(T _local_addr)
|
static void |
setRandomSeed(long seed)
|
static void |
setRealLargeNetworkParameters()
|
void |
shutDown(java.io.DataOutputStream os)
|
protected void |
simpleCoordinateUpdate(T addr,
Coordinate r_coord,
double r_error,
double rtt,
double sample_rtt,
long sample_age,
int sample_size,
long curr_time)
|
boolean |
stabilized()
|
void |
startUp(java.io.DataInputStream is)
|
java.lang.String |
toString()
|
protected void |
updateError(T addr,
Coordinate r_coord,
double r_error,
double smoothed_rtt,
double sample_rtt,
long sample_age,
int sample_size,
long curr_time)
|
protected void |
updateSystemCoordinate(long curr_time)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static edu.harvard.syrah.prp.Log logger
public static boolean KEEP_STATS
public static boolean DEBUG
public static boolean VERBOSE
public static boolean SIM
public static final byte VERSION_04
public static final byte CURRENT_VERSION
public static double COORD_ERROR
public static double COORD_CONTROL
public static boolean USE_HEIGHT
public static int MAX_NEIGHBORS
public static long RS_EXPIRATION
public static final long MAINTENANCE_PERIOD
public static final long MAX_PING_RESPONSE_TIME
public static final int MAX_RS_MAP_SIZE
public static java.util.Random random
public static double OUTRAGEOUSLY_LARGE_RTT
public static double GRAVITY_DIAMETER
public static double MAX_DIST_FROM_ORIGIN
public static long MIN_UPDATE_TIME_TO_PING
protected static final java.text.NumberFormat nf
protected static final int NFDigits
protected final int num_dims
protected Coordinate sys_coord
protected double error
public static final double MAX_ERROR
public static int RUNNING_STAT_HISTORY
protected WindowStatistic running_sys_error
protected EWMAStatistic running_sys_dd
protected EWMAStatistic running_sys_update_frequency
protected final java.util.List<RemoteState<T>> neighbors
protected long time_of_last_sys_update
protected final ObserverList obs_list
protected final java.util.HashMap<T,RemoteState<T>> rs_map
protected final java.util.Set<T> hosts
protected T local_addr
Constructor Detail |
---|
public NCClient(int _num_dims)
_num_dims
- the number of Euclidian dimensions coordinates should haveMethod Detail |
---|
public static void setRealLargeNetworkParameters()
public void setLocalID(T _local_addr)
setLocalID
in interface NCClientIF<T>
public java.lang.String toString()
toString
in interface NCClientIF<T>
toString
in class java.lang.Object
public java.util.Hashtable<java.lang.String,java.lang.Double> getStatistics()
getStatistics
in interface NCClientIF<T>
public double getDistanceDelta()
public void reset()
reset
in interface NCClientIF<T>
public int getNumDimensions()
NCClientIF
getNumDimensions
in interface NCClientIF<T>
public Coordinate getSystemCoords()
NCClientIF
getSystemCoords
in interface NCClientIF<T>
public double getSystemError()
NCClientIF
getSystemError
in interface NCClientIF<T>
public long getAge(long curr_time)
NCClientIF
getAge
in interface NCClientIF<T>
public ObserverList getObserverList()
NCClientIF
getObserverList
in interface NCClientIF<T>
public boolean addHost(T addr)
NCClientIF
VivaldiClient
object that a host that supports
Vivaldi has joined the system. State associated with the new host is
created. This method succeeds and returns true
only if the
host is not already registered with this VivaldiClient
object.
addHost
in interface NCClientIF<T>
addr
- the address of the joining host
true
if addr
is registered and its
associated state created, false
otherwisepublic boolean addHost(T addr, Coordinate _r_coord, double r_error, long curr_time, boolean can_update)
NCClientIF
VivaldiClient
object that a host that supports
Vivaldi and has the provided coordinates and error has joined the system.
State associated with the new host is created. This method succeeds and
returns true
only if the host is not already registered with
this VivaldiClient
object.
addHost
in interface NCClientIF<T>
addr
- the address of the joining host_r_coord
- the app-level coordinates of the remote hostr_error
- the system-level error of the remote hostcurr_time
- the current time, in millisecondscan_update
- true
if this method can update a host already
present
true
if addr
is registered and its
associated state created, false
otherwisepublic boolean removeHost(T addr)
NCClientIF
VivaldiClient
object that a host that supports
Vivaldi has left the system. However, the state (i.e. short list of RTT
values) is kept because it will be useful if and when the node returns into
the system
removeHost
in interface NCClientIF<T>
addr
- the address of the departing host
true
if addr
was a known nodepublic boolean containsHost(T addr)
NCClientIF
VivaldiClient
object.
containsHost
in interface NCClientIF<T>
addr
- the address to query as registered
true
if registered, false
otherwisepublic java.util.Set<T> getHosts()
NCClientIF
VivaldiClient
object. The returned set is backed by the true
set of registered hosts, but cannot be modified.
getHosts
in interface NCClientIF<T>
public boolean processSample(T addr, Coordinate _r_coord, double r_error, double sample_rtt, long sample_age, long curr_time, boolean can_add)
NCClientIF
true
only
if the host is already registered with this VivaldiClient
object, and the RTT sample is valid.
processSample
in interface NCClientIF<T>
addr
- the address of the host_r_coord
- the system-level coordinates of the remote hostr_error
- the system-level error of the remote hostsample_rtt
- the RTT sample to the remote hostcurr_time
- the current time, in millisecondscan_add
- true
if this method can add a host not already
present
true
if addr
is registered and the
sample is processed, false
otherwiseprotected int getIdFromAddr(T addr)
protected void simpleCoordinateUpdate(T addr, Coordinate r_coord, double r_error, double rtt, double sample_rtt, long sample_age, int sample_size, long curr_time)
protected void updateError(T addr, Coordinate r_coord, double r_error, double smoothed_rtt, double sample_rtt, long sample_age, int sample_size, long curr_time)
protected boolean addNeighbor(RemoteState<T> guy)
public boolean hasAllNeighbors()
hasAllNeighbors
in interface NCClientIF<T>
public boolean stabilized()
stabilized
in interface NCClientIF<T>
public java.lang.String printNeighbors()
printNeighbors
in interface NCClientIF<T>
protected boolean removeNeighbor(RemoteState<T> guy)
public T getNeighborToPing(long curr_time)
getNeighborToPing
in interface NCClientIF<T>
protected void updateSystemCoordinate(long curr_time)
protected void performMaintenance(long curr_time)
public static void setRandomSeed(long seed)
public void startUp(java.io.DataInputStream is) throws java.io.IOException
startUp
in interface NCClientIF<T>
java.io.IOException
public void shutDown(java.io.DataOutputStream os) throws java.io.IOException
shutDown
in interface NCClientIF<T>
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |