/** * Test the {@link GobblinMetrics} instance is removed from {@link GobblinMetricsRegistry} when * it stops metrics reporting */ public void testStopReportingMetrics() { String id = getClass().getSimpleName() + "-" + System.currentTimeMillis(); GobblinMetrics gobblinMetrics = GobblinMetrics.get(id); gobblinMetrics.startMetricReporting(new Properties()); Assert.assertEquals(GobblinMetricsRegistry.getInstance().get(id).get(), gobblinMetrics); gobblinMetrics.stopMetricsReporting(); Assert.assertFalse(GobblinMetricsRegistry.getInstance().get(id).isPresent()); } }
/** * Get a {@link GobblinMetrics} instance with the given ID, parent {@link MetricContext}, * and list of {@link Tag}s. * * @param id the given {@link GobblinMetrics} ID * @param parentContext the given parent {@link MetricContext} * @param tags the given list of {@link Tag}s * @return a {@link GobblinMetrics} instance */ public static GobblinMetrics get(final String id, final MetricContext parentContext, final List<Tag<?>> tags) { return GOBBLIN_METRICS_REGISTRY.getOrDefault(id, new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new GobblinMetrics(id, parentContext, tags); } }); }
@Override public void close() throws IOException { try { this.cancellationExecutor.shutdownNow(); try { this.jobContext.getSource().shutdown(this.jobContext.getJobState()); } finally { if (GobblinMetrics.isEnabled(this.jobProps)) { GobblinMetricsRegistry.getInstance().remove(this.jobContext.getJobId()); } } } finally { unlockJob(); } }
public HiveMetaStoreBasedRegister(State state, Optional<String> metastoreURI) throws IOException { super(state); this.optimizedChecks = state.getPropAsBoolean(this.OPTIMIZED_CHECK_ENABLED, true); GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(this.props.getNumThreads()); config.setMaxIdle(this.props.getNumThreads()); this.clientPool = HiveMetastoreClientPool.get(this.props.getProperties(), metastoreURI); this.metricContext = GobblinMetricsRegistry.getInstance().getMetricContext(state, HiveMetaStoreBasedRegister.class, GobblinMetrics.getCustomTagsFromState(state)); this.eventSubmitter = new EventSubmitter.Builder(this.metricContext, "org.apache.gobblin.hive.HiveMetaStoreBasedRegister").build(); }
/** * Remove the {@link GobblinMetrics} instance associated with the given ID. * * @param id the given {@link GobblinMetrics} ID */ public static void remove(String id) { GOBBLIN_METRICS_REGISTRY.remove(id); }
public HiveMetaStoreBasedRegister(State state, Optional<String> metastoreURI) throws IOException { super(state); this.optimizedChecks = state.getPropAsBoolean(this.OPTIMIZED_CHECK_ENABLED, true); GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(this.props.getNumThreads()); config.setMaxIdle(this.props.getNumThreads()); this.clientPool = HiveMetastoreClientPool.get(this.props.getProperties(), metastoreURI); this.metricContext = GobblinMetricsRegistry.getInstance().getMetricContext(state, HiveMetaStoreBasedRegister.class, GobblinMetrics.getCustomTagsFromState(state)); this.eventSubmitter = new EventSubmitter.Builder(this.metricContext, "org.apache.gobblin.hive.HiveMetaStoreBasedRegister").build(); }
/** * Remove the {@link GobblinMetrics} instance associated with the given ID. * * @param id the given {@link GobblinMetrics} ID */ public static void remove(String id) { GOBBLIN_METRICS_REGISTRY.remove(id); }
? GobblinMetricsRegistry.getInstance().get(state.getProp(ConfigurationKeys.METRIC_CONTEXT_NAME_KEY)) : Optional.<GobblinMetrics> absent();
GobblinMetricsRegistry.getInstance().remove(jobMetrics.getId()); JobMetrics jobMetrics2 = JobMetrics.get(jobName + "_", jobId); Assert.assertNotNull(jobMetrics2.getMetricContext());
/** * Get a {@link TaskMetrics} instance for the task with the given {@link TaskState} instance. * * @param taskState the given {@link TaskState} instance * @return a {@link TaskMetrics} instance */ public static TaskMetrics get(final TaskState taskState) { return (TaskMetrics) GOBBLIN_METRICS_REGISTRY.getOrDefault(name(taskState), new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new TaskMetrics(taskState); } }); }
? GobblinMetricsRegistry.getInstance().get(state.getProp(METRIC_CONTEXT_NAME_KEY)) : Optional.<GobblinMetrics> absent();
@Override public void close() throws IOException { try { this.cancellationExecutor.shutdownNow(); try { this.jobContext.getSource().shutdown(this.jobContext.getJobState()); } finally { if (GobblinMetrics.isEnabled(this.jobProps)) { GobblinMetricsRegistry.getInstance().remove(this.jobContext.getJobId()); } } } finally { unlockJob(); } }
/** * Get a {@link ContainerMetrics} instance given the {@link State} of a container, the name of the application the * container belongs to, and the workerId of the container. * * @param containerState the {@link State} of the container * @param applicationName a {@link String} representing the name of the application the container belongs to * @return a {@link ContainerMetrics} instance */ public static ContainerMetrics get(final State containerState, final String applicationName, final String workerId) { return (ContainerMetrics) GOBBLIN_METRICS_REGISTRY.getOrDefault(name(workerId), new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new ContainerMetrics(containerState, applicationName, workerId); } }); }
? GobblinMetricsRegistry.getInstance().get(state.getProp(ConfigurationKeys.METRIC_CONTEXT_NAME_KEY)) : Optional.<GobblinMetrics> absent();
/** * Get a {@link JobMetrics} instance for the job with the given {@link JobState} instance. * * @param jobState the given {@link JobState} instance * @return a {@link JobMetrics} instance */ public static JobMetrics get(final JobState jobState) { return (JobMetrics) GOBBLIN_METRICS_REGISTRY.getOrDefault(name(jobState), new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new JobMetrics(jobState); } }); }
? GobblinMetricsRegistry.getInstance().get(state.getProp(METRIC_CONTEXT_NAME_KEY)) : Optional.<GobblinMetrics> absent();
/** * Get a new {@link GobblinMetrics} instance for a given job. * * @param jobState the given {@link JobState} instance * @param parentContext is the parent {@link MetricContext} * @return a {@link JobMetrics} instance */ public static JobMetrics get(final JobState jobState, final MetricContext parentContext) { return (JobMetrics) GOBBLIN_METRICS_REGISTRY.getOrDefault(name(jobState), new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new JobMetrics(jobState, parentContext); } }); }
/** * Get a {@link GobblinMetrics} instance with the given ID, parent {@link MetricContext}, * and list of {@link Tag}s. * * @param id the given {@link GobblinMetrics} ID * @param parentContext the given parent {@link MetricContext} * @param tags the given list of {@link Tag}s * @return a {@link GobblinMetrics} instance */ public static GobblinMetrics get(final String id, final MetricContext parentContext, final List<Tag<?>> tags) { return GOBBLIN_METRICS_REGISTRY.getOrDefault(id, new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new GobblinMetrics(id, parentContext, tags); } }); }
/** * Get a {@link TaskMetrics} instance for the task with the given {@link TaskState} instance. * * @param taskState the given {@link TaskState} instance * @return a {@link TaskMetrics} instance */ public static TaskMetrics get(final TaskState taskState) { return (TaskMetrics) GOBBLIN_METRICS_REGISTRY.getOrDefault(name(taskState), new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new TaskMetrics(taskState); } }); }
/** * Get a {@link ContainerMetrics} instance given the {@link State} of a container, the name of the application the * container belongs to, and the workerId of the container. * * @param containerState the {@link State} of the container * @param applicationName a {@link String} representing the name of the application the container belongs to * @return a {@link ContainerMetrics} instance */ public static ContainerMetrics get(final State containerState, final String applicationName, final String workerId) { return (ContainerMetrics) GOBBLIN_METRICS_REGISTRY.getOrDefault(name(workerId), new Callable<GobblinMetrics>() { @Override public GobblinMetrics call() throws Exception { return new ContainerMetrics(containerState, applicationName, workerId); } }); }