Package freenet.node.stats

Examples of freenet.node.stats.DataStoreStats



    Map<DataStoreInstanceType, DataStoreStats> storeStats = node.getDataStoreStats();
    for (Map.Entry<DataStoreInstanceType, DataStoreStats> entry : storeStats.entrySet()) {
      DataStoreInstanceType instance = entry.getKey();
      DataStoreStats stats = entry.getValue();
     
      StoreAccessStats sessionAccess = stats.getSessionAccessStats();
      StoreAccessStats totalAccess;
      long totalUptimeSeconds = 0;
      try {
        totalAccess = stats.getTotalAccessStats();
        // FIXME this is not necessarily the same as the datastore's uptime if we've switched.
        // Ideally we'd track uptime there too.
        totalUptimeSeconds =
          node.clientCore.bandwidthStatsPutter.getLatestUptimeData().totalUptime;
      } catch (StatsNotAvailableException e) {
        totalAccess = null;
      }
     
      row = storeSizeTable.addChild("tr");
      row.addChild("th", l10n(instance.store.name()) + "\n" + " (" + l10n(instance.key.name()) + ")");

      row.addChild("td", thousandPoint.format(stats.keys()));
      row.addChild("td", thousandPoint.format(stats.capacity()));
      row.addChild("td", SizeUtil.formatSize(stats.dataSize()));
      row.addChild("td", fix3p1pct.format(stats.utilization()));
      row.addChild("td", thousandPoint.format(sessionAccess.readRequests()) +
          (totalAccess == null ? "" : (" ("+thousandPoint.format(totalAccess.readRequests())+")")));
      row.addChild("td", thousandPoint.format(sessionAccess.successfulReads()) +
          (totalAccess == null ? "" : (" ("+thousandPoint.format(totalAccess.successfulReads())+")")));
      try {
        String rate = fix1p4.format(sessionAccess.successRate()) + "%";
        if(totalAccess != null) {
          try {
            rate += " (" + fix1p4.format(totalAccess.successRate()) + "%)";
          } catch (StatsNotAvailableException e) {
            // Ignore
          }
        }
        row.addChild("td", rate);
      } catch (StatsNotAvailableException e) {
        row.addChild("td", "N/A");
      }
      row.addChild("td", thousandPoint.format(sessionAccess.writes()) +
          (totalAccess == null ? "" : (" ("+thousandPoint.format(totalAccess.writes())+")")));
      String access = fix1p2.format(sessionAccess.accessRate(nodeUptimeSeconds)) + " /s";
      if(totalAccess != null)
        access += " (" + fix1p2.format(totalAccess.accessRate(totalUptimeSeconds)) + " /s)";
      row.addChild("td", access);
      access = fix1p2.format(sessionAccess.writeRate(nodeUptimeSeconds)) + " /s";
      if(totalAccess != null)
        access += " (" + fix1p2.format(totalAccess.writeRate(totalUptimeSeconds)) + " /s)";
      row.addChild("td", access);
      row.addChild("td", thousandPoint.format(sessionAccess.falsePos()) +
          (totalAccess == null ? "" : (" ("+thousandPoint.format(totalAccess.falsePos())+")")));
      try {
        row.addChild("td", fix1p4.format(stats.avgLocation()));
      } catch (StatsNotAvailableException e) {
        row.addChild("td", "N/A");
      }

      try {
        row.addChild("td", fix1p4.format(stats.avgSuccess()));
      } catch (StatsNotAvailableException e) {
        row.addChild("td", "N/A");
      }

      try {
        row.addChild("td", fix1p4.format(stats.furthestSuccess()));
      } catch (StatsNotAvailableException e) {
        row.addChild("td", "N/A");
      }

      try {
        row.addChild("td", fix1p4.format(stats.avgDist()));
      } catch (StatsNotAvailableException e) {
        row.addChild("td", "N/A");
      }

      try {
        row.addChild("td", fix3p1pct.format(stats.distanceStats()));
      } catch (StatsNotAvailableException e) {
        row.addChild("td", "N/A");
      }
    }
View Full Code Here


    // drawStoreSizeBox
    textBuilder.append("Store Size:\n");
    Map<DataStoreInstanceType, DataStoreStats> storeStats = node.getDataStoreStats();
    for (Map.Entry<DataStoreInstanceType, DataStoreStats> entry : storeStats.entrySet()) {
      DataStoreInstanceType instance = entry.getKey();
      DataStoreStats stats = entry.getValue();
      StoreAccessStats sessionAccess = stats.getSessionAccessStats();
      StoreAccessStats totalAccess;
      try {
        totalAccess = stats.getTotalAccessStats();
      } catch (StatsNotAvailableException e) {
        totalAccess = null;
      }
      textBuilder.append(l10n(instance.store.name())).append(": (").append(l10n(instance.key.name())).append(")\n");
      textBuilder.append("  ").append(l10n("keys")).append(": ").append(thousandPoint.format(stats.keys())).append("\n");
      textBuilder.append("  ").append(l10n("capacity")).append(": ").append(thousandPoint.format(stats.capacity())).append("\n");
      textBuilder.append("  ").append(l10n("datasize")).append(": ").append(SizeUtil.formatSize(stats.dataSize())).append("\n");
      textBuilder.append("  ").append(l10n("utilization")).append(": ").append(fix3p1pct.format(stats.utilization())).append("\n");
      textBuilder.append("  ").append(l10n("readRequests")).append(": ").append(thousandPoint.format(sessionAccess.readRequests()) +
          (totalAccess == null ? "" : (" ("+thousandPoint.format(totalAccess.readRequests())+")"))).append("\n");
      textBuilder.append("  ").append(l10n("successfulReads")).append(": ").append(thousandPoint.format(sessionAccess.successfulReads()) +
          (totalAccess == null ? "" : (" ("+thousandPoint.format(totalAccess.successfulReads())+")"))).append("\n");
      try {
        textBuilder.append(fix1p4.format(sessionAccess.successRate())).append("%");
        if(totalAccess != null) {
          try {
            textBuilder.append(" (").append(fix1p4.format(totalAccess.successRate())).append("%)");
          } catch (StatsNotAvailableException e) {
            // Ignore
          }
        }
        textBuilder.append("\n");
      } catch (StatsNotAvailableException e) {
      }
    }
    textBuilder.append("\n");

    // drawActivity
    textBuilder.append("Activity:\n");
    RequestTracker tracker = node.tracker;
    int numLocalCHKInserts = tracker.getNumLocalCHKInserts();
    int numRemoteCHKInserts = tracker.getNumRemoteCHKInserts();
    int numLocalSSKInserts = tracker.getNumLocalSSKInserts();
    int numRemoteSSKInserts = tracker.getNumRemoteSSKInserts();
    int numLocalCHKRequests = tracker.getNumLocalCHKRequests();
    int numRemoteCHKRequests = tracker.getNumRemoteCHKRequests();
    int numLocalSSKRequests = tracker.getNumLocalSSKRequests();
    int numRemoteSSKRequests = tracker.getNumRemoteSSKRequests();
    int numTransferringRequests = tracker.getNumTransferringRequestSenders();
    int numTransferringRequestHandlers = tracker.getNumTransferringRequestHandlers();
    int numCHKOfferReplys = tracker.getNumCHKOfferReplies();
    int numSSKOfferReplys = tracker.getNumSSKOfferReplies();
    int numCHKRequests = numLocalCHKRequests + numRemoteCHKRequests;
    int numSSKRequests = numLocalSSKRequests + numRemoteSSKRequests;
    int numCHKInserts = numLocalCHKInserts + numRemoteCHKInserts;
    int numSSKInserts = numLocalSSKInserts + numRemoteSSKInserts;
    if ((numTransferringRequests == 0) &&
        (numCHKRequests == 0) && (numSSKRequests == 0) &&
        (numCHKInserts == 0) && (numSSKInserts == 0) &&
        (numTransferringRequestHandlers == 0) &&
        (numCHKOfferReplys == 0) && (numSSKOfferReplys == 0)) {
      textBuilder.append(l10n("noRequests")).append("\n");
    } else {
      if (numCHKInserts > 0 || numSSKInserts > 0) {
        textBuilder.append(l10n("activityInserts",
            new String[] { "CHKhandlers", "SSKhandlers", "local" } ,
            new String[] { Integer.toString(numCHKInserts), Integer.toString(numSSKInserts), Integer.toString(numLocalCHKInserts)+"/" + Integer.toString(numLocalSSKInserts)})
            + "\n");
      }
      if (numCHKRequests > 0 || numSSKRequests > 0) {
        textBuilder.append(l10n("activityRequests",
            new String[] { "CHKhandlers", "SSKhandlers", "local" } ,
            new String[] { Integer.toString(numCHKRequests), Integer.toString(numSSKRequests), Integer.toString(numLocalCHKRequests)+"/" + Integer.toString(numLocalSSKRequests)})
            + "\n");
      }
      if (numTransferringRequests > 0 || numTransferringRequestHandlers > 0) {
        textBuilder.append(l10n("transferringRequests",
            new String[] { "senders", "receivers", "turtles" }, new String[] { Integer.toString(numTransferringRequests), Integer.toString(numTransferringRequestHandlers), "0"})
            + "\n");
      }
      if (numCHKOfferReplys > 0 || numSSKOfferReplys > 0) {
        textBuilder.append(l10n("offerReplys",
            new String[] { "chk", "ssk" }, new String[] { Integer.toString(numCHKOfferReplys), Integer.toString(numSSKOfferReplys) })
            + "\n");
      }
      textBuilder.append(l10n("runningBlockTransfers",
          new String[] { "sends", "receives" }, new String[] { Integer.toString(BlockTransmitter.getRunningSends()), Integer.toString(BlockReceiver.getRunningReceives()) })
          + "\n");
    }
    textBuilder.append("\n");

    // drawPeerStatsBox
    textBuilder.append("Peer Statistics:\n");
    PeerNodeStatus[] peerNodeStatuses = peers.getPeerNodeStatuses(true);
    Arrays.sort(peerNodeStatuses, new Comparator<PeerNodeStatus>() {
      @Override
      public int compare(PeerNodeStatus firstNode, PeerNodeStatus secondNode) {
        int statusDifference = firstNode.getStatusValue() - secondNode.getStatusValue();
        if (statusDifference != 0) {
          return statusDifference;
        }
        return 0;
      }
    });
    int numberOfConnected = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_CONNECTED);
    int numberOfRoutingBackedOff = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF);
    int numberOfTooNew = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_TOO_NEW);
    int numberOfTooOld = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_TOO_OLD);
    int numberOfDisconnected = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_DISCONNECTED);
    int numberOfNeverConnected = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_NEVER_CONNECTED);
    int numberOfDisabled = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_DISABLED);
    int numberOfBursting = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_BURSTING);
    int numberOfListening = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_LISTENING);
    int numberOfListenOnly = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_LISTEN_ONLY);
    int numberOfSeedServers = getCountSeedServers(peerNodeStatuses);
    int numberOfSeedClients = getCountSeedClients(peerNodeStatuses);
    int numberOfRoutingDisabled = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_ROUTING_DISABLED);
    int numberOfClockProblem = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_CLOCK_PROBLEM);
    int numberOfConnError = getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_CONN_ERROR);
    int numberOfDisconnecting = PeerNodeStatus.getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_DISCONNECTING);
    int numberOfNoLoadStats = PeerNodeStatus.getPeerStatusCount(peerNodeStatuses, PeerManager.PEER_NODE_STATUS_NO_LOAD_STATS);
    if (numberOfConnected > 0)
      textBuilder.append(l10nDark("connectedShort")).append(": ").append(numberOfConnected).append("\n");
    if (numberOfRoutingBackedOff > 0)
      textBuilder.append(l10nDark("backedOffShort")).append(": ").append(numberOfRoutingBackedOff).append("\n");
    if (numberOfTooNew > 0)
      textBuilder.append(l10nDark("tooNewShort")).append(": ").append(numberOfTooNew).append("\n");
    if (numberOfTooOld > 0)
      textBuilder.append(l10nDark("tooOldShort")).append(": ").append(numberOfTooOld).append("\n");
    if (numberOfDisconnected > 0)
      textBuilder.append(l10nDark("notConnectedShort")).append(": ").append(numberOfDisconnected).append("\n");
    if (numberOfNeverConnected > 0)
      textBuilder.append(l10nDark("neverConnectedShort")).append(": ").append(numberOfNeverConnected).append("\n");
    if (numberOfDisabled > 0)
      textBuilder.append(l10nDark("disabledShort")).append(": ").append(numberOfDisabled).append("\n");
    if (numberOfBursting > 0)
      textBuilder.append(l10nDark("burstingShort")).append(": ").append(numberOfBursting).append("\n");
    if (numberOfListening > 0)
      textBuilder.append(l10nDark("listeningShort")).append(": ").append(numberOfListening).append("\n");
    if (numberOfListenOnly > 0)
      textBuilder.append(l10nDark("listenOnlyShort")).append(": ").append(numberOfListenOnly).append("\n");
    if (numberOfClockProblem > 0)
      textBuilder.append(l10nDark("clockProblemShort")).append(": ").append(numberOfClockProblem).append("\n");
    if (numberOfConnError > 0)
      textBuilder.append(l10nDark("connErrorShort")).append(": ").append(numberOfConnError).append("\n");
    if (numberOfDisconnecting > 0)
      textBuilder.append(l10nDark("disconnectingShort")).append(": ").append(numberOfDisconnecting).append("\n");
    if (numberOfSeedServers > 0)
      textBuilder.append(l10nDark("seedServersShort")).append(": ").append(numberOfSeedServers).append("\n");
    if (numberOfSeedClients > 0)
      textBuilder.append(l10nDark("seedClientsShort")).append(": ").append(numberOfSeedClients).append("\n");
    if (numberOfRoutingDisabled > 0)
      textBuilder.append(l10nDark("routingDisabledShort")).append(": ").append(numberOfRoutingDisabled).append("\n");
    if (numberOfNoLoadStats > 0)
      textBuilder.append(l10nDark("noLoadStatsShort")).append(": ").append(numberOfNoLoadStats).append("\n");
    OpennetManager om = node.getOpennet();
    if(om != null) {
      textBuilder.append(l10n("maxTotalPeers")+": "+om.getNumberOfConnectedPeersToAimIncludingDarknet()).append("\n");
      textBuilder.append(l10n("maxOpennetPeers")+": "+om.getNumberOfConnectedPeersToAim()).append("\n");
    }
    textBuilder.append("\n");

    // drawBandwidth
    textBuilder.append("Bandwidth:\n");
    long[] total = node.collector.getTotalIO();
    if(total[0] == 0 || total[1] == 0)
      textBuilder.append("bandwidth error\n");
    else  {
      final long now = System.currentTimeMillis();
      final long nodeUptimeSeconds = (now - node.startupTime) / 1000;
      long total_output_rate = (total[0]) / nodeUptimeSeconds;
      long total_input_rate = (total[1]) / nodeUptimeSeconds;
      long totalPayload = node.getTotalPayloadSent();
      long total_payload_rate = totalPayload / nodeUptimeSeconds;
      if(node.clientCore == null) throw new NullPointerException();
      BandwidthStatsContainer stats = node.clientCore.bandwidthStatsPutter.getLatestBWData();
      if(stats == null) throw new NullPointerException();
      long overall_total_out = stats.totalBytesOut;
      long overall_total_in = stats.totalBytesIn;
      int percent = (int) (100 * totalPayload / total[0]);
      long[] rate = node.nodeStats.getNodeIOStats();
      long delta = (rate[5] - rate[2]) / 1000;
      if(delta > 0) {
        long output_rate = (rate[3] - rate[0]) / delta;
        long input_rate = (rate[4] - rate[1]) / delta;
        int outputBandwidthLimit = nodeConfig.getInt("outputBandwidthLimit");
        int inputBandwidthLimit = nodeConfig.getInt("inputBandwidthLimit");
        if(inputBandwidthLimit == -1) {
          inputBandwidthLimit = outputBandwidthLimit * 4;
        }
        textBuilder.append(l10n("inputRate", new String[] { "rate", "max" }, new String[] { SizeUtil.formatSize(input_rate, true), SizeUtil.formatSize(inputBandwidthLimit, true) })).append("\n");
        textBuilder.append(l10n("outputRate", new String[] { "rate", "max" }, new String[] { SizeUtil.formatSize(output_rate, true), SizeUtil.formatSize(outputBandwidthLimit, true) })).append("\n");
      }
      textBuilder.append(l10n("totalInputSession", new String[] { "total", "rate" }, new String[] { SizeUtil.formatSize(total[1], true), SizeUtil.formatSize(total_input_rate, true) })).append("\n");
      textBuilder.append(l10n("totalOutputSession", new String[] { "total", "rate" }, new String[] { SizeUtil.formatSize(total[0], true), SizeUtil.formatSize(total_output_rate, true) } )).append("\n");
      textBuilder.append(l10n("payloadOutput", new String[] { "total", "rate", "percent" }, new String[] { SizeUtil.formatSize(totalPayload, true), SizeUtil.formatSize(total_payload_rate, true), Integer.toString(percent) } )).append("\n");
      textBuilder.append(l10n("totalInput", new String[] { "total" }, new String[] { SizeUtil.formatSize(overall_total_in, true) })).append("\n");
      textBuilder.append(l10n("totalOutput", new String[] { "total" }, new String[] { SizeUtil.formatSize(overall_total_out, true) } )).append("\n");
      long totalBytesSentCHKRequests = node.nodeStats.getCHKRequestTotalBytesSent();
      long totalBytesSentSSKRequests = node.nodeStats.getSSKRequestTotalBytesSent();
      long totalBytesSentCHKInserts = node.nodeStats.getCHKInsertTotalBytesSent();
      long totalBytesSentSSKInserts = node.nodeStats.getSSKInsertTotalBytesSent();
      long totalBytesSentOfferedKeys = node.nodeStats.getOfferedKeysTotalBytesSent();
      long totalBytesSendOffers = node.nodeStats.getOffersSentBytesSent();
      long totalBytesSentSwapOutput = node.nodeStats.getSwappingTotalBytesSent();
      long totalBytesSentAuth = node.nodeStats.getTotalAuthBytesSent();
      long totalBytesSentAckOnly = node.nodeStats.getNotificationOnlyPacketsSentBytes();
      long totalBytesSentResends = node.nodeStats.getResendBytesSent();
      long totalBytesSentUOM = node.nodeStats.getUOMBytesSent();
      long totalBytesSentAnnounce = node.nodeStats.getAnnounceBytesSent();
      long totalBytesSentAnnouncePayload = node.nodeStats.getAnnounceBytesPayloadSent();
      long totalBytesSentRoutingStatus = node.nodeStats.getRoutingStatusBytes();
      long totalBytesSentNetworkColoring = node.nodeStats.getNetworkColoringSentBytes();
      long totalBytesSentPing = node.nodeStats.getPingSentBytes();
      long totalBytesSentProbeRequest = node.nodeStats.getProbeRequestSentBytes();
      long totalBytesSentRouted = node.nodeStats.getRoutedMessageSentBytes();
      long totalBytesSentDisconn = node.nodeStats.getDisconnBytesSent();
      long totalBytesSentInitial = node.nodeStats.getInitialMessagesBytesSent();
      long totalBytesSentChangedIP = node.nodeStats.getChangedIPBytesSent();
      long totalBytesSentNodeToNode = node.nodeStats.getNodeToNodeBytesSent();
      long totalBytesSentAllocationNotices = node.nodeStats.getAllocationNoticesBytesSent();
      long totalBytesSentFOAF = node.nodeStats.getFOAFBytesSent();
      long totalBytesSentRemaining = total[0] -
        (totalPayload + totalBytesSentCHKRequests + totalBytesSentSSKRequests +
        totalBytesSentCHKInserts + totalBytesSentSSKInserts +
        totalBytesSentOfferedKeys + totalBytesSendOffers + totalBytesSentSwapOutput +
        totalBytesSentAuth + totalBytesSentAckOnly + totalBytesSentResends +
        totalBytesSentUOM + totalBytesSentAnnounce +
        totalBytesSentRoutingStatus + totalBytesSentNetworkColoring + totalBytesSentPing +
        totalBytesSentProbeRequest + totalBytesSentRouted + totalBytesSentDisconn +
        totalBytesSentInitial + totalBytesSentChangedIP + totalBytesSentNodeToNode + totalBytesSentAllocationNotices + totalBytesSentFOAF);
      textBuilder.append(l10n("requestOutput", new String[] { "chk", "ssk" }, new String[] { SizeUtil.formatSize(totalBytesSentCHKRequests, true), SizeUtil.formatSize(totalBytesSentSSKRequests, true) })).append("\n");
      textBuilder.append(l10n("insertOutput", new String[] { "chk", "ssk" }, new String[] { SizeUtil.formatSize(totalBytesSentCHKInserts, true), SizeUtil.formatSize(totalBytesSentSSKInserts, true) })).append("\n");
      textBuilder.append(l10n("offeredKeyOutput", new String[] { "total", "offered" }, new String[] { SizeUtil.formatSize(totalBytesSentOfferedKeys, true), SizeUtil.formatSize(totalBytesSendOffers, true) })).append("\n");
      textBuilder.append(l10n("swapOutput", "total", SizeUtil.formatSize(totalBytesSentSwapOutput, true))).append("\n");
      textBuilder.append(l10n("authBytes", "total", SizeUtil.formatSize(totalBytesSentAuth, true))).append("\n");
      textBuilder.append(l10n("ackOnlyBytes", "total", SizeUtil.formatSize(totalBytesSentAckOnly, true))).append("\n");
      textBuilder.append(l10n("resendBytes", new String[] { "total", "percent" }, new String[] { SizeUtil.formatSize(totalBytesSentResends, true), Long.toString((100 * totalBytesSentResends) / Math.max(1, total[0])) } )).append("\n");
      textBuilder.append(l10n("uomBytes", "total",  SizeUtil.formatSize(totalBytesSentUOM, true))).append("\n");
      textBuilder.append(l10n("announceBytes", new String[] { "total", "payload" }, new String[] { SizeUtil.formatSize(totalBytesSentAnnounce, true), SizeUtil.formatSize(totalBytesSentAnnouncePayload, true) })).append("\n");
      textBuilder.append(l10n("adminBytes", new String[] { "routingStatus", "disconn", "initial", "changedIP" }, new String[] { SizeUtil.formatSize(totalBytesSentRoutingStatus, true), SizeUtil.formatSize(totalBytesSentDisconn, true), SizeUtil.formatSize(totalBytesSentInitial, true), SizeUtil.formatSize(totalBytesSentChangedIP, true) })).append("\n");
      textBuilder.append(l10n("debuggingBytes", new String[] { "netColoring", "ping", "probe", "routed" }, new String[] { SizeUtil.formatSize(totalBytesSentNetworkColoring, true), SizeUtil.formatSize(totalBytesSentPing, true), SizeUtil.formatSize(totalBytesSentProbeRequest, true), SizeUtil.formatSize(totalBytesSentRouted, true) } )).append("\n");
      textBuilder.append(l10n("nodeToNodeBytes", "total", SizeUtil.formatSize(totalBytesSentNodeToNode, true))).append("\n");
      textBuilder.append(l10n("loadAllocationNoticesBytes", "total", SizeUtil.formatSize(totalBytesSentAllocationNotices, true))).append("\n");
      textBuilder.append(l10n("foafBytes", "total", SizeUtil.formatSize(totalBytesSentFOAF, true))).append("\n");
      textBuilder.append(l10n("unaccountedBytes", new String[] { "total", "percent" },
          new String[] { SizeUtil.formatSize(totalBytesSentRemaining, true), Integer.toString((int)(totalBytesSentRemaining*100 / total[0])) })).append("\n");
      double sentOverheadPerSecond = node.nodeStats.getSentOverheadPerSecond();
      textBuilder.append(l10n("totalOverhead", new String[] { "rate", "percent" },
          new String[] { SizeUtil.formatSize((long)sentOverheadPerSecond), Integer.toString((int)((100 * sentOverheadPerSecond) / total_output_rate)) })).append("\n");
    }
    textBuilder.append("\n");

    // showStartingPlugins
    textBuilder.append("Plugins:\n");
    PluginManager pm = node.pluginManager;
    if (!pm.getPlugins().isEmpty()) {
      textBuilder.append(baseL10n.getString("PluginToadlet.pluginListTitle")).append("\n");
      for(PluginInfoWrapper pi: pm.getPlugins()) {
        long ver = pi.getPluginLongVersion();
        if (ver != -1)
          textBuilder.append(pi.getFilename()).append(" (").append(pi.getPluginClassName()).append(") - " ).append(pi.getPluginVersion()+ " ("+ver+")").append(" ").append(pi.getThreadName()).append("\n");
        else
          textBuilder.append(pi.getFilename()).append(" (").append(pi.getPluginClassName()).append(") - ").append(pi.getPluginVersion()).append(" ").append(pi.getThreadName()).append("\n");
      }
    }
    textBuilder.append("\n");

    // handleGetInner
    textBuilder.append("Queue:\n");
    try {
      RequestStatus[] reqs = fcp.getGlobalRequests();
      if(reqs.length < 1)
        textBuilder.append(baseL10n.getString("QueueToadlet.globalQueueIsEmpty")).append("\n");
      else {
        long totalQueuedDownload = 0;
        long totalQueuedUpload = 0;
        for(RequestStatus req: reqs) {
          if(req instanceof DownloadRequestStatus) {
            totalQueuedDownload++;
          } else if(req instanceof UploadFileRequestStatus) {
            totalQueuedUpload++;
          } else if(req instanceof UploadDirRequestStatus) {
            totalQueuedUpload++;
          }
        }
        textBuilder.append("Downloads Queued: ").append(totalQueuedDownload).append(" (").append(totalQueuedDownload).append(")\n");
        textBuilder.append("Uploads Queued: ").append(totalQueuedUpload).append(" (").append(totalQueuedUpload).append(")\n");
      }
    } catch (PersistenceDisabledException e) {
      textBuilder.append("DatabaseDisabledException\n");
    }
    textBuilder.append("\n");

    // drawThreadPriorityStatsBox
    textBuilder.append("Threads:\n");
    int[] activeThreadsByPriority = stats.getActiveThreadsByPriority();
    int[] waitingThreadsByPriority = stats.getWaitingThreadsByPriority();
    for(int i=0; i<activeThreadsByPriority.length; i++) {
      textBuilder.append(l10n("running")).append(": ").append(String.valueOf(activeThreadsByPriority[i])).append(" (").append(String.valueOf(i+1)).append(")\n");
      textBuilder.append(l10n("waiting")).append(": ").append(String.valueOf(waitingThreadsByPriority[i])).append(" (").append(String.valueOf(i+1)).append(")\n");
    }
    textBuilder.append("\n");
View Full Code Here

TOP

Related Classes of freenet.node.stats.DataStoreStats

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.