Package net.tomp2p.connection

Examples of net.tomp2p.connection.PeerException


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

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

    trackerStorage.put(n320, selfAddress, null, new Data("test"));
    trackerStorage.peerFailed(selfAddress, new PeerException(PeerException.AbortCause.PEER_ABORT, ""));
    Assert.assertEquals(0, trackerStorage.size());
  }
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"));
    trackerStorage.peerFailed(selfAddress, new PeerException(PeerException.AbortCause.PEER_ABORT, ""));
    Assert.assertEquals(0, trackerStorage.sizeUnverified());
  }
View Full Code Here

        for (int i = 1; i <= 200; i++) {
            PeerAddress r1 = new PeerAddress(new Number160(i + 1));
            peerMap.peerFound(r1, null, null);
        }
        Assert.assertEquals(20, peerMap.size());
        peerMap.peerFailed(new PeerAddress(new Number160(100)), new PeerException(AbortCause.PROBABLY_OFFLINE, "probably offline"));
        Assert.assertTrue(peerMap.isPeerRemovedTemporarly(new PeerAddress(new Number160(100))));
        Assert.assertEquals(20, peerMap.size());
        peerMap.peerFailed(new PeerAddress(new Number160(2)), new PeerException(AbortCause.PROBABLY_OFFLINE, "probably offline"));
        Assert.assertEquals(19, peerMap.size());
        Assert.assertTrue(peerMap.isPeerRemovedTemporarly(new PeerAddress(new Number160(2))));
        Thread.sleep(1000);
        Assert.assertFalse(peerMap.isPeerRemovedTemporarly(new PeerAddress(new Number160(2))));
        Assert.assertFalse(peerMap.isPeerRemovedTemporarly(new PeerAddress(new Number160(100))));
View Full Code Here

        Assert.assertEquals(20, peerMap.size());
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 50; i++) {
                    peerMap.peerFailed(new PeerAddress(new Number160(i + 1)), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
                }
            }
        });
        t1.start();
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 100; i++) {
                    peerMap.peerFailed(new PeerAddress(new Number160(i + 1)), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
                }
            }
        });
        t2.start();
View Full Code Here

                            if (retVal) {
                                add.incrementAndGet();
                            }
                        }
                        if (i - diff > 1) {
                            boolean retVal = peerMap.peerFailed(new PeerAddress(new Number160(i - diff)), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
                            if (retVal) {
                                del.incrementAndGet();
                            }
                        }
View Full Code Here

        for (PeerAddress r1 : listAdded) {
            peerMap.peerFound(r1, null, null);
        }
        for (int i = 0; i < 100; i++) {
            PeerAddress removed = listAdded.get(random.nextInt(i + 1));
            if (peerMap.peerFailed(removed, new PeerException(AbortCause.SHUTDOWN, "shutdown"))) {
                listRemoved.add(removed);
            }
        }
        for (PeerAddress r1 : listAdded) {
            peerMap.peerFound(r1, r1, null);
        }
        Assert.assertEquals(47, peerMap.size());
        for (PeerAddress r1 : listRemoved) {
            Assert.assertTrue(peerMap.isPeerRemovedTemporarly(r1));
        }
        //
        for (PeerAddress r1 : listRemoved) {
            listAdded.remove(r1);
        }
        for (int i = 0; i < 300; i++) {
            PeerAddress removed = listAdded.get(random.nextInt(i + 1));
            peerMap.peerFailed(removed, new PeerException(AbortCause.SHUTDOWN, "shutdown"));
        }
        for (PeerAddress r1 : listRemoved) {
            Assert.assertTrue(peerMap.isPeerRemovedTemporarly(r1));
        }
        System.err.println("Time used: " + (System.currentTimeMillis() - start)
View Full Code Here

            }
            return false;
        }
        // not forced
        if (updatePeerStatistic(remotePeer, peerMapVerified.get(classMember), offlineCount)) {
            return peerFailed(remotePeer, new PeerException(AbortCause.PROBABLY_OFFLINE, "peer failed in verified map"));
        }
        if (updatePeerStatistic(remotePeer, peerMapOverflow.get(classMember), offlineCount)) {
            return peerFailed(remotePeer, new PeerException(AbortCause.PROBABLY_OFFLINE, "peer failed in overflow map"));
        }
        return false;
    }
View Full Code Here

      FutureGet fget = master1.get(id).routingConfiguration(rc).requestP2PConfiguration(pc)
              .domainKey(Number160.createHash("test")).contentKey(new Number160(5)).start();
      fget.awaitUninterruptibly();
      Assert.assertEquals(true, fget.isSuccess());

      master1.peerBean().peerMap().peerFailed(master2.peerAddress(), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
      master3.peerBean().peerMap().peerFailed(master2.peerAddress(), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
      master2 = new PeerBuilderDHT(new PeerBuilder(new Number160(rnd)).p2pId(1).ports(4002).start()).start();
      master1.peerBean().peerMap().peerFound(master2.peerAddress(), null, null);
      master3.peerBean().peerMap().peerFound(master2.peerAddress(), null, null);
      master2.peerBean().peerMap().peerFound(master1.peerAddress(), null, null);
      master2.peerBean().peerMap().peerFound(master3.peerAddress(), null, null);
View Full Code Here

                responseMessage.intValue(digestInfo.size());
            }
            else if (message.type() == Type.REQUEST_4) {
              synchronized (peerBean().peerStatusListeners()) {
                for (PeerStatusListener peerStatusListener : peerBean().peerStatusListeners()) {
              peerStatusListener.peerFailed(message.sender(), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
            }
              }
            }
             
        }
View Full Code Here

            fr.awaitUninterruptibly();
            // s1.put(location, Number160.ZERO, null, dataMap, false, false);
            final int slavePort = 7701;
            slave = new PeerBuilderDHT(new PeerBuilder(new Number160("0xfe")).ports(slavePort).start()).start();
            master.peerBean().peerMap().peerFound(slave.peerAddress(), null, null);
            master.peerBean().peerMap().peerFailed(slave.peerAddress(), new PeerException(AbortCause.SHUTDOWN, "shutdown"));
            Assert.assertEquals(1, test1.get());
            Assert.assertEquals(2, test2.get());
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
View Full Code Here

TOP

Related Classes of net.tomp2p.connection.PeerException

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.