Search in sources :

Example 1 with ClusterConfigurationMonitor

use of org.apache.knox.gateway.topology.discovery.ClusterConfigurationMonitor in project knox by apache.

the class AmbariServiceDiscovery method getConfigurationChangeMonitor.

/**
 * Get the Ambari configuration change monitor from the associated gateway service.
 */
private AmbariConfigurationMonitor getConfigurationChangeMonitor() {
    AmbariConfigurationMonitor ambariMonitor = null;
    try {
        Class<?> clazz = Class.forName(GATEWAY_SERVICES_ACCESSOR_CLASS);
        if (clazz != null) {
            Method m = clazz.getDeclaredMethod(GATEWAY_SERVICES_ACCESSOR_METHOD);
            if (m != null) {
                Object obj = m.invoke(null);
                if (GatewayServices.class.isAssignableFrom(obj.getClass())) {
                    ClusterConfigurationMonitorService clusterMonitorService = ((GatewayServices) obj).getService(GatewayServices.CLUSTER_CONFIGURATION_MONITOR_SERVICE);
                    ClusterConfigurationMonitor monitor = clusterMonitorService.getMonitor(AmbariConfigurationMonitor.getType());
                    if (monitor != null) {
                        if (AmbariConfigurationMonitor.class.isAssignableFrom(monitor.getClass())) {
                            ambariMonitor = (AmbariConfigurationMonitor) monitor;
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        log.errorAccessingConfigurationChangeMonitor(e);
    }
    return ambariMonitor;
}
Also used : ClusterConfigurationMonitorService(org.apache.knox.gateway.topology.ClusterConfigurationMonitorService) GatewayServices(org.apache.knox.gateway.services.GatewayServices) ClusterConfigurationMonitor(org.apache.knox.gateway.topology.discovery.ClusterConfigurationMonitor) JSONObject(net.minidev.json.JSONObject) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 JSONObject (net.minidev.json.JSONObject)1 GatewayServices (org.apache.knox.gateway.services.GatewayServices)1 ClusterConfigurationMonitorService (org.apache.knox.gateway.topology.ClusterConfigurationMonitorService)1 ClusterConfigurationMonitor (org.apache.knox.gateway.topology.discovery.ClusterConfigurationMonitor)1