// Path: hangout-core/src/main/java/com/ctrip/ops/sysdev/baseplugin/BaseMetric.java
// public abstract class BaseMetric extends Base {
//     public BaseMetric(Map config) {
//         super(config);
//     }
// 
//     public void register() {
//     }
// }
// 
// Path: hangout-core/src/main/java/com/ctrip/ops/sysdev/metric/Metric.java
// public  class Metric {
// 
//     private static MetricRegistry metricRegistry = new MetricRegistry();
// 
//     public static Meter setMetric(String metricName) {
//         return metricRegistry.meter(metricName);
//     }
// 
//     public static MetricRegistry getMetricRegistry()
//     {
//         return metricRegistry;
//     }
// }


import com.codahale.metrics.health.HealthCheckRegistry;
import com.codahale.metrics.servlets.AdminServlet;
import com.codahale.metrics.servlets.HealthCheckServlet;
import com.codahale.metrics.servlets.MetricsServlet;
import com.ctrip.ops.sysdev.baseplugin.BaseMetric;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.server.handlers.PathHandler;
import io.undertow.servlet.Servlets;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.DeploymentManager;
import lombok.extern.log4j.Log4j2;
import javax.servlet.ServletException;
import java.util.Map;
import com.ctrip.ops.sysdev.metric.Metric;
package com.ctrip.ops.sysdev.metrics;






/**
 * Created by liujia on 17/7/4.
 */
@Log4j2
public class Watcher extends BaseMetric {


    private final String host;
    private final int port;
    private HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();

    public Watcher(Map config) {
        super(config);

        this.host = (String) config.get("host");
        this.port = (Integer) config.get("port");

    }

    public void register() {
        Runnable task = () -> {
            DeploymentInfo servletBuilder = Servlets.deployment()
                    .setClassLoader(Watcher.class.getClassLoader())
                    .setContextPath("/")
                    .setDeploymentName("admin.war")
// Path: hangout-core/src/main/java/com/ctrip/ops/sysdev/baseplugin/BaseMetric.java
// public abstract class BaseMetric extends Base {
//     public BaseMetric(Map config) {
//         super(config);
//     }
// 
//     public void register() {
//     }
// }
// 
// Path: hangout-core/src/main/java/com/ctrip/ops/sysdev/metric/Metric.java
// public  class Metric {
// 
//     private static MetricRegistry metricRegistry = new MetricRegistry();
// 
//     public static Meter setMetric(String metricName) {
//         return metricRegistry.meter(metricName);
//     }
// 
//     public static MetricRegistry getMetricRegistry()
//     {
//         return metricRegistry;
//     }
// }


// Path: hangout-metric-plugins/hangout-metric-watcher/src/main/java/com/ctrip/ops/sysdev/metrics/Watcher.java
import com.codahale.metrics.health.HealthCheckRegistry;
import com.codahale.metrics.servlets.AdminServlet;
import com.codahale.metrics.servlets.HealthCheckServlet;
import com.codahale.metrics.servlets.MetricsServlet;
import com.ctrip.ops.sysdev.baseplugin.BaseMetric;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.server.handlers.PathHandler;
import io.undertow.servlet.Servlets;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.DeploymentManager;
import lombok.extern.log4j.Log4j2;
import javax.servlet.ServletException;
import java.util.Map;
import com.ctrip.ops.sysdev.metric.Metric;

package com.ctrip.ops.sysdev.metrics;






/**
 * Created by liujia on 17/7/4.
 */
@Log4j2
public class Watcher extends BaseMetric {


    private final String host;
    private final int port;
    private HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();

    public Watcher(Map config) {
        super(config);

        this.host = (String) config.get("host");
        this.port = (Integer) config.get("port");

    }

    public void register() {
        Runnable task = () -> {
            DeploymentInfo servletBuilder = Servlets.deployment()
                    .setClassLoader(Watcher.class.getClassLoader())
                    .setContextPath("/")
                    .setDeploymentName("admin.war")
                    .addServletContextAttribute(MetricsServlet.METRICS_REGISTRY, Metric.getMetricRegistry())