@Override public MetricsContext load(Map<String, String> key) throws Exception { return metricsCollectionService.getContext(key); } });
@Override public MetricsContext load(Map<String, String> key) throws Exception { return metricsCollectionService.getContext(key); } });
@Override public MetricsContext load(NamespaceId namespaceId) { return metricsCollectionService.getContext(getStreamMetricsContext(namespaceId)); } });
@Override public MetricsContext get() { MetricsContext context = this.context; if (context == null) { // The service.getContext already handle concurrent calls, so no need to synchronize here this.context = context = serviceProvider.get().getContext(Constants.Metrics.TRANSACTION_MANAGER_CONTEXT); } return context; } };
@Override public MetricsContext get() { MetricsContext context = this.context; if (context == null) { // The service.getContext already handle concurrent calls, so no need to synchronize here this.context = context = serviceProvider.get().getContext(Constants.Metrics.TRANSACTION_MANAGER_CONTEXT); } return context; } };
ProgramRunnableResourceReporter(ProgramId programId, MetricsCollectionService collectionService, TwillContext context) { super(collectionService.getContext(getMetricContext(programId, context))); this.runContext = context; }
@Override protected Service createService(Set<Integer> topicNumbers) { return factory.create(topicNumbers, metricsCollectionService.getContext(Constants.Metrics.METRICS_PROCESSOR_CONTEXT), instanceId); } }
ProgramRunnableResourceReporter(ProgramId programId, MetricsCollectionService collectionService, TwillContext context) { super(collectionService.getContext(getMetricContext(programId, context))); this.runContext = context; }
@Override protected Service createService(Set<Integer> topicNumbers) { return factory.create(topicNumbers, metricsCollectionService.getContext(Constants.Metrics.METRICS_PROCESSOR_CONTEXT), instanceId); } }
@Override public DynamicDatasetCache get() { SystemDatasetInstantiator dsInstantiator = new SystemDatasetInstantiator(dsFramework); return new MultiThreadDatasetCache( dsInstantiator, txClient, NamespaceId.SYSTEM, ImmutableMap.of(), metricsCollectionService.getContext(ImmutableMap.of()), ImmutableMap.of() ); } }
@Override public DynamicDatasetCache get() { SystemDatasetInstantiator dsInstantiator = new SystemDatasetInstantiator(dsFramework); return new MultiThreadDatasetCache( dsInstantiator, txClient, NamespaceId.SYSTEM, ImmutableMap.of(), metricsCollectionService.getContext(ImmutableMap.of()), ImmutableMap.of() ); } }
ClusterResourceReporter(MetricsCollectionService metricsCollectionService, Configuration hConf) { super(metricsCollectionService.getContext(ImmutableMap.of())); YarnClient yarnClient = YarnClient.createYarnClient(); yarnClient.init(hConf); this.yarnClient = yarnClient; }
ClusterResourceReporter(MetricsCollectionService metricsCollectionService, Configuration hConf) { super(metricsCollectionService.getContext(ImmutableMap.of())); YarnClient yarnClient = YarnClient.createYarnClient(); yarnClient.init(hConf); this.yarnClient = yarnClient; }
/** * Creates a {@link MetricsContext} for {@link MessageCache} to use for the given topic. */ private MetricsContext createMetricsContext(CConfiguration cConf, TopicId topicId, MetricsCollectionService metricsCollectionService) { return metricsCollectionService.getContext(ImmutableMap.of( Constants.Metrics.Tag.COMPONENT, Constants.Service.MESSAGING_SERVICE, Constants.Metrics.Tag.INSTANCE_ID, cConf.get(Constants.MessagingSystem.CONTAINER_INSTANCE_ID, "0"), Constants.Metrics.Tag.NAMESPACE, topicId.getNamespace(), Constants.Metrics.Tag.TOPIC, topicId.getTopic() )); } }
/** * Creates a {@link MetricsContext} for {@link MessageCache} to use for the given topic. */ private MetricsContext createMetricsContext(CConfiguration cConf, TopicId topicId, MetricsCollectionService metricsCollectionService) { return metricsCollectionService.getContext(ImmutableMap.of( Constants.Metrics.Tag.COMPONENT, Constants.Service.MESSAGING_SERVICE, Constants.Metrics.Tag.INSTANCE_ID, cConf.get(Constants.MessagingSystem.CONTAINER_INSTANCE_ID, "0"), Constants.Metrics.Tag.NAMESPACE, topicId.getNamespace(), Constants.Metrics.Tag.TOPIC, topicId.getTopic() )); } }
/** * Emit the metrics context for the program, the tags are constructed with the program run id and * the profile id */ private void emitProfileMetrics(ProgramRunId programRunId, ProfileId profileId, String metricName) { Map<String, String> tags = ImmutableMap.<String, String>builder() .put(Constants.Metrics.Tag.PROFILE_SCOPE, profileId.getScope().name()) .put(Constants.Metrics.Tag.PROFILE, profileId.getProfile()) .put(Constants.Metrics.Tag.NAMESPACE, programRunId.getNamespace()) .put(Constants.Metrics.Tag.PROGRAM_TYPE, programRunId.getType().getPrettyName()) .put(Constants.Metrics.Tag.APP, programRunId.getApplication()) .put(Constants.Metrics.Tag.PROGRAM, programRunId.getProgram()) .put(Constants.Metrics.Tag.RUN_ID, programRunId.getRun()) .build(); metricsCollectionService.getContext(tags).increment(metricName, 1L); }
/** * Creates a {@link MetricsContext} for metrics emission of the program represented by this context. * * @param programRunId the {@link ProgramRunId} of the current execution * @param metricsService the underlying service for metrics publishing; or {@code null} to suppress metrics publishing * @param metricsTags a set of extra tags to be used for creating the {@link MetricsContext} * @return a {@link MetricsContext} for emitting metrics for the current program context. */ private MetricsContext createProgramMetrics(ProgramRunId programRunId, @Nullable MetricsCollectionService metricsService, Map<String, String> metricsTags) { Map<String, String> tags = Maps.newHashMap(metricsTags); tags.put(Constants.Metrics.Tag.NAMESPACE, programRunId.getNamespace()); tags.put(Constants.Metrics.Tag.APP, programRunId.getApplication()); tags.put(ProgramTypeMetricTag.getTagName(programRunId.getType()), programRunId.getProgram()); tags.put(Constants.Metrics.Tag.RUN_ID, programRunId.getRun()); return metricsService == null ? new NoopMetricsContext(tags) : metricsService.getContext(tags); }
/** * Emit the metrics context for the program, the tags are constructed with the program run id and * the profile id */ private void emitProfileMetrics(ProgramRunId programRunId, ProfileId profileId, String metricName) { Map<String, String> tags = ImmutableMap.<String, String>builder() .put(Constants.Metrics.Tag.PROFILE_SCOPE, profileId.getScope().name()) .put(Constants.Metrics.Tag.PROFILE, profileId.getProfile()) .put(Constants.Metrics.Tag.NAMESPACE, programRunId.getNamespace()) .put(Constants.Metrics.Tag.PROGRAM_TYPE, programRunId.getType().getPrettyName()) .put(Constants.Metrics.Tag.APP, programRunId.getApplication()) .put(Constants.Metrics.Tag.PROGRAM, programRunId.getProgram()) .put(Constants.Metrics.Tag.RUN_ID, programRunId.getRun()) .build(); metricsCollectionService.getContext(tags).increment(metricName, 1L); }
protected AbstractAppenderContext(DatasetFramework datasetFramework, TransactionSystemClient txClient, LocationFactory locationFactory, MetricsCollectionService metricsCollectionService) { this.locationFactory = locationFactory; // No need to have retry for dataset admin operations // The log framework itself will perform retries and state management this.datasetManager = new DefaultDatasetManager(datasetFramework, NamespaceId.SYSTEM, co.cask.cdap.common.service.RetryStrategies.noRetry(), null); this.transactional = Transactions.createTransactionalWithRetry( Transactions.createTransactional(new MultiThreadDatasetCache( new SystemDatasetInstantiator(datasetFramework), txClient, NamespaceId.SYSTEM, ImmutableMap.<String, String>of(), null, null)), RetryStrategies.retryOnConflict(20, 100) ); this.metricsContext = metricsCollectionService.getContext(Collections.<String, String>emptyMap()); }
protected AbstractAppenderContext(DatasetFramework datasetFramework, TransactionSystemClient txClient, LocationFactory locationFactory, MetricsCollectionService metricsCollectionService) { this.locationFactory = locationFactory; // No need to have retry for dataset admin operations // The log framework itself will perform retries and state management this.datasetManager = new DefaultDatasetManager(datasetFramework, NamespaceId.SYSTEM, co.cask.cdap.common.service.RetryStrategies.noRetry(), null); this.transactional = Transactions.createTransactionalWithRetry( Transactions.createTransactional(new MultiThreadDatasetCache( new SystemDatasetInstantiator(datasetFramework), txClient, NamespaceId.SYSTEM, ImmutableMap.<String, String>of(), null, null)), RetryStrategies.retryOnConflict(20, 100) ); this.metricsContext = metricsCollectionService.getContext(Collections.<String, String>emptyMap()); }