コード例 #1
0
  /** Setup renderer hints. */
  public static void init() {
    if (initialized.getAndSet(true)) return;

    final Function<Double, Long> longValue =
        new Function<Double, Long>() {
          @Override
          public Long apply(@Nullable Double input) {
            if (input == null) return null;
            return input.longValue();
          }
        };

    RendererHints.register(UPTIME, RendererHints.displayValue(Time.toTimeStringRounded()));

    RendererHints.register(CPU_USAGE, RendererHints.displayValue(MathFunctions.percent(2)));
    RendererHints.register(AVERAGE_CPU_USAGE, RendererHints.displayValue(MathFunctions.percent(2)));

    RendererHints.register(
        FREE_MEMORY,
        RendererHints.displayValue(
            Functionals.chain(MathFunctions.times(1000L), ByteSizeStrings.metric())));
    RendererHints.register(
        TOTAL_MEMORY,
        RendererHints.displayValue(
            Functionals.chain(MathFunctions.times(1000L), ByteSizeStrings.metric())));
    RendererHints.register(
        USED_MEMORY,
        RendererHints.displayValue(
            Functionals.chain(MathFunctions.times(1000L), ByteSizeStrings.metric())));
    RendererHints.register(
        USED_MEMORY_DELTA_PER_SECOND_LAST,
        RendererHints.displayValue(Functionals.chain(longValue, ByteSizeStrings.metric())));
    RendererHints.register(
        USED_MEMORY_DELTA_PER_SECOND_IN_WINDOW,
        RendererHints.displayValue(Functionals.chain(longValue, ByteSizeStrings.metric())));
  }
コード例 #2
0
  /** Setup renderer hints for the MXBean attributes. */
  public static void init() {
    if (initialized.get()) return;
    synchronized (initialized) {
      if (initialized.get()) return;

      RendererHints.register(
          UsesJavaMXBeans.USED_HEAP_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
      RendererHints.register(
          UsesJavaMXBeans.INIT_HEAP_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
      RendererHints.register(
          UsesJavaMXBeans.MAX_HEAP_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
      RendererHints.register(
          UsesJavaMXBeans.COMMITTED_HEAP_MEMORY,
          RendererHints.displayValue(ByteSizeStrings.metric()));
      RendererHints.register(
          UsesJavaMXBeans.NON_HEAP_MEMORY_USAGE,
          RendererHints.displayValue(ByteSizeStrings.metric()));
      RendererHints.register(
          UsesJavaMXBeans.TOTAL_PHYSICAL_MEMORY_SIZE,
          RendererHints.displayValue(ByteSizeStrings.metric()));
      RendererHints.register(
          UsesJavaMXBeans.FREE_PHYSICAL_MEMORY_SIZE,
          RendererHints.displayValue(ByteSizeStrings.metric()));

      RendererHints.register(
          UsesJavaMXBeans.START_TIME, RendererHints.displayValue(Time.toDateString()));
      RendererHints.register(
          UsesJavaMXBeans.UP_TIME, RendererHints.displayValue(Duration.millisToStringRounded()));
      RendererHints.register(
          UsesJavaMXBeans.PROCESS_CPU_TIME,
          RendererHints.displayValue(Duration.millisToStringRounded()));
      RendererHints.register(
          UsesJavaMXBeans.PROCESS_CPU_TIME_FRACTION_LAST,
          RendererHints.displayValue(MathFunctions.percent(4)));
      RendererHints.register(
          UsesJavaMXBeans.PROCESS_CPU_TIME_FRACTION_IN_WINDOW,
          RendererHints.displayValue(MathFunctions.percent(4)));

      initialized.set(true);
    }
  }