edu.harvard.syrah.pyxida.nc.lib
Class AppCoordClient<T>

java.lang.Object
  extended by edu.harvard.syrah.pyxida.nc.lib.NCClient<T>
      extended by edu.harvard.syrah.pyxida.nc.lib.AppCoordClient<T>
Type Parameters:
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.
All Implemented Interfaces:
NCClientIF<T>

public class AppCoordClient<T>
extends 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
protected  Coordinate app_coord
           
static double APP_UPDATE_THRESHOLD
           
protected  java.util.List<Coordinate> current_coords
           
protected  Coordinate nearest_neighbor
           
protected  ObserverList obs_list
           
protected  EWMAStatistic running_age
           
protected  EWMAStatistic running_app_dd
           
protected  WindowStatistic running_app_error
           
protected  EWMAStatistic running_app_update_frequency
           
protected  EWMAStatistic running_gravity
           
protected  EWMAStatistic running_neighbors_used
           
protected  EWMAStatistic running_relative_diff
           
protected  Coordinate start_centroid
           
protected  java.util.List<Coordinate> start_coords
           
protected  long time_of_last_app_update
           
protected  long time_of_last_sys_update
           
protected  boolean updated_app_coord_at_least_once
           
static int WINDOW_SIZE
           
 
Fields inherited from class edu.harvard.syrah.pyxida.nc.lib.NCClient
COORD_CONTROL, COORD_ERROR, CURRENT_VERSION, DEBUG, error, GRAVITY_DIAMETER, hosts, KEEP_STATS, local_addr, logger, MAINTENANCE_PERIOD, MAX_DIST_FROM_ORIGIN, MAX_ERROR, MAX_NEIGHBORS, MAX_PING_RESPONSE_TIME, MAX_RS_MAP_SIZE, MIN_UPDATE_TIME_TO_PING, neighbors, nf, NFDigits, num_dims, OUTRAGEOUSLY_LARGE_RTT, random, RS_EXPIRATION, rs_map, RUNNING_STAT_HISTORY, running_sys_dd, running_sys_error, running_sys_update_frequency, SIM, sys_coord, USE_HEIGHT, VERBOSE, VERSION_04
 
Constructor Summary
AppCoordClient(int _num_dims)
          Creates a new instance.
 
Method Summary
protected  edu.harvard.syrah.pyxida.nc.lib.AppCoordClient.ApplicationStatistics computeApplicationStatistics()
           
 Coordinate getApplicationCoords()
          Returns the application-level Vivaldi coordinates.
 java.util.Hashtable<java.lang.String,java.lang.Double> getStatistics()
           
 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.
 void reset()
           
 java.lang.String toString()
           
protected  void tryUpdateAppCoordinate(long curr_time)
           
 boolean updatedYet()
          Returns whether the application level coordinates have been updated at least once.
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)
           
 
Methods inherited from class edu.harvard.syrah.pyxida.nc.lib.NCClient
addHost, addHost, addNeighbor, containsHost, getAge, getDistanceDelta, getHosts, getIdFromAddr, getNeighborToPing, getNumDimensions, getObserverList, getSystemCoords, getSystemError, hasAllNeighbors, performMaintenance, printNeighbors, removeHost, removeNeighbor, setLocalID, setRandomSeed, setRealLargeNetworkParameters, shutDown, simpleCoordinateUpdate, stabilized, startUp, updateSystemCoordinate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

APP_UPDATE_THRESHOLD

public static double APP_UPDATE_THRESHOLD

WINDOW_SIZE

public static int WINDOW_SIZE

app_coord

protected Coordinate app_coord

running_app_error

protected WindowStatistic running_app_error

running_app_dd

protected EWMAStatistic running_app_dd

running_neighbors_used

protected EWMAStatistic running_neighbors_used

running_relative_diff

protected EWMAStatistic running_relative_diff

running_app_update_frequency

protected EWMAStatistic running_app_update_frequency

running_age

protected EWMAStatistic running_age

running_gravity

protected EWMAStatistic running_gravity

time_of_last_app_update

protected long time_of_last_app_update

time_of_last_sys_update

protected long time_of_last_sys_update

obs_list

protected ObserverList obs_list

start_centroid

protected Coordinate start_centroid

updated_app_coord_at_least_once

protected boolean updated_app_coord_at_least_once

start_coords

protected final java.util.List<Coordinate> start_coords

current_coords

protected final java.util.List<Coordinate> current_coords

nearest_neighbor

protected Coordinate nearest_neighbor
Constructor Detail

AppCoordClient

public AppCoordClient(int _num_dims)
Creates a new instance. Typically an application should only have one instance of this class, as it only needs one set of Vivaldi coordinates.

Parameters:
_num_dims - the number of Euclidian dimensions coordinates should have
Method Detail

computeApplicationStatistics

protected edu.harvard.syrah.pyxida.nc.lib.AppCoordClient.ApplicationStatistics computeApplicationStatistics()

toString

public java.lang.String toString()
Specified by:
toString in interface NCClientIF<T>
Overrides:
toString in class NCClient<T>

getStatistics

public java.util.Hashtable<java.lang.String,java.lang.Double> getStatistics()
Specified by:
getStatistics in interface NCClientIF<T>
Overrides:
getStatistics in class NCClient<T>

reset

public void reset()
Specified by:
reset in interface NCClientIF<T>
Overrides:
reset in class NCClient<T>

updatedYet

public boolean updatedYet()
Returns whether the application level coordinates have been updated at least once.

Returns:
true if updated, false otherwise

getApplicationCoords

public Coordinate getApplicationCoords()
Returns the application-level Vivaldi coordinates.

Returns:
the application-level coordinates

processSample

public 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. This method succeeds and returns true only if the host is already registered with this VivaldiClient object, and the RTT sample is valid.

Specified by:
processSample in interface NCClientIF<T>
Overrides:
processSample in class NCClient<T>
Parameters:
addr - the address of the host
_r_coord - the system-level coordinates of the remote host
r_error - the system-level error of the remote host
sample_rtt - the RTT sample to the remote host
curr_time - the current time, in milliseconds
can_add - true if this method can add a host not already present
Returns:
true if addr is registered and the sample is processed, false otherwise

updateError

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)
Overrides:
updateError in class NCClient<T>

tryUpdateAppCoordinate

protected void tryUpdateAppCoordinate(long curr_time)