Package net.tomp2p.message

Examples of net.tomp2p.message.NeighborSet


                    Type.REQUEST_2, cc, new DefaultConnectionConfiguration());

            fr.awaitUninterruptibly();
            // Thread.sleep(10000000);
            Assert.assertEquals(true, fr.isSuccess());
            NeighborSet pas = fr.responseMessage().neighborsSet(0);
            // we are able to fit 40 neighbors into 1400 bytes
            Assert.assertEquals(33, pas.size());
            Assert.assertEquals(10, (int) fr.responseMessage().intAt(0));
            Assert.assertEquals(new Number160("0x1"), pas.neighbors().iterator().next().peerId());
            Assert.assertEquals(PORT_TCP, pas.neighbors().iterator().next().tcpPort());
            Assert.assertEquals(PORT_UDP, pas.neighbors().iterator().next().udpPort());
            cc.shutdown();
        } finally {
            if (sender != null) {
                sender.shutdown().await();
            }
View Full Code Here


                    Type.REQUEST_2, cc, new DefaultConnectionConfiguration());

            fr.awaitUninterruptibly();
            // Thread.sleep(10000000);
            Assert.assertEquals(true, fr.isSuccess());
            NeighborSet pas = fr.responseMessage().neighborsSet(0);
            // we are able to fit 40 neighbors into 1400 bytes
            Assert.assertEquals(33, pas.size());
            Assert.assertEquals(new Number160("0x1"), pas.neighbors().iterator().next().peerId());
            Assert.assertEquals(PORT_TCP, pas.neighbors().iterator().next().tcpPort());
            Assert.assertEquals(PORT_UDP, pas.neighbors().iterator().next().udpPort());
            cc.shutdown();
        } finally {
            if (sender != null) {
                sender.shutdown().await();
            }
View Full Code Here

            fr.awaitUninterruptibly();
            System.err.println(fr.failedReason());
            // Thread.sleep(10000000);
            Assert.assertEquals(true, fr.isSuccess());
            NeighborSet pas = fr.responseMessage().neighborsSet(0);
            // we are able to fit 40 neighbors into 1400 bytes
            Assert.assertEquals(33, pas.size());
            Assert.assertEquals(new Number160("0x1"), pas.neighbors().iterator().next().peerId());
            Assert.assertEquals(PORT_TCP, pas.neighbors().iterator().next().tcpPort());
            Assert.assertEquals(PORT_UDP, pas.neighbors().iterator().next().udpPort());
            cc.shutdown();
        } finally {
            if (sender != null) {
                sender.shutdown().await();
            }
View Full Code Here

            SearchValues v = new SearchValues(new Number160("0x30"), null);
            FutureResponse fr = neighbors2.closeNeighbors(sender.peerAddress(), v,
                    Type.REQUEST_2, cc, new DefaultConnectionConfiguration());
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());
            NeighborSet pas = fr.responseMessage().neighborsSet(0);

            // I see no one, not evenmyself. My peer was added in the overflow map
            Assert.assertEquals(0, pas.size());
            cc.shutdown();
        } finally {
            if (sender != null) {
                sender.shutdown().await();
            }
View Full Code Here

    Collection<PeerAddress> neighbors = getNeighbors(locationKey, NeighborRPC.NEIGHBOR_SIZE);
    if (neighbors == null) {
      // return empty neighbor set
      Message response = createResponseMessage(message, Type.NOT_FOUND, unreachablePeer);
      response.neighborsSet(new NeighborSet(-1, Collections.<PeerAddress> emptyList()));
      responder.response(response);
      return;
    }

    // Create response message and set neighbors
    final Message responseMessage = createResponseMessage(message, Type.OK, unreachablePeer);

    // TODO: the relayed peer must be up-to-date here
    // neighbors.add(peerConnection.remotePeer());

    LOG.debug("found the following neighbors {}", neighbors);

    NeighborSet neighborSet = new NeighborSet(NeighborRPC.NEIGHBOR_LIMIT, neighbors);
    responseMessage.neighborsSet(neighborSet);

    // we can't do fast get here, as we only send over the neighbors and not the keys stored
    responder.response(responseMessage);
  }
View Full Code Here

    LOG.debug("Sending current routing table to relay {}", connection.relayAddress());

    final Message message = relayRPC
        .createMessage(connection.relayAddress(), RPC.Commands.RELAY.getNr(), Type.REQUEST_3);
    // TODO: neighbor size limit is 256, we might have more here
    message.neighborsSet(new NeighborSet(-1, RelayUtils.flatten(map)));

    final FutureResponse fr = connection.sendToRelay(message);
    fr.addListener(new BaseFutureAdapter<BaseFuture>() {
      public void operationComplete(BaseFuture future) throws Exception {
        if (future.isFailed()) {
View Full Code Here

  private Message createForwardMessage(final Message message, final PeerAddress recipient) {
    // creates the Message to forward to the unreachable peer
    Message forwardMessage = createMessage(recipient, RPC.Commands.RCON.getNr(), Message.Type.REQUEST_2);

    // transmit PeerAddress of reachablePeer
    final NeighborSet ns = new NeighborSet(1, new ArrayList<PeerAddress>(1));
    ns.add(message.sender());
    forwardMessage.neighborsSet(ns);

    if (!message.intList().isEmpty()) {
      // store the message id for new message to identify the cached message afterwards
      forwardMessage.intValue(message.intAt(0));
View Full Code Here

     * @return The neighborset with exactly one peer
     */
    private NeighborSet createNeighborSet(final PeerAddress self) {
        Collection<PeerAddress> tmp = new ArrayList<PeerAddress>();
        tmp.add(self);
        return new NeighborSet(-1, tmp);
    }
View Full Code Here

      @Override
            public void operationComplete(FutureResponse future) throws Exception {
              if(future.isSuccess()) {
                Message response = future.responseMessage();
                if(response != null) {
                  NeighborSet ns = response.neighborsSet(0);
                  if(ns!=null) {
                    for(PeerAddress neighbors:ns.neighbors()) {
                      synchronized (peerBean().peerStatusListeners()) {
                        for (PeerStatusListener peerStatusListener : peerBean().peerStatusListeners()) {
                          peerStatusListener.peerFound(neighbors, response.sender(), null);
                        }
                      }
View Full Code Here

       
        Collection<PeerAddress> neighbors = getNeighbors(locationKey, NEIGHBOR_SIZE);
        if(neighbors == null) {
            //return empty neighbor set
            Message response = createResponseMessage(message, Type.NOT_FOUND);
            response.neighborsSet(new NeighborSet(-1, Collections.<PeerAddress>emptyList()));
            responder.response(response);
            return;
        }
       
        // Create response message and set neighbors
        final Message responseMessage = createResponseMessage(message, Type.OK);
       
        LOG.debug("found the following neighbors {}", neighbors);
        NeighborSet neighborSet = new NeighborSet(NEIGHBOR_LIMIT, neighbors);
        responseMessage.neighborsSet(neighborSet);
        // check for fastget, -1 if, no domain provided, so we cannot
        // check content length, 0 for content not here , > 0 content here
        // int contentLength = -1;
        Number160 contentKey = message.key(2);
View Full Code Here

TOP

Related Classes of net.tomp2p.message.NeighborSet

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.