Package freenet.node

Examples of freenet.node.SeedServerTestPeerNode


  List<SeedServerTestPeerNode> seedNodes = new ArrayList<SeedServerTestPeerNode>();
  List<SimpleFieldSet> seedNodesAsSFS = Announcer.readSeednodes(new File("/tmp/", Announcer.SEEDNODES_FILENAME));
  int numberOfNodesInTheFile = 0;
  for(SimpleFieldSet sfs : seedNodesAsSFS) {
    numberOfNodesInTheFile++;
    SeedServerTestPeerNode seednode = node.createNewSeedServerTestPeerNode(sfs);
    try {
      node.connectToSeednode(seednode);
      seedNodes.add(seednode);
    } catch (Exception fse) {
      System.err.println("ERROR adding "+seednode.toString()+ " "+fse.getMessage());
    }
  }
  // Start it
        node.start(true);
  //Logger.setupStdoutLogging(LogLevel.MINOR, "freenet:NORMAL,freenet.node.NodeDispatcher:MINOR,freenet.node.FNPPacketMangler:MINOR");
  Logger.getChain().setThreshold(LogLevel.ERROR); // kill logging
  Thread.sleep(SECONDS.toMillis(2));
  if(seedNodes.size() != numberOfNodesInTheFile)
        System.out.println("ERROR ADDING SOME OF THE SEEDNODES!!");
  System.out.println("Let some time for the "+ seedNodes.size() +" nodes to connect...");
  Thread.sleep(SECONDS.toMillis(8));

  int pingID = 0;
  long deadline = System.currentTimeMillis() + MINUTES.toMillis(2);
  while(System.currentTimeMillis() < deadline) {
    int countConnectedSeednodes = 0;
    for(SeedServerPeerNode seednode : node.peers.getConnectedSeedServerPeersVector(null)) {
      try {
        double pingTime = seednode.averagePingTime();
        int uptime = seednode.getUptime();
        long timeDelta = seednode.getClockDelta();
        if(seednode.isRealConnection())
          continue;
        countConnectedSeednodes++;
        boolean ping = seednode.ping(pingID++);
        if(ping)
          System.out.println(seednode.getIdentityString()+
            " uptime="+uptime+
            " ping="+ping+
            " pingTime="+pingTime+
            " uptime="+seednode.getUptime()+
            " timeDelta="+TimeUtil.formatTime(timeDelta));
        // sanity check
        if(seednode.isRoutable())
          System.out.println(seednode + " is routable!");
      } catch (NotConnectedException e) {
        System.out.println(seednode.getIdentityString() + " is not connected "+seednode.getHandshakeCount());
      }
    }
    Map<FATE, Integer> totals = new EnumMap<FATE, Integer>(SeedServerTestPeerNode.FATE.class);
    for(SeedServerTestPeerNode seednode : seedNodes) {
      FATE fate = seednode.getFate();
      Integer x = totals.get(fate);
      if(x == null)
        totals.put(fate, 1);
      else
        totals.put(fate, x+1);
      System.out.println(seednode.getIdentityString() + " : "+fate+ " : "+seednode.getPeerNodeStatusString());
    }
    System.out.println("TOTALS:");
    for (Entry<FATE, Integer> fateEntry : totals.entrySet()) {
      System.out.println(fateEntry.getKey() + " : " + fateEntry.getValue());
    }
    System.out.println("################## ("+node.peers.countConnectedPeers()+") "+countConnectedSeednodes+'/'+node.peers.countSeednodes());
    Thread.sleep(SECONDS.toMillis(5));
  }
  Map<FATE, Integer> totals = new EnumMap<FATE, Integer>(SeedServerTestPeerNode.FATE.class);
  for(SeedServerTestPeerNode seednode : seedNodes) {
    FATE fate = seednode.getFate();
    Integer x = totals.get(fate);
    if(x == null)
      totals.put(fate, 1);
    else
      totals.put(fate, x+1);
    System.out.println(seednode.getIdentityString() + " : "+fate+ " : "+seednode.getPeerNodeStatusString());
  }
  System.out.println("RESULT:TOTALS:");
  for(FATE fate : totals.keySet()) {
    System.out.println("RESULT:"+fate + " : "+totals.get(fate));
  }
View Full Code Here

TOP

Related Classes of freenet.node.SeedServerTestPeerNode

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.