View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.omid.metrics;
19  
20  import org.slf4j.Logger;
21  import org.slf4j.LoggerFactory;
22  
23  public class NullMetricsProvider implements MetricsProvider, MetricsRegistry {
24  
25      private static final Logger LOG = LoggerFactory.getLogger(NullMetricsProvider.class);
26  
27      public NullMetricsProvider() {
28      }
29  
30      /* ********************************** MetricsProvider interface implementation ********************************** */
31  
32      @Override
33      public void startMetrics() {
34          LOG.info("Null metrics provider started");
35      }
36  
37      @Override
38      public void stopMetrics() {
39          LOG.info("Null metrics provider stopped");
40      }
41  
42      /* ********************************** MetricsRegistry interface implementation ********************************** */
43  
44      @Override
45      public <T extends Number> void gauge(String name, Gauge<T> gauge) {
46      }
47  
48      @Override
49      public Counter counter(final String name) {
50          return new Counter() {
51  
52              @Override
53              public void inc() {
54                  // Do nothing
55              }
56  
57              @Override
58              public void inc(long n) {
59                  // Do nothing
60              }
61  
62              @Override
63              public void dec() {
64                  // Do nothing
65              }
66  
67              @Override
68              public void dec(long n) {
69                  // Do nothing
70              }
71  
72          };
73  
74      }
75  
76      @Override
77      public Timer timer(final String name) {
78  
79          return new Timer() {
80              @Override
81              public void start() {
82                  // Do nothing
83              }
84  
85              @Override
86              public void stop() {
87                  // Do nothing
88              }
89  
90              @Override
91              public void update(long duration) {
92                  // Do nothing
93              }
94          };
95  
96      }
97  
98      @Override
99      public Meter meter(final String name) {
100 
101         return new Meter() {
102 
103             @Override
104             public void mark() {
105                 // Do nothing
106             }
107 
108             @Override
109             public void mark(long n) {
110                 // Do nothing
111             }
112 
113         };
114     }
115 
116     @Override
117     public Histogram histogram(final String name) {
118 
119         return new Histogram() {
120 
121             @Override
122             public void update(long value) {
123                 // Do nothing
124             }
125 
126             @Override
127             public void update(int value) {
128                 // Do nothing
129             }
130         };
131     }
132 
133     /* ********************************************** Private methods *********************************************** */
134 
135 }