Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/
package alluxio.master.metrics;
import alluxio.Constants;
import alluxio.clock.SystemClock;
import alluxio.conf.PropertyKey;
import alluxio.conf.ServerConfiguration;
import alluxio.grpc.GrpcService;
import alluxio.grpc.ServiceType;
import alluxio.heartbeat.HeartbeatContext;
import alluxio.heartbeat.HeartbeatExecutor;
import alluxio.heartbeat.HeartbeatThread;
import alluxio.master.CoreMaster;
import alluxio.master.CoreMasterContext;
import alluxio.master.journal.NoopJournaled;
import alluxio.metrics.ClientMetrics;
import alluxio.metrics.Metric;
import alluxio.metrics.MetricsAggregator;
import alluxio.metrics.MetricsFilter;
import alluxio.metrics.MetricsSystem;
import alluxio.metrics.MultiValueMetricsAggregator;
import alluxio.metrics.SingleValueAggregator;
import alluxio.metrics.WorkerMetrics;
import alluxio.metrics.aggregator.SingleTagValueAggregator;
import alluxio.metrics.aggregator.SumInstancesAggregator;
import alluxio.util.executor.ExecutorServiceFactories;
import alluxio.util.executor.ExecutorServiceFactory;
import com.codahale.metrics.Gauge;
import com.google.common.annotations.VisibleForTesting;
import java.io.IOException;
import java.time.Clock;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* Default implementation of the metrics master.
*/
public class DefaultMetricsMaster extends CoreMaster implements MetricsMaster, NoopJournaled {
private final Map mMetricsAggregatorRegistry = new HashMap<>();
private final Set mMultiValueMetricsAggregatorRegistry =
new HashSet<>();
private final MetricsStore mMetricsStore;
private final HeartbeatThread mClusterMetricsUpdater;
/**
* Creates a new instance of {@link MetricsMaster}.
*
* @param masterContext the context for metrics master
*/
DefaultMetricsMaster(CoreMasterContext masterContext) {
this(masterContext, new SystemClock(),
ExecutorServiceFactories.cachedThreadPool(Constants.METRICS_MASTER_NAME));
}
/**
* Creates a new instance of {@link MetricsMaster}.
*
* @param masterContext the context for metrics master
* @param clock the clock to use for determining the time
* @param executorServiceFactory a factory for creating the executor service to use for running
* maintenance threads
*/
DefaultMetricsMaster(CoreMasterContext masterContext, Clock clock,
ExecutorServiceFactory executorServiceFactory) {
super(masterContext, clock, executorServiceFactory);
mMetricsStore = new MetricsStore();
registerAggregators();
mClusterMetricsUpdater =
new HeartbeatThread(HeartbeatContext.MASTER_CLUSTER_METRICS_UPDATER,
new ClusterMetricsUpdater(),
ServerConfiguration.getMs(PropertyKey.MASTER_CLUSTER_METRICS_UPDATE_INTERVAL),
ServerConfiguration.global(), mMasterContext.getUserState());
}
@VisibleForTesting
protected void addAggregator(SingleValueAggregator aggregator) {
mMetricsAggregatorRegistry.put(aggregator.getName(), aggregator);
MetricsSystem.registerGaugeIfAbsent(MetricsSystem.getClusterMetricName(aggregator.getName()),
(Gauge