@Test public void testAddSample() { RTT rtt = RTTStore.getRtt(nodeId, vodAddress1); assert (rtt == null); rtt = RTTStore.addSample(nodeId, vodAddress1, 10); RTTStore.addSample(nodeId, vodAddress1, 20); RTTStore.addSample(nodeId, vodAddress2, 30); List<RTT> rtts = RTTStore.getOnAvgBest(nodeId, 2); Collections.sort(rtts, RTT.Order.ByRto); assert(rtts.get(0).getRTO() < rtts.get(1).getRTO() ); RttStats stats = rtt.getRttStats(); }
public static RTT addSample(int nodeId, VodAddress address, long rttValue) { if (address.isOpen()) { RTT rtt; if (!publicRtts.containsKey(nodeId)) { ConcurrentHashMap<Integer, RTT> m = new ConcurrentHashMap<Integer, RTT>(); publicRtts.put(nodeId, m); } ConcurrentHashMap<Integer, RTT> m = publicRtts.get(nodeId); if (!m.containsKey(address.getId())) { rtt = new RTT(address, 10 ); m.put(address.getId(), rtt); rtt.addSample(rttValue); } else { rtt = m.get(address.getId()); rtt.addSample(rttValue); } return rtt; } else { return null; } }
RTTStore { public static RTT addSample(int nodeId, VodAddress address, long rttValue) { if (address.isOpen()) { RTT rtt; if (!publicRtts.containsKey(nodeId)) { ConcurrentHashMap<Integer, RTT> m = new ConcurrentHashMap<Integer, RTT>(); publicRtts.put(nodeId, m); } ConcurrentHashMap<Integer, RTT> m = publicRtts.get(nodeId); if (!m.containsKey(address.getId())) { rtt = new RTT(address, 10 ); m.put(address.getId(), rtt); rtt.addSample(rttValue); } else { rtt = m.get(address.getId()); rtt.addSample(rttValue); } return rtt; } else { return null; } } }
RTTStore { public static RTT addSample(int nodeId, VodAddress address, long rttValue) { if (address.isOpen()) { RTT rtt; if (!publicRtts.containsKey(nodeId)) { ConcurrentHashMap<Integer, RTT> m = new ConcurrentHashMap<Integer, RTT>(); publicRtts.put(nodeId, m); } ConcurrentHashMap<Integer, RTT> m = publicRtts.get(nodeId); if (!m.containsKey(address.getId())) { rtt = new RTT(address, 10 ); m.put(address.getId(), rtt); rtt.addSample(rttValue); } else { rtt = m.get(address.getId()); rtt.addSample(rttValue); } return rtt; } else { return null; } }  }
RTTStore { public static RTT addSample(int nodeId, VodAddress address, long rttValue) { if (address.isOpen()) { RTT rtt; if (!publicRtts.containsKey(nodeId)) { ConcurrentHashMap<Integer, RTT> m = new ConcurrentHashMap<Integer, RTT>(); publicRtts.put(nodeId, m); } ConcurrentHashMap<Integer, RTT> m = publicRtts.get(nodeId); if (!m.containsKey(address.getId())) { rtt = new RTT(address, 10 ); m.put(address.getId(), rtt); rtt.addSample(rttValue); } else { rtt = m.get(address.getId()); rtt.addSample(rttValue); } return rtt; } else { return null; } }  static RTT addSample(int nodeId, VodAddress address, long rttValue); static void removeSamples(int nodeId, VodAddress failedNode); static RTT getRtt(int nodeId, VodAddress address); static boolean containsPublicSample(int nodeId, VodAddress address); static List<RTT> getOnAvgBest(int nodeId, int numNodes); static List<RTT> getOnAvgBest(int nodeId, int numNodes,
            Set<Address> ignoreSet); static List<RTT> getAllOnAvgBetterRtts(int nodeId, long value, long rttGreaterThanTolerance); static List<RTT> getOnAvgBetterRtts(int nodeId, int numNodes, 
            long value, long tolerance); }
RTTStore { public static RTT addSample(int nodeId, VodAddress address, long rttValue) { if (address.isOpen()) { RTT rtt; if (!publicRtts.containsKey(nodeId)) { ConcurrentHashMap<Integer, RTT> m = new ConcurrentHashMap<Integer, RTT>(); publicRtts.put(nodeId, m); } ConcurrentHashMap<Integer, RTT> m = publicRtts.get(nodeId); if (!m.containsKey(address.getId())) { rtt = new RTT(address, 10 ); m.put(address.getId(), rtt); rtt.addSample(rttValue); } else { rtt = m.get(address.getId()); rtt.addSample(rttValue); } return rtt; } else { return null; } }  static RTT addSample(int nodeId, VodAddress address, long rttValue); static void removeSamples(int nodeId, VodAddress failedNode); static RTT getRtt(int nodeId, VodAddress address); static boolean containsPublicSample(int nodeId, VodAddress address); static List<RTT> getOnAvgBest(int nodeId, int numNodes); static List<RTT> getOnAvgBest(int nodeId, int numNodes,
            Set<Address> ignoreSet); static List<RTT> getAllOnAvgBetterRtts(int nodeId, long value, long rttGreaterThanTolerance); static List<RTT> getOnAvgBetterRtts(int nodeId, int numNodes, 
            long value, long tolerance);  }