Exemplo n.º 1
0
 private void addToMaintenanceQueue(PeerAddress remotePeer) {
   if (maintenanceTimeoutsSeconds.length == 0) return;
   long scheduledCheck;
   if (peerMapStat.getLastSeenOnlineTime(remotePeer) == 0) {
     // we need to check now!
     scheduledCheck = Timings.currentTimeMillis();
   } else {
     // check for next schedule
     int checked = peerMapStat.getChecked(remotePeer);
     if (checked >= maintenanceTimeoutsSeconds.length)
       checked = maintenanceTimeoutsSeconds.length - 1;
     scheduledCheck = Timings.currentTimeMillis() + (maintenanceTimeoutsSeconds[checked] * 1000L);
   }
   synchronized (maintenance) {
     maintenance.put(remotePeer, scheduledCheck);
   }
 }
Exemplo n.º 2
0
 private void prepareInsertOrUpdate(PeerAddress remotePeer, boolean firstHand) {
   if (firstHand) {
     peerMapStat.setSeenOnlineTime(remotePeer);
     // get the amount of milliseconds for the online time
     long online = peerMapStat.online(remotePeer);
     // get the time we want to wait between maintenance checks
     if (maintenanceTimeoutsSeconds.length > 0) {
       int checked = peerMapStat.getChecked(remotePeer);
       if (checked >= maintenanceTimeoutsSeconds.length)
         checked = maintenanceTimeoutsSeconds.length - 1;
       long time = maintenanceTimeoutsSeconds[checked] * 1000L;
       // if we have a higer online time than the maintenance time,
       // increase checked to increase the maintenace interval.
       if (online >= time) {
         peerMapStat.incChecked(remotePeer);
       }
     }
   }
   addToMaintenanceQueue(remotePeer);
 }