Please wait. This can take some minutes ...
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.
com.alibaba.metrics.NOPMetricManager Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.metrics;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
/**
* IMetricManager的空实现
*
*/
public class NOPMetricManager implements IMetricManager {
private static final SortedMap emptyMap = new TreeMap();
private static final SortedSet emptySet = new TreeSet();
@Override
public Meter getMeter(String group, MetricName name) {
return NOP_METER;
}
@Override
public Counter getCounter(String group, MetricName name) {
return NOP_COUNTER;
}
@Override
public Histogram getHistogram(String group, MetricName name) {
return NOP_HISTOGRAM;
}
@Override
public Histogram getHistogram(String group, MetricName name, ReservoirType type) {
return NOP_HISTOGRAM;
}
@Override
public Timer getTimer(String group, MetricName name) {
return NOP_TIMER;
}
@Override
public Timer getTimer(String group, MetricName name, ReservoirType type) {
return NOP_TIMER;
}
@Override
public Compass getCompass(String group, MetricName name, ReservoirType type) {
return NOP_COMPASS;
}
@Override
public Compass getCompass(String group, MetricName name) {
return NOP_COMPASS;
}
@Override
public FastCompass getFastCompass(String group, MetricName name) {
return NOP_FAST_COMPASS;
}
@Override
public ClusterHistogram getClusterHistogram(String group, MetricName name, long[] buckets) {
return NOP_CLUSTER_HISTOGRAM;
}
@Override
public List listMetricGroups() {
return Collections.emptyList();
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public void setEnabled(boolean enabled) {
}
@Override
public Map> listMetricNamesByGroup() {
return Collections.emptyMap();
}
@Override
public MetricRegistry getMetricRegistryByGroup(String group) {
return NOP_REGISTRY;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getGauges(String group, MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getCounters(String group, MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getHistograms(String group, MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getMeters(String group, MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getTimers(String group, MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getCompasses(String group, MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getFastCompasses(String group, MetricFilter filter) {
return emptyMap;
}
@Override
public void register(String group, MetricName name, Metric metric) {
}
static final Meter NOP_METER = new Meter() {
@Override
public void mark() {
}
@Override
public void mark(long n) {
}
@Override
public long getCount() {
return 0;
}
@Override
public double getFifteenMinuteRate() {
return 0;
}
@Override
public double getFiveMinuteRate() {
return 0;
}
@Override
public double getMeanRate() {
return 0;
}
@Override
public double getOneMinuteRate() {
return 0;
}
@Override
public Map getInstantCount() {
return emptyMap;
}
@Override
public int getInstantCountInterval() {
return 0;
}
@Override
public Map getInstantCount(long startTime) {
return emptyMap;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
static final BucketCounter NOP_BUCKET_COUNTER = new BucketCounter() {
@Override
public void update() {
}
@Override
public void update(long n) {
}
@Override
public Map getBucketCounts() {
return emptyMap;
}
@Override
public Map getBucketCounts(long startTime) {
return emptyMap;
}
@Override
public int getBucketInterval() {
return 0;
}
@Override
public void inc() {
}
@Override
public void inc(long n) {
}
@Override
public void dec() {
}
@Override
public void dec(long n) {
}
@Override
public long getCount() {
return 0;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
static final Counter NOP_COUNTER = new Counter() {
@Override
public void inc() {
}
@Override
public void inc(long n) {
}
@Override
public void dec() {
}
@Override
public void dec(long n) {
}
@Override
public long getCount() {
return 0;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
static final Histogram NOP_HISTOGRAM = new Histogram() {
@Override
public void update(int value) {
}
@Override
public void update(long value) {
}
@Override
public long getCount() {
return 0;
}
@Override
public Snapshot getSnapshot() {
return NOP_SNAPSHOT;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
private static final Timer.Context NOP_CONTEXT = new Timer.Context() {
@Override
public void close() throws IOException {
}
@Override
public long stop() {
return 0;
}
};
private static final Compass.Context NOP_COMPASS_CONTEXT = new Compass.Context() {
@Override
public long stop() {
return 0;
}
@Override
public void success() {
}
@Override
public void error(String errorCode) {
}
@Override
public void close() throws IOException {
}
@Override
public void markAddon(String suffix) {
}
};
private static final Snapshot NOP_SNAPSHOT = new Snapshot() {
@Override
public double getValue(double quantile) {
return 0;
}
@Override
public long[] getValues() {
return new long[0];
}
@Override
public int size() {
return 0;
}
@Override
public double getMedian() {
return 0;
}
@Override
public double get75thPercentile() {
return 0;
}
@Override
public double get95thPercentile() {
return 0;
}
@Override
public double get98thPercentile() {
return 0;
}
@Override
public double get99thPercentile() {
return 0;
}
@Override
public double get999thPercentile() {
return 0;
}
@Override
public long getMax() {
return 0;
}
@Override
public double getMean() {
return 0;
}
@Override
public long getMin() {
return 0;
}
@Override
public double getStdDev() {
return 0;
}
@Override
public void dump(OutputStream output) {
}
};
static final Timer NOP_TIMER = new Timer() {
@Override
public void update(long duration, TimeUnit unit) {
}
@Override
public T time(Callable event) throws Exception {
return event.call();
}
@Override
public Context time() {
return NOP_CONTEXT;
}
@Override
public long getCount() {
return 0;
}
@Override
public double getFifteenMinuteRate() {
return 0;
}
@Override
public double getFiveMinuteRate() {
return 0;
}
@Override
public double getMeanRate() {
return 0;
}
@Override
public double getOneMinuteRate() {
return 0;
}
@Override
public Snapshot getSnapshot() {
return NOP_SNAPSHOT;
}
@Override
public Map getInstantCount() {
return emptyMap;
}
@Override
public int getInstantCountInterval() {
return 0;
}
@Override
public Map getInstantCount(long startTime) {
return emptyMap;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
static final Compass NOP_COMPASS = new Compass() {
@Override
public Map getErrorCodeCounts() {
return Collections.emptyMap();
}
@Override
public double getSuccessRate() {
return 0;
}
@Override
public long getSuccessCount() {
return 0;
}
@Override
public void update(long duration, TimeUnit unit) {
}
@Override
public void update(long duration, TimeUnit unit, boolean isSuccess, String errorCode, String addon) {
}
@Override
public T time(Callable event) throws Exception {
return event.call();
}
@Override
public Compass.Context time() {
return NOP_COMPASS_CONTEXT;
}
@Override
public long getCount() {
return 0;
}
@Override
public double getFifteenMinuteRate() {
return 0;
}
@Override
public double getFiveMinuteRate() {
return 0;
}
@Override
public double getMeanRate() {
return 0;
}
@Override
public double getOneMinuteRate() {
return 0;
}
@Override
public Snapshot getSnapshot() {
return NOP_SNAPSHOT;
}
@Override
public Map getInstantCount() {
return emptyMap;
}
@Override
public Map getAddonCounts() {
return emptyMap;
}
@Override
public BucketCounter getBucketSuccessCount() {
return NOP_BUCKET_COUNTER;
}
@Override
public int getInstantCountInterval() {
return 0;
}
@Override
public Map getInstantCount(long startTime) {
return emptyMap;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
static final FastCompass NOP_FAST_COMPASS = new FastCompass() {
@Override
public void record(long duration, String subCategory) {
}
@Override
public Map> getMethodCountPerCategory() {
return emptyMap;
}
@Override
public Map> getMethodRtPerCategory() {
return emptyMap;
}
@Override
public Map> getMethodCountPerCategory(long startTime) {
return emptyMap;
}
@Override
public Map> getMethodRtPerCategory(long startTime) {
return emptyMap;
}
@Override
public int getBucketInterval() {
return 0;
}
@Override
public Map> getCountAndRtPerCategory() {
return emptyMap;
}
@Override
public Map> getCountAndRtPerCategory(long startTime) {
return emptyMap;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
static final ClusterHistogram NOP_CLUSTER_HISTOGRAM = new ClusterHistogram() {
@Override
public void update(long value) {
}
@Override
public Map> getBucketValues(long startTime) {
return emptyMap;
}
@Override
public long lastUpdateTime() {
return 0;
}
};
private static final MetricRegistry NOP_REGISTRY = new MetricRegistry() {
@Override
public T register(String name, T metric) throws IllegalArgumentException {
return metric;
}
@Override
public T register(MetricName name, T metric) throws IllegalArgumentException {
return metric;
}
@Override
public void registerAll(MetricSet metrics) throws IllegalArgumentException {
}
@Override
public Counter counter(String name) {
return NOP_COUNTER;
}
@Override
public Counter counter(MetricName name) {
return NOP_COUNTER;
}
@Override
public Histogram histogram(MetricName name) {
return NOP_HISTOGRAM;
}
@Override
public Histogram histogram(MetricName name, ReservoirType type) {
return NOP_HISTOGRAM;
}
@Override
public Histogram histogram(String name) {
return NOP_HISTOGRAM;
}
@Override
public Meter meter(MetricName name) {
return NOP_METER;
}
@Override
public Meter meter(String name) {
return NOP_METER;
}
@Override
public Timer timer(MetricName name) {
return NOP_TIMER;
}
@Override
public Timer timer(String name) {
return NOP_TIMER;
}
@Override
public Timer timer(MetricName name, ReservoirType type) {
return NOP_TIMER;
}
@Override
public Compass compass(MetricName name) {
return NOP_COMPASS;
}
@Override
public Compass compass(String name) {
return NOP_COMPASS;
}
@Override
public Compass compass(MetricName name, ReservoirType type) {
return NOP_COMPASS;
}
@Override
public FastCompass fastCompass(MetricName name) {
return NOP_FAST_COMPASS;
}
@Override
public ClusterHistogram clusterHistogram(MetricName name, long[] buckets) {
return NOP_CLUSTER_HISTOGRAM;
}
@Override
public boolean remove(MetricName name) {
return false;
}
@Override
public void removeMatching(MetricFilter filter) {
}
@Override
public void addListener(MetricRegistryListener listener) {
}
@Override
public void removeListener(MetricRegistryListener listener) {
}
@Override
@SuppressWarnings("unchecked")
public SortedSet getNames() {
return emptySet;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getGauges() {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getGauges(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getCounters() {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getCounters(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getHistograms() {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getHistograms(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getMeters() {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getMeters(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getTimers() {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getTimers(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getCompasses(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getCompasses() {
return emptyMap;
}
@Override
public SortedMap getFastCompasses() {
return emptyMap;
}
@Override
public SortedMap getFastCompasses(MetricFilter filter) {
return emptyMap;
}
@Override
public SortedMap getClusterHistograms(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public SortedMap getMetrics(MetricFilter filter) {
return emptyMap;
}
@Override
@SuppressWarnings("unchecked")
public Map getMetrics() {
return emptyMap;
}
@Override
public long lastUpdateTime() {
return 0;
}
@Override
public SortedMap getClusterHistograms() {
return emptyMap;
}
};
@Override
public Map getMetrics(String group) {
return emptyMap;
}
@Override
public Map, Map> getCategoryMetrics(String group) {
return getCategoryMetrics(group, MetricFilter.ALL);
}
@Override
public Map, Map> getCategoryMetrics(String group,
MetricFilter filter) {
Map, Map> result = new HashMap, Map>();
Map gauges = Collections.emptyMap();
Map counters = Collections.emptyMap();
Map histograms = Collections.emptyMap();
Map meters = Collections.emptyMap();
Map timers = Collections.emptyMap();
Map compasses = Collections.emptyMap();
Map fastCompasses = Collections.emptyMap();
Map clusterHistogrames = Collections.emptyMap();
result.put(Gauge.class, gauges);
result.put(Counter.class, counters);
result.put(Histogram.class, histograms);
result.put(Meter.class, meters);
result.put(Timer.class, timers);
result.put(Compass.class, compasses);
result.put(FastCompass.class, fastCompasses);
result.put(ClusterHistogram.class, clusterHistogrames);
return result;
}
@Override
public void clear() {
}
@Override
public Map, Map> getAllCategoryMetrics(MetricFilter filter) {
return emptyMap;
}
@Override
public SortedMap getClusterHistogram(String group, MetricFilter filter) {
return emptyMap;
}
}