2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.metricservice.impl;
28 import java.util.concurrent.ConcurrentHashMap;
30 import org.openecomp.appc.metricservice.MetricRegistry;
31 import org.openecomp.appc.metricservice.metric.Counter;
32 import org.openecomp.appc.metricservice.metric.Metric;
33 import org.openecomp.appc.metricservice.metric.MetricBuilderFactory;
34 import org.openecomp.appc.metricservice.metric.impl.MetricBuilderFactoryImpl;
35 import org.openecomp.appc.metricservice.policy.PolicyBuilderFactory;
36 import org.openecomp.appc.metricservice.policy.PublishingPolicy;
37 import org.openecomp.appc.metricservice.policy.impl.PolicyBuilderFactoryImpl;
40 public class MetricRegistryImpl implements MetricRegistry {
42 private Map<String,Metric> concurrentMetricMap=new ConcurrentHashMap<String,Metric>();
44 public MetricRegistryImpl(String name) {
49 public boolean register(Metric metric) {
50 if(concurrentMetricMap.get(metric.name())==null){
51 concurrentMetricMap.put(metric.name(),metric);
58 public void attach(PublishingPolicy publishPolicy) {
63 public MetricBuilderFactory metricBuilderFactory() {
64 return new MetricBuilderFactoryImpl();
68 public PolicyBuilderFactory policyBuilderFactory() {
69 return new PolicyBuilderFactoryImpl() ;
73 public Counter counter(String value) {
74 if(concurrentMetricMap.get(value)!=null )
75 return (Counter)concurrentMetricMap.get(value) ;
82 public Counter[] counters() {
83 return (Counter[])concurrentMetricMap.values().toArray();
87 public Metric[] metrics() {
88 java.util.Collection<Metric> var = concurrentMetricMap.values();
89 return var.toArray(new Metric[var.size()]);
93 public Metric metric(String metricName) {
94 return concurrentMetricMap.get(metricName);
98 public void dispose() {
99 concurrentMetricMap.clear();