Package freenet.support.math

Examples of freenet.support.math.BootstrappingDecayingRunningAverage


    /** Data size for purposes of getRate() */
    private final int size;
    private final boolean realTime;

    public MyRequestThrottle(int rtt, String string, SimpleFieldSet fs, int size, boolean realTime) {
      roundTripTime = new BootstrappingDecayingRunningAverage(rtt, 10, MINUTES.toMillis(5), 10, fs == null ? null : fs.subset("RoundTripTime"));
      this.size = size;
      this.realTime = realTime;
    }
View Full Code Here


        sender = new SwapRequestSender();
        this.r = r;
        this.node = node;
        recentlyForwardedIDs = new Hashtable<Long, RecentlyForwardedItem>();
        // FIXME persist to disk!
        averageSwapTime = new BootstrappingDecayingRunningAverage(SEND_SWAP_INTERVAL, 0, Integer.MAX_VALUE, 20, null);
        timeLocSet = System.currentTimeMillis();

        logMINOR = Logger.shouldLog(LogLevel.MINOR, this);
    }
View Full Code Here

    this.routingMissDistanceBulk = new TimeDecayingRunningAverage(0.0, 180000, 0.0, 1.0, node);
    this.routingMissDistanceRT = new TimeDecayingRunningAverage(0.0, 180000, 0.0, 1.0, node);
    this.backedOffPercent = new TimeDecayingRunningAverage(0.0, 180000, 0.0, 1.0, node);
    preemptiveRejectReasons = new StringCounter();
    localPreemptiveRejectReasons = new StringCounter();
    pInstantRejectIncomingOverall = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingCHKRequestRT = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingSSKRequestRT = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingCHKInsertRT = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingSSKInsertRT = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingCHKRequestBulk = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingSSKRequestBulk = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingCHKInsertBulk = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    pInstantRejectIncomingSSKInsertBulk = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 1000, null);
    REJECT_STATS_AVERAGERS = new RunningAverage[] {
          pInstantRejectIncomingCHKRequestBulk,
          pInstantRejectIncomingSSKRequestBulk,
          pInstantRejectIncomingCHKInsertBulk,
          pInstantRejectIncomingSSKInsertBulk
    };
    noisyRejectStats = new byte[4];
    ThreadGroup tg = Thread.currentThread().getThreadGroup();
    while(tg.getParent() != null) tg = tg.getParent();
    this.rootThreadGroup = tg;
    throttledPacketSendAverage =
      new BootstrappingDecayingRunningAverage(0, 0, Long.MAX_VALUE, 100, null);
    throttledPacketSendAverageRT =
      new BootstrappingDecayingRunningAverage(0, 0, Long.MAX_VALUE, 100, null);
    throttledPacketSendAverageBulk =
      new BootstrappingDecayingRunningAverage(0, 0, Long.MAX_VALUE, 100, null);
    nodePinger = new NodePinger(node);

    previous_input_stat = 0;
    previous_output_stat = 0;
    previous_io_stat_time = 1;
View Full Code Here

    int lastSwaps = 0;
    int lastNoSwaps = 0;
    int failures = 0;
    int successes = 0;
    RunningAverage avg = new SimpleRunningAverage(100, 0.0);
    RunningAverage avg2 = new BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 100, null);
    int pings = 0;
    for(int total = 0; total < maxTests; total++) {
      cycleNumber++;
      try {
        Thread.sleep(sleepTime);
      } catch(InterruptedException e) {
        // Ignore
      }
      for(int i = 0; i < nodes.length; i++) {
        System.err.println("Cycle " + cycleNumber + " node " + i + ": " + nodes[i].getLocation());
      }
      int newSwaps = LocationManager.swaps;
      int totalStarted = LocationManager.startedSwaps;
      int noSwaps = LocationManager.noSwaps;
      System.err.println("Swaps: " + (newSwaps - lastSwaps));
      System.err.println("\nTotal swaps: Started*2: " + totalStarted * 2 + ", succeeded: " + newSwaps + ", last minute failures: " + noSwaps +
        ", ratio " + (double) noSwaps / (double) newSwaps + ", early failures: " + ((totalStarted * 2) - (noSwaps + newSwaps)));
      System.err.println("This cycle ratio: " + ((double) (noSwaps - lastNoSwaps)) / ((double) (newSwaps - lastSwaps)));
      lastNoSwaps = noSwaps;
      System.err.println("Swaps rejected (already locked): " + LocationManager.swapsRejectedAlreadyLocked);
      System.err.println("Swaps rejected (nowhere to go): " + LocationManager.swapsRejectedNowhereToGo);
      System.err.println("Swaps rejected (rate limit): " + LocationManager.swapsRejectedRateLimit);
      System.err.println("Swaps rejected (recognized ID):" + LocationManager.swapsRejectedRecognizedID);
      System.err.println("Swaps failed:" + LocationManager.noSwaps);
      System.err.println("Swaps succeeded:" + LocationManager.swaps);

      double totalSwapInterval = 0.0;
      double totalSwapTime = 0.0;
      for(int i = 0; i < nodes.length; i++) {
        totalSwapInterval += nodes[i].lm.getSendSwapInterval();
        totalSwapTime += nodes[i].lm.getAverageSwapTime();
      }
      System.err.println("Average swap time: " + (totalSwapTime / nodes.length));
      System.err.println("Average swap sender interval: " + (totalSwapInterval / nodes.length));

      waitForAllConnected(nodes);

      lastSwaps = newSwaps;
      // Do some (routed) test-pings
      for(int i = 0; i < 10; i++) {
        try {
          Thread.sleep(sleepTime);
        } catch(InterruptedException e1) {
        }
        try {
          Node randomNode = nodes[random.nextInt(nodes.length)];
          Node randomNode2 = randomNode;
          while(randomNode2 == randomNode) {
            randomNode2 = nodes[random.nextInt(nodes.length)];
          }
          double loc2 = randomNode2.getLocation();
          Logger.normal(RealNodeRoutingTest.class, "Pinging " + randomNode2.getDarknetPortNumber() + " @ " + loc2 + " from " + randomNode.getDarknetPortNumber() + " @ " + randomNode.getLocation());
         
          int hopsTaken = randomNode.routedPing(loc2, randomNode2.getDarknetPubKeyHash());
          pings++;
          if(hopsTaken < 0) {
            failures++;
            avg.report(0.0);
            avg2.report(0.0);
            double ratio = (double) successes / ((double) (failures + successes));
            System.err.println("Routed ping " + pings + " FAILED from " + randomNode.getDarknetPortNumber() + " to " + randomNode2.getDarknetPortNumber() + " (long:" + ratio + ", short:" + avg.currentValue() + ", vague:" + avg2.currentValue() + ')');
          } else {
            totalHopsTaken += hopsTaken;
            successes++;
            avg.report(1.0);
            avg2.report(1.0);
            double ratio = (double) successes / ((double) (failures + successes));
            System.err.println("Routed ping " + pings + " success: " + hopsTaken + ' ' + randomNode.getDarknetPortNumber() + " to " + randomNode2.getDarknetPortNumber() + " (long:" + ratio + ", short:" + avg.currentValue() + ", vague:" + avg2.currentValue() + ')');
          }
        } catch(Throwable t) {
          Logger.error(RealNodeRoutingTest.class, "Caught " + t, t);
        }
      }
View Full Code Here

TOP

Related Classes of freenet.support.math.BootstrappingDecayingRunningAverage

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.