Package tahrir.io.net

Examples of tahrir.io.net.RemoteNodeAddress


    }

    public static RemoteNodeAddress genericRemoteNodeAddress() {
        final RSAPublicKey pubKey = TrCrypto.createRsaKeyPair().a;
        final PhysicalNetworkLocation location = new UdpNetworkLocation(genericInetAddress(), genericPort());
        return new RemoteNodeAddress(location, pubKey);
    }
View Full Code Here


    Assert.assertEquals(ot2.subObj.i, ot.subObj.i);
  }

  @Test
  public void trPeerInfoTest() throws Exception {
    final TrPeerInfo ot = new TrPeerInfo(new RemoteNodeAddress(new UdpNetworkLocation(InetAddress.getByName("127.0.0.1"), 1234), TrCrypto.createRsaKeyPair().a));
    final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
    final DataOutputStream dos = new DataOutputStream(baos);
    TrSerializer.serializeTo(ot, dos);
    final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
    final TrPeerInfo ot2 = TrSerializer.deserializeFrom(TrPeerInfo.class, dis);
View Full Code Here

    seedConfig.peers.runBroadcast = false;
    seedConfig.localHostName = "localhost";
    seedConfig.udp.listenPort = 7643;
    final File seedDir = TestUtils.createTempDirectory();
    final TrNode seedNode = new TrNode(seedDir, seedConfig);
    final RemoteNodeAddress seedPublicNodeId = seedNode.getRemoteNodeAddress();

    final File joinerDir = TestUtils.createTempDirectory();

    final TrNodeConfig joinerConfig = new TrNodeConfig();
View Full Code Here

        seedConfig.peers.runBroadcast = false;
        seedConfig.localHostName = "localhost";
        seedConfig.udp.listenPort = 7643;
        final File seedDir = TestUtils.createTempDirectory();
        final TrNode seedNode = new TrNode(seedDir, seedConfig);
        final RemoteNodeAddress seedPublicNodeId = seedNode.getRemoteNodeAddress();

        final File joinerDir = TestUtils.createTempDirectory();

        final TrNodeConfig joinerConfig = new TrNodeConfig();
View Full Code Here

      receivedProbeFrom = sender();
      hopsToLive--;
      node.getPeerManager().hasForwardedRecently = true;
    }

    final RemoteNodeAddress closestPeerAddress = node.getPeerManager().getClosestPeer(locationToFind);

    if (logger.isDebugEnabled()) {
      logger.debug("The closest peer found was {}, with a location of {}", node.getRemoteNodeAddress().physicalLocation, node.getPeerManager().getLocInfo().getLocation());
    }

    if (hopsToLive == 0 || closestPeerAddress.equals(node.getRemoteNodeAddress()) || (!initator && closestPeerAddress.physicalLocation.equals(sender()))) {
      // the current node is the closest to what we're looking for or we've given up
      acceptor = true;
      sendResponses(forwarders);
    } else {
      if (hopsToLive > TrConstants.MAINTENANCE_HOPS_TO_LIVE) {
View Full Code Here

    willConnectTo = Lists.newLinkedList();

    // get nodes we're going to connect to
    while (peersToAccept > 0 && forwarders.size() > 0) {
      final int randomNum = TrUtils.rand.nextInt(forwarders.size());
      final RemoteNodeAddress randomForwarder = forwarders.remove(randomNum);

      // check to see if connected
      if (!node.getPeerManager().peers.containsKey(randomForwarder.physicalLocation)) {
        willConnectTo.add(randomForwarder);
        peersToAccept--;
View Full Code Here

  public void myCapabilitiesAre(final Capabilities myCapabilities, final int topologyLocation) {
    if (!acceptor) {
      node.getPeerManager().addByReplacement(acceptorAddress, myCapabilities, topologyLocation);
    } else {
      RemoteNodeAddress forwarderAddress = null;
      // find the remote address corresponding to sender()
      for (RemoteNodeAddress address : willConnectTo) {
        if (address.physicalLocation.equals(sender())) {
          forwarderAddress = address;
          break;
View Full Code Here

TOP

Related Classes of tahrir.io.net.RemoteNodeAddress

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.