Package net.tomp2p.connection

Examples of net.tomp2p.connection.Bindings


    public static Peer[] createNodes(int nrOfPeers, Random rnd, int port, AutomaticFuture automaticFuture,
            boolean maintenance) throws Exception {
        if (nrOfPeers < 1) {
            throw new IllegalArgumentException("Cannot create less than 1 peer");
        }
        Bindings bindings = new Bindings().addInterface("lo");
        Peer[] peers = new Peer[nrOfPeers];
        if (automaticFuture != null) {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
            peers[0] = new PeerBuilder(peerId)
View Full Code Here


  public void startServer(String addr) throws Exception {
    PeerDHT peer = null;
    try {
      Random r = new Random(42L);
      // peer.getP2PConfiguration().setBehindFirewall(true);
      Bindings b = new Bindings();
      // b.addInterface("eth0");
      b.addAddress(InetAddress.getByName(addr));
      // b.addAddress(InetAddress.getByAddress(addr));
      peer = new PeerBuilderDHT(new PeerBuilder(new Number160(r)).bindings(b).ports(serverPort).start()).start();
      System.out.println("peer started.");
      for (;;) {
        Thread.sleep(5000);
View Full Code Here

    public void testBootstrap() throws Exception {
        Peer master = null;
        Peer client = null;
        try {
            //TODO: make this generic
          Bindings b = new Bindings().addInterface("wlp3s0");
            master = new PeerBuilder(new Number160(rnd)).bindings(b).ports(4000).enableMaintenance(false).start();
            client = new PeerBuilder(new Number160(rnd)).bindings(b).ports(4001).enableMaintenance(false).start();

            DiscoverResults dr = master.connectionBean().channelServer().discoverNetworks().currentDiscoverResults();
            if(dr.existingBroadcastAddresses().size() == 0) {
View Full Code Here

    @Test
    public void testBootstrap2() throws Exception {
        Peer master = null;
        Peer client = null;
        try {
          Bindings b = new Bindings().addInterface("lo");
          master = new PeerBuilder(new Number160(rnd)).bindings(b).ports(4002).start();
            client = new PeerBuilder(new Number160(rnd)).bindings(b).ports(4001).start();
            BaseFuture tmp = client.ping().broadcast().port(4001).start();
            tmp.awaitUninterruptibly();
            Assert.assertEquals(false, tmp.isSuccess());
View Full Code Here

                        LOG.info("I'm seen as {} by peer {}. I see myself as {}",
                                seenAs, peerAddress, peer.peerAddress().inetAddress());
                        if (!peer.peerAddress().inetAddress().equals(seenAs.inetAddress())) {
                            // check if we have this interface in that we can
                            // listen to
                            Bindings bindings2 = new Bindings().addAddress(seenAs.inetAddress());
                         
                            DiscoverResults discoverResults = DiscoverNetworks.discoverInterfaces(bindings2);
                            String status = discoverResults.status();
                            LOG.info("2nd interface discovery: {}", status);
                            if (discoverResults.newAddresses().size() > 0
View Full Code Here

      p2pID = 1;
    }
   
   
    if (bindings == null) {
      bindings = new Bindings();
    } else {
      channelServerConfiguration.bindings(bindings);
      channelClientConfiguration.bindings(bindings);
    }
    if (peerMap == null) {
View Full Code Here

    return peer;
  }

  public static ChannelServerConfiguration createDefaultChannelServerConfiguration() {
    ChannelServerConfiguration channelServerConfiguration = new ChannelServerConfiguration();
    channelServerConfiguration.bindings(new Bindings());
    //these two values may be overwritten in the peer builder
    channelServerConfiguration.ports(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
    channelServerConfiguration.portsForwarding(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
    channelServerConfiguration.behindFirewall(false);
    channelServerConfiguration.pipelineFilter(new DefaultPipelineFilter());
View Full Code Here

    return channelServerConfiguration;
  }

  public static ChannelClientConfiguration createDefaultChannelClientConfiguration() {
    ChannelClientConfiguration channelClientConfiguration = new ChannelClientConfiguration();
    channelClientConfiguration.bindings(new Bindings());
    channelClientConfiguration.maxPermitsPermanentTCP(MAX_PERMITS_PERMANENT_TCP);
    channelClientConfiguration.maxPermitsTCP(MAX_PERMITS_TCP);
    channelClientConfiguration.maxPermitsUDP(MAX_PERMITS_UDP);
    channelClientConfiguration.pipelineFilter(new DefaultPipelineFilter());
    channelClientConfiguration.signatureFactory(new DSASignatureFactory());
View Full Code Here

    final Random rnd = new Random(42L);
    Peer p1 = null;
    Peer p2 = null;
    try {
      // setup (step 1)
      Bindings b = new Bindings().addInterface("lo");
      p1 = new PeerBuilder(new Number160(rnd)).ports(4001).bindings(b).start();
      p2 = new PeerBuilder(new Number160(rnd)).ports(4002).bindings(b).start();
      FutureBootstrap fb = p2.bootstrap().peerAddress(p1.peerAddress()).start();
      fb.awaitUninterruptibly();
      Assert.assertEquals(true, fb.isSuccess());
View Full Code Here

TOP

Related Classes of net.tomp2p.connection.Bindings

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.