Package freenet.support

Examples of freenet.support.PooledExecutor


      FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
      fis.close();

      // Create one node
      node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL,
              0, random, new PooledExecutor(), 1000, 4 * 1024 * 1024, true, true, true, true, true, true, true,
              12 * 1024, true, true, false, false, null);
      Logger.getChain().setThreshold(LogLevel.ERROR);

      // Start it
      node.start(true);
      long t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node)) {
        exitCode = EXIT_FAILED_TARGET;
        return;
      }
       
      long t2 = System.currentTimeMillis();
      System.out.println("SEED-TIME:" + (t2 - t1));
      csvLine.add(String.valueOf(t2 - t1));

      // PUSH N+1 BLOCKS
      for (int i = 0; i <= MAX_N; i++) {
          RandomAccessBucket data = randomData(node);
        HighLevelSimpleClient client = node.clientCore.makeClient((short) 0, false, false);
        FreenetURI uri = new FreenetURI("KSK@" + uid + "-" + dateFormat.format(today.getTime()) + "-" + i);
        System.out.println("PUSHING " + uri);
        client.addEventHook(new ClientEventListener() {

          @Override
          public void receive(ClientEvent ce, ClientContext context) {
            System.out.println(ce.getDescription());
          }
         
        });

        try {
          InsertBlock block = new InsertBlock(data, new ClientMetadata(), uri);
          t1 = System.currentTimeMillis();
          client.insert(block, false, null);
          t2 = System.currentTimeMillis();

          System.out.println("PUSH-TIME-" + i + ":" + (t2 - t1));
          csvLine.add(String.valueOf(t2 - t1));
        } catch (InsertException e) {
          e.printStackTrace();
          csvLine.add("N/A");
        }

        data.free();
      }

      node.park();

      // Node 2
      File innerDir2 = new File(dir, Integer.toString(DARKNET_PORT2));
      innerDir2.mkdir();
      fis = new FileInputStream(seednodes);
      FileUtil.writeTo(fis, new File(innerDir2, "seednodes.fref"));
      fis.close();
      node2 = NodeStarter.createTestNode(DARKNET_PORT2, OPENNET_PORT2, dir.getPath(), false,
              Node.DEFAULT_MAX_HTL, 0, random, new PooledExecutor(), 1000, 5 * 1024 * 1024, true, true, true,
              true, true, true, true, 12 * 1024, false, true, false, false, null);
      node2.start(true);

      t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node2)) {
View Full Code Here


        DummyRandomSource random = new DummyRandomSource(3142);
        DummyRandomSource topologyRandom = new DummyRandomSource(3143);
        //DiffieHellman.init(random);
        Node[] nodes = new Node[NUMBER_OF_NODES];
        Logger.normal(RealNodeRoutingTest.class, "Creating nodes...");
        Executor executor = new PooledExecutor();
        for(int i=0;i<NUMBER_OF_NODES;i++) {
            nodes[i] =
              NodeStarter.createTestNode(DARKNET_PORT_BASE+i, 0, name, DISABLE_PROBABILISTIC_HTLS, MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true, ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES, ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING, BWLIMIT, ENABLE_FOAF, false, true, USE_SLASHDOT_CACHE, null);
            Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
        }
View Full Code Here

      FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
      fis.close();

      // Create one node
      node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL,
              0, random, new PooledExecutor(), 1000, 4 * 1024 * 1024, true, true, true, true, true, true, true,
              12 * 1024, true, true, false, false, null);
      Logger.getChain().setThreshold(LogLevel.ERROR);

      // Start it
      node.start(true);
      long t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node)) {
        exitCode = EXIT_FAILED_TARGET;
        return;
      }
       
      long t2 = System.currentTimeMillis();
      System.out.println("SEED-TIME:" + (t2 - t1));
      csvLine.add(String.valueOf(t2 - t1));

      // Push one block only.
     
      RandomAccessBucket data = randomData(node);
      HighLevelSimpleClient client = node.clientCore.makeClient((short) 0, false, false);
      FreenetURI uri = new FreenetURI("KSK@" + uid + "-" + dateFormat.format(today.getTime()));
      System.out.println("PUSHING " + uri);
     
      try {
        InsertBlock block = new InsertBlock(data, new ClientMetadata(), uri);
        t1 = System.currentTimeMillis();
        client.insert(block, false, null);
        t2 = System.currentTimeMillis();
       
        System.out.println("PUSH-TIME-" + ":" + (t2 - t1));
        csvLine.add(String.valueOf(t2 - t1));
      } catch (InsertException e) {
        e.printStackTrace();
        csvLine.add("N/A");
      }

      data.free();

      node.park();

      // Node 2
      File innerDir2 = new File(dir, Integer.toString(DARKNET_PORT2));
      innerDir2.mkdir();
      fis = new FileInputStream(seednodes);
      FileUtil.writeTo(fis, new File(innerDir2, "seednodes.fref"));
      fis.close();
      node2 = NodeStarter.createTestNode(DARKNET_PORT2, OPENNET_PORT2, dir.getPath(), false,
              Node.DEFAULT_MAX_HTL, 0, random, new PooledExecutor(), 1000, 5 * 1024 * 1024, true, true, true,
              true, true, true, true, 12 * 1024, false, true, false, false, null);
      node2.start(true);

      t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node2)) {
View Full Code Here

      FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
      fis.close();

      // Create one node
      node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL,
              0, random, new PooledExecutor(), 1000, 4 * 1024 * 1024, true, true, true, true, true, true, true,
              12 * 1024, true, true, false, false, null);
      Logger.getChain().setThreshold(LogLevel.ERROR);

      // Start it
      node.start(true);
View Full Code Here

        innerDir.mkdir();
        FileInputStream fis = new FileInputStream(seednodes);
        FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
        fis.close();
        // Create one node
        Executor executor = new PooledExecutor();
        node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 5*1024*1024, true, true, true, true, true, true, true, 12*1024, false, true, false, false, ipOverride);
        //NodeCrypto.DISABLE_GROUP_STRIP = true;
      //Logger.setupStdoutLogging(LogLevel.MINOR, "freenet:NORMAL,freenet.node.NodeDispatcher:MINOR,freenet.node.FNPPacketMangler:MINOR");
      Logger.getChain().setThreshold(LogLevel.ERROR); // kill logging
      // Start it
        node.start(true);
    if (!TestUtil.waitForNodes(node)) {
      node.park();
      System.exit(EXIT_FAILED_TARGET);
    }
        System.err.println("Creating test data: "+TEST_SIZE+" bytes.");
        RandomAccessBucket data = node.clientCore.tempBucketFactory.makeBucket(TEST_SIZE);
        OutputStream os = data.getOutputStream();
    try {
        byte[] buf = new byte[4096];
        for(long written = 0; written < TEST_SIZE;) {
          node.fastWeakRandom.nextBytes(buf);
          int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
          os.write(buf, 0, toWrite);
          written += toWrite;
        }
    } finally {
        os.close();
    }
        System.err.println("Inserting test data.");
        HighLevelSimpleClient client = node.clientCore.makeClient((short)0, false, false);
        InsertBlock block = new InsertBlock(data, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
        long startInsertTime = System.currentTimeMillis();
        FreenetURI uri;
        try {
      uri = client.insert(block, false, null);
    } catch (InsertException e) {
      System.err.println("INSERT FAILED: "+e);
      e.printStackTrace();
      System.exit(EXIT_INSERT_FAILED);
      return;
    }
        long endInsertTime = System.currentTimeMillis();
        System.err.println("RESULT: Insert took "+(endInsertTime-startInsertTime)+"ms ("+TimeUtil.formatTime(endInsertTime-startInsertTime)+") to "+uri+" .");
        node.park();
   
        // Bootstrap a second node.
        File secondInnerDir = new File(dir, Integer.toString(DARKNET_PORT2));
        secondInnerDir.mkdir();
        fis = new FileInputStream(seednodes);
        FileUtil.writeTo(fis, new File(secondInnerDir, "seednodes.fref"));
        fis.close();
        executor = new PooledExecutor();
        secondNode = NodeStarter.createTestNode(DARKNET_PORT2, OPENNET_PORT2, dir.getPath(), false, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 5*1024*1024, true, true, true, true, true, true, true, 12*1024, false, true, false, false, ipOverride);       
        secondNode.start(true);
    if (!TestUtil.waitForNodes(secondNode)) {
      secondNode.park();
      System.exit(EXIT_FAILED_TARGET);
View Full Code Here

      FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
      fis.close();

      // Create one node
      node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL,
              0, random, new PooledExecutor(), 1000, 4 * 1024 * 1024, true, true, true, true, true, true, true,
              12 * 1024, true, true, false, false, null);
      Logger.getChain().setThreshold(LogLevel.ERROR);

      // Start it
      node.start(true);
View Full Code Here

      FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
      fis.close();

      // Create one node
      node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL,
              0, random, new PooledExecutor(), 1000, 4 * 1024 * 1024, true, true, true, true, true, true, true,
              12 * 1024, true, true, false, false, null);
      Logger.getChain().setThreshold(LogLevel.ERROR);

      // Start it
      node.start(true);
      long t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node)) {
        exitCode = EXIT_FAILED_TARGET;
        return;
      }
       
      long t2 = System.currentTimeMillis();
      System.out.println("SEED-TIME:" + (t2 - t1));
      csvLine.add(String.valueOf(t2 - t1));
     
      FreenetURI todaysInsert = null;

      // PUSH N+1 BLOCKS
      for (int i = 0; i <= MAX_N; i++) {
          RandomAccessBucket data = randomData(node);
        HighLevelSimpleClient client = node.clientCore.makeClient((short) 0, false, false);
        System.out.println("PUSHING " + i);

        try {
          InsertBlock block = new InsertBlock(data, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
          t1 = System.currentTimeMillis();
          FreenetURI uri = client.insert(block, false, null);
          if(i == 0) todaysInsert = uri;
          t2 = System.currentTimeMillis();

          System.out.println("PUSH-TIME-" + i + ":" + (t2 - t1)+" for "+uri);
          csvLine.add(String.valueOf(t2 - t1));
          csvLine.add(uri.toASCIIString());
        } catch (InsertException e) {
          e.printStackTrace();
          csvLine.add("N/A");
          csvLine.add("N/A");
        }

        data.free();
      }

      node.park();

      // Node 2
      File innerDir2 = new File(dir, Integer.toString(DARKNET_PORT2));
      innerDir2.mkdir();
      fis = new FileInputStream(seednodes);
      FileUtil.writeTo(fis, new File(innerDir2, "seednodes.fref"));
      fis.close();
      node2 = NodeStarter.createTestNode(DARKNET_PORT2, OPENNET_PORT2, dir.getPath(), false,
              Node.DEFAULT_MAX_HTL, 0, random, new PooledExecutor(), 1000, 5 * 1024 * 1024, true, true, true,
              true, true, true, true, 12 * 1024, false, true, false, false, null);
      node2.start(true);

      t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node2)) {
View Full Code Here

      try {
      if(args.length == 1)
        STATUS_DIR = new File(args[0]);
        RandomSource random = NodeStarter.globalTestInit("seednode-pingtest", false, LogLevel.ERROR, "", false);
        // Create one node
        Executor executor = new PooledExecutor();
  node = NodeStarter.createTestNode(DARKNET_PORT, OPENNET_PORT, "seednode-pingtest", false, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 5*1024*1024, true, false, false, false, false, false, false, 0, false, false, false, false, null);
  // Connect & ping
  List<SeedServerTestPeerNode> seedNodes = new ArrayList<SeedServerTestPeerNode>();
  List<SimpleFieldSet> seedNodesAsSFS = Announcer.readSeednodes(new File("/tmp/", Announcer.SEEDNODES_FILENAME));
  int numberOfNodesInTheFile = 0;
View Full Code Here

        innerDir.mkdir();
        FileInputStream fis = new FileInputStream(seednodes);
        FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
        fis.close();
        // Create one node
        Executor executor = new PooledExecutor();
        node = NodeStarter.createTestNode(DARKNET_PORT, OPENNET_PORT, "bootstrap-test", false, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 5*1024*1024, true, true, true, true, true, true, true, 12*1024, false, true, false, false, ipOverride);
        //NodeCrypto.DISABLE_GROUP_STRIP = true;
      //Logger.setupStdoutLogging(LogLevel.MINOR, "freenet:NORMAL,freenet.node.NodeDispatcher:MINOR,freenet.node.FNPPacketMangler:MINOR");
      Logger.getChain().setThreshold(LogLevel.ERROR); // kill logging
      long startTime = System.currentTimeMillis();
View Full Code Here

    // Make the network reproducible so we can easily compare different routing options by specifying a seed.
    DummyRandomSource random = new DummyRandomSource(3142);
    //DiffieHellman.init(random);
    Node[] nodes = new Node[NUMBER_OF_NODES];
    Logger.normal(RealNodeRoutingTest.class, "Creating nodes...");
    Executor executor = new PooledExecutor();
    for(int i = 0; i < NUMBER_OF_NODES; i++) {
      System.err.println("Creating node " + i);
      nodes[i] = NodeStarter.createTestNode(DARKNET_PORT_BASE + i, 0, dir, true, MAX_HTL, 0 /* no dropped packets */, random, executor, 500 * NUMBER_OF_NODES, 65536, true, ENABLE_SWAPPING, false, false, false, ENABLE_SWAP_QUEUEING, true, 0, ENABLE_FOAF, false, true, false, null);
      Logger.normal(RealNodeRoutingTest.class, "Created node " + i);
    }
View Full Code Here

TOP

Related Classes of freenet.support.PooledExecutor

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.