@Override public boolean apply(Void input) { long uptimeMs = driver.getMetrics().getUptimeMs().getValue().longValue(); return uptimeMs >= elapsedMs; } }, "uptime > elapsedMs");
@Test public void testTaggableGauge() { ContextAwareGauge<Long> queueSize = this.context.newContextAwareGauge( QUEUE_SIZE, new Gauge<Long>() { @Override public Long getValue() { return 1000l; } }); this.context.register(QUEUE_SIZE, queueSize); Assert.assertEquals(queueSize.getValue().longValue(), 1000l); Assert.assertEquals( this.context.getGauges().get(queueSize.getName()), queueSize.getInnerMetric()); Assert.assertEquals(queueSize.getContext(), this.context); Assert.assertEquals(queueSize.getName(), QUEUE_SIZE); }
private void checkLaunchJob(StandardGobblinInstanceLauncher instanceLauncher, JobSpec js1, GobblinInstanceDriver instance) throws TimeoutException, InterruptedException, ExecutionException { JobExecutionDriver jobDriver = null; JobExecutionMonitor monitor = instance.getJobLauncher().launchJob(js1); if (monitor instanceof JobLauncherExecutionDriver.JobExecutionMonitorAndDriver) { jobDriver = ((JobLauncherExecutionDriver.JobExecutionMonitorAndDriver) monitor).getDriver(); } new Thread(jobDriver).run(); JobExecutionResult jobResult = jobDriver.get(5, TimeUnit.SECONDS); Assert.assertTrue(jobResult.isSuccessful()); instanceLauncher.stopAsync(); instanceLauncher.awaitTerminated(5, TimeUnit.SECONDS); Assert.assertEquals(instance.getMetrics().getUpFlag().getValue().intValue(), 0); Assert.assertEquals(instance.getMetrics().getUptimeMs().getValue().longValue(), 0); }
Assert.assertEquals(cat.getMetrics().getNumActiveJobs().getValue().intValue(), 1); Assert.assertEquals(cat.getMetrics().getTotalAddCalls().getValue().longValue(), 1); Assert.assertEquals(cat.getMetrics().getTotalUpdateCalls().getValue().longValue(), 0); Assert.assertEquals(cat.getMetrics().getTotalDeleteCalls().getValue().longValue(), 0); ma.assertEvent(Predicates.and( MetricsAssert.eqEventNamespace(JobCatalog.class.getName()), Assert.assertEquals(cat.getMetrics().getNumActiveJobs().getValue().intValue(), 1); Assert.assertEquals(cat.getMetrics().getTotalAddCalls().getValue().longValue(), 1); Assert.assertEquals(cat.getMetrics().getTotalUpdateCalls().getValue().longValue(), 1); Assert.assertEquals(cat.getMetrics().getTotalDeleteCalls().getValue().longValue(), 0); ma.assertEvent(Predicates.and( MetricsAssert.eqEventNamespace(JobCatalog.class.getName()), Assert.assertEquals(cat.getMetrics().getNumActiveJobs().getValue().intValue(), 2); Assert.assertEquals(cat.getMetrics().getTotalAddCalls().getValue().longValue(), 2); Assert.assertEquals(cat.getMetrics().getTotalUpdateCalls().getValue().longValue(), 1); Assert.assertEquals(cat.getMetrics().getTotalDeleteCalls().getValue().longValue(), 0); ma.assertEvent(Predicates.and( MetricsAssert.eqEventNamespace(JobCatalog.class.getName()), Assert.assertEquals(cat.getMetrics().getNumActiveJobs().getValue().intValue(), 2); Assert.assertEquals(cat.getMetrics().getTotalAddCalls().getValue().longValue(), 2); Assert.assertEquals(cat.getMetrics().getTotalUpdateCalls().getValue().longValue(), 2); Assert.assertEquals(cat.getMetrics().getTotalDeleteCalls().getValue().longValue(), 0); ma.assertEvent(Predicates.and( MetricsAssert.eqEventNamespace(JobCatalog.class.getName()), Assert.assertEquals(cat.getMetrics().getNumActiveJobs().getValue().intValue(), 1);
long uptimeMs = driver.getMetrics().getUptimeMs().getValue().longValue(); Assert.assertTrue(uptimeMs <= 2 * elapsedMs, "uptime=" + uptimeMs + " elapsedMs=" + elapsedMs); driver.awaitTerminated(100, TimeUnit.MILLISECONDS); Assert.assertEquals(driver.state(), State.TERMINATED); Assert.assertEquals(driver.getMetrics().getUpFlag().getValue().intValue(), 0);