Package net.tomp2p.peers

Examples of net.tomp2p.peers.PeerMapConfiguration


  private static final Logger log = LoggerFactory.getLogger(SeedNodeForTesting.class);

  public static void main(String[] args) throws Exception {
    try {
      Number160 peerId = Number160.createHash(TomP2PTests.SEED_ID_WAN_1);
          PeerMapConfiguration pmc = new PeerMapConfiguration(peerId).peerNoVerification();
          PeerMap pm = new PeerMap(pmc);
      peer = new PeerBuilder(peerId).ports(5000).peerMap(pm).start();
      peer.objectDataReply(new ObjectDataReply() {
        @Override
        public Object reply(PeerAddress sender, Object request) throws Exception {
View Full Code Here


            return cachedPeers.get(id);
        }*/
        Peer peer = null;
        try {
          Number160 peerId = Number160.createHash(clientId);
          PeerMapConfiguration pmc = new PeerMapConfiguration(peerId).peerNoVerification();
          PeerMap pm = new PeerMap(pmc);
          ChannelClientConfiguration cc = PeerBuilder.createDefaultChannelClientConfiguration();
          cc.maxPermitsTCP(100);
          cc.maxPermitsUDP(100);
            peer = new PeerBuilder(peerId).channelClientConfiguration(cc).ports(clientPort).peerMap(pm).start();
View Full Code Here

        Bindings bindings = new Bindings();// .addInterface("lo");
        PeerDHT[] peers = new PeerDHT[nrOfPeers];
        final Peer master;
        if (automaticFuture != null) {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
          master = new PeerBuilder(peerId)
                    .ports(port).enableMaintenance(maintenance)
                    .bindings(bindings).peerMap(peerMap).start().addAutomaticFuture(automaticFuture);
            peers[0] = new PeerBuilderDHT(master).start();
           
        } else {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
          master = new PeerBuilder(peerId).enableMaintenance(maintenance).bindings(bindings)
                    .peerMap(peerMap).ports(port).start();
          peers[0] = new PeerBuilderDHT(master).start();
        }

        for (int i = 1; i < nrOfPeers; i++) {
            if (automaticFuture != null) {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
                Peer peer = new PeerBuilder(peerId)
                        .masterPeer(master)
                        .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap).bindings(bindings).start().addAutomaticFuture(automaticFuture);
                peers[i] = new PeerBuilderDHT(peer).start();
            } else {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId).peerNoVerification());
              Peer peer = new PeerBuilder(peerId).enableMaintenance(maintenance)
                        .bindings(bindings).peerMap(peerMap).masterPeer(master)
                        .start();
                peers[i] = new PeerBuilderDHT(peer).start();
            }
View Full Code Here

        Bindings bindings = new Bindings().addAddress(InetAddress.getLocalHost());
//        Bindings bindings = new Bindings().addInterface("lo0");
        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)
                    .ports(port).enableMaintenance(maintenance)
                    .bindings(bindings).peerMap(peerMap).start().addAutomaticFuture(automaticFuture);
        } else {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
            peers[0] = new PeerBuilder(peerId).enableMaintenance(maintenance).bindings(bindings)
                   .peerMap(peerMap).ports(port).start();
        }

        for (int i = 1; i < nrOfPeers; i++) {
            if (automaticFuture != null) {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
                peers[i] = new PeerBuilder(peerId)
                        .masterPeer(peers[0])
                        .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap).bindings(bindings).start().addAutomaticFuture(automaticFuture);
            } else {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId).peerNoVerification());
                peers[i] = new PeerBuilder(peerId).enableMaintenance(maintenance)
                        .bindings(bindings).peerMap(peerMap).masterPeer(peers[0])
                        .start();
            }
        }
View Full Code Here

  public void testCountPeers1() throws UnknownHostException {
    Random rnd = new Random(42L);

    for (int j = 1; j < 20; j++) {
      int nr = 100000 * j;
      PeerMapConfiguration conf = new PeerMapConfiguration(ID);
      conf.bagSizeVerified(20).bagSizeOverflow(20);
      conf.offlineCount(1000).offlineTimeout(60);
      conf.addPeerFilter(new DefaultPeerFilter()).maintenance(new DefaultMaintenance(0, new int[] {}));
      PeerMap peerMap = new PeerMap(conf);

      Statistics statistics = new Statistics(peerMap);
      for (int i = 0; i < nr; i++) {
        PeerAddress pa = Utils2.createAddress(new Number160(rnd));
View Full Code Here

  private RelayUtils() {
    // only static methods
  }

  public static List<Map<Number160, PeerStatistic>> unflatten(Collection<PeerAddress> map, PeerAddress sender) {
    PeerMapConfiguration peerMapConfiguration = new PeerMapConfiguration(sender.peerId());
    PeerMap peerMap = new PeerMap(peerMapConfiguration);
    for (PeerAddress peerAddress : map) {
      peerMap.peerFound(peerAddress, null, null);
    }
    return peerMap.peerMapVerified();
View Full Code Here

        Bindings bindings = new Bindings().addInterface("lo");
        PeerDHT[] peers = new PeerDHT[nrOfPeers];
        final Peer master;
        if (automaticFuture != null) {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
          master = new PeerBuilder(peerId)
                    .ports(port).enableMaintenance(maintenance)
                    .bindings(bindings).peerMap(peerMap).start().addAutomaticFuture(automaticFuture);
            peers[0] = new PeerBuilderDHT(master).start();
           
        } else {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
          master = new PeerBuilder(peerId).enableMaintenance(maintenance).bindings(bindings)
                    .peerMap(peerMap).ports(port).start();
          peers[0] = new PeerBuilderDHT(master).start();
        }

        for (int i = 1; i < nrOfPeers; i++) {
            if (automaticFuture != null) {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
                Peer peer = new PeerBuilder(peerId)
                        .masterPeer(master)
                        .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap).bindings(bindings).start().addAutomaticFuture(automaticFuture);
                peers[i] = new PeerBuilderDHT(peer).start();
            } else {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId).peerNoVerification());
              Peer peer = new PeerBuilder(peerId).enableMaintenance(maintenance)
                        .bindings(bindings).peerMap(peerMap).masterPeer(master)
                        .start();
                peers[i] = new PeerBuilderDHT(peer).start();
            }
View Full Code Here

        Bindings bindings = new Bindings().addInterface("lo");
        PeerDHT[] peers  = new PeerDHT[nrOfPeers];
        final Peer master;
        if (automaticFuture != null) {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
          master = new PeerBuilder(peerId)
                    .ports(port)
                    .bindings(bindings).peerMap(peerMap).start().addAutomaticFuture(automaticFuture);
          peers[0] = new PeerBuilderDHT(master).start();
           
        } else {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
          master = new PeerBuilder(peerId).bindings(bindings)
                    .peerMap(peerMap).ports(port).start();
          peers[0] = new PeerBuilderDHT(master).start();
        }
       
        IndirectReplication i1 = new IndirectReplication(peers[0])
    .intervalMillis(1000)
    .nRoot()
    .replicationFactor(6)
    .keepData(false).start();

        for (int i = 1; i < nrOfPeers; i++) {
            if (automaticFuture != null) {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
                Peer peer = new PeerBuilder(peerId)
                        .masterPeer(master)
                        .peerMap(peerMap).bindings(bindings).start().addAutomaticFuture(automaticFuture);
                peers[i] = new PeerBuilderDHT(peer).start();
            } else {
              Number160 peerId = new Number160(rnd);
              PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId).peerNoVerification());
              Peer peer = new PeerBuilder(peerId)
                        .bindings(bindings).peerMap(peerMap).masterPeer(master)
                        .start();
                peers[i] = new PeerBuilderDHT(peer).start();
            }
View Full Code Here

 
  @Test
  public void testStoragePutGetVerified() throws IOException, ClassNotFoundException {
    Number160 self = Number160.ONE;
    PeerAddress selfAddress = new PeerAddress(self);
    PeerMapConfiguration pmc = new PeerMapConfiguration(self);
    PeerMap pm = new PeerMap(pmc);
    TrackerStorage trackerStorage = new TrackerStorage(10, new int[] { 10 }, 1, pm, selfAddress, false);

    Number320 n320 = new Number320(Number160.ZERO, Number160.ZERO);
View Full Code Here

 
  @Test
  public void testStoragePutGetUnverified() throws IOException, ClassNotFoundException {
    Number160 self = Number160.ONE;
    PeerAddress selfAddress = new PeerAddress(self);
    PeerMapConfiguration pmc = new PeerMapConfiguration(self);
    PeerMap pm = new PeerMap(pmc);
    TrackerStorage trackerStorage = new TrackerStorage(10, new int[] { 10 }, 1, pm, selfAddress, true);

    Number320 n320 = new Number320(Number160.ZERO, Number160.ZERO);
View Full Code Here

TOP

Related Classes of net.tomp2p.peers.PeerMapConfiguration

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.