forked from I2P_Developers/i2p.i2p
Router: Convert Vector to List
This commit is contained in:
@ -16,7 +16,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.router.RouterAddress;
|
||||
@ -114,11 +113,11 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
*
|
||||
* A positive number means our clock is ahead of theirs.
|
||||
*
|
||||
* Todo: change Vectors to milliseconds
|
||||
* Todo: change List to milliseconds
|
||||
*/
|
||||
@Override
|
||||
public long getFramedAveragePeerClockSkew(int percentToInclude) {
|
||||
Vector<Long> skews = _manager.getClockSkews();
|
||||
List<Long> skews = _manager.getClockSkews();
|
||||
if (skews == null ||
|
||||
skews.isEmpty() ||
|
||||
(skews.size() < 5 && _context.clock().getUpdatedSuccessfully())) {
|
||||
|
@ -12,7 +12,6 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.router.RouterAddress;
|
||||
@ -26,6 +25,8 @@ import net.i2p.router.OutNetMessage;
|
||||
* To implement a new or pluggable I2P transport, implement this interface,
|
||||
* and add it to TransportManager.startListening().
|
||||
*
|
||||
* API is subject to change.
|
||||
* Please contact us if you're writing a new transport or transport plugin.
|
||||
*/
|
||||
public interface Transport {
|
||||
|
||||
@ -162,7 +163,12 @@ public interface Transport {
|
||||
public int countActiveSendPeers();
|
||||
public boolean haveCapacity();
|
||||
public boolean haveCapacity(int pct);
|
||||
public Vector<Long> getClockSkews();
|
||||
|
||||
/**
|
||||
* Previously returned Vector, now List as of 0.9.46.
|
||||
*/
|
||||
public List<Long> getClockSkews();
|
||||
|
||||
public List<String> getMostRecentErrorMessages();
|
||||
|
||||
public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException;
|
||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@ -199,10 +198,10 @@ public abstract class TransportImpl implements Transport {
|
||||
|
||||
/**
|
||||
* Return our peer clock skews on a transport.
|
||||
* Vector composed of Long, each element representing a peer skew in seconds.
|
||||
* List composed of Long, each element representing a peer skew in seconds.
|
||||
* Dummy version. Transports override it.
|
||||
*/
|
||||
public Vector<Long> getClockSkews() { return new Vector<Long>(); }
|
||||
public List<Long> getClockSkews() { return Collections.emptyList(); }
|
||||
|
||||
public List<String> getMostRecentErrorMessages() { return Collections.emptyList(); }
|
||||
|
||||
|
@ -23,7 +23,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.i2p.crypto.SigType;
|
||||
@ -538,14 +537,14 @@ public class TransportManager implements TransportEventListener {
|
||||
|
||||
/**
|
||||
* Return our peer clock skews on all transports.
|
||||
* Vector composed of Long, each element representing a peer skew in seconds.
|
||||
* List composed of Long, each element representing a peer skew in seconds.
|
||||
* A positive number means our clock is ahead of theirs.
|
||||
* Note: this method returns them in whimsical order.
|
||||
*/
|
||||
Vector<Long> getClockSkews() {
|
||||
Vector<Long> skews = new Vector<Long>();
|
||||
List<Long> getClockSkews() {
|
||||
List<Long> skews = new ArrayList<Long>();
|
||||
for (Transport t : _transports.values()) {
|
||||
Vector<Long> tempSkews = t.getClockSkews();
|
||||
List<Long> tempSkews = t.getClockSkews();
|
||||
if ((tempSkews == null) || (tempSkews.isEmpty())) continue;
|
||||
skews.addAll(tempSkews);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.i2p.crypto.EncType;
|
||||
@ -787,12 +786,12 @@ public class NTCPTransport extends TransportImpl {
|
||||
|
||||
/**
|
||||
* Return our peer clock skews on this transport.
|
||||
* Vector composed of Long, each element representing a peer skew in seconds.
|
||||
* List composed of Long, each element representing a peer skew in seconds.
|
||||
* A positive number means our clock is ahead of theirs.
|
||||
*/
|
||||
@Override
|
||||
public Vector<Long> getClockSkews() {
|
||||
Vector<Long> skews = new Vector<Long>();
|
||||
public List<Long> getClockSkews() {
|
||||
List<Long> skews = new ArrayList<Long>(_conByIdent.size());
|
||||
// Omit ones established too long ago,
|
||||
// since the skew is only set at startup (or after a meta message)
|
||||
// and won't include effects of later offset adjustments
|
||||
@ -801,13 +800,13 @@ public class NTCPTransport extends TransportImpl {
|
||||
for (NTCPConnection con : _conByIdent.values()) {
|
||||
// TODO skip isEstablished() check?
|
||||
if (con.isEstablished() && con.getCreated() > tooOld)
|
||||
skews.addElement(Long.valueOf(con.getClockSkew()));
|
||||
skews.add(Long.valueOf(con.getClockSkew()));
|
||||
}
|
||||
|
||||
// If we don't have many peers, maybe it is because of a bad clock, so
|
||||
// return the last bad skew we got
|
||||
if (skews.size() < 5 && _lastBadSkew != 0)
|
||||
skews.addElement(Long.valueOf(_lastBadSkew));
|
||||
skews.add(Long.valueOf(_lastBadSkew));
|
||||
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("NTCP transport returning " + skews.size() + " peer clock skews.");
|
||||
|
@ -16,7 +16,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@ -2845,12 +2844,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
|
||||
/**
|
||||
* Return our peer clock skews on this transport.
|
||||
* Vector composed of Long, each element representing a peer skew in seconds.
|
||||
* List composed of Long, each element representing a peer skew in seconds.
|
||||
* A positive number means our clock is ahead of theirs.
|
||||
*/
|
||||
@Override
|
||||
public Vector<Long> getClockSkews() {
|
||||
Vector<Long> skews = new Vector<Long>();
|
||||
public List<Long> getClockSkews() {
|
||||
List<Long> skews = new ArrayList<Long>(_peersByIdent.size());
|
||||
|
||||
// If our clock is way off, we may not have many (or any) successful connections,
|
||||
// so try hard in that case to return good data
|
||||
@ -2861,7 +2860,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
continue; // skip old peers
|
||||
if (peer.getRTT() > 1250)
|
||||
continue; // Big RTT makes for a poor calculation
|
||||
skews.addElement(Long.valueOf(peer.getClockSkew() / 1000));
|
||||
skews.add(Long.valueOf(peer.getClockSkew() / 1000));
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("UDP transport returning " + skews.size() + " peer clock skews.");
|
||||
|
Reference in New Issue
Block a user