Changeset 363aaadb


Ignore:
Timestamp:
Jun 2, 2018 12:28:50 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
06106c75
Parents:
7713284
Message:

Console: Sort tunnels within pools by expiration (ticket #2232)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/helpers/TunnelRenderer.java

    r7713284 r363aaadb  
    211211         public int compare(HopConfig l, HopConfig r) {
    212212             return (r.getProcessedMessagesCount() - l.getProcessedMessagesCount());
     213        }
     214    }
     215
     216    /** @since 0.9.35 */
     217    private static class TunnelInfoComparator implements Comparator<TunnelInfo>, Serializable {
     218         public int compare(TunnelInfo l, TunnelInfo r) {
     219             long le = l.getExpiration();
     220             long re = r.getExpiration();
     221             if (le < re)
     222                 return -1;
     223             if (le > re)
     224                 return 1;
     225             return 0;
    213226        }
    214227    }
     
    248261
    249262    private void renderPool(Writer out, TunnelPool in, TunnelPool outPool) throws IOException {
    250         List<TunnelInfo> tunnels = null;
    251         if (in == null)
     263        Comparator<TunnelInfo> comp = new TunnelInfoComparator();
     264        List<TunnelInfo> tunnels;
     265        if (in == null) {
    252266            tunnels = new ArrayList<TunnelInfo>();
    253         else
     267        } else {
    254268            tunnels = in.listTunnels();
    255         if (outPool != null)
    256             tunnels.addAll(outPool.listTunnels());
     269            Collections.sort(tunnels, comp);
     270        }
     271        if (outPool != null) {
     272            List<TunnelInfo> otunnels = outPool.listTunnels();
     273            Collections.sort(otunnels, comp);
     274            tunnels.addAll(otunnels);
     275        }
    257276
    258277        long processedIn = (in != null ? in.getLifetimeProcessed() : 0);
Note: See TracChangeset for help on using the changeset viewer.