Changeset 675e8a9


Ignore:
Timestamp:
Mar 22, 2012 8:40:35 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c2e36453
Parents:
cae9432
Message:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • apps/BOB/src/net/i2p/BOB/BOB.java

    rcae9432 r675e8a9  
    3939import net.i2p.I2PAppContext;
    4040import net.i2p.client.I2PClient;
    41 import net.i2p.client.streaming.RetransmissionTimer;
    4241import net.i2p.util.Log;
    4342import net.i2p.util.SimpleScheduler;
     
    183182                String configLocation = System.getProperty(PROP_CONFIG_LOCATION, "bob.config");
    184183                // This is here just to ensure there is no interference with our threadgroups.
    185                 RetransmissionTimer Y = RetransmissionTimer.getInstance();
    186184                SimpleScheduler Y1 = SimpleScheduler.getInstance();
    187185                SimpleTimer2 Y2 = SimpleTimer2.getInstance();
    188                 i = Y.hashCode();
    189186                i = Y1.hashCode();
    190187                i = Y2.hashCode();
  • apps/BOB/src/net/i2p/BOB/Main.java

    rcae9432 r675e8a9  
    2424package net.i2p.BOB;
    2525
    26 import net.i2p.client.streaming.RetransmissionTimer;
    2726import net.i2p.util.SimpleScheduler;
    2827import net.i2p.util.SimpleTimer2;
     
    4140        public static void main(String[] args) {
    4241                // THINK THINK THINK THINK THINK THINK
    43                 RetransmissionTimer Y = RetransmissionTimer.getInstance();
    4442                SimpleScheduler Y1 = SimpleScheduler.getInstance();
    4543                SimpleTimer2 Y2 = SimpleTimer2.getInstance();
     
    4947                Y2.stop();
    5048                Y1.stop();
    51                 Y.stop();
    5249        }
    5350}
  • apps/streaming/java/src/net/i2p/client/streaming/Connection.java

    rcae9432 r675e8a9  
    7575    private int _localPort;
    7676    private int _remotePort;
     77    private final SimpleTimer2 _timer;
    7778   
    7879    private long _lifetimeBytesSent;
     
    8990    public static final int MAX_WINDOW_SIZE = 128;
    9091   
     92/****
    9193    public Connection(I2PAppContext ctx, ConnectionManager manager, SchedulerChooser chooser,
    9294                      PacketQueue queue, ConnectionPacketHandler handler) {
    9395        this(ctx, manager, chooser, queue, handler, null);
    9496    }
    95 
     97****/
     98
     99    /** */
    96100    public Connection(I2PAppContext ctx, ConnectionManager manager, SchedulerChooser chooser,
     101                      SimpleTimer2 timer,
    97102                      PacketQueue queue, ConnectionPacketHandler handler, ConnectionOptions opts) {
    98103        _context = ctx;
     
    105110        _inputStream = new MessageInputStream(_context);
    106111        // FIXME pass through a passive flush delay setting as the 4th arg
    107         _outputStream = new MessageOutputStream(_context, _receiver, (opts == null ? Packet.MAX_PAYLOAD_SIZE : opts.getMaxMessageSize()));
     112        _outputStream = new MessageOutputStream(_context, timer, _receiver, (opts == null ? Packet.MAX_PAYLOAD_SIZE : opts.getMaxMessageSize()));
     113        _timer = timer;
    108114        _outboundPackets = new TreeMap();
    109115        if (opts != null) {
     
    896902    private class ActivityTimer extends SimpleTimer2.TimedEvent {
    897903        public ActivityTimer() {
    898             super(RetransmissionTimer.getInstance());
     904            super(_timer);
    899905            setFuzz(5*1000); // sloppy timer, don't reschedule unless at least 5s later
    900906        }
     
    10941100        private long _nextSendTime;
    10951101        public ResendPacketEvent(PacketLocal packet, long delay) {
    1096             super(RetransmissionTimer.getInstance());
     1102            super(_timer);
    10971103            _packet = packet;
    10981104            _nextSendTime = delay + _context.clock().now();
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionManager.java

    rcae9432 r675e8a9  
    1515import net.i2p.util.Log;
    1616import net.i2p.util.SimpleTimer;
     17import net.i2p.util.SimpleTimer2;
    1718
    1819/**
     
    4546    private ConnThrottler _hourThrottler;
    4647    private ConnThrottler _dayThrottler;
     48    /** since 0.9, each manager instantiates its own timer */
     49    private final SimpleTimer2 _timer;
    4750   
    4851    public ConnectionManager(I2PAppContext context, I2PSession session, int maxConcurrent, ConnectionOptions defaultOptions) {
     
    5962        _schedulerChooser = new SchedulerChooser(_context);
    6063        _conPacketHandler = new ConnectionPacketHandler(_context);
    61         _tcbShare = new TCBShare(_context);
     64        _timer = new RetransmissionTimer(_context, "Streaming Timer " +
     65                                         session.getMyDestination().calculateHash().toBase64().substring(0, 4));
     66        _tcbShare = new TCBShare(_context, _timer);
    6267        // PROTO_ANY is for backward compatibility (pre-0.7.1)
    6368        // TODO change proto to PROTO_STREAMING someday.
     
    147152        opts.setPort(synPacket.getRemotePort());
    148153        opts.setLocalPort(synPacket.getLocalPort());
    149         Connection con = new Connection(_context, this, _schedulerChooser, _outboundQueue, _conPacketHandler, opts);
     154        Connection con = new Connection(_context, this, _schedulerChooser, _timer, _outboundQueue, _conPacketHandler, opts);
    150155        _tcbShare.updateOptsFromShare(con);
    151156        con.setInbound();
     
    254259                    try { Thread.sleep(remaining/4); } catch (InterruptedException ie) {}
    255260                } else {
    256                     con = new Connection(_context, this, _schedulerChooser, _outboundQueue, _conPacketHandler, opts);
     261                    con = new Connection(_context, this, _schedulerChooser, _timer, _outboundQueue, _conPacketHandler, opts);
    257262                    con.setRemotePeer(peer);
    258263           
     
    369374        }
    370375        _tcbShare.stop();
     376        _timer.stop();
    371377    }
    372378   
     
    468474   
    469475    private class PingFailed implements SimpleTimer.TimedEvent {
    470         private Long _id;
    471         private PingNotifier _notifier;
     476        private final Long _id;
     477        private final PingNotifier _notifier;
     478
    472479        public PingFailed(Long id, PingNotifier notifier) {
    473480            _id = id;
     
    488495    private static class PingRequest {
    489496        private boolean _ponged;
    490         private Destination _peer;
    491         private PacketLocal _packet;
    492         private PingNotifier _notifier;
     497        private final Destination _peer;
     498        private final PacketLocal _packet;
     499        private final PingNotifier _notifier;
     500
    493501        public PingRequest(Destination peer, PacketLocal packet, PingNotifier notifier) {
    494             _ponged = false;
    495502            _peer = peer;
    496503            _packet = packet;
    497504            _notifier = notifier;
    498505        }
     506
    499507        public void pong() {
    500508            // static, no log
  • apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java

    rcae9432 r675e8a9  
    5050    private static final int DEFAULT_PASSIVE_FLUSH_DELAY = 250;
    5151
     52/****
    5253    public MessageOutputStream(I2PAppContext ctx, DataReceiver receiver) {
    5354        this(ctx, receiver, Packet.MAX_PAYLOAD_SIZE);
    5455    }
    55     public MessageOutputStream(I2PAppContext ctx, DataReceiver receiver, int bufSize) {
    56         this(ctx, receiver, bufSize, DEFAULT_PASSIVE_FLUSH_DELAY);
    57     }
    58     public MessageOutputStream(I2PAppContext ctx, DataReceiver receiver, int bufSize, int passiveFlushDelay) {
     56****/
     57
     58    /** */
     59    public MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer,
     60                               DataReceiver receiver, int bufSize) {
     61        this(ctx, timer, receiver, bufSize, DEFAULT_PASSIVE_FLUSH_DELAY);
     62    }
     63
     64    public MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer,
     65                               DataReceiver receiver, int bufSize, int passiveFlushDelay) {
    5966        super();
    6067        _dataCache = ByteCache.getInstance(128, bufSize);
     
    6976        _sendPeriodBeginTime = ctx.clock().now();
    7077        _context.statManager().createRateStat("stream.sendBps", "How fast we pump data through the stream", "Stream", new long[] { 60*1000, 5*60*1000, 60*60*1000 });
    71         _flusher = new Flusher();
     78        _flusher = new Flusher(timer);
    7279        if (_log.shouldLog(Log.DEBUG))
    7380            _log.debug("MessageOutputStream created");
     
    213220    private class Flusher extends SimpleTimer2.TimedEvent {
    214221        private boolean _enqueued;
    215         public Flusher() {
    216             super(RetransmissionTimer.getInstance());
     222        public Flusher(SimpleTimer2 timer) {
     223            super(timer);
    217224        }
    218225        public void enqueue() {
  • apps/streaming/java/src/net/i2p/client/streaming/RetransmissionTimer.java

    rcae9432 r675e8a9  
    11package net.i2p.client.streaming;
    22
     3import net.i2p.I2PAppContext;
    34import net.i2p.util.SimpleTimer2;
    45
    56/**
    6  *  Not clear that we really need to create our own timer group, but we do,
    7  *  to prevent us clogging the router's timer group.
    8  *  Use from outside this package is deprecated.
    9  *  (BOB instantiates this for thread group reasons)
     7 *  Per-destination timer
    108 */
    119public class RetransmissionTimer extends SimpleTimer2 {
    12     private static final RetransmissionTimer _instance = new RetransmissionTimer();
    13     public static final RetransmissionTimer getInstance() { return _instance; }
    14     protected RetransmissionTimer() { super("StreamingTimer"); }
     10
     11    /**
     12     *  @deprecated Don't use this to prestart threads, this is no longer a static instance
     13     *  @return a new instance as of 0.9
     14     */
     15    public static final RetransmissionTimer getInstance() {
     16        return new RetransmissionTimer(I2PAppContext.getGlobalContext(), "RetransmissionTimer");
     17    }
     18
     19
     20    /**
     21     *  @since 0.9
     22     */
     23    RetransmissionTimer(I2PAppContext ctx, String name) {
     24        super(ctx, name, false);
     25    }
    1526}
  • apps/streaming/java/src/net/i2p/client/streaming/TCBShare.java

    rcae9432 r675e8a9  
    3434    private static final int MAX_WINDOW_SIZE = Connection.MAX_WINDOW_SIZE / 4;
    3535   
    36     public TCBShare(I2PAppContext ctx) {
     36    public TCBShare(I2PAppContext ctx, SimpleTimer2 timer) {
    3737        _context = ctx;
    3838        _log = ctx.logManager().getLog(TCBShare.class);
    3939        _cache = new ConcurrentHashMap(4);
    40         _cleaner = new CleanEvent();
     40        _cleaner = new CleanEvent(timer);
    4141        _cleaner.schedule(CLEAN_TIME);
    4242    }
     
    126126
    127127    private class CleanEvent extends SimpleTimer2.TimedEvent {
    128         public CleanEvent() {
    129             super(RetransmissionTimer.getInstance());
     128        public CleanEvent(SimpleTimer2 timer) {
     129            // Use router's SimpleTimer2
     130            super(timer);
    130131        }
    131132        public void timeReached() {
  • history.txt

    rcae9432 r675e8a9  
    33  * Reseeder: Get rid of static instance, root in netDB,
    44              don't use system properties for status
     5  * RetransmissionTimer: Instantiate per-destination
    56  * Router: When removing a config setting, remove from context also
    67  * SimpleScheduler, SimpleTimer, SimpleTimer2: Replace static instances
Note: See TracChangeset for help on using the changeset viewer.