Package net.tomp2p.p2p

Examples of net.tomp2p.p2p.Peer.peerAddress()


        public Object reply(PeerAddress sender, Object request) throws Exception {
          System.out.println("request [" + request + "]");
          return "world";
        }
      });
      FutureDirect futureData = p1.sendDirect(p2.peerAddress()).object("hello").start();
      futureData.awaitUninterruptibly();
      System.out.println("reply [" + futureData.object() + "]");
    } finally {
      if (p1 != null) {
        p1.shutdown().await();
View Full Code Here


      List<BaseFuture> list1 = new ArrayList<BaseFuture>();
      List<BaseFuture> list2 = new ArrayList<BaseFuture>();
      List<FuturePeerConnection> list3 = new ArrayList<FuturePeerConnection>();
      for (int i = 0; i < 125; i++) {
        final byte[] b = new byte[10000];
        FuturePeerConnection pc = master.createPeerConnection(slave.peerAddress());
        list1.add(master.sendDirect(pc).buffer(new Buffer(Unpooled.wrappedBuffer(b))).start());
        list3.add(pc);
        // pc.close();
      }
      for (int i = 0; i < 20000; i++) {
View Full Code Here

        list1.add(master.sendDirect(pc).buffer(new Buffer(Unpooled.wrappedBuffer(b))).start());
        list3.add(pc);
        // pc.close();
      }
      for (int i = 0; i < 20000; i++) {
        list2.add(master.discover().peerAddress(slave.peerAddress()).start());
        final byte[] b = new byte[10000];
        byte[] me = Utils.intToByteArray(i);
        System.arraycopy(me, 0, b, 0, 4);
        list2.add(master.sendDirect(slave.peerAddress()).buffer(new Buffer(Unpooled.wrappedBuffer(b)))
                .start());
View Full Code Here

      for (int i = 0; i < 20000; i++) {
        list2.add(master.discover().peerAddress(slave.peerAddress()).start());
        final byte[] b = new byte[10000];
        byte[] me = Utils.intToByteArray(i);
        System.arraycopy(me, 0, b, 0, 4);
        list2.add(master.sendDirect(slave.peerAddress()).buffer(new Buffer(Unpooled.wrappedBuffer(b)))
                .start());
      }
      for (BaseFuture bf : list1) {
        bf.awaitListenersUninterruptibly();
        if (bf.isFailed()) {
View Full Code Here

      FutureRelayNAT startRelay = uNat.startRelay(peers[0].peerAddress()).awaitUninterruptibly();
      Assert.assertTrue(startRelay.isSuccess());
      mockGCM(peers, uNat);

      // Check if flags are set correctly
      Assert.assertTrue(unreachablePeer.peerAddress().isRelayed());
      Assert.assertFalse(unreachablePeer.peerAddress().isFirewalledTCP());
      Assert.assertFalse(unreachablePeer.peerAddress().isFirewalledUDP());
    } finally {
      if (master != null) {
        master.shutdown().await();
View Full Code Here

      Assert.assertTrue(startRelay.isSuccess());
      mockGCM(peers, uNat);

      // Check if flags are set correctly
      Assert.assertTrue(unreachablePeer.peerAddress().isRelayed());
      Assert.assertFalse(unreachablePeer.peerAddress().isFirewalledTCP());
      Assert.assertFalse(unreachablePeer.peerAddress().isFirewalledUDP());
    } finally {
      if (master != null) {
        master.shutdown().await();
      }
View Full Code Here

      mockGCM(peers, uNat);

      // Check if flags are set correctly
      Assert.assertTrue(unreachablePeer.peerAddress().isRelayed());
      Assert.assertFalse(unreachablePeer.peerAddress().isFirewalledTCP());
      Assert.assertFalse(unreachablePeer.peerAddress().isFirewalledUDP());
    } finally {
      if (master != null) {
        master.shutdown().await();
      }
      if (unreachablePeer != null) {
View Full Code Here

      Assert.assertTrue(futureBootstrap.isSuccess());

      boolean otherPeersHaveRelay = false;

      for (Peer peer : peers) {
        if (peer.peerBean().peerMap().allOverflow().contains(unreachablePeer.peerAddress())) {
          for (PeerAddress pa : peer.peerBean().peerMap().allOverflow()) {
            if (pa.peerId().equals(unreachablePeer.peerID())) {
              if (pa.peerSocketAddresses().size() > 0) {
                otherPeersHaveRelay = true;
              }
View Full Code Here

      // wait for maintenance
      Thread.sleep(uNat.peerMapUpdateInterval() * 1000);

      boolean otherPeersMe = false;
      for (Peer peer : peers) {
        if (peer.peerBean().peerMap().all().contains(unreachablePeer.peerAddress())) {
          System.err.println("check 2! " + peer.peerAddress());
          otherPeersMe = true;
        }
      }
      Assert.assertTrue(otherPeersMe);
View Full Code Here

      }
      list.add(new PeerSocketAddress(InetAddress.getByName("10.10.10.10"), 10, 10));
      unreachablePeer2.peerBean().serverPeerAddress(unreachablePeer2.peerBean().serverPeerAddress().changePeerSocketAddresses(list));
           
      System.err.println("unreachablePeer1: " + unreachablePeer1.peerAddress());
      System.err.println("unreachablePeer2: "+unreachablePeer2.peerAddress());
     
            FutureDirect fd = unreachablePeer2.sendDirect(unreachablePeer1.peerAddress()).object(request).start().awaitUninterruptibly();
            System.err.println("got msg from: "+fd.futureResponse().responseMessage().sender());
            Assert.assertEquals(response, fd.object());
            //make sure we did not receive it from the unreachable peer with port 13337
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.