@Test public void stripInstanceAndHostTest() { assertEquals("name", MetricsSystem.stripInstanceAndHost("Master.name")); assertEquals("name", MetricsSystem.stripInstanceAndHost("Worker.name.10_0_0_136")); assertEquals("name.UFS:ufs", MetricsSystem.stripInstanceAndHost("Client.name.UFS:ufs.0_0_0_0")); assertEquals("name.UFS:ufs.UFS_TYPE:local", MetricsSystem.stripInstanceAndHost("Worker.name.UFS:ufs.UFS_TYPE:local.0_0_0_0")); }
public static String stripInstanceAndHost(String metricsName) { String[] pieces = metricsName.split("\\."); int len = pieces.length; if (len <= 1) { return metricsName; } if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString()) && !pieces[0].equals(InstanceType.CLUSTER.toString()) && pieces.length > 2) { pieces[len - 1] = null; } pieces[0] = null; return Joiner.on(".").skipNulls().join(pieces); }
MetricsSystem { public static String stripInstanceAndHost(String metricsName) { String[] pieces = metricsName.split("\\."); int len = pieces.length; if (len <= 1) { return metricsName; } if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString()) && !pieces[0].equals(InstanceType.CLUSTER.toString()) && pieces.length > 2) { pieces[len - 1] = null; } pieces[0] = null; return Joiner.on(".").skipNulls().join(pieces); } }
MetricsSystem { public static String stripInstanceAndHost(String metricsName) { String[] pieces = metricsName.split("\\."); int len = pieces.length; if (len <= 1) { return metricsName; } if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString()) && !pieces[0].equals(InstanceType.CLUSTER.toString()) && pieces.length > 2) { pieces[len - 1] = null; } pieces[0] = null; return Joiner.on(".").skipNulls().join(pieces); } private  MetricsSystem(); }
MetricsSystem { public static String stripInstanceAndHost(String metricsName) { String[] pieces = metricsName.split("\\."); int len = pieces.length; if (len <= 1) { return metricsName; } if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString()) && !pieces[0].equals(InstanceType.CLUSTER.toString()) && pieces.length > 2) { pieces[len - 1] = null; } pieces[0] = null; return Joiner.on(".").skipNulls().join(pieces); } private  MetricsSystem(); static void startSinks(String metricsConfFile); static synchronized void startSinksFromConfig(MetricsConfig config); static synchronized void stopSinks(); static synchronized int getNumSinks(); static String getMetricName(String name); static String getMasterMetricName(String name); static String getJobWorkerMetricName(String name); static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod); static String stripInstanceAndHost(String metricsName); static String escape(AlluxioURI uri); static String unescape(String uri); static Counter counter(String name); static Counter counterWithTags(String name, boolean shouldReport, String... tags); static Meter meter(String name); static Meter meterWithTags(String name, boolean shouldReport, String... tags); static Timer timer(String name); static synchronized void registerGaugeIfAbsent(String name, Gauge<T> metric); static List<alluxio.grpc.Metric> reportWorkerMetrics(); static List<alluxio.grpc.Metric> reportClientMetrics(); static Map<String, Set<Metric>> getMasterMetrics(Set<String> metricNames); @Nullable static Metric getMetricValue(String fullName); static Map<String, MetricValue> allMetrics(); @VisibleForTesting static void initShouldReportMetrics(InstanceType instanceType); static synchronized void resetAllMetrics(); @VisibleForTesting static void clearAllMetrics(); @VisibleForTesting static void resetCountersAndGauges(); }
MetricsSystem { public static String stripInstanceAndHost(String metricsName) { String[] pieces = metricsName.split("\\."); int len = pieces.length; if (len <= 1) { return metricsName; } if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString()) && !pieces[0].equals(InstanceType.CLUSTER.toString()) && pieces.length > 2) { pieces[len - 1] = null; } pieces[0] = null; return Joiner.on(".").skipNulls().join(pieces); } private  MetricsSystem(); static void startSinks(String metricsConfFile); static synchronized void startSinksFromConfig(MetricsConfig config); static synchronized void stopSinks(); static synchronized int getNumSinks(); static String getMetricName(String name); static String getMasterMetricName(String name); static String getJobWorkerMetricName(String name); static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod); static String stripInstanceAndHost(String metricsName); static String escape(AlluxioURI uri); static String unescape(String uri); static Counter counter(String name); static Counter counterWithTags(String name, boolean shouldReport, String... tags); static Meter meter(String name); static Meter meterWithTags(String name, boolean shouldReport, String... tags); static Timer timer(String name); static synchronized void registerGaugeIfAbsent(String name, Gauge<T> metric); static List<alluxio.grpc.Metric> reportWorkerMetrics(); static List<alluxio.grpc.Metric> reportClientMetrics(); static Map<String, Set<Metric>> getMasterMetrics(Set<String> metricNames); @Nullable static Metric getMetricValue(String fullName); static Map<String, MetricValue> allMetrics(); @VisibleForTesting static void initShouldReportMetrics(InstanceType instanceType); static synchronized void resetAllMetrics(); @VisibleForTesting static void clearAllMetrics(); @VisibleForTesting static void resetCountersAndGauges(); static final String CLUSTER; static final MetricRegistry METRIC_REGISTRY; static final String SINK_REGEX; }