예제 #1
0
파일: PeerMap.java 프로젝트: xzqttt/TomP2P
 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);
 }