/** 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()))); }
/** * Supplies the value to be returned by each poll. * * <p>Note this <em>must</em> use generics, otherwise the return type of subsequent chained calls * will (e.g. to {@link FeedConfig#onException(com.google.common.base.Function)} will return the * wrong type. */ @SuppressWarnings("unchecked") public <newS> FunctionPollConfig<newS, T> supplier(final Supplier<? extends newS> val) { this.callable = Functionals.callable(checkNotNull(val, "supplier")); return (FunctionPollConfig<newS, T>) this; }