/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.reporting;

import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;

/**
 * Maintains metrics registry that is provided to reporters.
 * At the moment only one reporter exists {@code JmxReporter}.
 * More reporters can be added.
 * <p/>
 * The consumers of this class will only be interested in {@code MetricsRegistry}
 * where metrics for that consumer gets stored.
 */
public class MetricsReporter implements AutoCloseable{

    private final MetricRegistry METRICS_REGISTRY = new MetricRegistry();
    private final String DOMAIN = "org.opendaylight.controller.actor.metric";

    public final JmxReporter jmxReporter = JmxReporter.forRegistry(METRICS_REGISTRY).inDomain(DOMAIN).build();

    private static MetricsReporter inst = new MetricsReporter();

    private MetricsReporter(){
        jmxReporter.start();
    }

    public static MetricsReporter getInstance(){
        return inst;
    }

    public MetricRegistry getMetricsRegistry(){
        return METRICS_REGISTRY;
    }

    @Override
    public void close() throws Exception {
        jmxReporter.close();
    }
}

@@ -798,16 +798,17 @@
 loseable
+ 
 %7B%0A%0A    p
@@ -810,24 +810,31 @@
     private 
+static 
 final Metric
@@ -895,16 +895,23 @@
 private 
+static 
 final St
@@ -968,27 +968,103 @@
 etric%22;%0A
-%0A
     p
-ublic
+rivate static final MetricsReporter INSTANCE = new MetricsReporter();%0A%0A    private
  final J
@@ -1173,74 +1173,8 @@
 ate 
-static MetricsReporter inst = new MetricsReporter();%0A%0A    private 
 Metr
@@ -1186,16 +1186,17 @@
 porter()
+ 
 %7B%0A      
@@ -1272,16 +1272,17 @@
 stance()
+ 
 %7B%0A      
@@ -1294,12 +1294,16 @@
 urn 
-inst
+INSTANCE
 ;%0A  
@@ -1353,16 +1353,17 @@
 gistry()
+ 
 %7B%0A      
@@ -1437,25 +1437,8 @@
 se()
- throws Exception
  %7B%0A 

Optimize MetricsReporter class