Exemplo n.º 1
0
 private void requeuePending(long ms) {
   if (_pendingRequeueJob == null) _pendingRequeueJob = new RequeuePending(getContext());
   long now = getContext().clock().now();
   if (_pendingRequeueJob.getTiming().getStartAfter() < now)
     _pendingRequeueJob.getTiming().setStartAfter(now + ms);
   getContext().jobQueue().addJob(_pendingRequeueJob);
 }
Exemplo n.º 2
0
 public void runJob() {
   boolean wasFF = _facade.floodfillEnabled();
   boolean ff = shouldBeFloodfill();
   _facade.setFloodfillEnabled(ff);
   if (ff != wasFF) {
     if (ff) {
       getContext().router().eventLog().addEvent(EventLog.BECAME_FLOODFILL);
     } else {
       getContext().router().eventLog().addEvent(EventLog.NOT_FLOODFILL);
     }
     getContext().router().rebuildRouterInfo(true);
     Job routerInfoFlood = new FloodfillRouterInfoFloodJob(getContext(), _facade);
     if (getContext().router().getUptime() < 5 * 60 * 1000) {
       // Needed to prevent race if router.floodfillParticipant=true (not auto)
       routerInfoFlood.getTiming().setStartAfter(getContext().clock().now() + 5 * 60 * 1000);
       getContext().jobQueue().addJob(routerInfoFlood);
       if (_log.shouldLog(Log.DEBUG)) {
         _log.logAlways(
             Log.DEBUG, "Deferring our FloodfillRouterInfoFloodJob run because of low uptime.");
       }
     } else {
       routerInfoFlood.runJob();
       if (_log.shouldLog(Log.DEBUG)) {
         _log.logAlways(Log.DEBUG, "Running FloodfillRouterInfoFloodJob");
       }
     }
   }
   if (_log.shouldLog(Log.INFO)) _log.info("Should we be floodfill? " + ff);
   int delay = (REQUEUE_DELAY / 2) + getContext().random().nextInt(REQUEUE_DELAY);
   // there's a lot of eligible non-floodfills, keep them from all jumping in at once
   // TODO: somehow assess the size of the network to make this adaptive?
   if (!ff) delay *= 4; // this was 7, reduced for moar FFs --zab
   requeue(delay);
 }
  @Override
  public synchronized void startup() {
    super.startup();
    _context.jobQueue().addJob(new FloodfillMonitorJob(_context, this));
    _lookupThrottler = new LookupThrottler();
    _negativeCache = new NegativeLookupCache();

    // refresh old routers
    Job rrj = new RefreshRoutersJob(_context, this);
    rrj.getTiming().setStartAfter(_context.clock().now() + 5 * 60 * 1000);
    _context.jobQueue().addJob(rrj);
  }