@Test public void testHeapMetrics() throws Exception { final InterceptingOperatorMetricGroup heapMetrics = new InterceptingOperatorMetricGroup(); MetricUtils.instantiateHeapMemoryMetrics(heapMetrics); @SuppressWarnings("unchecked") final Gauge<Long> used = (Gauge<Long>) heapMetrics.get(MetricNames.MEMORY_USED); final long usedHeapInitially = used.getValue(); for (int x = 0; x < 10; x++) { final byte[] array = new byte[1024 * 1024 * 8]; final long usedHeapAfterAllocation = used.getValue(); if (usedHeapInitially != usedHeapAfterAllocation) { return; } Thread.sleep(50); } Assert.fail("Heap usage metric never changed it's value."); }
@VisibleForTesting static void instantiateHeapMemoryMetrics(final MetricGroup metricGroup) { instantiateMemoryUsageMetrics(metricGroup, () -> ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); }
MetricUtils { @VisibleForTesting static void instantiateHeapMemoryMetrics(final MetricGroup metricGroup) { instantiateMemoryUsageMetrics(metricGroup, () -> ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); } }
MetricUtils { @VisibleForTesting static void instantiateHeapMemoryMetrics(final MetricGroup metricGroup) { instantiateMemoryUsageMetrics(metricGroup, () -> ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); } private  MetricUtils(); }
MetricUtils { @VisibleForTesting static void instantiateHeapMemoryMetrics(final MetricGroup metricGroup) { instantiateMemoryUsageMetrics(metricGroup, () -> ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); } private  MetricUtils(); static JobManagerMetricGroup instantiateJobManagerMetricGroup(
			final MetricRegistry metricRegistry,
			final String hostname,
			final Optional<Time> systemResourceProbeInterval); static TaskManagerMetricGroup instantiateTaskManagerMetricGroup(
			MetricRegistry metricRegistry,
			TaskManagerLocation taskManagerLocation,
			NetworkEnvironment network,
			Optional<Time> systemResourceProbeInterval); static void instantiateStatusMetrics(
			MetricGroup metricGroup); static ActorSystem startMetricsActorSystem(Configuration configuration, String hostname, Logger logger); }
MetricUtils { @VisibleForTesting static void instantiateHeapMemoryMetrics(final MetricGroup metricGroup) { instantiateMemoryUsageMetrics(metricGroup, () -> ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); } private  MetricUtils(); static JobManagerMetricGroup instantiateJobManagerMetricGroup(
			final MetricRegistry metricRegistry,
			final String hostname,
			final Optional<Time> systemResourceProbeInterval); static TaskManagerMetricGroup instantiateTaskManagerMetricGroup(
			MetricRegistry metricRegistry,
			TaskManagerLocation taskManagerLocation,
			NetworkEnvironment network,
			Optional<Time> systemResourceProbeInterval); static void instantiateStatusMetrics(
			MetricGroup metricGroup); static ActorSystem startMetricsActorSystem(Configuration configuration, String hostname, Logger logger);  }