Package net.tomp2p.peers

Examples of net.tomp2p.peers.PeerStatistic


    } else if(verifyPeersOnTracker) {
      dataMapToStore = dataMapUnverified;
    } else {
      dataMapToStore = dataMap;
    }
    return add(key, new PeerStatistic(peerAddress), dataMapToStore, attachement);
  }
View Full Code Here


  @Override
  public boolean peerFailed(PeerAddress remotePeer, PeerException reason) {
    peerOffline.put(remotePeer.peerId(), Boolean.TRUE);
    Number320 keyToRemove = null;
    PeerStatistic statToRemove = null;
    for (Map.Entry<Number320, TrackerData> entry : dataMapUnverified.entrySet()) {
      for (Map.Entry<PeerStatistic, Data> entry2 : entry.getValue().peerAddresses().entrySet()) {
        if (entry2.getKey().peerAddress().equals(remotePeer)) {
          keyToRemove = entry.getKey();
          statToRemove = entry2.getKey();
View Full Code Here

  public boolean peerFound(PeerAddress remotePeer, PeerAddress referrer, PeerConnection peerConnection) {
    boolean firsthand = referrer == null;
    if (firsthand) {
      peerOffline.remove(remotePeer.peerId());
      Number320 keyToRemove = null;
      PeerStatistic statToRemove = null;
      for (Map.Entry<Number320, TrackerData> entry : dataMapUnverified.entrySet()) {
        for (Map.Entry<PeerStatistic, Data> entry2 : entry.getValue().peerAddresses().entrySet()) {
          PeerAddress tmp = entry2.getKey().peerAddress();
          if (tmp.equals(remotePeer)) {
            if (add(entry.getKey(), entry2.getKey(), dataMap, entry2.getValue())) {
              // only remove from unverified if we could store to
              // verified
              keyToRemove = entry.getKey();
              statToRemove = entry2.getKey();
              statToRemove.successfullyChecked();
              // TODO: here we can break to the if statement below
            }
          }
        }
      }
View Full Code Here

    TrackerData trackerData = new TrackerData(new HashMap<PeerStatistic, Data>());
    PeerAddress peerAddressToAnnounce = builder.peerAddressToAnnounce();
    if (peerAddressToAnnounce == null) {
      peerAddressToAnnounce = peerBean().serverPeerAddress();
    }
    trackerData.put(new PeerStatistic(peerAddressToAnnounce), builder.attachement());
    trackerData = UtilsTracker.limit(trackerData, TrackerRPC.MAX_MSG_SIZE_UDP);
    message.trackerData(trackerData);

    if (builder.isForceTCP()) {
      return requestHandler.sendTCP(channelCreator);
View Full Code Here

            Number160 locationKey = new Number160("0x5555");
            Number160 domainKey = new Number160("0x7777");
            Number320 key = new Number320(locationKey, domainKey);
           
            sender.trackerStorage().put(key, recv1.peerAddress(), null, new Data("test"));
            PeerStatistic ps = sender.trackerStorage().nextForMaintenance(new ArrayList<PeerAddress>());
            FuturePing fp = sender.peer().ping().peerAddress(ps.peerAddress()).start().awaitListeners();
            Assert.assertEquals(true, fp.isSuccess());
           
           
            sender.peer().addAutomaticFuture(new AutomaticFuture() {
        @Override
View Full Code Here

    TrackerStorage trackerStorage = new TrackerStorage(10, new int[] { 10 }, 1, pm, selfAddress, true);

    Number320 n320 = new Number320(Number160.ZERO, Number160.ZERO);

    trackerStorage.put(n320, selfAddress, null, new Data("test"));
    PeerStatistic ps = trackerStorage.nextForMaintenance(null);
    Assert.assertEquals(ps.peerAddress().peerId(), self)
  }
View Full Code Here

    TrackerStorage trackerStorage = new TrackerStorage(10, new int[] { 10 }, 1, pm, selfAddress, true);

    Number320 n320 = new Number320(Number160.ZERO, Number160.ZERO);

    trackerStorage.put(n320, selfAddress, null, new Data("test"));
    PeerStatistic ps = trackerStorage.nextForMaintenance(null);
    trackerStorage.peerFound(selfAddress, null, null);
    ps = trackerStorage.nextForMaintenance(null);
    Assert.assertNull(ps);
  }
View Full Code Here

      PeerDHT[] peers = UtilsDHT2.createNodes(2000, rnd, 4001);
      master = peers[0];
      UtilsDHT2.perfectRoutingIndirect(peers);
      // do testing

      PeerStatistic peerStatatistic = master.peerBean().peerMap()
              .nextForMaintenance(new ArrayList<PeerAddress>());
      Assert.assertNotEquals(master.peerAddress(), peerStatatistic.peerAddress());
      Thread.sleep(10000);
      System.err.println("DONE");
    } finally {
      if (master != null) {
        master.shutdown().await();
View Full Code Here

          if (buf.readableBytes() < size) {
            return false;
          }
          PeerAddress pa = new PeerAddress(buf);
          PeerStatistic ps = new PeerStatistic(pa);

          currentTrackerData = Data.decodeHeader(buf, signatureFactory);
          if (currentTrackerData == null) {
            return false;
          }
View Full Code Here

            //make sure we only have 5 ping in parallel
            if (shutdown || COUNTER.get() > MAX_PING) {
                return;
            }
            for (Maintainable maintainable : maintainables) {
                PeerStatistic peerStatatistic = maintainable.nextForMaintenance(runningFutures.values());
                if(peerStatatistic == null) {
                    continue;
                }
                BaseFuture future = peer.ping().peerAddress(peerStatatistic.peerAddress()).start();
                LOG.debug("maintenance ping from {} to {}", peer.peerAddress(), peerStatatistic.peerAddress());
               
                peer.notifyAutomaticFutures(future);
                runningFutures.put(future, peerStatatistic.peerAddress());
                COUNTER.incrementAndGet();
                future.addListener(new BaseFutureAdapter<BaseFuture>() {
                    @Override
                    public void operationComplete(BaseFuture future) throws Exception {
                      synchronized (lock) {
View Full Code Here

TOP

Related Classes of net.tomp2p.peers.PeerStatistic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.