You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(123) |
Dec
(100) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(12) |
Feb
(80) |
Mar
(35) |
Apr
|
May
|
Jun
(28) |
Jul
(10) |
Aug
(6) |
Sep
|
Oct
|
Nov
(16) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
| 2009 |
Jan
(20) |
Feb
(1) |
Mar
(19) |
Apr
(12) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
|
From: Jonathan L. <le...@us...> - 2009-01-22 15:15:57
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/sim In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv600/src/edu/harvard/syrah/pyxida/sim Log Message: Directory /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/sim added to the repository |
|
From: Jonathan L. <le...@us...> - 2009-01-22 15:14:23
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv473/src/edu/harvard/syrah/pyxida/nc/lib Modified Files: NCClient.java Coordinate.java NCClientIF.java Added Files: AppCoordClient.java Log Message: Factored out app level coordinates to make each node's coordinate a bit more lightweight. This should allow for better simulations. AppCoordClient has a minor templating problem. Index: NCClientIF.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClientIF.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NCClientIF.java 27 Mar 2008 18:33:01 -0000 1.2 --- NCClientIF.java 22 Jan 2009 15:14:17 -0000 1.3 *************** *** 1,3 **** --- 1,7 ---- + package edu.harvard.syrah.pyxida.nc.lib; + /* + * Pyxida - a network coordinate library + * * Copyright 2008 Jonathan Ledlie and Peter Pietzuch * *************** *** 16,22 **** * limitations under the License. */ - package edu.harvard.syrah.pyxida.nc.lib; ! public interface NCClientIF { ! } --- 20,191 ---- * limitations under the License. */ ! import java.io.DataInputStream; ! import java.io.DataOutputStream; ! import java.io.IOException; ! import java.util.Hashtable; ! import java.util.Set; ! public interface NCClientIF<T> { ! ! // for debugging simulations ! public abstract void setLocalID(T _local_addr); ! ! public abstract String toString(); ! ! public abstract Hashtable<String, Double> getStatistics(); ! ! public abstract void reset(); ! ! /** ! * Returns the dimension of the Euclidian space coordinates are embedded in. ! * ! * @return the coordinate space dimension ! */ ! public abstract int getNumDimensions(); ! ! /** ! * Returns the system-level Vivaldi coordinates. These coordinates change more ! * frequently than the application-level coordinates. ! * ! * @return the system-level coordinates ! */ ! public abstract Coordinate getSystemCoords(); ! ! /** ! * Returns the system-level error, which denotes the accuracy of the ! * system-level coordinates. ! * ! * @return the system-level error ! */ ! public abstract double getSystemError(); ! ! /** ! * Returns the age of our coordinate Note that this does not require ! * clock-synchronization because it is relative to our coordinate ! * ! * @return relative age of our coordinate since we last updated it ! */ ! public abstract long getAge(long curr_time); ! ! /** ! * Returns the list of observers, to which observers for the application-level ! * coordinate can be added, removed, and so forth. ! * ! * @return the list of observers for the application-level coordinate ! */ ! public abstract ObserverList getObserverList(); ! ! /** ! * Notifies this <code>VivaldiClient</code> object that a host that supports ! * Vivaldi has joined the system. State associated with the new host is ! * created. This method succeeds and returns <code>true</code> only if the ! * host is not already registered with this <code>VivaldiClient</code> ! * object. ! * ! * @param addr ! * the address of the joining host ! * @return <code>true</code> if <code>addr</code> is registered and its ! * associated state created, <code>false</code> otherwise ! */ ! public abstract boolean addHost(T addr); ! ! /** ! * Notifies this <code>VivaldiClient</code> 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 <code>true</code> only if the host is not already registered with ! * this <code>VivaldiClient</code> object. ! * ! * @param addr ! * the address of the joining host ! * @param _r_coord ! * the app-level coordinates of the remote host ! * @param r_error ! * the system-level error of the remote host ! * @param sample_rtt ! * the RTT sample to the remote host ! * @param curr_time ! * the current time, in milliseconds ! * @param can_update ! * <code>true</code> if this method can update a host already ! * present ! * @return <code>true</code> if <code>addr</code> is registered and its ! * associated state created, <code>false</code> otherwise ! */ ! ! public abstract boolean addHost(T addr, Coordinate _r_coord, ! double r_error, long curr_time, boolean can_update); ! ! /** ! * Notifies this <code>VivaldiClient</code> 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 ! * ! * @param addr ! * the address of the departing host ! * @return <code>true</code> if <code>addr</code> was a known node ! */ ! ! public abstract boolean removeHost(T addr); ! ! /** ! * Returns whether the given host has been registered with this ! * <code>VivaldiClient</code> object. ! * ! * @param addr ! * the address to query as registered ! * @return <code>true</code> if registered, <code>false</code> otherwise ! */ ! public abstract boolean containsHost(T addr); ! ! /** ! * Returns all hosts that support Vivaldi and have been registered with this ! * <code>VivaldiClient</code> object. The returned set is backed by the true ! * set of registered hosts, but cannot be modified. ! * ! * @return the set of registered Vivaldi-supporting hosts ! */ ! public abstract Set<T> getHosts(); ! ! /** ! * This method is invoked when a new RTT sample is made to a host that ! * supports Vivaldi. This method succeeds and returns <code>true</code> only ! * if the host is already registered with this <code>VivaldiClient</code> ! * object, and the RTT sample is valid. ! * ! * @param addr ! * the address of the host ! * @param _r_coord ! * the system-level coordinates of the remote host ! * @param r_error ! * the system-level error of the remote host ! * @param sample_rtt ! * the RTT sample to the remote host ! * @param curr_time ! * the current time, in milliseconds ! * @param can_add ! * <code>true</code> if this method can add a host not already ! * present ! * @return <code>true</code> if <code>addr</code> is registered and the ! * sample is processed, <code>false</code> otherwise ! */ ! ! public abstract boolean processSample(T addr, Coordinate _r_coord, ! double r_error, double sample_rtt, long sample_age, long curr_time, ! boolean can_add); ! ! public abstract boolean hasAllNeighbors(); ! ! public abstract boolean stabilized(); ! ! public abstract String printNeighbors(); ! ! public abstract T getNeighborToPing(long curr_time); ! ! public abstract void startUp(DataInputStream is) throws IOException; ! ! public abstract void shutDown(DataOutputStream os) throws IOException; ! ! } \ No newline at end of file Index: Coordinate.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Coordinate.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Coordinate.java 21 Jan 2009 19:22:48 -0000 1.9 --- Coordinate.java 22 Jan 2009 15:14:17 -0000 1.10 *************** *** 197,201 **** if (c == null) { ! assert (!NCClient.SIMULATION); return -1.; } --- 197,201 ---- if (c == null) { ! //assert (!NCClient.SIMULATION); return -1.; } *************** *** 271,275 **** for (int i = 0; i < coords.length; ++i) { if (Double.isNaN(coords[i])) { ! if (NCClient.SIMULATION) System.err.println("coord isNaN i=" + i); return false; --- 271,275 ---- for (int i = 0; i < coords.length; ++i) { if (Double.isNaN(coords[i])) { ! if (NCClient.SIM) System.err.println("coord isNaN i=" + i); return false; *************** *** 277,281 **** if (coords[i] > NCClient.MAX_DIST_FROM_ORIGIN || coords[i] < NEG_MAX_DIST_FROM_ORIGIN) { ! if (NCClient.SIMULATION) System.err.println("coord too far from origin i=" + i + " coord=" + coords[i]); --- 277,281 ---- if (coords[i] > NCClient.MAX_DIST_FROM_ORIGIN || coords[i] < NEG_MAX_DIST_FROM_ORIGIN) { ! if (NCClient.SIM) System.err.println("coord too far from origin i=" + i + " coord=" + coords[i]); --- NEW FILE: AppCoordClient.java --- package edu.harvard.syrah.pyxida.nc.lib; /* * Pyxida - a network coordinate library * * Copyright 2008 Jonathan Ledlie and Peter Pietzuch * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. * * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.logging.Logger; /** * 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. * * @author Michael Parker, Jonathan Ledlie, Peter Pietzuch * * @param <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 AppCoordClient<T> extends NCClient<T> { // Do an update if we've moved a third of the way to our nearest known neighbor. // Lowering this value leads to more frequent updates. // Should be 0.5 or less. public static double APP_UPDATE_THRESHOLD = 0.5; public static int WINDOW_SIZE = 64; protected Coordinate app_coord; protected WindowStatistic running_app_error; protected EWMAStatistic running_app_dd; protected EWMAStatistic running_neighbors_used; protected EWMAStatistic running_relative_diff; protected EWMAStatistic running_app_update_frequency; protected EWMAStatistic running_age; protected EWMAStatistic running_gravity; protected long time_of_last_app_update = -1; // note: not just part of statistics // this is returned to querier of our coords so he knows how stale they are protected long time_of_last_sys_update = -1; protected final ObserverList obs_list; protected Coordinate start_centroid; protected boolean updated_app_coord_at_least_once = false; protected final List<Coordinate> start_coords; protected final List<Coordinate> current_coords; protected Coordinate nearest_neighbor; //protected T local_addr; /** * Creates a new instance. Typically an application should only have one * instance of this class, as it only needs one set of Vivaldi coordinates. * * @param _num_dims * the number of Euclidian dimensions coordinates should have */ public AppCoordClient(int _num_dims) { // super.NCClient (_num_dims); app_coord = new Coordinate(num_dims); start_coords = new LinkedList<Coordinate>(); current_coords = new LinkedList<Coordinate>(); nearest_neighbor = null; if (KEEP_STATS) { running_app_update_frequency = new EWMAStatistic(); running_app_error = new WindowStatistic(RUNNING_STAT_HISTORY); running_sys_dd = new EWMAStatistic(); running_app_dd = new EWMAStatistic(); running_neighbors_used = new EWMAStatistic(); running_relative_diff = new EWMAStatistic(); running_age = new EWMAStatistic(); running_gravity = new EWMAStatistic(); } } // See Lua IMC 2005, Pietzuch WORLDS 2005, Ledlie ICDCS 2006 // for description of these statistics protected ApplicationStatistics computeApplicationStatistics() { ApplicationStatistics appStats = new ApplicationStatistics(); if (sys_coord.atOrigin() || neighbors == null || neighbors.size() == 0) return appStats; int rrl_wrong = 0; int rrl_count = 0; double narl_loss = 0; double narl_sum = 0; double ralp_loss = 0; double ralp_sum = 0; // TODO might want to use the app coord here so as to get the average // location for (Iterator<RemoteState<T>> i = neighbors.iterator(); i.hasNext();) { RemoteState<T> A_rs = i.next(); double A_rtt = A_rs.getSample(); double A_metric = sys_coord.distanceTo(A_rs.getLastCoordinate()); if (A_rtt > 0 && A_metric > 0) { for (Iterator<RemoteState<T>> j = neighbors.iterator(); j.hasNext();) { RemoteState<T> B_rs = j.next(); if (!A_rs.addr.equals(B_rs.addr)) { double B_rtt = B_rs.getSample(); double B_metric = sys_coord.distanceTo(B_rs.getLastCoordinate()); if (B_rtt > 0 && B_metric > 0) { double rtt_diff = Math.abs(A_rtt - B_rtt); rrl_count++; narl_sum += rtt_diff; if ((A_rtt > B_rtt && A_metric < B_metric) || (B_rtt > A_rtt && B_metric < A_metric)) { // oops coordinates have incorrectly ranked // these two guys rrl_wrong++; narl_loss += rtt_diff; } // relative latency penalty for using A, // which the metric says is closer, // when A is actually further away if (A_rtt > B_rtt && A_metric < B_metric) { ralp_loss += rtt_diff; ralp_sum += A_rtt; } if (B_rtt > A_rtt && B_metric < A_metric) { ralp_loss += rtt_diff; ralp_sum += B_rtt; } } } } } } appStats.validLinkCount = rrl_count; if (rrl_count > 0) appStats.rrl = rrl_wrong / (double) rrl_count; if (narl_sum > 0) appStats.narl = narl_loss / narl_sum; if (ralp_sum > 0) appStats.ralp = ralp_loss / ralp_sum; return appStats; } // poor man's public struct class ApplicationStatistics { double rrl = 0; double narl = 0; double ralp = 0; int validLinkCount = 0; public ApplicationStatistics() { }; } synchronized public String toString() { if (KEEP_STATS) { ApplicationStatistics appStats = computeApplicationStatistics(); return new String("[sc=" + sys_coord + ",ac=" + app_coord + ",er=" + nf.format(error) + ",sys_re50=" + nf.format(running_sys_error.getPercentile(.5)) + ",sys_re95=" + nf.format(running_sys_error.getPercentile(.95)) + ",app_re50=" + nf.format(running_app_error.getPercentile(.5)) + ",app_re95=" + nf.format(running_app_error.getPercentile(.95)) + ",sys_dd=" + nf.format(running_sys_dd.get()) + ",app_dd=" + nf.format(running_app_dd.get()) + ",ne=" + nf.format(running_neighbors_used.get()) + ",rd=" + nf.format(running_relative_diff.get()) + ",sf=" + nf.format(running_sys_update_frequency.get()) + ",af=" + nf.format(running_app_update_frequency.get()) + ",rrl=" + nf.format(appStats.rrl) + ",narl=" + nf.format(appStats.narl) + ",ralp=" + nf.format(appStats.ralp) + ",age=" + getAge(System.currentTimeMillis()) + ",vl=" + nf.format(appStats.validLinkCount) + ",gr=" + nf.format(running_gravity.get()) + ",nn=" + nf.format(sys_coord.distanceTo(nearest_neighbor)) + "]"); } else { return new String("[sc=" + sys_coord + ",ac=" + app_coord + ",er=" + nf.format(error) + ",nn=" + nf.format(sys_coord.distanceTo(nearest_neighbor)) + "]"); } } synchronized public Hashtable<String, Double> getStatistics() { Hashtable<String, Double> stats = new Hashtable<String, Double>(); for (int i = 0; i < num_dims; i++) { stats.put("sys_coord_" + i, sys_coord.coords[i]); stats.put("app_coord_" + i, sys_coord.coords[i]); } stats.put("er", error); stats.put("nn", sys_coord.distanceTo(nearest_neighbor)); if (KEEP_STATS) { ApplicationStatistics appStats = computeApplicationStatistics(); stats.put("rrl", appStats.rrl); stats.put("narl", appStats.narl); stats.put("ralp", appStats.ralp); stats.put("age", new Double(getAge(System.currentTimeMillis()))); stats.put("vl", new Double(appStats.validLinkCount)); stats.put("gr", running_gravity.get()); stats.put("sys_re50", running_sys_error.getPercentile(.5)); stats.put("sys_re95", running_sys_error.getPercentile(.95)); stats.put("app_re50", running_app_error.getPercentile(.5)); stats.put("app_re95", running_app_error.getPercentile(.95)); stats.put("sys_dd", running_sys_dd.get()); stats.put("app_dd", running_app_dd.get()); stats.put("ne", running_neighbors_used.get()); stats.put("rd", running_relative_diff.get()); stats.put("sf", running_sys_update_frequency.get()); stats.put("af", running_app_update_frequency.get()); } return stats; } synchronized public void reset() { super.reset(); app_coord.reset(); start_coords.clear(); current_coords.clear(); nearest_neighbor = null; } /** * Returns whether the application level coordinates have been updated at * least once. * * @return <code>true</code> if updated, <code>false</code> otherwise */ synchronized public boolean updatedYet() { return updated_app_coord_at_least_once; } /** * Returns the application-level Vivaldi coordinates. * * @return the application-level coordinates */ synchronized public Coordinate getApplicationCoords() { return new Coordinate(app_coord); } /** * This method is invoked when a new RTT sample is made to a host that * supports Vivaldi. This method succeeds and returns <code>true</code> only * if the host is already registered with this <code>VivaldiClient</code> * object, and the RTT sample is valid. * * @param addr * the address of the host * @param _r_coord * the system-level coordinates of the remote host * @param r_error * the system-level error of the remote host * @param sample_rtt * the RTT sample to the remote host * @param curr_time * the current time, in milliseconds * @param can_add * <code>true</code> if this method can add a host not already * present * @return <code>true</code> if <code>addr</code> is registered and the * sample is processed, <code>false</code> otherwise */ synchronized public boolean processSample(T addr, Coordinate _r_coord, double r_error, double sample_rtt, long sample_age, long curr_time, boolean can_add) { boolean didUpdate = super.processSample(addr, _r_coord, r_error, sample_rtt, sample_age, curr_time, can_add); if (didUpdate) { tryUpdateAppCoordinate(curr_time); } return didUpdate; } 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) { super.updateError(addr, r_coord, r_error, smoothed_rtt, sample_rtt, sample_age, sample_size, curr_time); double app_distance = 0; if (app_coord != null) app_distance = app_coord.distanceTo(r_coord); if (app_distance == 0.) { if (DEBUG) logger.info("bad distance app " + app_distance); return; } double app_sample_error = Math.abs(app_distance - smoothed_rtt) / smoothed_rtt; if (KEEP_STATS) { running_app_error.add(app_sample_error); } } protected void tryUpdateAppCoordinate(long curr_time) { final double scale_factor = 1.0 / ((double) WINDOW_SIZE); // Make sure app coord always has a value. // calculate centroid of starting coordinates by averaging vectors if (start_coords.size() < WINDOW_SIZE) { Vec start_vec = new Vec(num_dims); start_coords.add(sys_coord); for (Iterator<Coordinate> i = start_coords.iterator(); i.hasNext();) { Coordinate next_coord = i.next(); start_vec.add(next_coord.asVectorFromZero(false)); } start_vec.scale(scale_factor); start_centroid = start_vec.asCoordinateFromZero(false); } current_coords.add(sys_coord); if (current_coords.size() > WINDOW_SIZE) { current_coords.remove(0); } // calculate centroid of current coordinates by averaging vectors Vec curr_vec = new Vec(num_dims); for (Iterator<Coordinate> i = current_coords.iterator(); i.hasNext();) { Coordinate next_coord = i.next(); curr_vec.add(next_coord.asVectorFromZero(false)); } curr_vec.scale(scale_factor); // create centroids Coordinate curr_centroid = curr_vec.asCoordinateFromZero(false); // get distances of centroids from nearest neighbor double start_dist = start_centroid.distanceTo(nearest_neighbor); double curr_dist = curr_centroid.distanceTo(nearest_neighbor); // fraction of space moved through, relative to distance to our NN double relative_diff = Math.abs((start_dist - curr_dist) / start_dist); if (KEEP_STATS) { running_relative_diff.add(relative_diff); } if (relative_diff > APP_UPDATE_THRESHOLD) { // exceed threshold, update application-level coordinate updated_app_coord_at_least_once = true; // clear coordinate windows start_coords.clear(); current_coords.clear(); } // This will keep updating the observers as we get rolling // until we've had one time when the coord windows differ boolean did_update = false; if (relative_diff > APP_UPDATE_THRESHOLD || !updated_app_coord_at_least_once) { if (KEEP_STATS) { double app_dd = app_coord.distanceTo(curr_centroid); running_app_dd.add(app_dd); } app_coord = curr_centroid; did_update = true; // If we've gotten ourselves into a situation where the coord // very accurate, stop always updating the app. // Currently can only use this if keep track of statistics if (KEEP_STATS) { final double MIN_SYS_ERROR_SIZE = (RUNNING_STAT_HISTORY / 8.); if (!updated_app_coord_at_least_once && running_sys_error.getSize() > MIN_SYS_ERROR_SIZE && running_sys_error.getPercentile(.5) < 0.20) { updated_app_coord_at_least_once = true; } } // notify observers of new application-level coordinate for (Iterator<ApplicationObserver> i = obs_list.iterator(); i.hasNext();) { ApplicationObserver obs = i.next(); obs.coordinatesUpdated(app_coord); } if (KEEP_STATS) { if (time_of_last_app_update > 0) { long since_last_app_update = curr_time - time_of_last_app_update; running_app_update_frequency.add(since_last_app_update); } time_of_last_app_update = curr_time; } } if (DEBUG) { System.out.println("app_coord update: done " + did_update + " rolling " + updated_app_coord_at_least_once + " start " + start_coords.size() + " current " + current_coords.size() + " diff " + nf.format(relative_diff)); } } } Index: NCClient.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClient.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NCClient.java 21 Jan 2009 19:51:18 -0000 1.13 --- NCClient.java 22 Jan 2009 15:14:17 -0000 1.14 *************** *** 52,80 **** * passed in as parameters. */ ! public class NCClient<T> implements NCClientIF { ! ! // protected static edu.harvard.syrah.prp.Log crawler_log = ! // new edu.harvard.syrah.prp.Log(VivaldiClient.class); ! protected static Logger crawler_log = Logger.getLogger(NCClient.class.getName()); ! ! public static final boolean SIMULATION = false; ! [...1455 lines suppressed...] *************** *** 1289,1292 **** --- 867,873 ---- } + /* (non-Javadoc) + * @see edu.harvard.syrah.pyxida.nc.lib.NCClientIF#startUp(java.io.DataInputStream) + */ public void startUp(DataInputStream is) throws IOException { *************** *** 1303,1306 **** --- 884,890 ---- } + /* (non-Javadoc) + * @see edu.harvard.syrah.pyxida.nc.lib.NCClientIF#shutDown(java.io.DataOutputStream) + */ synchronized public void shutDown(DataOutputStream os) throws IOException { // could also save a number of neighbors |
|
From: Jonathan L. <le...@us...> - 2009-01-21 19:51:23
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12957/src/edu/harvard/syrah/pyxida/nc/lib Modified Files: NCClient.java Log Message: Put in spots in code where alg links to NSDI paper. It does not appear that delta is being used (line 5), but that time (neighbor decay) is being used instead. Hmm, some simulations are in order. Index: NCClient.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClient.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NCClient.java 19 Dec 2008 02:50:54 -0000 1.12 --- NCClient.java 21 Jan 2009 19:51:18 -0000 1.13 *************** *** 782,785 **** --- 782,789 ---- assert (smoothed_rtt > 0.); + + // line 2 in NSDI paper + // compute epsilon aka sys_sample_error + // epsilon = | |x_i - x_j| - l(i,j) | / l(i,j) double sys_sample_error = Math.abs(sys_distance - smoothed_rtt) / smoothed_rtt; double app_sample_error = Math.abs(app_distance - smoothed_rtt) / smoothed_rtt; *************** *** 806,810 **** --- 810,820 ---- // EWMA on error + // lines 1 and 3 in NSDI paper + // (1) w_s = w_i / (w_i + w_j) + // (3) alpha = c_e * w_s double alpha = error / (error + r_error) * COORD_ERROR; + + // line 4 in NSDI paper + // w_i = (alpha * epsilon) + ( (1-alpha) * w_i ) error = (sys_sample_error * alpha) + ((1 - alpha) * error); *************** *** 1045,1048 **** --- 1055,1060 ---- Vec unitVector = sys_coord.getDirection(neighbor.getLastCoordinate()); double latency = neighbor.getSample(); + + // ~line 1 in NSDI paper (except we are using our current confidence) double weight = error / (neighbor.getLastError() + error); if (weight == 0.) *************** *** 1051,1054 **** --- 1063,1070 ---- // error of sample double sampleError = distance - latency; + + // TODO seems like weight should be used here as well. + // JL has a vague memory of this just leading to slower convergence + // but not affecting actual error, but this could be wrong. double sampleWeight = 1.; if (sampleWeightSum > 0) { |
|
From: Jonathan L. <le...@us...> - 2009-01-21 19:22:52
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11697/src/edu/harvard/syrah/pyxida/nc/lib Modified Files: Coordinate.java Log Message: Fixed bug #2 Lorch pointed out: no matter where we are, when we do a bump(), we should move a little. Not just when we are near the origin. Index: Coordinate.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Coordinate.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Coordinate.java 5 Nov 2008 01:22:49 -0000 1.8 --- Coordinate.java 21 Jan 2009 19:22:48 -0000 1.9 *************** *** 155,169 **** } public void bump() { for (int i = 0; i < coords.length; ++i) { ! if (Math.abs(coords[i]) < MIN_COORD) { ! double length = NCClient.random.nextDouble() + MIN_COORD; ! // don't set height to be negative, if we are using it ! if ((!NCClient.USE_HEIGHT || i < coords.length - 1) ! && (NCClient.random.nextBoolean())) { ! length *= -1.; ! } ! coords[i] += length; } } } --- 155,171 ---- } + /** + * Move a small distance along each dimension from where we are currently. + */ + public void bump() { for (int i = 0; i < coords.length; ++i) { ! double length = NCClient.random.nextDouble() + MIN_COORD; ! // don't set height to be negative, if we are using it ! if ((!NCClient.USE_HEIGHT || i < coords.length - 1) ! && (NCClient.random.nextBoolean())) { ! length *= -1.; } + coords[i] += length; } } |
|
From: Jonathan L. <le...@us...> - 2009-01-18 03:16:43
|
Update of /cvsroot/pyxida/Pyxida/sim In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21465/sim Modified Files: vivaldi.cc vs.cc Log Message: releasing 0.1.5 Index: vivaldi.cc =================================================================== RCS file: /cvsroot/pyxida/Pyxida/sim/vivaldi.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** vivaldi.cc 15 Mar 2007 12:20:50 -0000 1.1 --- vivaldi.cc 18 Jan 2009 01:58:05 -0000 1.2 *************** *** 25,29 **** if (debug) ! cout << "\n\nLINE: "<< o_stamp << " me " << myId << " you " << o_yourId << " s " << o_rawLatency << endl; --- 25,29 ---- if (debug) ! cout << "\n\nLINE: EXIT"<< o_stamp << " me " << myId << " you " << o_yourId << " s " << o_rawLatency << endl; Index: vs.cc =================================================================== RCS file: /cvsroot/pyxida/Pyxida/sim/vs.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vs.cc 19 Dec 2008 19:00:52 -0000 1.2 --- vs.cc 18 Jan 2009 01:58:05 -0000 1.3 *************** *** 8,11 **** --- 8,12 ---- #include <unistd.h> #include <signal.h> + #include <map> #include "node.h" *************** *** 91,94 **** --- 92,96 ---- << " -O output prefix\n" << " -z use height\n" + << " -a autonomous system mapping file\n" << " -s seed\n"; exit (-1); *************** *** 105,109 **** char c = 0; char *sampleFile = NULL; ! char *trueLatencyMatrixFile = NULL; int seed = getpid(); int meanLifetime = 0; --- 107,111 ---- char c = 0; char *sampleFile = NULL; ! char *trueLatencyMatrixFile = NULL, *as_map_file; int seed = getpid(); int meanLifetime = 0; *************** *** 111,119 **** bool clearCoordMemory = false; bool bimodalPrune = false; (void) signal(SIGINT, exit_program); ! FILE *fp; ! while ((c = getopt(argc,argv,"BCc:I:bf:n:e:u:s:o:x:h:p:dg:m:t:w:i:l:zr:j:O:k:M")) >= 0) { switch (c) { case 'O': outputPrefix = optarg; --- 113,128 ---- bool clearCoordMemory = false; bool bimodalPrune = false; + bool as_clustering = false; (void) signal(SIGINT, exit_program); + map<int,int> id2as; + char line_buffer [8192]; ! FILE *fp, *as_fp; ! while ((c = getopt(argc,argv,"a:BCc:I:bf:n:e:u:s:o:x:h:p:dg:m:t:w:i:l:zr:j:O:k:M")) >= 0) { switch (c) { + case 'a': + as_map_file = optarg; + as_clustering = true; + break; case 'O': outputPrefix = optarg; *************** *** 279,283 **** #ifdef TRUE_MATRIX ! for (int myId = 0; myId < nodeCount; myId++) { --- 288,294 ---- #ifdef TRUE_MATRIX ! // Scans in files of form ! // L(0,0) L(0,1) L(0,n-1) ! // L(1,0) L(1,1) for (int myId = 0; myId < nodeCount; myId++) { *************** *** 433,436 **** --- 444,474 ---- } + + if (as_clustering) { + if ((as_fp = fopen (as_map_file, "r")) == NULL) { + printf ("Cannot open as_map file %s", as_map_file); + exit (-1); + } + + int as_id = 0; + + while (1) { + memset (line_buffer, 0, sizeof(line_buffer)); + if (fgets(line_buffer, sizeof(line_buffer), as_fp) == NULL) + break; + int node_in_as; + char *line_ptr; + char *lb_ptr = line_buffer; + while (line_ptr = strtok (lb_ptr, " ")) { + lb_ptr = NULL; + int ret = sscanf (line_ptr, "%d", &node_in_as); + ASSERT (ret == 1); + id2as[node_in_as] = as_id; + //printf ("id %d as %d\n", node_in_as, as_id); + } + as_id++; + } + } + if (PING_SAMPLE_PERCENTILE < 0 || PING_SAMPLE_PERCENTILE > 1) { printf ("Bad ping sample percentile\n"); *************** *** 573,576 **** --- 611,630 ---- ASSERT (rawLatencySample > 0); + if (as_clustering) { + if (id2as[myId] == id2as[yourId]) { + float clusterSample = randPct() * 10; + //if (debug) { + //printf ("same AS: me %d you %d as %d lat %f rLat %f\n", + //myId, yourId, id2as[myId], rawLatencySample, + //clusterSample); + //} + rawLatencySample = clusterSample; + } else { + //printf ("diff AS: me %d %d you %d %d lat %f\n", + //myId, yourId, id2as[myId], id2as[yourId], + //rawLatencySample); + } + } + nodes[myId].processSample (stamp, myId, yourId, rawLatencySample); |
|
From: Jonathan L. <le...@us...> - 2008-12-19 19:00:58
|
Update of /cvsroot/pyxida/Pyxida/sim In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24280 Modified Files: Makefile vs.cc Log Message: added signal handling to vivaldi simulator to allow for unbounded runs that can be stopped after looking at the log file (untested) Index: vs.cc =================================================================== RCS file: /cvsroot/pyxida/Pyxida/sim/vs.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** vs.cc 15 Mar 2007 12:20:50 -0000 1.1 --- vs.cc 19 Dec 2008 19:00:52 -0000 1.2 *************** *** 4,9 **** --- 4,17 ---- */ + // For ctrl-c + #include <stdio.h> + #include <unistd.h> + #include <signal.h> + #include "node.h" + int stamp = 0; + int ROUNDS = 0; + bool shutdown = false; int **neighbors; int neighborCount; *************** *** 87,90 **** --- 95,105 ---- } + void exit_program(int sig) { + printf("Caught signal: %d\n", sig); + shutdown = true; + (void) signal(SIGINT, SIG_DFL); + } + + int main (int argc, char **argv) { char c = 0; *************** *** 92,100 **** char *trueLatencyMatrixFile = NULL; int seed = getpid(); - int ROUNDS = 0; int meanLifetime = 0; bool useChurn = false; bool clearCoordMemory = false; bool bimodalPrune = false; FILE *fp; --- 107,115 ---- char *trueLatencyMatrixFile = NULL; int seed = getpid(); int meanLifetime = 0; bool useChurn = false; bool clearCoordMemory = false; bool bimodalPrune = false; + (void) signal(SIGINT, exit_program); FILE *fp; *************** *** 216,220 **** int myId, yourId; ! int stamp = 0; float rawLatencySample; bool *validNode; --- 231,235 ---- int myId, yourId; ! float rawLatencySample; bool *validNode; *************** *** 260,263 **** --- 275,330 ---- int totalLatencySampleCount = 0; int badBounds = 0; + + #define TRUE_MATRIX 1 + #ifdef TRUE_MATRIX + + + + for (int myId = 0; myId < nodeCount; myId++) { + + for (int yourId = 0; yourId < nodeCount; yourId++) { + + int scanRet = 0; + + scanRet = fscanf (fp, "%f", &rawLatencySample); + ASSERT (scanRet == 1); + + + if (yourId < nodeCount - 1) { + scanRet = fscanf (fp, " "); + ASSERT (scanRet == 0); + //printf ("got space\n"); + } else { + scanRet += fscanf (fp, "\n"); + ASSERT (scanRet == 1); + //printf ("got ret\n"); + } + + + //ASSERT (myId >= 0 && myId < nodeCount); + //ASSERT (yourId >= 0 && yourId < nodeCount); + + //if (!sparseOK) { + //ASSERT (rawLatencySample >= 0); + //} + if (myId == yourId) { + if (rawLatencySample != 0) { + fprintf (stderr, "src %d dst %d sample %f\n", + myId, yourId, rawLatencySample); + ASSERT (rawLatencySample == 0); + } + } + if (rawLatencySample < 0) { + //missingCount++; + badLatencySampleCount++; + } + + totalLatencySampleCount++; + rtts[myId][yourId] = rawLatencySample; + } + } + + + #else while (fscanf (fp, "%d %d %f\n", &myId, &yourId, &rawLatencySample) > 0) { if (rawLatencySample > 0.) { *************** *** 278,281 **** --- 345,350 ---- } } + #endif + fclose (fp); if (badLatencySampleCount > 0) { *************** *** 458,462 **** // process from rtts ! while (stamp < ROUNDS) { // pick random sample --- 527,531 ---- // process from rtts ! while (!shutdown && (stamp < ROUNDS || ROUNDS == 0)) { // pick random sample Index: Makefile =================================================================== RCS file: /cvsroot/pyxida/Pyxida/sim/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 15 Mar 2007 12:20:49 -0000 1.1 --- Makefile 19 Dec 2008 19:00:52 -0000 1.2 *************** *** 13,17 **** #PROGRAMS = histogram #PROGRAMS = zone ! #PROGRAMS = vivaldi LD = ld --- 13,17 ---- #PROGRAMS = histogram #PROGRAMS = zone ! PROGRAMS = vivaldi LD = ld |
|
From: Jonathan L. <le...@us...> - 2008-12-19 02:50:59
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17194/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: debugging output for Erics fixes and increased version number, currently running overnight to check for errors and behavior Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** NCManager.java 18 Dec 2008 21:49:51 -0000 1.42 --- NCManager.java 19 Dec 2008 02:50:54 -0000 1.43 *************** *** 734,738 **** // ask our ncClient if it has a preferred gossip node ! if (localNC.primaryNC.stabilized() && localNC.primaryNC.neighborsFull()) { log.info("NCManager - stabilized and full"); neighbor = localNC.primaryNC.getNeighborToPing(System.currentTimeMillis()); --- 734,738 ---- // ask our ncClient if it has a preferred gossip node ! if (localNC.primaryNC.stabilized() && localNC.primaryNC.hasAllNeighbors()) { log.info("NCManager - stabilized and full"); neighbor = localNC.primaryNC.getNeighborToPing(System.currentTimeMillis()); |
|
From: Jonathan L. <le...@us...> - 2008-12-19 02:50:59
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17194/src/edu/harvard/syrah/pyxida/nc/lib Modified Files: NCClient.java RemoteState.java WindowStatistic.java Log Message: debugging output for Erics fixes and increased version number, currently running overnight to check for errors and behavior Index: WindowStatistic.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/WindowStatistic.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WindowStatistic.java 5 Nov 2008 01:22:49 -0000 1.4 --- WindowStatistic.java 19 Dec 2008 02:50:54 -0000 1.5 *************** *** 16,150 **** * limitations under the License. */ ! package edu.harvard.syrah.pyxida.nc.lib; ! ! import java.util.Arrays; ! import java.util.LinkedList; ! import java.util.List; ! ! /* ! * @version $Revision$ on $Date$ ! * @since Mar 7, 2006 ! */ ! ! /** ! * ! */ ! public class WindowStatistic { ! ! // Could be re-written as a circular buffer to avoid ! // memory (re-)alloc ! ! public static boolean debug = false; ! ! protected final int max_history; ! //protected final long expiration; ! protected final List<Statistic> samples; ! protected boolean dirty = true; ! ! // short-cut code (getPercentile was taking a significant percentage of time in simulation) ! protected double previousPercentile = -1; ! protected double previousValue = -1; ! ! class Statistic { ! public final double sample; ! public Statistic (double _sample) { ! sample = _sample; ! } ! /* ! public int compareTo (Object _s) { ! Statistic s = (Statistic)_s; ! if (stamp < s.stamp) ! return -1; ! else if (stamp > s.stamp) ! return 1; ! else ! return 0; ! } ! */ ! public String toString () { ! //return new String ("[i="+sample+",s="+stamp+"]"); ! return new String ("v="+sample); ! } ! } ! ! public WindowStatistic (int _max_history) { ! assert (_max_history >= 0); ! max_history = _max_history; ! samples = new LinkedList<Statistic>(); ! } ! ! synchronized public void clear () { ! samples.clear(); ! dirty = true; ! } ! ! synchronized public void add (double sample) { ! samples.add(new Statistic(sample)); ! dirty = true; ! while (samples.size() > max_history) { ! samples.remove(0); ! if (debug) { ! System.out.println ("tossing sample "+samples.get(0)+", size="+samples.size()); ! } ! } ! } ! ! synchronized public int getSize () { ! return samples.size(); ! } ! ! synchronized public boolean withinVariance (double pct) { ! if (samples.size() < 2) return true; ! double mean = getMean(); ! for (int i = 0; i < samples.size(); i++) { ! double pctDiff = Math.abs(samples.get(i).sample-mean)/mean; ! if (pctDiff > pct) { ! return false; ! } ! } ! return true; ! } ! ! synchronized public double getPercentile (double p) { ! if (!dirty && p == previousPercentile) ! return previousValue; ! double val = calcPercentile (p); ! previousPercentile = p; ! previousValue = val; ! dirty = false; ! return val; ! } ! ! protected double calcPercentile (double p) { ! if (samples.size() == 0) return 0; ! Double[] samples_copy = new Double[samples.size()]; ! for (int i = 0; i < samples.size(); i++) { ! samples_copy[i] = samples.get(i).sample; ! if (debug) ! System.out.println (i+" "+samples_copy[i]); ! } ! Arrays.sort(samples_copy); ! int percentile = (int)(samples_copy.length*p); ! if (percentile < 0) percentile = 0; ! double val = samples_copy[percentile].doubleValue(); ! if (debug) ! System.out.println ("p= "+p+" per="+percentile+" val="+val); ! return val; ! } ! ! protected double getSum () { ! double sampleSum = 0.; ! if (samples.size() > 0) { ! for (int i = 0; i < samples.size(); i++) { ! sampleSum += samples.get(i).sample; ! } ! } ! return sampleSum; ! } ! ! // can be undefined ! public double getMean () { ! return getSum()/getSize(); ! } ! ! } --- 16,150 ---- * limitations under the License. */ ! package edu.harvard.syrah.pyxida.nc.lib; ! ! import java.util.Arrays; ! import java.util.LinkedList; ! import java.util.List; ! ! /* ! * @version $Revision$ on $Date$ ! * @since Mar 7, 2006 ! */ ! ! /** ! * ! */ ! public class WindowStatistic { ! ! // Could be re-written as a circular buffer to avoid ! // memory (re-)alloc ! ! public static boolean debug = false; ! ! protected final int max_history; ! //protected final long expiration; ! protected final List<Statistic> samples; ! protected boolean dirty = true; ! ! // short-cut code (getPercentile was taking a significant percentage of time in simulation) ! protected double previousPercentile = -1; ! protected double previousValue = -1; ! ! class Statistic { ! public final double sample; ! public Statistic (double _sample) { ! sample = _sample; ! } ! /* ! public int compareTo (Object _s) { ! Statistic s = (Statistic)_s; ! if (stamp < s.stamp) ! return -1; ! else if (stamp > s.stamp) ! return 1; ! else ! return 0; ! } ! */ ! public String toString () { ! //return new String ("[i="+sample+",s="+stamp+"]"); ! return new String ("v="+sample); ! } ! } ! ! public WindowStatistic (int _max_history) { ! assert (_max_history >= 0); ! max_history = _max_history; ! samples = new LinkedList<Statistic>(); ! } ! ! synchronized public void clear () { ! samples.clear(); ! dirty = true; ! } ! ! synchronized public void add (double sample) { ! samples.add(new Statistic(sample)); ! dirty = true; ! while (samples.size() > max_history) { ! samples.remove(0); ! if (debug) { ! System.out.println ("tossing sample "+samples.get(0)+", size="+samples.size()); ! } ! } ! } ! ! synchronized public int getSize () { ! return samples.size(); ! } ! ! synchronized public boolean withinVariance (double pct) { ! if (samples.size() < 2) return true; ! double mean = getMean(); ! for (int i = 0; i < samples.size(); i++) { ! double pctDiff = Math.abs(samples.get(i).sample-mean)/mean; ! if (pctDiff > pct) { ! return false; ! } ! } ! return true; ! } ! ! synchronized public double getPercentile (double p) { ! if (!dirty && p == previousPercentile) ! return previousValue; ! double val = calcPercentile (p); ! previousPercentile = p; ! previousValue = val; ! dirty = false; ! return val; ! } ! ! protected double calcPercentile (double p) { ! if (samples.size() == 0) return 0; ! Double[] samples_copy = new Double[samples.size()]; ! for (int i = 0; i < samples.size(); i++) { ! samples_copy[i] = samples.get(i).sample; ! if (debug) ! System.out.println (i+" "+samples_copy[i]); ! } ! Arrays.sort(samples_copy); ! int percentile = (int)(samples_copy.length*p); ! if (percentile < 0) percentile = 0; ! double val = samples_copy[percentile].doubleValue(); ! if (debug) ! System.out.println ("p= "+p+" per="+percentile+" val="+val); ! return val; ! } ! ! protected double getSum () { ! double sampleSum = 0.; ! if (samples.size() > 0) { ! for (int i = 0; i < samples.size(); i++) { ! sampleSum += samples.get(i).sample; ! } ! } ! return sampleSum; ! } ! ! // can be undefined ! public double getMean () { ! return getSum()/getSize(); ! } ! ! } Index: RemoteState.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/RemoteState.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RemoteState.java 18 Dec 2008 21:49:51 -0000 1.4 --- RemoteState.java 19 Dec 2008 02:50:54 -0000 1.5 *************** *** 62,65 **** --- 62,73 ---- } + public String toString () { + return "["+addr+" s "+ping_samples.getSize()+ + " update "+last_update_time+ + " ping "+last_ping_time+ + " error "+last_error+ + " coord "+last_coords+"]"; + } + public T getAddress () { return addr; Index: NCClient.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClient.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NCClient.java 18 Dec 2008 21:49:51 -0000 1.11 --- NCClient.java 19 Dec 2008 02:50:54 -0000 1.12 *************** *** 60,68 **** public static final boolean SIMULATION = false; ! public static boolean debug = false; ! public static boolean debugCrawler = false; // include even good events in output, not just problems ! public static boolean debugGood = false; // Old version --- 60,68 ---- public static final boolean SIMULATION = false; ! public static boolean debug = true; ! public static boolean debugCrawler = true; // include even good events in output, not just problems ! public static boolean debugGood = true; // Old version *************** *** 819,825 **** --- 819,827 ---- if (!neighbors.contains(guy)) { neighbors.add(guy); + crawler_log.info("addNeighbor: adding "+guy); added = true; } if (neighbors.size() > MAX_NEIGHBORS) { + crawler_log.info("addNeighbor: removing "+guy); neighbors.remove(0); } *************** *** 860,865 **** //ERIC START - added ! /* ! public boolean neighborsFull() { if (neighbors.size() < MAX_NEIGHBORS) { return false; --- 862,867 ---- //ERIC START - added ! ! public boolean hasAllNeighbors() { if (neighbors.size() < MAX_NEIGHBORS) { return false; *************** *** 868,872 **** } } ! */ /* --- 870,874 ---- } } ! /* *************** *** 950,961 **** List<RemoteState<T>> grayingNeighbors = new ArrayList<RemoteState<T>>(); for (RemoteState<T> neighbor : neighbors) { if (curr_time - neighbor.getLastPingTime() > MIN_UPDATE_TIME_TO_PING) { grayingNeighbors.add(neighbor); } } if (grayingNeighbors.size() > 0) { - crawler_log.info("picking from grayingNeighbors"); Collections.shuffle(grayingNeighbors); RemoteState<T> neighbor = grayingNeighbors.get(0); --- 952,977 ---- List<RemoteState<T>> grayingNeighbors = new ArrayList<RemoteState<T>>(); + double avgTimeSincePing = 0.; + int pingedNeighborCount = 0, nonPingedNeighborCount = 0; for (RemoteState<T> neighbor : neighbors) { + if (curr_time - neighbor.getLastPingTime() > MIN_UPDATE_TIME_TO_PING) { grayingNeighbors.add(neighbor); } + + if (neighbor.getLastPingTime() > 0) { + avgTimeSincePing += (curr_time - neighbor.getLastPingTime()); + pingedNeighborCount++; + } else { + nonPingedNeighborCount++; + } } + crawler_log.info + ("getNeighborToPing: pinged/non "+ + pingedNeighborCount+"/"+nonPingedNeighborCount+ + " avgTimeSincePing "+(avgTimeSincePing/pingedNeighborCount)+ + " minTime "+MIN_UPDATE_TIME_TO_PING); if (grayingNeighbors.size() > 0) { Collections.shuffle(grayingNeighbors); RemoteState<T> neighbor = grayingNeighbors.get(0); *************** *** 968,980 **** MIN_UPDATE_TIME_TO_PING /= 2; if (MIN_UPDATE_TIME_TO_PING <= 1) MIN_UPDATE_TIME_TO_PING = 1; ! crawler_log.info("lowered MIN_UPDATE_TIME_TO_PING "+MIN_UPDATE_TIME_TO_PING); } return neighbor.getAddress(); } ! crawler_log.info("getNeighborToPing returning null"); // we do want to get some nodes in grayingNeighbors MIN_UPDATE_TIME_TO_PING *= 2; ! crawler_log.info("increased MIN_UPDATE_TIME_TO_PING "+MIN_UPDATE_TIME_TO_PING); return null; } --- 984,1005 ---- MIN_UPDATE_TIME_TO_PING /= 2; if (MIN_UPDATE_TIME_TO_PING <= 1) MIN_UPDATE_TIME_TO_PING = 1; ! crawler_log.info ! ("getNeighborToPing: lowered MIN_UPDATE_TIME_TO_PING " ! +MIN_UPDATE_TIME_TO_PING); } + crawler_log.info + ("getNeighborToPing: picking from grayingNeighbors "+ + grayingNeighbors.size()+"/"+neighbors.size()+ + " "+neighbor.getAddress()); + return neighbor.getAddress(); } ! // we do want to get some nodes in grayingNeighbors MIN_UPDATE_TIME_TO_PING *= 2; ! crawler_log.info ! ("getNeighborToPing: returning null, increased MIN_UPDATE_TIME_TO_PING " ! +MIN_UPDATE_TIME_TO_PING); return null; } *************** *** 1125,1129 **** RemoteState<T> rs = i.next(); if (rs.getLastPingTime() - rs.getLastUpdateTime() > MAX_PING_RESPONSE_TIME) { ! crawler_log.info("performMaintenance removed " + rs.getAddress()); i.remove(); //removeNeighbor(A_rs); --- 1150,1160 ---- RemoteState<T> rs = i.next(); if (rs.getLastPingTime() - rs.getLastUpdateTime() > MAX_PING_RESPONSE_TIME) { ! crawler_log.info ! ("performMaintenance: removed " + rs.getAddress() + ! " lastPing "+rs.getLastPingTime()+ ! " lastUpdate "+rs.getLastUpdateTime()+ ! " diff "+(rs.getLastPingTime()-rs.getLastUpdateTime())+ ! " > MAX "+MAX_PING_RESPONSE_TIME); ! i.remove(); //removeNeighbor(A_rs); |
|
From: Jonathan L. <le...@us...> - 2008-12-19 02:50:59
|
Update of /cvsroot/pyxida/Pyxida In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17194 Modified Files: build.xml Log Message: debugging output for Erics fixes and increased version number, currently running overnight to check for errors and behavior Index: build.xml =================================================================== RCS file: /cvsroot/pyxida/Pyxida/build.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** build.xml 4 Jun 2007 17:47:39 -0000 1.13 --- build.xml 19 Dec 2008 02:50:53 -0000 1.14 *************** *** 13,17 **** <property name="log-nodes" location="log/nodes" /> ! <property name="version" value="0.1.4" /> <property name="Pyxida-jar" value="pyxida-${version}.jar" /> --- 13,17 ---- <property name="log-nodes" location="log/nodes" /> ! <property name="version" value="0.1.5" /> <property name="Pyxida-jar" value="pyxida-${version}.jar" /> *************** *** 134,137 **** --- 134,138 ---- <target name="run-pyxida-jar-profile" description="Execute Pyxida from the jar file with profiling support."> <java classname="edu.harvard.syrah.pyxida.Pyxida" fork="true" maxmemory="256m"> + <sysproperty key="java.library.path" value="/data/jprofiler5/bin/linux-x86"/> <classpath> <pathelement location="${dist}/${Pyxida-jar}"/> *************** *** 139,145 **** <jvmarg value="-ea"/> <!-- Turn on assertions --> <!-- <jvmarg value="-Xloggc:"/> --> ! <jvmarg value="-Xbootclasspath/a:/home/prp/local/jprofiler/bin/agent.jar"/> ! <jvmarg value="-agentlib:jprofilerti"/> <!-- <jvmarg value="-Xrunjprofiler"/> --> <sysproperty key="pyxida.config" value="${pyxida.config}" /> <sysproperty key="java.util.logging.config.file" value="${java.util.logging.config.file}" /> --- 140,148 ---- <jvmarg value="-ea"/> <!-- Turn on assertions --> <!-- <jvmarg value="-Xloggc:"/> --> ! ! <jvmarg value="-Xbootclasspath/a:/data/jprofiler5/bin/agent.jar"/> ! <jvmarg value="-agentlib:jprofilerti=port=8849"/> <!-- <jvmarg value="-Xrunjprofiler"/> --> + <!-- <jvmarg value="-verbose:gc"/> --> <sysproperty key="pyxida.config" value="${pyxida.config}" /> <sysproperty key="java.util.logging.config.file" value="${java.util.logging.config.file}" /> |
|
From: Jonathan L. <le...@us...> - 2008-12-18 22:43:57
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30573/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: first pass on integrating erics changes which make neighbor set more stable Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** NCManager.java 27 Mar 2008 18:33:01 -0000 1.41 --- NCManager.java 18 Dec 2008 21:49:51 -0000 1.42 *************** *** 16,19 **** --- 16,21 ---- * limitations under the License. */ + + package edu.harvard.syrah.pyxida.nc; *************** *** 142,145 **** --- 144,148 ---- public void printStats() { log.info("coord=" + localNC.primaryNC + " " + summarizeNeighbors()); + log.info(localNC.primaryNC.printNeighbors()); } *************** *** 724,741 **** } AddressIF pickGossipNode() { AddressIF neighbor; ! // LOWTODO ask our ncClient if it has a preferred gossip node ! // if not, use somebody from our neighbor set ! neighbor = getUpNeighbor(); ! if (neighbor == null) { ! resetBootstrapNeighbors(); neighbor = getUpNeighbor(); } //assert (neighbor != null) : "Could not find a bootstrap neighbour"; return neighbor; } - } --- 727,759 ---- } + // Note that primaryNC and secondaryNC are using the same set of ping neighbors + // (drawn from primary's suggestions) + AddressIF pickGossipNode() { AddressIF neighbor; ! // ask our ncClient if it has a preferred gossip node ! if (localNC.primaryNC.stabilized() && localNC.primaryNC.neighborsFull()) { ! log.info("NCManager - stabilized and full"); ! neighbor = localNC.primaryNC.getNeighborToPing(System.currentTimeMillis()); ! if (neighbor == null) { ! log.info("NCManager - stabilized and full but null neighbor"); ! neighbor = getUpNeighbor(); ! if (neighbor == null) { ! resetBootstrapNeighbors(); ! neighbor = getUpNeighbor(); ! } ! } ! } else { ! // if not, use somebody from our neighbor set neighbor = getUpNeighbor(); + if (neighbor == null) { + resetBootstrapNeighbors(); + neighbor = getUpNeighbor(); + } } //assert (neighbor != null) : "Could not find a bootstrap neighbour"; return neighbor; } } |
|
From: Jonathan L. <le...@us...> - 2008-12-18 22:43:54
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30573/edu/harvard/syrah/pyxida/nc/lib Modified Files: ApplicationObserver.java NCClient.java RemoteState.java Log Message: first pass on integrating erics changes which make neighbor set more stable Index: RemoteState.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/RemoteState.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RemoteState.java 5 Nov 2008 01:22:49 -0000 1.3 --- RemoteState.java 18 Dec 2008 21:49:51 -0000 1.4 *************** *** 16,161 **** * limitations under the License. */ ! package edu.harvard.syrah.pyxida.nc.lib; ! ! import java.io.BufferedReader; ! import java.io.File; ! import java.io.FileNotFoundException; ! import java.io.FileReader; ! import java.util.StringTokenizer; ! ! ! /** ! * The state kept of a remote node between samples. ! * ! * @author Michael Parker, Jonathan Ledlie ! * ! * @param <T> ! * the type of the unique identifier of a host ! */ ! public class RemoteState<T> { ! // made not final so they can be changed by simulator ! protected static double SAMPLE_PERCENTILE = 0.5; ! // Don't keep more than this many samples ! public static int MAX_SAMPLE_SIZE = 16; ! // Don't use a guy unless we have this many samples ! public static int MIN_SAMPLE_SIZE = 4; ! ! protected final T addr; ! protected final WindowStatistic ping_samples; ! ! protected Coordinate last_coords; ! protected double last_error; ! protected long last_update_time; ! ! public RemoteState(T _addr) { ! addr = _addr; ! ping_samples = new WindowStatistic(MAX_SAMPLE_SIZE); ! ! last_coords = null; ! last_error = 0.0; ! last_update_time = -1L; ! } ! ! public T getAddress () { ! return addr; ! } ! ! public void assign(Coordinate _last_coords, double _last_error, ! long _curr_time) { ! last_coords = _last_coords; ! last_error = _last_error; ! last_update_time = _curr_time; ! } ! ! public void addSample(double sample_rtt, long sample_age, Coordinate r_coord, ! double r_error, long curr_time) { ! ping_samples.add(sample_rtt); ! last_coords = r_coord; ! last_error = r_error; ! if (sample_age > 0) ! last_update_time = curr_time-sample_age; ! else ! last_update_time = curr_time; ! } ! ! public boolean isValid (long curr_time) { ! if (getLastError() <= 0. || last_update_time <= 0 || ! last_coords.atOrigin()) { ! return false; ! } ! ! if (getSampleSize() >= MIN_SAMPLE_SIZE && getSample() > 0) { ! return true; ! } ! ! if (getSampleSize() >= 2 && ping_samples.withinVariance(.1)) { ! return true; ! } ! ! return false; ! } ! ! public double getSample() { ! return ping_samples.getPercentile(SAMPLE_PERCENTILE); ! } ! ! public int getSampleSize() { ! return ping_samples.getSize(); ! } ! /* ! public boolean isLowVariance () { ! return ping_samples.isLowVariance(); ! } ! */ ! ! public Coordinate getLastCoordinate() { ! return last_coords; ! } ! ! public double getLastError() { ! return last_error; ! } ! /* ! public boolean beenSampled() { ! return (last_update_time >= 0L); ! } ! */ ! public long getLastUpdateTime() { ! return last_update_time; ! } ! ! public static void main (String args[]) { ! System.out.println("Testing Remote State Object"); ! String sampleFile = args[0]; ! RemoteState<String> rs = new RemoteState<String>(sampleFile); ! BufferedReader sampleReader = null; ! try { ! sampleReader = new BufferedReader (new FileReader (new File (sampleFile))); ! }catch (FileNotFoundException ex) { ! System.err.println("Cannot open file "+sampleFile+": "+ex); ! System.exit(-1); ! } ! ! long sample_age = 0; ! Coordinate r_coord = null; ! double r_error = 0; ! ! try { ! String sampleLine = sampleReader.readLine(); ! while (sampleLine != null) { ! // reads in timestamp in ms and raw rtt ! StringTokenizer sampleTokenizer = new StringTokenizer (sampleLine); ! long curr_time = Long.parseLong((String)(sampleTokenizer.nextElement())); ! int rawRTT = Integer.parseInt((String)(sampleTokenizer.nextElement())); ! sampleLine = sampleReader.readLine(); ! rs.addSample (rawRTT, sample_age, r_coord, r_error, curr_time); ! double smoothedRTT = rs.getSample(); ! System.out.println(curr_time+" raw "+rawRTT+" smooth "+smoothedRTT); ! } ! } catch (Exception ex) { ! System.err.println("Problem parsing "+sampleFile+": "+ex); ! System.exit(-1); ! } ! } ! ! } --- 16,174 ---- * limitations under the License. */ ! ! package edu.harvard.syrah.pyxida.nc.lib; ! ! import java.io.BufferedReader; ! import java.io.File; ! import java.io.FileNotFoundException; ! import java.io.FileReader; ! import java.util.StringTokenizer; ! ! ! /** ! * The state kept of a remote node between samples. ! * ! * @author Michael Parker, Jonathan Ledlie ! * ! * @param <T> ! * the type of the unique identifier of a host ! */ ! public class RemoteState<T> { ! // made not final so they can be changed by simulator ! protected static double SAMPLE_PERCENTILE = 0.5; ! // Don't keep more than this many samples ! public static int MAX_SAMPLE_SIZE = 16; ! // Don't use a guy unless we have this many samples ! public static int MIN_SAMPLE_SIZE = 4; ! ! protected final T addr; ! protected final WindowStatistic ping_samples; ! ! protected Coordinate last_coords; ! protected double last_error; ! // when we last update our coord vs this node ! protected long last_update_time; ! // when we last pinged this node ! protected long last_ping_time; ! ! public RemoteState(T _addr) { ! addr = _addr; ! ping_samples = new WindowStatistic(MAX_SAMPLE_SIZE); ! ! last_coords = null; ! last_error = 0.0; ! last_update_time = -1L; ! last_ping_time = 0L; ! } ! ! public T getAddress () { ! return addr; ! } ! ! public void assign(Coordinate _last_coords, double _last_error, ! long _curr_time) { ! last_coords = _last_coords; ! last_error = _last_error; ! last_update_time = _curr_time; ! } ! ! public void addSample(double sample_rtt, long sample_age, Coordinate r_coord, ! double r_error, long curr_time) { ! ping_samples.add(sample_rtt); ! last_coords = r_coord; ! last_error = r_error; ! if (sample_age > 0) ! last_update_time = curr_time-sample_age; ! else ! last_update_time = curr_time; ! } ! ! public boolean isValid (long curr_time) { ! if (getLastError() <= 0. || last_update_time <= 0 || ! last_coords.atOrigin()) { ! return false; ! } ! ! if (getSampleSize() >= MIN_SAMPLE_SIZE && getSample() > 0) { ! return true; ! } ! ! if (getSampleSize() >= 2 && ping_samples.withinVariance(.1)) { ! return true; ! } ! ! return false; ! } ! ! public double getSample() { ! return ping_samples.getPercentile(SAMPLE_PERCENTILE); ! } ! ! public int getSampleSize() { ! return ping_samples.getSize(); ! } ! /* ! public boolean isLowVariance () { ! return ping_samples.isLowVariance(); ! } ! */ ! ! public Coordinate getLastCoordinate() { ! return last_coords; ! } ! ! public double getLastError() { ! return last_error; ! } ! /* ! public boolean beenSampled() { ! return (last_update_time >= 0L); ! } ! */ ! public long getLastUpdateTime() { ! return last_update_time; ! } ! ! public long getLastPingTime() { ! return last_ping_time; ! } ! ! public void setLastPingTime(long time) { ! last_ping_time = time; ! } ! ! public static void main (String args[]) { ! System.out.println("Testing Remote State Object"); ! String sampleFile = args[0]; ! RemoteState<String> rs = new RemoteState<String>(sampleFile); ! BufferedReader sampleReader = null; ! try { ! sampleReader = new BufferedReader (new FileReader (new File (sampleFile))); ! }catch (FileNotFoundException ex) { ! System.err.println("Cannot open file "+sampleFile+": "+ex); ! System.exit(-1); ! } ! ! long sample_age = 0; ! Coordinate r_coord = null; ! double r_error = 0; ! ! try { ! String sampleLine = sampleReader.readLine(); ! while (sampleLine != null) { ! // reads in timestamp in ms and raw rtt ! StringTokenizer sampleTokenizer = new StringTokenizer (sampleLine); ! long curr_time = Long.parseLong((String)(sampleTokenizer.nextElement())); ! int rawRTT = Integer.parseInt((String)(sampleTokenizer.nextElement())); ! sampleLine = sampleReader.readLine(); ! rs.addSample (rawRTT, sample_age, r_coord, r_error, curr_time); ! double smoothedRTT = rs.getSample(); ! System.out.println(curr_time+" raw "+rawRTT+" smooth "+smoothedRTT); ! } ! } catch (Exception ex) { ! System.err.println("Problem parsing "+sampleFile+": "+ex); ! System.exit(-1); ! } ! } ! ! } Index: ApplicationObserver.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/ApplicationObserver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ApplicationObserver.java 5 Nov 2008 01:22:49 -0000 1.3 --- ApplicationObserver.java 18 Dec 2008 21:49:51 -0000 1.4 *************** *** 16,33 **** * limitations under the License. */ ! package edu.harvard.syrah.pyxida.nc.lib; ! ! /** ! * An observer to be notified when the application coordinates change. ! * ! * @author Michael Parker, Jonathan Ledlie ! */ ! public interface ApplicationObserver { ! /** ! * This method is invoked when the application-level coordinates are ! * updated. ! * ! * @param new_coords the new application-level coordinates ! */ ! public void coordinatesUpdated(Coordinate new_coords); ! } --- 16,33 ---- * limitations under the License. */ ! package edu.harvard.syrah.pyxida.nc.lib; ! ! /** ! * An observer to be notified when the application coordinates change. ! * ! * @author Michael Parker, Jonathan Ledlie ! */ ! public interface ApplicationObserver { ! /** ! * This method is invoked when the application-level coordinates are ! * updated. ! * ! * @param new_coords the new application-level coordinates ! */ ! public void coordinatesUpdated(Coordinate new_coords); ! } Index: NCClient.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClient.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NCClient.java 5 Nov 2008 01:22:49 -0000 1.10 --- NCClient.java 18 Dec 2008 21:49:51 -0000 1.11 *************** *** 1,3 **** --- 1,7 ---- + package edu.harvard.syrah.pyxida.nc.lib; + /* + * Pyxida - a network coordinate library + * * Copyright 2008 Jonathan Ledlie and Peter Pietzuch * *************** *** 16,20 **** * limitations under the License. */ - package edu.harvard.syrah.pyxida.nc.lib; import java.io.DataInputStream; --- 20,23 ---- *************** *** 43,46 **** --- 46,54 ---- * @param <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> implements NCClientIF { *************** *** 78,83 **** public static boolean USE_HEIGHT = true; // Try to minimize our error between up to MAX_NEIGHBORS guys at once ! final public static int MAX_NEIGHBORS = 512; final protected static int WINDOW_SIZE = 64; --- 86,92 ---- public static boolean USE_HEIGHT = true; + // Note: for larger installations, use e.g. 512 // Try to minimize our error between up to MAX_NEIGHBORS guys at once ! final public static int MAX_NEIGHBORS = 32; final protected static int WINDOW_SIZE = 64; *************** *** 90,93 **** --- 99,104 ---- final public static long MAINTENANCE_PERIOD = 10 * 60 * 1000; // ten minutes + final public static long MAX_PING_RESPONSE_TIME = 10 * 60 * 1000; // ten minutes + // target max number of remote states kept // set to be larger than MAX_NEIGHBORS *************** *** 115,118 **** --- 126,153 ---- // Gravity should keep everybody within this ball public static double MAX_DIST_FROM_ORIGIN = 60000.; + + //ERIC START + /* After STABILIZE_TIME, only ping neighbors from neighbors list + * and do not remove first guy from the neighbors list + * This is to ensure a stable neighbors list + */ + //public static final long STABILIZE_TIME = 1 * 60 * 60 * 1000; //1 hour + + /* + * The time the NCClient has been created/started. + */ + //public long START_TIME; + + /* + * The minimum time to wait before kicking a neighbor off the list + * if that neighbor has not been pinged yet. + */ + public static long MIN_UPDATE_TIME_TO_PING = 2 * MAINTENANCE_PERIOD; + + /* + * The weight to be used in calculating the probability + */ + //public static final double WEIGHT_PING = (double)1.5 * (double)MAINTENANCE_PERIOD; + //ERIC END final static protected NumberFormat nf = NumberFormat.getInstance(); *************** *** 208,211 **** --- 243,250 ---- current_coords = new LinkedList<Coordinate>(); nearest_neighbor = null; + + //ERIC START -- added + //START_TIME = System.currentTimeMillis(); + //ERIC END // bootstrapCoordinates (); *************** *** 656,660 **** if (addr_rs.isValid(curr_time)) { ! addNeighbor(addr_rs); // first update our error updateError(addr, r_coord, r_error, smoothed_rtt, sample_rtt, sample_age, sample_size, --- 695,700 ---- if (addr_rs.isValid(curr_time)) { ! if (!stabilized() || neighbors.size() < MAX_NEIGHBORS) ! addNeighbor(addr_rs); // first update our error updateError(addr, r_coord, r_error, smoothed_rtt, sample_rtt, sample_age, sample_size, *************** *** 688,692 **** } ! // System.out.println ("maint?"); if (lastMaintenanceStamp < curr_time - MAINTENANCE_PERIOD) { performMaintenance(curr_time); --- 728,732 ---- } ! if (lastMaintenanceStamp < curr_time - MAINTENANCE_PERIOD) { performMaintenance(curr_time); *************** *** 787,790 **** --- 827,904 ---- } + + //ERIC START - updated + /* If stabilized, then only add to neighbors if list is not full + * else do the normal thing, add anyway, and if full kick out the first guy + */ + /* + protected boolean addNeighbor(RemoteState<T> guy) { + boolean added = false; + if (stabilized()) { + crawler_log.info("addNeighbor stabilized"); + if (neighbors.size() < MAX_NEIGHBORS) { + if (!neighbors.contains(guy)) { + crawler_log.info("addNeighbor stabilized added"); + neighbors.add(guy); + added = true; + } + } + } else { + crawler_log.info("addNeighbor NOT stabilized"); + if (!neighbors.contains(guy)) { + neighbors.add(guy); + added = true; + } + if (neighbors.size() > MAX_NEIGHBORS) { + neighbors.remove(0); + } + } + return added; + } + */ + //ERIC END + + //ERIC START - added + /* + public boolean neighborsFull() { + if (neighbors.size() < MAX_NEIGHBORS) { + return false; + } else { + return true; + } + } + */ + + /* + public boolean stabilized() { + if (System.currentTimeMillis() >= START_TIME + STABILIZE_TIME) { + return true; + } else { + return false; + } + } + */ + + public boolean stabilized() { + // Could also do something more sophisticated with the app level coordinates + // but this should be a rough approximation. + // May want to be on the lookout for transitional behavior. + // That is, we don't want nodes to suddenly act differently based on this value. + if (error < 0.5) { + return true; + } + return false; + } + + public String printNeighbors() { + String toPrint = ""; + for (Iterator<RemoteState<T>> i = neighbors.iterator(); i.hasNext();) { + RemoteState<T> A_rs = i.next(); + toPrint=toPrint+","+A_rs.getAddress(); + } + return toPrint; + } + //ERIC END + protected boolean removeNeighbor(RemoteState<T> guy) { if (neighbors.contains(guy)) { *************** *** 795,799 **** } ! synchronized public T getNeighborToPing(long curr_time) { final long NEIGHBOR_PING_EXPIRE_TIME = 10 * 60 * 1000; // 10 minutes long expire_time = curr_time - NEIGHBOR_PING_EXPIRE_TIME; --- 909,914 ---- } ! //ERIC START - modified getNeighborToPing to add "weight" probability ! /*synchronized public T getNeighborToPing(long curr_time) { final long NEIGHBOR_PING_EXPIRE_TIME = 10 * 60 * 1000; // 10 minutes long expire_time = curr_time - NEIGHBOR_PING_EXPIRE_TIME; *************** *** 818,822 **** } return null; ! } protected void updateSystemCoordinate(long curr_time) { --- 933,983 ---- } return null; ! }*/ ! ! /* ! * Pick a "random" neighbor from the neighbors list to send a ping request ! * For each neighbor, calculate the weight (probability that it will be ! * sent a ping) ! * If, on the off chance, that no neighbor was picked, then randomly pick ! * one. ! */ ! ! /* ! * JL Note: Eric used a weight here which might be nicer... ! */ ! ! synchronized public T getNeighborToPing(long curr_time) { ! List<RemoteState<T>> grayingNeighbors = new ArrayList<RemoteState<T>>(); ! ! for (RemoteState<T> neighbor : neighbors) { ! if (curr_time - neighbor.getLastPingTime() > MIN_UPDATE_TIME_TO_PING) { ! grayingNeighbors.add(neighbor); ! } ! } ! ! if (grayingNeighbors.size() > 0) { ! crawler_log.info("picking from grayingNeighbors"); ! Collections.shuffle(grayingNeighbors); ! RemoteState<T> neighbor = grayingNeighbors.get(0); ! neighbor.setLastPingTime(curr_time); ! ! // reduce the likely size of graying neighbors ! // if it is (relatively) too big, but only if it is (absolutely) too big ! if (grayingNeighbors.size() > neighbors.size() / 8 && ! grayingNeighbors.size() > 3) { ! MIN_UPDATE_TIME_TO_PING /= 2; ! if (MIN_UPDATE_TIME_TO_PING <= 1) MIN_UPDATE_TIME_TO_PING = 1; ! crawler_log.info("lowered MIN_UPDATE_TIME_TO_PING "+MIN_UPDATE_TIME_TO_PING); ! } ! ! return neighbor.getAddress(); ! } ! crawler_log.info("getNeighborToPing returning null"); ! // we do want to get some nodes in grayingNeighbors ! MIN_UPDATE_TIME_TO_PING *= 2; ! crawler_log.info("increased MIN_UPDATE_TIME_TO_PING "+MIN_UPDATE_TIME_TO_PING); ! return null; ! } ! //ERIC END protected void updateSystemCoordinate(long curr_time) { *************** *** 953,956 **** --- 1114,1140 ---- } } + + //ERIC START + //remove neighbors that are "dead" -- the last update time is more than + //10 minutes (MAINTENANCE_PERIOD) ago + //Also check that the lastPingTime is not greater than the MIN_UPDATE_TIME_TO_PING + + // Toss guys we've pinged but who haven't responded. + + for (Iterator<RemoteState<T>> i = neighbors.iterator(); i.hasNext();) { + RemoteState<T> rs = i.next(); + if (rs.getLastPingTime() - rs.getLastUpdateTime() > MAX_PING_RESPONSE_TIME) { + crawler_log.info("performMaintenance removed " + rs.getAddress()); + i.remove(); + //removeNeighbor(A_rs); + } + } + + //for (RemoteState<T> neighbor : neighbors) { + // if (neighbor.getLastUpdateTime() < (curr_time - MAINTENANCE_PERIOD)) { + // neighbors.remove(neighbor); + // } + //} + //ERIC END } |
|
From: Jonathan L. <le...@us...> - 2008-11-05 01:22:53
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6304 Modified Files: ApplicationObserver.java Coordinate.java EWMAStatistic.java NCClient.java ObserverList.java RemoteState.java Vec.java WindowStatistic.java Removed Files: License.txt Log Message: removed extra references to previous license Index: RemoteState.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/RemoteState.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RemoteState.java 27 Mar 2008 18:33:01 -0000 1.2 --- RemoteState.java 5 Nov 2008 01:22:49 -0000 1.3 *************** *** 24,43 **** import java.util.StringTokenizer; - /* - * NCLib - a network coordinate library - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details ( - * see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ /** --- 24,27 ---- Index: NCClient.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClient.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NCClient.java 27 Mar 2008 18:33:01 -0000 1.9 --- NCClient.java 5 Nov 2008 01:22:49 -0000 1.10 *************** *** 18,38 **** package edu.harvard.syrah.pyxida.nc.lib; - /* - * Pyxida - a network coordinate library - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details ( - * see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - import java.io.DataInputStream; import java.io.DataOutputStream; --- 18,21 ---- Index: WindowStatistic.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/WindowStatistic.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WindowStatistic.java 27 Mar 2008 18:33:01 -0000 1.3 --- WindowStatistic.java 5 Nov 2008 01:22:49 -0000 1.4 *************** *** 18,38 **** package edu.harvard.syrah.pyxida.nc.lib; - /* - * NCLib - a network coordinate library - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details ( see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - import java.util.Arrays; import java.util.LinkedList; --- 18,21 ---- Index: Coordinate.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Coordinate.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Coordinate.java 27 Mar 2008 18:33:01 -0000 1.7 --- Coordinate.java 5 Nov 2008 01:22:49 -0000 1.8 *************** *** 25,45 **** import edu.harvard.syrah.prp.Log; - /* - * Pyxida - a network coordinate library - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details ( - * see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - /** * A coordinate in the Euclidian space. --- 25,28 ---- Index: Vec.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Vec.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Vec.java 27 Mar 2008 18:33:01 -0000 1.5 --- Vec.java 5 Nov 2008 01:22:49 -0000 1.6 *************** *** 19,39 **** /* - * NCLib - a network coordinate library - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details ( see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - /* * A vector in the Euclidian space. */ --- 19,22 ---- Index: ApplicationObserver.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/ApplicationObserver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ApplicationObserver.java 27 Mar 2008 18:33:01 -0000 1.2 --- ApplicationObserver.java 5 Nov 2008 01:22:49 -0000 1.3 *************** *** 18,38 **** package edu.harvard.syrah.pyxida.nc.lib; - /* - * NCLib - a network coordinate library - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details ( see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - /** * An observer to be notified when the application coordinates change. --- 18,21 ---- Index: EWMAStatistic.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/EWMAStatistic.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EWMAStatistic.java 27 Mar 2008 18:33:01 -0000 1.2 --- EWMAStatistic.java 5 Nov 2008 01:22:49 -0000 1.3 *************** *** 23,43 **** package edu.harvard.syrah.pyxida.nc.lib; ! /* ! * NCLib - a network coordinate library ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details ( ! * see the LICENSE file ). ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! public class EWMAStatistic { --- 23,27 ---- package edu.harvard.syrah.pyxida.nc.lib; ! public class EWMAStatistic { Index: ObserverList.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/ObserverList.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObserverList.java 27 Mar 2008 18:33:01 -0000 1.2 --- ObserverList.java 5 Nov 2008 01:22:49 -0000 1.3 *************** *** 18,38 **** package edu.harvard.syrah.pyxida.nc.lib; ! /* ! * NCLib - a network coordinate library ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details ( see the LICENSE file ). ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! import java.util.Iterator; import java.util.LinkedList; --- 18,22 ---- package edu.harvard.syrah.pyxida.nc.lib; ! import java.util.Iterator; import java.util.LinkedList; --- License.txt DELETED --- |
|
From: Cristian L. <clu...@us...> - 2008-08-27 18:18:09
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18860 Modified Files: ICMPPinger.java Log Message: Modified ICMPPinger to send echo requests using raw sockets instead of PCap (needed to work with new PlanetLab versions) Index: ICMPPinger.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/ICMPPinger.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ICMPPinger.java 27 Mar 2008 18:33:01 -0000 1.14 --- ICMPPinger.java 27 Aug 2008 18:18:18 -0000 1.15 *************** *** 1,21 **** /* ! * Copyright 2008 Jonathan Ledlie and Peter Pietzuch ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package edu.harvard.syrah.pyxida.ping; import jpcap.packet.*; import edu.harvard.syrah.prp.ANSI; --- 1,24 ---- /* ! * Copyright 2008 Jonathan Ledlie and Peter Pietzuch ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or ! * implied. ! * ! * See the License for the specific language governing permissions and ! * limitations under the License. ! */ + package edu.harvard.syrah.pyxida.ping; + + import jpcap.JpcapSender; import jpcap.packet.*; import edu.harvard.syrah.prp.ANSI; *************** *** 31,34 **** --- 34,39 ---- class ICMPPinger extends JpcapPinger implements PingerIF { private static final Log log = new Log(JpcapPinger.class); + + protected static JpcapSender rawSender=null; public void init(AddressIF defaultPingAddr, final CB0 cbDone) { *************** *** 44,50 **** pd.sendPacket = createICMP(pd.pingAddr); try { ! sender.sendPacket(pd.sendPacket); } catch (Exception e) { ! log.warn("Failed sending packet: " + e); } pd.sendTS = System.nanoTime() / 1000; --- 49,64 ---- pd.sendPacket = createICMP(pd.pingAddr); try { ! //need to change this to sending an ICMP message on a raw socket ! //apparently, the sendPacket function will do that if we set things up differently though. ! if(rawSender==null) ! { ! rawSender=JpcapSender.openRawSocket(); ! } ! if(rawSender!=null) ! rawSender.sendPacket(pd.sendPacket); ! else ! sender.sendPacket(pd.sendPacket); } catch (Exception e) { ! log.warn("Failed sending packet: " + e + " "+ e.getMessage()); } pd.sendTS = System.nanoTime() / 1000; *************** *** 76,79 **** --- 90,95 ---- ether.dst_mac = gwMAC; icmp.datalink = ether; + + log.debug("Ethernet header for this ICMP ping is "+ether.toString()); return icmp; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:43
|
Update of /cvsroot/pyxida/Pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1688 Added Files: license.txt Log Message: applied Apache 2 license --- NEW FILE: license.txt --- Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:03
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243 Modified Files: LogServer.java Pyxida.java Log Message: applied Apache 2 license Index: Pyxida.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/Pyxida.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Pyxida.java 20 Jul 2007 13:22:18 -0000 1.25 --- Pyxida.java 27 Mar 2008 18:33:01 -0000 1.26 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida; Index: LogServer.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/LogServer.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** LogServer.java 30 Mar 2007 18:03:27 -0000 1.12 --- LogServer.java 27 Mar 2008 18:33:01 -0000 1.13 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:03
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243/nc Modified Files: CoordRequestMsg.java CoordResponseMsg.java GossipRequestMsg.java GossipResponseMsg.java NCManager.java ProxyPingRequestMsg.java ProxyPingResponseMsg.java Log Message: applied Apache 2 license Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** NCManager.java 20 Jul 2007 13:33:15 -0000 1.40 --- NCManager.java 27 Mar 2008 18:33:01 -0000 1.41 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; Index: ProxyPingResponseMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/ProxyPingResponseMsg.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProxyPingResponseMsg.java 20 Mar 2007 12:27:52 -0000 1.3 --- ProxyPingResponseMsg.java 27 Mar 2008 18:33:01 -0000 1.4 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; Index: ProxyPingRequestMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/ProxyPingRequestMsg.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProxyPingRequestMsg.java 20 Mar 2007 12:27:52 -0000 1.3 --- ProxyPingRequestMsg.java 27 Mar 2008 18:33:01 -0000 1.4 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; Index: GossipRequestMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/GossipRequestMsg.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GossipRequestMsg.java 20 Mar 2007 12:27:53 -0000 1.5 --- GossipRequestMsg.java 27 Mar 2008 18:33:01 -0000 1.6 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; Index: CoordResponseMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/CoordResponseMsg.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CoordResponseMsg.java 20 Mar 2007 12:27:53 -0000 1.3 --- CoordResponseMsg.java 27 Mar 2008 18:33:01 -0000 1.4 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; Index: CoordRequestMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/CoordRequestMsg.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CoordRequestMsg.java 20 Mar 2007 12:27:52 -0000 1.3 --- CoordRequestMsg.java 27 Mar 2008 18:33:01 -0000 1.4 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; Index: GossipResponseMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/GossipResponseMsg.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GossipResponseMsg.java 20 Mar 2007 12:27:52 -0000 1.6 --- GossipResponseMsg.java 27 Mar 2008 18:33:01 -0000 1.7 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:03
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243/api Modified Files: APIInstanceIF.java APIManager.java ExternalAPI.java ExternalAPIIF.java XMLRPC_API.java Log Message: applied Apache 2 license Index: ExternalAPIIF.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api/ExternalAPIIF.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ExternalAPIIF.java 3 Jan 2007 10:00:56 -0000 1.14 --- ExternalAPIIF.java 27 Mar 2008 18:33:01 -0000 1.15 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.api; Index: ExternalAPI.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api/ExternalAPI.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ExternalAPI.java 20 Mar 2007 12:27:53 -0000 1.21 --- ExternalAPI.java 27 Mar 2008 18:33:01 -0000 1.22 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.api; Index: APIInstanceIF.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api/APIInstanceIF.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** APIInstanceIF.java 30 Nov 2006 18:47:17 -0000 1.1 --- APIInstanceIF.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.api; Index: APIManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api/APIManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** APIManager.java 1 Dec 2006 17:19:51 -0000 1.5 --- APIManager.java 27 Mar 2008 18:33:01 -0000 1.6 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.api; Index: XMLRPC_API.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api/XMLRPC_API.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** XMLRPC_API.java 30 Mar 2007 18:03:27 -0000 1.8 --- XMLRPC_API.java 27 Mar 2008 18:33:01 -0000 1.9 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.api; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:03
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243/nc/lib Modified Files: ApplicationObserver.java Coordinate.java EWMAStatistic.java NCClient.java NCClientIF.java ObserverList.java RemoteState.java Vec.java WindowStatistic.java Log Message: applied Apache 2 license Index: RemoteState.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/RemoteState.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RemoteState.java 21 Nov 2006 21:14:59 -0000 1.1 --- RemoteState.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: NCClient.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClient.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NCClient.java 20 Mar 2007 13:17:26 -0000 1.8 --- NCClient.java 27 Mar 2008 18:33:01 -0000 1.9 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: WindowStatistic.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/WindowStatistic.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WindowStatistic.java 5 Feb 2007 18:43:04 -0000 1.2 --- WindowStatistic.java 27 Mar 2008 18:33:01 -0000 1.3 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: NCClientIF.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/NCClientIF.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NCClientIF.java 21 Nov 2006 21:14:59 -0000 1.1 --- NCClientIF.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: Coordinate.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Coordinate.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Coordinate.java 5 Feb 2007 18:43:04 -0000 1.6 --- Coordinate.java 27 Mar 2008 18:33:01 -0000 1.7 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: Vec.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Vec.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Vec.java 5 Feb 2007 18:43:04 -0000 1.4 --- Vec.java 27 Mar 2008 18:33:01 -0000 1.5 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: ApplicationObserver.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/ApplicationObserver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ApplicationObserver.java 21 Nov 2006 21:14:59 -0000 1.1 --- ApplicationObserver.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; Index: EWMAStatistic.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/EWMAStatistic.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EWMAStatistic.java 21 Nov 2006 21:14:59 -0000 1.1 --- EWMAStatistic.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * @author Last modified by $Author$ Index: ObserverList.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/ObserverList.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ObserverList.java 21 Nov 2006 21:14:59 -0000 1.1 --- ObserverList.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.nc.lib; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:03
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243/ping Modified Files: ICMPPinger.java JpcapPinger.java PingManager.java Pinger.java PingerIF.java TCPSynPinger.java UDPAppPinger.java Log Message: applied Apache 2 license Index: Pinger.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/Pinger.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Pinger.java 30 Mar 2007 18:03:27 -0000 1.6 --- Pinger.java 27 Mar 2008 18:33:01 -0000 1.7 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; Index: UDPAppPinger.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/UDPAppPinger.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UDPAppPinger.java 20 Mar 2007 12:27:53 -0000 1.5 --- UDPAppPinger.java 27 Mar 2008 18:33:01 -0000 1.6 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; Index: PingManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/PingManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PingManager.java 20 Mar 2007 12:27:53 -0000 1.12 --- PingManager.java 27 Mar 2008 18:33:01 -0000 1.13 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; Index: ICMPPinger.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/ICMPPinger.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ICMPPinger.java 30 Mar 2007 18:03:27 -0000 1.13 --- ICMPPinger.java 27 Mar 2008 18:33:01 -0000 1.14 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; Index: JpcapPinger.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/JpcapPinger.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** JpcapPinger.java 30 Mar 2007 18:03:27 -0000 1.8 --- JpcapPinger.java 27 Mar 2008 18:33:01 -0000 1.9 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; Index: PingerIF.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/PingerIF.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PingerIF.java 20 Mar 2007 12:27:53 -0000 1.4 --- PingerIF.java 27 Mar 2008 18:33:01 -0000 1.5 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; Index: TCPSynPinger.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/TCPSynPinger.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TCPSynPinger.java 30 Mar 2007 18:03:27 -0000 1.10 --- TCPSynPinger.java 27 Mar 2008 18:33:01 -0000 1.11 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.ping; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:02
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/log In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243/log Modified Files: LogManager.java ReportCoordReplyMsg.java ReportCoordReqMsg.java Log Message: applied Apache 2 license Index: ReportCoordReplyMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/log/ReportCoordReplyMsg.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReportCoordReplyMsg.java 20 Mar 2007 12:27:53 -0000 1.4 --- ReportCoordReplyMsg.java 27 Mar 2008 18:33:01 -0000 1.5 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.log; Index: LogManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/log/LogManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LogManager.java 30 Mar 2007 18:03:27 -0000 1.7 --- LogManager.java 27 Mar 2008 18:33:01 -0000 1.8 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.log; Index: ReportCoordReqMsg.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/log/ReportCoordReqMsg.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ReportCoordReqMsg.java 20 Mar 2007 12:27:53 -0000 1.5 --- ReportCoordReqMsg.java 27 Mar 2008 18:33:01 -0000 1.6 *************** *** 1,2 **** --- 1,19 ---- + /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package edu.harvard.syrah.pyxida.log; |
|
From: Jonathan L. <le...@us...> - 2008-03-27 18:33:02
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/knn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1243/knn Modified Files: HyperCubeZoneManager.java KnnSim.java NodeDesc.java Zone.java ZoneManager.java Log Message: applied Apache 2 license Index: HyperCubeZoneManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/knn/HyperCubeZoneManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HyperCubeZoneManager.java 20 Mar 2007 13:17:26 -0000 1.5 --- HyperCubeZoneManager.java 27 Mar 2008 18:33:01 -0000 1.6 *************** *** 1,3 **** --- 1,20 ---- /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * @author Last modified by $Author$ * @version $Revision$ on $Date$ Index: Zone.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/knn/Zone.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Zone.java 21 Mar 2007 13:47:52 -0000 1.5 --- Zone.java 27 Mar 2008 18:33:01 -0000 1.6 *************** *** 1,3 **** --- 1,20 ---- /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * @author Last modified by $Author$ * @version $Revision$ on $Date$ Index: ZoneManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/knn/ZoneManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ZoneManager.java 20 Mar 2007 12:27:53 -0000 1.4 --- ZoneManager.java 27 Mar 2008 18:33:01 -0000 1.5 *************** *** 1,3 **** --- 1,20 ---- /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * @author Last modified by $Author$ * @version $Revision$ on $Date$ Index: KnnSim.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/knn/KnnSim.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** KnnSim.java 20 Mar 2007 13:17:26 -0000 1.6 --- KnnSim.java 27 Mar 2008 18:33:01 -0000 1.7 *************** *** 1,3 **** --- 1,20 ---- /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * @author Last modified by $Author$ * @version $Revision$ on $Date$ Index: NodeDesc.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/knn/NodeDesc.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NodeDesc.java 13 Mar 2007 21:48:08 -0000 1.1 --- NodeDesc.java 27 Mar 2008 18:33:01 -0000 1.2 *************** *** 1,3 **** --- 1,20 ---- /* + * Copyright 2008 Jonathan Ledlie and Peter Pietzuch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * @author Last modified by $Author$ * @version $Revision$ on $Date$ |
|
From: Peter P. <pr...@us...> - 2007-11-19 17:50:12
|
Update of /cvsroot/pyxida/Util-PRP/src/de/ceyco/text In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17572/src/de/ceyco/text Added Files: HtmlEntities2Latin1Charset.java Log Message: Initial checkin --- NEW FILE: HtmlEntities2Latin1Charset.java --- /* * HtmlEntities2Latin1Charset.java * A description of this class is given in the JavaDoc comments * below. * * Created: 10.09.2005 00:57:33 * Copyright (C) 2005 Christian Ey <ey...@in...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package de.ceyco.text; import java.util.HashMap; import java.util.Map; /** * Converts a <code>String</code> containing HTML entities to * a <code>String</code> containing only ISO8859-1 characters. * * Uses <a href="http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html">ISO * 8859-1 table by Martin Ramsch</a>. * * @author <a href="mailto:ey...@in...">Christian Ey</a> * @version 1.0 */ public class HtmlEntities2Latin1Charset { private static final char ENTITY_START = '&'; private static final char ENTITY_END = ';'; private static Map<String, String> iso2htmlMappings = new HashMap<String, String>(); static { String[] mappingArray = new String[] { """, "\"", "&", "&", "<", "<", ">", ">", " ", " ", "¡", "¡", "¢", "¢", "£", "£", "¤", "¤", "¥", "¥", "¦", "¦", "§", "§", "¨", "¨", "©", "©", "ª", "ª", "«", "«", "¬", "¬", "­", "", "®", "®", "¯", "¯", "°", "°", "±", "±", "²", "²", "³", "³", "´", "´", "µ", "µ", "¶", "¶", "·", "·", "¸", "¸", "¹", "¹", "º", "º", "»", "»", "¼", "¼", "½", "½", "¾", "¾", "¿", "¿", "À", "À", "Á", "Á", "Â", "Â", "Ã", "Ã", "Ä", "Ä", "Å", "Å", "Æ", "Æ", "Ç", "Ç", "È", "È", "É", "É", "Ê", "Ê", "Ë", "Ë", "Ì", "Ì", "Í", "Í", "Î", "Î", "Ï", "Ï", "Ð", "Ð", "Ñ", "Ñ", "Ò", "Ò", "Ó", "Ó", "Ô", "Ô", "Õ", "Õ", "Ö", "Ö", "×", "×", "Ø", "Ø", "Ù", "Ù", "Ú", "Ú", "Û", "Û", "Ü", "Ü", "Ý", "Ý", "Þ", "Þ", "ß", "ß", "à", "à", "á", "á", "â", "â", "ã", "ã", "ä", "ä", "å", "å", "æ", "æ", "ç", "ç", "è", "è", "é", "é", "ê", "ê", "ë", "ë", "ì", "ì", "í", "í", "î", "î", "ï", "ï", "ð", "ð", "ñ", "ñ", "ò", "ò", "ó", "ó", "ô", "ô", "õ", "õ", "ö", "ö", "÷", "÷", "ø", "ø", "ù", "ù", "ú", "ú", "û", "û", "ü", "ü", "ý", "ý", "þ", "þ", "ÿ", "ÿ", """, "\"", "&", "&", "<", "<", ">", ">", " ", " ", "¡", "¡", "¢", "¢", "£", "£", "¤", "¤", "¥", "¥", "¦", "¦", "§", "§", "¨", "¨", "©", "©", "ª", "ª", "«", "«", "¬", "¬", "­", "", "®", "®", "¯", "¯", "°", "°", "±", "±", "²", "²", "³", "³", "´", "´", "µ", "µ", "¶", "¶", "·", "·", "¸", "¸", "¹", "¹", "º", "º", "»", "»", "¼", "¼", "½", "½", "¾", "¾", "¿", "¿", "À", "À", "Á", "Á", "Â", "Â", "Ã", "Ã", "Ä", "Ä", "Å", "Å", "Æ", "Æ", "Ç", "Ç", "È", "È", "É", "É", "Ê", "Ê", "Ë", "Ë", "Ì", "Ì", "Í", "Í", "Î", "Î", "Ï", "Ï", "Ð", "Ð", "Ñ", "Ñ", "Ò", "Ò", "Ó", "Ó", "Ô", "Ô", "Õ", "Õ", "Ö", "Ö", "×", "×", "Ø", "Ø", "Ù", "Ù", "Ú", "Ú", "Û", "Û", "Ü", "Ü", "Ý", "Ý", "Þ", "Þ", "ß", "ß", "à", "à", "á", "á", "â", "â", "ã", "ã", "ä", "ä", "å", "å", "æ", "æ", "ç", "ç", "è", "è", "é", "é", "ê", "ê", "ë", "ë", "ì", "ì", "í", "í", "î", "î", "ï", "ï", "ð", "ð", "ñ", "ñ", "ò", "ò", "ó", "ó", "ô", "ô", "õ", "õ", "ö", "ö", "÷", "÷", "ø", "ø", "ù", "ù", "ú", "ú", "û", "û", "ü", "ü", "ý", "ý", "þ", "þ", "ÿ", "ÿ" }; for (int i = 0; i < mappingArray.length; i = i + 2) { iso2htmlMappings.put(mappingArray[i], mappingArray[i+1]); } } /** * Converts a <code>String</code> containing HTML entities to * a <code>String</code> containing only ISO8859-1 characters. * * @param htmlString The <code>String</code> containing HTML * entities * @return A <code>String</code> containing only ISO8859-1 * characters */ public static String convert( String htmlString) { if (htmlString != null) { // first condition is met: input is not null int indexStart = htmlString.indexOf( ENTITY_START); if (indexStart >= 0) { // second condition is met: entity start detected // copy everything from the beginning to entity start into buffer StringBuffer isoBuffer = new StringBuffer( htmlString.substring( 0, indexStart)); while (indexStart >= 0) { int indexEnd = htmlString.indexOf( ENTITY_END, indexStart + 1); if (indexEnd >= 0) { int alternativeStart = htmlString.indexOf( ENTITY_START, indexStart + 1); if ((alternativeStart > indexStart) && (alternativeStart < indexEnd)) { // a second index start is found inbetween current index start // and index end // flush the html string inbetween isoBuffer.append( htmlString.substring( indexStart, alternativeStart)); // use the second index start and loop again indexStart = alternativeStart; } else { String entity = htmlString.substring( indexStart, indexEnd + 1); String isoCharacter = (String) iso2htmlMappings.get( entity); if (isoCharacter != null) { // insert iso character instead of html entity isoBuffer.append( isoCharacter); } else { // illegal entity detected, ignore gracefully isoBuffer.append( entity); } indexStart = htmlString.indexOf( ENTITY_START, indexEnd + 1); if (indexStart >= 0) { // another entity start detected, flush the html string inbetween isoBuffer.append( htmlString.substring( indexEnd + 1, indexStart)); } else { // no further entity start detected, flush rest of html string isoBuffer.append( htmlString.substring( indexEnd + 1)); } } } else { // entity start without matching entity end detected, ignore gracefully isoBuffer.append( htmlString.substring( indexStart)); break; } } return isoBuffer.toString(); } else { // nothing to do return htmlString; } } else { // nothing to do return null; } } } |
|
From: Peter P. <pr...@us...> - 2007-11-19 17:50:08
|
Update of /cvsroot/pyxida/Util-PRP In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17572 Added Files: build.xml Log Message: Initial checkin --- NEW FILE: build.xml --- <project name="Util_PRP" default="compile" basedir="."> <property name="src" location="src" /> <property name="build" location="classes" /> <property name="dist" location="dist" /> <property name="bin" location="bin" /> <property name="lib" location="lib" /> <property name="config" location="config" /> <property name="PRPUtiljar" value="util-prp.jar" /> <property environment="env"/> <path id="classpath"> <pathelement path="${java.class.path}/" /> </path> <target name="init"> <!-- Create the time stamp --> <tstamp /> <!-- Create the build directory structure used by compile --> <mkdir dir="${build}" /> </target> <target name="compile" depends="init" description="Compile the source."> <!-- Compile the java code from ${src} into ${build} --> <javac debug="on" srcdir="${src}" destdir="${build}" classpathref="classpath"/> </target> <target name="jar" depends="compile" description="Create the distribution jar file."> <mkdir dir="${dist}" /> <jar destfile="${dist}/${PRPUtiljar}"> <zipfileset dir="${build}"/> <zipfileset src="${lib}/java-getopt-1.0.12.jar"/> </jar> </target> <target name="clean" description="Clean build and dist directory."> <!-- Delete the ${build} directory trees --> <delete dir="${build}" /> <delete dir="${dist}" /> </target> </project> |
|
From: Peter P. <pr...@us...> - 2007-11-19 17:50:08
|
Update of /cvsroot/pyxida/Util-PRP/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17572/lib Added Files: java-getopt-1.0.12.jar Log Message: Initial checkin --- NEW FILE: java-getopt-1.0.12.jar --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/pyxida/Util-PRP/src/edu/harvard/syrah/prp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17572/src/edu/harvard/syrah/prp Added Files: PrimitiveArray.java PUtil.java Stat2.java LongArray.java Triple.java Debug.java SortedList.java BitArray.java Log.java IntIntArray.java LogFormatter.java ByteArray.java UnknownPropertyException.java ByteArrayClassLoader.java Stat.java PTimer.java ANSI.java NetUtil.java IntArray.java POut.java PError.java RateCalc.java Pair.java TypedMap.java Log Message: Initial checkin --- NEW FILE: PUtil.java --- /* * Created on Apr 28, 2004 */ package edu.harvard.syrah.prp; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.InvalidMarkException; import java.util.*; /** * Useful static utility methods. * * @author prp */ public abstract class PUtil { static Log log = new Log(PUtil.class); private static final long GARBAGE_COLLECTION_DELAY = 1 * 1000; private static Random random = new Random(); public static void sleep(long time) { if (time == 0) return; try { Thread.sleep(time); } catch (InterruptedException e2) { /* ignore */ } } public static long getRandomLong() { return random.nextLong(); } public static int getRandomInt() { return random.nextInt(); } public static long getRandomPosLong() { return Math.abs(random.nextLong()); } public static int getRandomPosInt(int maxInt) { return random.nextInt(maxInt); } public static int getRandomPosInt() { return Math.abs(random.nextInt()); } public static String getRandomString(int minLength, int maxLength) { int start = 'a'; int end = 'z'; StringBuffer sb = new StringBuffer(); for (int i = 0; i < random.nextInt(maxLength - minLength) + minLength; i++) { sb.append((char) (random.nextInt(end - start) + start)); } return sb.toString(); } public static <T> T getRandomObject(Collection<T> collection) { // Is this set empty? if (collection.isEmpty()) return null; Iterator<T> objIt = collection.iterator(); int index = getRandomPosInt(collection.size()) + 1; T obj = null; for (int i = 0; i < index; i++) { obj = objIt.next(); } return obj; } public static Random getRandom() { return random; } public static double getMax(double[] array) { double max = 0; for (int i=0; i < array.length; i++) { if (array[i] > max) max = array[i]; } return max; } public static int getMax(int[] array) { int max = 0; for (int i=0; i < array.length; i++) { if (array[i] > max) max = array[i]; } return max; } public static double getLength(double[] vector) { double length = 0; for (int i = 0; i < vector.length; i++) length += vector[i] * vector[i]; length = Math.sqrt(length); return length; } public static void block() { while (!Thread.currentThread().isInterrupted()) { try { Thread.sleep(100000); } catch (InterruptedException e) { /* ignore */ } } } public static void gc() { System.gc(); System.runFinalization(); System.gc(); try { Thread.sleep(GARBAGE_COLLECTION_DELAY); } catch (InterruptedException e) { POut.abort("Util.gc(): Garbage Collection interrupted."); } } public static void delay(double seconds) { Object dummy = new Object(); synchronized (dummy) { try { dummy.wait(Math.round(seconds * 1000)); } catch (InterruptedException e) { /* ignore */ } } } public static InputStream createInputStream(final ByteBuffer buffer) { return new InputStream() { public synchronized int read() throws IOException { if (!buffer.hasRemaining()) return -1; return buffer.get(); } public synchronized int read(byte[] bytes, int off, int len) throws IOException { if (!buffer.hasRemaining()) return -1; len = Math.min(len, buffer.remaining()); buffer.get(bytes, off, len); return len; } }; } public static byte[] convertInputStreamToByteArray(InputStream is) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[1000]; int read = -1; try { while ((read = is.read(buf, 0, buf.length)) != -1) { baos.write(buf, 0, read); } } catch (IOException e) { log.error("Error converting byte array from stream: " + e); } return baos.toByteArray(); } /** * This methods extends a buffer to a new size by copying it. * * @param oldBuffer * @param newSize * @return */ public static ByteBuffer extendByteBuffer(ByteBuffer oldBuffer, int newSize) { int currentPosition = oldBuffer.position(); int limitPosition = oldBuffer.limit(); int markPosition = 0; try { oldBuffer.reset(); markPosition = oldBuffer.position(); } catch (InvalidMarkException e) { // No mark has been set yet } oldBuffer.position(0); ByteBuffer newBuffer = ByteBuffer.allocate(newSize); newBuffer.put(oldBuffer); newBuffer.position(markPosition); newBuffer.mark(); newBuffer.position(currentPosition); newBuffer.limit(limitPosition); return newBuffer; } public static String getDiffTimeStr(long time1, long time2) { long diff = (time2 - time1) / 1000; int days = (int) (diff / (3600 * 24)); diff -= days * 3600 * 24; int hours = (int) (diff / 3600); diff -= (hours * 3600); int mins = (int) (diff / 60); diff -= mins * 60; int secs = (int) diff; StringBuffer sb = new StringBuffer(); if (days > 1) sb.append(days + " days "); if (days == 1) sb.append(days + " day "); if (hours > 1) sb.append(hours + " hours "); if (hours == 1) sb.append(hours + " hour "); if (mins > 1) sb.append(mins + " mins "); if (mins == 1) sb.append(mins + " min "); if (secs > 1) sb.append(secs + " secs "); if (secs == 1) sb.append(secs + " sec "); if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1); return sb.toString(); } public static final void main(String[] args) { Set<String> set = new HashSet<String>(); set.add("One"); set.add("Two"); set.add("Three"); set.add("Four"); set.add("Five"); for (int i = 0; i < 10; i++) { POut.p((String) getRandomObject(set)); } } } --- NEW FILE: BitArray.java --- /* * Title: ByteArray * Description: Implements a variable size byte array.<p> * Copyright: Copyright (c) 2001 <p> * Company: Computer Laboratory, Cambridge University <p> * @author Peter Pietzuch <pr...@cl...> * @version 1.0 * * (C) Copyright 2001-2003 Peter R Pietzuch * * This file is part of Util. * * Util is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Util is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DSSim; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package edu.harvard.syrah.prp; public class BitArray extends PrimitiveArray { private boolean[] a; public BitArray() { super(); } public BitArray (int initialSize, int growStep) { super(initialSize, growStep); } public BitArray(int initialSize) { super(initialSize); } protected void init(int initialSize) { a = new boolean[initialSize]; } /** * Adds a new byte value to the array. The array is extended if necessary by doubling its size. * * @param byte Byte to be added. */ public void add(boolean b) { if ((len + 1) > a.length) { if (growthStep == 0) multiplySize(2); else resize(a.length + growthStep); } a[len++] = b; } /** * Adds an byte array to the variable size array. All the values are copied. * * @param b Byte array to be copied. * @param size Size of b to be copied. */ public void addAll(boolean[] b, int size) { if (size == 0) return; if ((len + size) > a.length) { if (growthStep == 0) multiplySize(((len + size) / a.length) + 1); else { int factor = ((len + size - a.length) / growthStep) + 1; resize ((factor * growthStep) + a.length); } } for (int i = 0; i < size; i++) a[len++] = b[i]; } /** * Returns the byte value at a particular index. * * @param index Index * @return Byte value */ public boolean get(int index) { if (index >= len) throw new IndexOutOfBoundsException(); return a[index]; } /** * Sets a value in the array to a new value. The index must exist. * * @param value New value * @param index Index */ public void set(boolean value, int index) { if (index >= len) throw new IndexOutOfBoundsException(); a[index] = value; } /** * Returns a new byte array which has the optimal size. This is done by copying. * * @return Byte Array */ public boolean[] getArrayCopy() { boolean[] retA = new boolean[len]; for (int i = 0; i < len; i++) retA[i] = a[i]; return retA; } public boolean[] getArray() { return a; } protected void resize(int newSize) { boolean[] newA = new boolean[newSize]; for (int i = 0; i < a.length; i++) newA[i] = a[i]; a = newA; } public int capacity() { return a.length; } public static void main(String[] args) { Debug.p("hello"); BitArray a1 = new BitArray(100, 100); boolean[] ba = {true, false, true, true, false}; for (int i = 0; i < 1000; i++) { a1.addAll(ba, ba.length); } System.out.println("a1.size() = " + a1.size()); //for (int i = 0; i < a1.size(); i++) //System.out.print(a1.elementAt(i) + " "); System.out.println(); } } --- NEW FILE: PTimer.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Feb 2, 2005 */ package edu.harvard.syrah.prp; import edu.harvard.syrah.prp.ANSI.Color; /** * */ public class PTimer { private static long hardLimit = Long.MAX_VALUE; private long startTime; private boolean isStarted = false; public PTimer() { this(true); } public PTimer(boolean start) { if (start) { startTime = System.nanoTime(); isStarted = true; } } public static void setHardLimit(long newHardLimit) { if (newHardLimit > 0) { hardLimit = newHardLimit; } } public void start() { startTime = System.nanoTime(); isStarted = true; } public boolean isStarted() { return isStarted; } public double stop() { isStarted = false; return (System.nanoTime() - startTime) / 1000000d; } public void setBack(double value) { startTime += (value * 1000000d); } public double lap() { long currentTime = System.nanoTime(); double runningTime = (currentTime - startTime) /1000000d; startTime = currentTime; return runningTime; } public void lap(Log log, String what) { double runningTime = (System.nanoTime() - startTime) / 1000000d; String output = "Lap : " + what + " " + ANSI.color(Color.GREEN, POut.toString(runningTime)) + " ms"; log.main(output); if (hardLimit < runningTime) { log.info(ANSI.color(Color.LIGHTRED, "Timer hit hard limit of " + hardLimit + " ms: " + output)); } } public void stop(Log log, String what) { isStarted = false; double runningTime = (System.nanoTime() - startTime) / 1000000d; String output = "Stop: " + what + " " + ANSI.color(Color.GREEN, POut.toString(runningTime)) + " ms"; log.main(output); if (hardLimit < runningTime) { log.info(ANSI.color(Color.LIGHTRED, "Timer hit hard limit of " + hardLimit + " ms: " + output)); } } public double getTime() { return (System.nanoTime() - startTime) / 1000000d; } public String toString() { return POut.toString(getTime()) + " ms"; } } --- NEW FILE: ByteArrayClassLoader.java --- /* * SBON * * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Jan 17, 2005 */ package edu.harvard.syrah.prp; import java.util.HashMap; import java.util.Map; import edu.harvard.syrah.prp.Log; /** * * This is an implementation of a Java class loader that loads a class from a byte array. * */ public class ByteArrayClassLoader extends ClassLoader { private static final Log log = new Log(ByteArrayClassLoader.class); private Map<String, byte[]> classByteCodeTable = new HashMap<String, byte[]>(); public void addClassByteCode(String className, byte[] byteCode) { classByteCodeTable.put(className, byteCode); } public synchronized Class< ? > loadClass(String name, boolean resolve) throws ClassNotFoundException { log.debug("Trying to load the className=" + name + " dynamically."); Class<?> newClass = findLoadedClass(name); if (newClass != null) return newClass; SecurityManager sm = System.getSecurityManager(); if (sm != null) { int i = name.lastIndexOf('.'); if (i >= 0) sm.checkPackageAccess(name.substring(0, i)); } if (sm != null) { int i = name.lastIndexOf('.'); if (i >= 0) sm.checkPackageDefinition(name.substring(0, i)); } try { //if (parent != null) // newClass = parent.loadClass(name, resolve); //else // Call this method in both 1.1 and 1.2 newClass = findSystemClass(name); if (newClass != null) return newClass; } catch (ClassNotFoundException e) { // Not a system class, simply continue } log.debug("Considering byte code cache."); byte[] byteCode = classByteCodeTable.get(name); //log.debug("byteCode=" + Util.toString(byteCode)); newClass = defineClass(null, byteCode, 0, byteCode.length); log.debug("newClass=" + newClass); if (resolve) resolveClass(newClass); return newClass; } } --- NEW FILE: SortedList.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Sep 8, 2005 */ package edu.harvard.syrah.prp; import java.io.Serializable; import java.util.*; public class SortedList<T> implements List<T>, Serializable { private static final Log log = new Log(SortedList.class); static final long serialVersionUID = 1000000000L; private int maxSize; private Comparator<? super T> comp; private List<T> list = new LinkedList<T>(); public SortedList(Comparator<? super T> comp) { this(0, comp); } public SortedList(int maxSize, Comparator<? super T> comp) { this.maxSize = maxSize; this.comp = comp; } public int size() { return list.size(); } public boolean isEmpty() { return list.isEmpty(); } public boolean contains(Object o) { return list.contains(o); } public Iterator<T> iterator() { return list.iterator(); } public Object[] toArray() { return list.toArray(); } public <U> U[] toArray(U[] a) { return list.toArray(a); } public boolean add(T o) { list.add(o); Collections.sort(list, comp); if (maxSize != 0 && list.size() > maxSize) { list.remove(list.size() - 1); } return true; } public boolean remove(Object o) { return list.remove(o); } public boolean containsAll(Collection< ? > c) { return list.containsAll(c); } public boolean addAll(Collection< ? extends T> c) { return list.addAll(c); } public boolean addAll(int index, Collection< ? extends T> c) { return list.addAll(index, c); } public boolean removeAll(Collection< ? > c) { return list.removeAll(c); } public boolean retainAll(Collection< ? > c) { return list.retainAll(c); } public void clear() { list.clear(); } public T get(int index) { return list.get(index); } public T set(int index, T element) { return list.set(index, element); } public void add(int index, T element) { list.add(index, element); } public T remove(int index) { return list.remove(index); } public int indexOf(Object o) { return list.indexOf(o); } public int lastIndexOf(Object o) { return list.lastIndexOf(o); } public ListIterator<T> listIterator() { return list.listIterator(); } public ListIterator<T> listIterator(int index) { return listIterator(index); } public List<T> subList(int fromIndex, int toIndex) { return list.subList(fromIndex, toIndex); } } --- NEW FILE: POut.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Aug 16, 2005 */ package edu.harvard.syrah.prp; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.text.NumberFormat; import java.util.Collection; import java.util.Iterator; import java.util.Map; public class POut { private static final Log log = new Log(POut.class); public static final String NL = System.getProperty("line.separator"); private static final int VSPACE_LINES = 3; private static boolean debugState = true; private static NumberFormat fpFormat = NumberFormat.getNumberInstance(); private static NumberFormat intFormat = NumberFormat.getIntegerInstance(); static { fpFormat.setMaximumFractionDigits(2); fpFormat.setMinimumFractionDigits(2); fpFormat.setGroupingUsed(false); intFormat.setGroupingUsed(false); intFormat.setMinimumFractionDigits(0); intFormat.setMaximumFractionDigits(0); } public static String toString(double[] vector, String sep) { StringBuffer sb = new StringBuffer(); sb.append("("); if (vector != null) { for (int i = 0; i < vector.length; i++) { sb.append(fpFormat.format(vector[i])); if (i < (vector.length - 1)) sb.append(sep); } } else sb.append("null"); sb.append(")"); return sb.toString(); } public static String toString(long[] vector, String sep) { StringBuffer sb = new StringBuffer(); sb.append("("); if (vector != null) { for (int i = 0; i < vector.length; i++) { sb.append(intFormat.format(vector[i])); if (i < (vector.length - 1)) sb.append(sep); } } else sb.append("null"); sb.append(")"); return sb.toString(); } public static String toString(Object[] vector) { return toString(vector, " "); } public static String toString(Object[] vector, String sep) { StringBuffer sb = new StringBuffer(); if (vector != null) { for (int i = 0; i < vector.length; i++) { sb.append(vector[i]); if (i < (vector.length - 1)) sb.append(sep); } } return sb.toString(); } public static String toString(double[] vector) { return toString(vector, " "); } public static String toString(long[] vector) { return toString(vector, " "); } public static String toString(byte[] vector, String sep) { StringBuffer sb = new StringBuffer(); sb.append("("); if (vector != null) { for (int i = 0; i < vector.length; i++) { sb.append(vector[i]); if (i < (vector.length - 1)) sb.append(sep); } } sb.append(")"); return sb.toString(); } public static String toString(byte[] vector) { return toString(vector, " "); } public static String toString(int[] vector, String sep) { StringBuffer sb = new StringBuffer(); sb.append("("); if (vector != null) { for (int i = 0; i < vector.length; i++) { sb.append(vector[i]); if (i < (vector.length - 1)) sb.append(sep); } } sb.append(")"); return sb.toString(); } public static String toString(double[][] matrix) { StringBuffer str = new StringBuffer(); str.append("("); if (matrix != null) { for (int i = 0; i < matrix.length; i++) { str.append(toString(matrix[i], ",")); if (i != (matrix.length - 1)) str.append(" "); } } else { str.append("null"); } str.append(")"); return str.toString(); } public static String toString(int[] vector) { return toString(vector, " "); } public static String toString(int[][] matrix, int space) { StringBuffer str = new StringBuffer(); str.append("\n"); if (matrix.length == 0) { str.append("empty"); } else { for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { for (int k = (new Integer(matrix[i][j])).toString().length(); k < space; k++) str.append(" "); str.append(matrix[i][j] + " "); } if (i != matrix.length - 1) str.append("\n"); } } //str.append("\n"); return str.toString(); } public static String toString(int[][] matrix) { return toString(matrix, 2); } public static String toString(Object[][] matrix, int space) { StringBuffer str = new StringBuffer(); str.append("\n\n"); for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { if (matrix[i][j] == null) { for (int k = 0; k < space; k++) str.append ("-"); str.append(" "); } else { for (int k = matrix[i][j].toString().length(); k < space; k++) str.append(" "); str.append(matrix[i][j] + " "); } } str.append("\n"); } str.append("\n"); return str.toString(); } @SuppressWarnings("unchecked") public static String toString(Iterator it) { return toString(it, ","); } @SuppressWarnings("unchecked") public static String toString(Iterator it, String sep) { StringBuffer strBuffer = new StringBuffer(); while (it.hasNext()) { strBuffer.append(it.next()); if (it.hasNext()) strBuffer.append(sep); } return strBuffer.toString(); } public static String toString(Object[][] matrix) { return toString(matrix, 2); } @SuppressWarnings("unchecked") public static String toString(Map m) { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("{"); for (Iterator it = m.keySet().iterator(); it.hasNext();) { Object key = it.next(); Object value = m.get(key); strBuffer.append("("); strBuffer.append(key != null ? key.toString() : "null"); strBuffer.append(","); strBuffer.append(value != null ? value.toString() : "null"); strBuffer.append(")"); if (it.hasNext()) strBuffer.append(", "); } strBuffer.append("}"); return strBuffer.toString(); } @SuppressWarnings("unchecked") public static String toString(Collection c) { return toString(c, ","); } @SuppressWarnings("unchecked") public static String toString(Collection c, String sep) { if (c != null) return toString(c.iterator(), sep); else return "null"; } public static String toString(double d) { return fpFormat.format(d); } public static String toString(int i, int digits) { return prependFixedLength(String.valueOf(i), digits); } public static void p() { System.out.println(); } public static void p(String what) { System.out.println(what); } public static void pStart(String what) { POut.pStart(what, false); } public static void pStart(String what, boolean newline) { if (newline) System.out.println("[" + what + "... "); else System.out.print("[" + what + "... "); } public static void pDone() { System.out.println("Done.]\n"); } public static void waitForReturn(String descr) { System.out.println("Press Return " + descr + "..."); try { (new BufferedReader (new InputStreamReader (System.in))).readLine(); } catch (IOException e) { /* ignore */ } } public static void waitForReturn() { waitForReturn("to continue"); } /** * Pads a string with whitspace or truncates it before adding it to a StringBuffer * @param sb * @param appendString * @param desiredLength */ public static void appendFixedLength(StringBuffer sb, String appendString, int desiredLength) { int currentLength = appendString.length(); if (currentLength < desiredLength) { sb.append(appendString); for (int i = 0; i < (desiredLength - currentLength); i++) sb.append(" "); } else { sb.append(appendString.substring(0, desiredLength)); } } public static String appendFixedLength(String what, int desiredLength) { StringBuffer padding = new StringBuffer(); for (int i = 0; i < desiredLength - what.length(); i++) { padding.append(" "); } return what + padding.toString(); } public static String prependFixedLength(String what, int desiredLength) { StringBuffer padding = new StringBuffer(); for (int i = 0; i < desiredLength - what.length(); i++) { padding.append(" "); } return padding.toString() + what; } public static String prependFL(String what, int desiredLength) { return prependFixedLength(what, desiredLength); } public static String prependFL(int i, int desiredLength) { return prependFixedLength(String.valueOf(i), desiredLength); } public static String print(ByteBuffer byteBuffer) { byteBuffer.rewind(); StringBuffer sB = new StringBuffer(); for (int i = 0; i < byteBuffer.limit(); i++) { sB.append(byteBuffer.get()); sB.append(" "); } byteBuffer.rewind(); return "{" + sB.toString() + "}"; } public static String printChar(ByteBuffer byteBuffer) { int pos = byteBuffer.position(); byteBuffer.rewind(); StringBuffer sB = new StringBuffer(); while (byteBuffer.remaining() > 0) { sB.append((char) byteBuffer.get()); } byteBuffer.position(pos); return "{" + sB.toString() + "}"; } public static void vspace() { for (int i = 0; i < VSPACE_LINES; i++) System.out.println(); } public static String ws(int length) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { sb.append(" "); } return sb.toString(); } public static void appendWS(StringBuffer sb, int length) { for (int i = 0; i < length; i++) { sb.append(" "); } } public static void debug(String msg) { if (debugState) PUtil.log.debug(msg); //System.out.println("Debug: " + msg); } // TODO should use log.config to do this sort of thing. public static void setDebugState(boolean state) { debugState = state; } public static void abort() { POut.abort("Program abort."); } public static void abort(String msg) { //System.out.println("Abort: " + msg); PUtil.log.error(msg); Thread.dumpStack(); System.exit(-1); } public static void main(String[] args) { String split[] = "imperial, university".split("\\,\\s"); System.out.println(split[0] + "/" + split[1] + "/"); } } --- NEW FILE: PrimitiveArray.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Jul 25, 2006 */ package edu.harvard.syrah.prp; public abstract class PrimitiveArray { protected int len = 0; protected int growthStep = 0; /** * The default initial size of the array. */ protected static final int DEFAULT_INITIAL_SIZE = 128; /** * Creates a new array. */ protected PrimitiveArray() { this(DEFAULT_INITIAL_SIZE); } /** * If this constructor is used, the array starts with an initial size and grows by stepSize. * * @param growthStep Step size */ protected PrimitiveArray(int initialSize, int growthStep) { this(initialSize); this.growthStep = growthStep; } /** * Creates a new array. * * @param initialSize The initial size of the array. */ protected PrimitiveArray(int initialSize) { init(initialSize); } protected abstract void init(int initialSize); /** * Returns the number of bytes stored in the array. * * @return Size of the array data. */ public int size() { return len; } /** * Sets the steps that are used for growing the array. * * @param growStep Step size. */ public void setGrowStep(int growStep) { this.growthStep = growStep; } public boolean isEmpty() { return len == 0; } public abstract int capacity(); /** * Makes the array at least this big. * * @param minCapacity Minimal capicity required. */ public void ensureCapacity(int minCapacity) { if (capacity() < minCapacity) resize(minCapacity); } public void fill(int length) { ensureCapacity(length); this.len = length; } protected void multiplySize(int factor) { resize(capacity() == 0 ? factor : factor * capacity()); } protected abstract void resize(int minCapacity); } --- NEW FILE: IntArray.java --- /* * Title: ByteArray * Description: Implements a variable size byte array.<p> * Copyright: Copyright (c) 2001 <p> * Company: Computer Laboratory, Cambridge University <p> * @author Peter Pietzuch <pr...@cl...> * @version 1.0 * * (C) Copyright 2001-2003 Peter R Pietzuch * * This file is part of Util. * * Util is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Util is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DSSim; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package edu.harvard.syrah.prp; public class IntArray extends PrimitiveArray{ private int[] a; public IntArray() { super(); } public IntArray (int initialSize, int growStep) { super(initialSize, growStep); } public IntArray(int initialSize) { super(initialSize); } protected void init(int initialSize) { a = new int[initialSize]; } /** * Adds a new byte value to the array. The array is extended if necessary by doubling its size. * * @param byte Byte to be added. */ public void add(int b) { if ((len + 1) > a.length) { if (growthStep == 0) multiplySize(2); else resize(a.length + growthStep); } a[len++] = b; } /** * Adds an byte array to the variable size array. All the values are copied. * * @param b Byte array to be copied. * @param size Size of b to be copied. */ public void addAll(int[] b, int size) { if (size == 0) return; if ((len + size) > a.length) { if (growthStep == 0) multiplySize(((len + size) / a.length) + 1); else { int factor = ((len + size - a.length) / growthStep) + 1; resize ((factor * growthStep) + a.length); } } for (int i = 0; i < size; i++) a[len++] = b[i]; } /** * Returns the byte value at a particular index. * * @param index Index * @return Byte value */ public int get(int index) { if (index >= len) throw new IndexOutOfBoundsException(); return a[index]; } /** * Sets a value in the array to a new value. The index must exist. * * @param value New value * @param index Index */ public void set(int value, int index) { if (index >= len) throw new IndexOutOfBoundsException(); a[index] = value; } /** * Returns a new byte array which has the optimal size. This is done by copying. * * @return Byte Array */ public int[] getArrayCopy() { int[] retA = new int[len]; for (int i = 0; i < len; i++) retA[i] = a[i]; return retA; } protected void resize(int newSize) { int[] newA = new int[newSize]; for (int i = 0; i < a.length; i++) newA[i] = a[i]; a = newA; } public int capacity() { return a.length; } public static void main(String[] args) { Debug.p("hello"); //IntArray a1 = new IntArray(100, 100); IntArray a1 = new IntArray(); int[] ba = {23, 42, 314, 16, 3}; for (int i = 0; i < 1000; i++) { a1.addAll(ba, ba.length); } System.out.println("a1.size() = " + a1.size()); //for (int i = 0; i < a1.size(); i++) //System.out.print(a1.elementAt(i) + " "); System.out.println(); } } --- NEW FILE: PError.java --- /* * Title: PError * Description: Error class <p> * Copyright: Copyright (c) 2001 <p> * Company: Computer Laboratory, Cambridge University <p> * @author Peter Pietzuch <pr...@cl...> * @version 1.0 * * (C) Copyright 2001-2003 Peter R Pietzuch * * This file is part of Util. * * Util is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Util is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DSSim; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package edu.harvard.syrah.prp; /** * This class is deprecated and should not be used anymore. * */ public class PError { /** * This method aborts the program and prints out an error message. * * @param where Name of class/method in which the error occurred. * @param what Description of the error condition */ public static void abort(String where, String what) { System.err.println("Error: [" + where + "] " + what); Thread.dumpStack(); System.exit(-1); } public static void abort(String where, String what, Exception e) { System.err.println("Error: [" + where + "] " + what + " : " + e.toString()); e.printStackTrace(); System.exit(-1); } public static void error(String where, String what) { System.err.println("Error: [" + where + "] " + what); System.err.flush(); } public static void warn(String where, String what) { warning(where, what); } public static void warning(String where, String what) { System.err.println("Warning: [" + where + "] " + what); } } --- NEW FILE: Debug.java --- /* * Title: Debug <p> * Description: This class contains Debug aids. <p> * Copyright: Copyright (c) 2001 <p> * Company: Computer Laboratory, Cambridge University <p> * @author Peter Pietzuch <pr...@cl...> * @version 1.0 * * (C) Copyright 2001-2003 Peter R Pietzuch * * This file is part of Util. * * Util is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Util is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DSSim; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package edu.harvard.syrah.prp; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.PrintStream; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; import java.util.Vector; public class Debug { private static final String DEBUG_SYSTEM_PROPERTY = "PDEBUG_CLASSES"; private static final int TRACE_DEPTH = 3; private static final int INDENT = 45; private static boolean debugState = true; private static Set<String> debugClasses; private static Set<String> noDebugClasses; static { debugClasses = new HashSet<String>(); noDebugClasses = new HashSet<String>(); String debugClassEnv = System.getProperty(DEBUG_SYSTEM_PROPERTY); //Util.p("debugClassEnv = " + debugClassEnv); if ((debugClassEnv != null) && (debugClassEnv.length() != 0)) addDebugClass(debugClassEnv); } @SuppressWarnings("deprecation") static Context getContext (int level) { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream pout = new PrintStream(out); new Exception().printStackTrace(pout); DataInputStream din = new DataInputStream(new ByteArrayInputStream(out.toByteArray())); String targetLine = " at CLASS.METHOD(FILE.java:0000)"; // ??? try { for (int i = 0; i < level; i++) { if (i == 1) { String line = din.readLine(); if (line.indexOf("Throwable") != -1) level = level + 2; } else din.readLine(); } targetLine = din.readLine(); } catch (IOException e) { /* empty */ } StringTokenizer tk = new StringTokenizer(targetLine, " \n\t.():"); Vector<String> tokens = new Vector<String>(); for (int i = 0; tk.hasMoreTokens(); i++) { tokens.add(tk.nextToken()); } int tokenSize = tokens.size(); Context context = new Context(); //context.lineNumber = Integer.parseInt((String) tokens.elementAt(tokenSize - 1)); String ext = (String) tokens.elementAt(tokenSize - 2); String file = (String) tokens.elementAt(tokenSize - 3); context.sourceFile = file + "." + ext; context.methodName = (String) tokens.elementAt(tokenSize - 4); context.className = (String) tokens.elementAt(tokenSize - 5); StringBuffer packages = new StringBuffer(); for (int i = 1; i < tokenSize - 5; i++) { packages.append(tokens.elementAt(i)); if (i < tokenSize - 6) packages.append("."); } context.packageName = packages.toString(); return context; } public static void p(String what) { if (!debugState == true) return; Context c = getContext(TRACE_DEPTH); String origName = c.packageName + "." + c.className; String className = new String(origName); while (className.indexOf(".") != -1) { if (noDebugClasses.contains(className)) return; className = className.substring(0, className.lastIndexOf(".")); } className = origName; while (true) { if (debugClasses.contains(className)) { System.out.print(" #Debug: (" + c + ") : "); for (int i = 0; i < INDENT - c.toString().length(); i++) System.out.print(" "); System.out.println(what); return; } if (className.indexOf(".") != -1) className = className.substring(0, className.lastIndexOf(".")); else return; } } public static void p(long what) { p(Long.toString(what)); } public static void p(String where, String what, int p) { p(what); } public static void p(String where, String what) { p(what); } @SuppressWarnings("unchecked") public static void addDebugClass(Class newClass) { System.out.println(newClass.getName()); debugClasses.add(newClass.getName()); } public static void addDebugClass(String newClass) { debugClasses.add(newClass); } public static void addNoDebugClass(String newClass) { noDebugClasses.add(newClass); } public static void setLevel(int l) { /* empty */ } public static void setDebugState(boolean newState) { debugState = newState; } } class Context { public String packageName; public String className; public String methodName; public String sourceFile; public int lineNumber; public String toString () { //return "[" + packageName + "." + className + ", " + methodName + "(...), " + sourceFile + ", " + lineNumber + "]"; return "[" + className + "." + methodName + "]"; } } --- NEW FILE: Stat.java --- /* * * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Sep 3, 2004 */ package edu.harvard.syrah.prp; import java.util.Arrays; /** * * This class gathers various statistics. * */ public class Stat { //private static final Log log = new Log(Stat.class); private static final int DEFAULT_CDF_BUCKET_NUM = 100; private static final double DEFAULT_BUCKET_SIZE = 1.0; private double[] data; private double[][] dataXY; private double[] sortedData; private double[] distribution; private double[][] histogram; private int index = 0; private boolean dataExists = false; private double max = Double.NaN; private double min = Double.NaN; private double sum = Double.NaN; private double avg = Double.NaN; public Stat(double[] data) { this.data = data; if (data.length > 0) this.dataExists = true; } public Stat(int[] data) { this.data = new double[data.length]; for (int i = 0; i < data.length; i++) this.data[i] = data[i]; if (data.length > 0) this.dataExists = true; } public Stat(int dataSize) { this.data = new double[dataSize]; this.dataXY = new double[dataSize][2]; } public void addData(double dataItem) { data[index] = dataItem; this.dataExists = true; index++; } public void addData(double x, double y) { this.dataXY[index][0] = x; this.dataXY[index++][1] = y; this.dataExists = true; } public void divideBy(double d) { for (int i = 0; i < data.length; i++) data[i] = data[i] / d; } public void calculate() { calculate(DEFAULT_CDF_BUCKET_NUM, DEFAULT_BUCKET_SIZE); } public void calculate(double bucketSize) { calculate(DEFAULT_CDF_BUCKET_NUM, bucketSize); } public void calculate(int cdfBucketNum, double bucketSize) { if (!dataExists) return; // Calculate the distribution function calculateCDF(cdfBucketNum); // Calculate the maximum value max = sortedData[data.length - 1]; min = sortedData[0]; // Calculate the histogram int bucketNum = (int) Math.ceil(max / bucketSize); histogram = new double[bucketNum + 1][2]; int index = 0; for (int i = 0; i < bucketNum; i++) { histogram[i + 1][0] = (i + 1) * bucketSize; while (index < sortedData.length && sortedData[index] <= ((i + 1) * bucketSize)) { histogram[i + 1][1]++; index++; } } sum = 0; for (int i = 0; i < data.length; i++) sum += data[i]; avg = sum / data.length; } private void calculateCDF(int numBuckets) { distribution = new double[numBuckets]; sortedData = new double[data.length]; System.arraycopy(data, 0, sortedData, 0, data.length); Arrays.sort(sortedData); for (int i = 0; i < numBuckets; i++) { double bucketIndex = (double) sortedData.length * (i + 1) / numBuckets; int arrayIndex = ((int) Math.ceil(bucketIndex)) - 1; //log.debug("arrayIndex=" + arrayIndex); if (i < distribution.length / data.length) distribution[i] = Double.NaN; else distribution[i] = sortedData[arrayIndex]; } } public double[] getData() { if (!dataExists) return null; double[] dataArray = new double[index]; System.arraycopy(data, 0, dataArray, 0, index); return dataArray; } public double[][] getDataXY() { return dataExists ? dataXY : null; } public double[] getCDF() { return dataExists ? distribution : null; } public double getCDFValue(int bucket) { return dataExists ? distribution[bucket - 1] : Double.NaN; } public double[][] getHistogram() { return dataExists ? histogram : null; } public double getMax() { return dataExists ? max : Double.NaN; } public double getMin() { return dataExists ? min : Double.NaN; } public double getSum() { return dataExists ? sum : Double.NaN; } public double getAverage() { return dataExists ? avg : Double.NaN; } public static void main(String[] argv) { double[] data = new double[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; //double[] data = new double[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; //double[] data = new double[] {-2, 7, 7, 4, 18, -5}; //double[] data = new double[1000]; //double[] data2 = new double[1000]; for (int i = 0; i < data.length; i++) { //data[i] = Util.getRandom().nextGaussian(); //data[i] = Util.getRandomPosInt(1000); //data2[i] = Util.getRandom().nextDouble(); } POut.p("data=" + POut.toString(data)); Stat stat = new Stat(data); stat.calculate(100, 1.0); POut.p("max=" + stat.getMax()); double[] distribution = stat.getCDF(); POut.p("distribution=" + POut.toString(distribution)); double[][] histogram = stat.getHistogram(); POut.p("histogram=" + POut.toString(histogram)); POut.p("50th percentile=" + stat.getCDFValue(50)); /* Stat stat2 = new Stat(data2); stat2.calculateCDF(1000); distribution = stat2.getCDF(); Util.p("distribution2=" + Util.toString(distribution)); */ } } --- NEW FILE: Pair.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Jan 11, 2005 */ package edu.harvard.syrah.prp; import java.io.Serializable; /** * Simple implementation of a Pair with generics. * * TODO: * - ensure that T and U are serializable */ @SuppressWarnings("unchecked") public class Pair<T, U> implements Comparable, Serializable { private static final Log log = new Log(Pair.class); static final long serialVersionUID = 1000000001L; public T first; public U second; public Pair() { this(null, null); } public Pair(T first, U second) { this.first = first; this.second = second; } public String toString() { return "(" + (first != null ? first.toString() : "null") + "," + (second != null ? second.toString() : "null") + ")"; } @Override public int hashCode() { int hc = 0; if (first != null) hc += first.hashCode(); if (second != null) hc += second.hashCode(); return hc; } @Override public boolean equals(Object obj) { if (!(obj instanceof Pair)) log.error("Cannot compare Pair to non-Pair."); // Consider the first element Pair cmpPair = (Pair) obj; if (!cmpPair.first.equals(first)) return false; if (second != null) { if (cmpPair.second != null) { if (!cmpPair.second.equals(second)) return false; } else return false; } return true; } /* * @see java.lang.Comparable#compareTo(java.lang.Object) */ @SuppressWarnings("unchecked") public int compareTo(Object o) { if (!(o instanceof Pair)) log.error("Cannot compare Pair to non-Pair."); // Consider the first element Pair cmpPair = (Pair) o; if (!(first instanceof Comparable)) log.error("first is not comparable."); Comparable c1 = (Comparable) first; if (!(cmpPair.first instanceof Comparable)) log.error("cmpPair.first is not comparable."); Comparable c2 = (Comparable) cmpPair.first; int result = c1.compareTo(c2); if (result != 0) return result; // Consider the second element if (!(second instanceof Comparable)) return 0; Comparable d1 = (Comparable) second; if (!(cmpPair.second instanceof Comparable)) return 0; Comparable d2 = (Comparable) cmpPair.second; result = d1.compareTo(d2); return result; } } --- NEW FILE: NetUtil.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Jul 5, 2005 */ package edu.harvard.syrah.prp; import java.io.*; import java.net.*; public class NetUtil { protected static final Log log = new Log(NetUtil.class); public static final byte[] HTTP_NEWLINE = NetUtil.toHTTPBytes("\r\n"); public static void checkHttpURL(String urlString) throws IOException { URL url = new URL(urlString); URLConnection connection = url.openConnection(); log.debug("URLConnection opened=" + connection); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; httpConnection.connect(); log.debug("HttpURLConnection connected=" + httpConnection); int response = httpConnection.getResponseCode(); if (response != 200 && response != 301 && response != 302) { throw new IOException("Could not access HTTP URL. Reponse=" + response); } } } /** * @param message * @return */ public static byte[] serializeObject(Object obj) { // Serialize a Java object and put it in a byte array ByteArrayOutputStream baOS = new ByteArrayOutputStream(); ObjectOutputStream objOS; try { objOS = new ObjectOutputStream(baOS); objOS.writeObject(obj); objOS.close(); baOS.close(); } catch (IOException e) { log.error("Could not serialize java object: " + e); } return baOS.toByteArray(); } /* public static byte[] serializeObjects(Object obj) { return serializeObjects(new Object[] {obj}); } public static byte[] serializeObjects(Object[] objs) { // Serialize a Java object and put it in a byte array ByteArrayOutputStream baOS = new ByteArrayOutputStream(); ObjectOutputStream objOS; try { objOS = new ObjectOutputStream(baOS); for (Object obj : objs) { objOS.writeObject(obj); } objOS.close(); baOS.close(); } catch (IOException e) { log.error("Could not serialize java object: " + e); } return baOS.toByteArray(); } */ public static Object deserializeObject(byte[] data) { return deserializeObject(data, ClassLoader.getSystemClassLoader()); } /** * @param data * @return */ public static Object deserializeObject(byte[] data, final ClassLoader classLoader) { // Deserialise a byte array into a Java object ByteArrayInputStream baIS = new ByteArrayInputStream(data); ObjectInputStream objIS; Object obj = null; try { objIS = new ObjectInputStream(baIS) { @SuppressWarnings("unchecked") @Override protected Class< ? > resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { //log.info("called with desc=" + desc); Class newClass = classLoader.loadClass(desc.getName()); //log.info("newClass=" + newClass); return newClass; } }; obj = objIS.readObject(); objIS.close(); baIS.close(); } catch (IOException e) { log.warn("Could not deserialize java object: " + e); obj = null; } catch (ClassNotFoundException e) { log.warn("Could not deserialize object: " + e); obj = null; } return obj; } /* public static Object[] deserializeObjects(byte[] data) { return deserializeObjects(data, ClassLoader.getSystemClassLoader()); } public static Object[] deserializeObjects(byte[] data, final ClassLoader classLoader) { Vector<Object> objectVector = new Vector<Object>(); ByteArrayInputStream baIS = new ByteArrayInputStream(data); ObjectInputStream objIS; try { objIS = new ObjectInputStream(baIS) { @Override protected Class< ? > resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { //log.info("called with desc=" + desc); Class newClass = classLoader.loadClass(desc.getName()); //Class newClass = NetUtil.loadClassFromURL(desc.getName(), jarURL, true); //log.info("newClass=" + newClass); return newClass; } }; while (baIS.available() > 0) { Object obj = objIS.readObject(); objectVector.add(obj); } objIS.close(); baIS.close(); } catch (IOException e) { log.error("Could not deserialize java object: " + e); } catch (ClassNotFoundException e) { log.error("Could not deserialize java object and local object: " + e); } return objectVector.toArray(); } */ public static Object deserializeObject(byte[] data, final String jarURL) { return deserializeObject(data, jarURL, ClassLoader.getSystemClassLoader()); } public static Object deserializeObject(byte[] data, final String jarURL, final ClassLoader classLoader) { // Deserialise a byte array into a Java object ByteArrayInputStream baIS = new ByteArrayInputStream(data); ObjectInputStream objIS; Object obj = null; try { objIS = new ObjectInputStream(baIS) { @SuppressWarnings("unchecked") @Override protected Class< ? > resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { //log.info("called with desc=" + desc); Class newClass = NetUtil.loadClassFromURL(desc.getName(), jarURL, classLoader); //log.info("newClass=" + newClass); return newClass; } }; obj = objIS.readObject(); objIS.close(); baIS.close(); } catch (IOException e) { log.warn("Could not deserialize java object: " + e); obj = null; } catch (ClassNotFoundException e) { log.warn("Could not deserialize java object and local object: " + e); obj = null; } return obj; } @SuppressWarnings("unchecked") public static Class loadClassFromURL(String className, String classURL, ClassLoader classLoader) throws MalformedURLException, ClassNotFoundException { Class newClass = null; try { if (classLoader != null) { newClass = classLoader.loadClass(className); } else { throw new ClassNotFoundException("Forcing fresh retrieval"); } } catch (ClassNotFoundException e1) { // Did we get an actual URL? if (classURL.length() > 0) { URL url = null; try { url = new URL(classURL); } catch (MalformedURLException e) { log.warn("Bad URL received: " + e); throw e; } URLClassLoader urlClassLoader = new URLClassLoader(new URL[] {url}); log.debug("Loading class=" + className); log.debug(" from url=" + url); try { newClass = urlClassLoader.loadClass(className); } catch (ClassNotFoundException e) { log.warn("Could not find class (bad URL?): " + e); throw e; } } else { log.warn("Could not locate class=" + className); throw new ClassNotFoundException("Could not locate class=" + className); } } return newClass; } public static String byteIPAddrToString(byte[] byteIPAddr) { StringBuffer sb = new StringBuffer(); sb.append(byteIPAddr[0] & 0Xff).append("."); sb.append(byteIPAddr[1] & 0xff).append("."); sb.append(byteIPAddr[2] & 0xff).append("."); sb.append(byteIPAddr[3] & 0xff); return sb.toString(); } public static String reverseByteIPAddrToString(byte[] byteIPAddr) { StringBuffer sb = new StringBuffer(); sb.append(byteIPAddr[3] & 0Xff).append("."); sb.append(byteIPAddr[2] & 0xff).append("."); sb.append(byteIPAddr[1] & 0xff).append("."); sb.append(byteIPAddr[0] & 0xff); return sb.toString(); } public static int byteIPToIntIP(byte[] byteIPAddr) { return ((byteIPAddr[0] & 0xff) << 24) + ((byteIPAddr[1] & 0xff) << 16) + ((byteIPAddr[2] & 0xff) << 8) + (byteIPAddr[3] & 0xff); } public static byte[] intIPToByteIP(Integer intIPAddr) { byte[] byteIPAddr = new byte[] { (byte) ((intIPAddr >> 24) & 0xff), (byte) ((intIPAddr >> 16) & 0xff), (byte) ((intIPAddr >> 8) & 0xff), (byte) (intIPAddr & 0xff)}; return byteIPAddr; } public static String intIPToString(Integer intIPAddr) { StringBuffer sb = new StringBuffer(); sb.append((byte) ((intIPAddr >> 24) & 0xff)).append("."); sb.append((byte) ((intIPAddr >> 16) & 0xff)).append("."); sb.append((byte) ((intIPAddr >> 8) & 0xff)).append("."); sb.append((byte) (intIPAddr & 0xff)); return sb.toString(); } public static byte[] stringIPToByteIP(String strIP) { String[] octetStr = strIP.split("\\."); byte [] byteIPAddr = new byte[] {(byte) (Integer.valueOf(octetStr[0]).intValue() & 0xff), (byte) (Integer.valueOf(octetStr[1]).intValue() & 0xff), (byte) (Integer.valueOf(octetStr[2]).intValue() & 0xff), (byte) (Integer.valueOf(octetStr[3]).intValue() & 0xff)}; return byteIPAddr; } /** * Returns the US-ASCII encoded byte representation of text for HTTP use (as * per section 2.2 of RFC 2068). */ public static final byte[] toHTTPBytes(String text) { try { return text.getBytes("US-ASCII"); } catch (UnsupportedEncodingException e) { log.error("HTTP requires US-ASCII encoding: " + e); return null; } } public static String toBase64(byte[] data) { // Convert a byte array to base64 string String s = new sun.misc.BASE64Encoder().encode(data); return s; } public static byte[] fromBase64(String base64) { byte[] data = null; try { // Convert base64 string to a byte array data = new sun.misc.BASE64Decoder().decodeBuffer(base64); } catch (IOException e) { log.error(e.toString()); } return data; } public static void main(String[] args) { byte[] byteArray = serializeObject(new Object[] {"Hello", "hello2", 42, 3.444}); Object[] objs = (Object[]) deserializeObject(byteArray); for (Object obj : objs) { POut.p("obj=" + obj.toString()); } } } --- NEW FILE: UnknownPropertyException.java --- /* * @author Last modified by $Author: prp $ * @version $Revision: 1.1 $ on $Date: 2007/11/19 17:50:10 $ * @since Sep 29, 2005 */ package edu.harvard.syrah.prp; public class UnknownPropertyException extends Exception { static final long serialVersionUID = 1000000001L; public UnknownPropertyException(String what) { super(what); } } --- NEW FILE: LongArray.java --- /* * Title: ByteArray * Description: Implements a variable size byte array.<p> * Copyright: Copyright (c) 2001 <p> * Company: Computer Laboratory, Cambridge University <p> * @author Peter Pietzuch <pr...@cl...> * @version 1.0 * * (C) Copyright 2001-2003 Peter R Pietzuch * * This file is part of Util. * * Util is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Util is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DSSim; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package edu.harvard.syrah.prp; public class LongArray extends PrimitiveArray { private long[] a; public LongArray() { super(); } public LongArray (int initialSize, int growStep) { super(initialSize, growStep); } public LongArray(int initialSize) { super(initialSize); } protected void init(int initialSize) { a = new long[initialSize]; } /** * Adds a new byte value to the array. The array is extended if necessary by doubling its size. * * @param byte Byte to be added. */ public void add(long b) { if ((len + 1) > a.length) { if (growthStep == 0) multiplySize(2); else resize(a.length + growthStep); } a[len++] = b; } public void addAll(long[] b) { addAll(b, b.length); } public void addAll(LongArray longArray) { addAll(longArray.getArray(), longArray.size()); } /** * Adds an byte array to the variable size array. All the values are copied. * * @param b Byte array to be copied. * @param size Size of b to be copied. */ public void addAll(long[] b, int size) { if (size == 0) return; if ((len + size) > a.length) { if (growthStep == 0) multiplySize(((len + size) / a.length) + 1); else { int factor = ((len + size - a.length) / growthStep) + 1; resize ((factor * growthStep) + a.length); } } for (int i = 0; i < size; i++) a[len++] = b[i]; } /** * Returns the byte value at a particular index. * * @param index Index * @return Byte value */ public long get(int index) { if (index >= len) throw new IndexOutOfBoundsException(); return a[index]; } /** * Sets a value in the array to a new value. The index must exist. * * @param value New value * @param index Index */ public void set(long value, int index) { if (index >= len) throw new IndexOutOfBoundsException(); a[index] = value; } /** * Returns a new byte array which has the optimal size. This is done by copying. * * @return Byte Array */ public long[] getArrayCopy() { long[] retA = new long[len]; for (int i = 0; i < len; i++) retA[i] = a[i]; return retA; } public long[] getArray() { return a; } protected void resize(int newSize) { long[] newA = new long[newSize]; for (int i = 0; i < a.length; i++) newA[i] = a[i]; a = newA; } public int capacity() { return a.length; } public String toString() { return POut.toString(getArrayCopy()); } public static void main(String[] args) { Debug.p("hello"); //IntArray a1 = new IntArray(100, 100); LongArray a1 = new LongArray(); long[] ba = {23, 42, 314, 16, 3}; for (int i = 0; i < ... [truncated message content] |