Search in sources :

Example 1 with ZooKeeperFacade

use of io.fabric8.core.jmx.ZooKeeperFacade in project fabric8 by jboss-fuse.

the class GroovyPlaceholderResolver method resolveValue.

/**
 * Returns the replacement of groovy expressions on the given string value.
 */
public static String resolveValue(CuratorFramework curator, String value) {
    try {
        Binding binding = new Binding();
        ZooKeeperFacade zk = new ZooKeeperFacade(curator);
        binding.setVariable("zk", zk);
        binding.setVariable("env", System.getenv());
        binding.setVariable("sys", System.getProperties());
        GroovyShell shell = new GroovyShell(binding);
        String expression = value;
        if (expression.startsWith(RESOLVER_SCHEME + ":")) {
            expression = expression.substring(RESOLVER_SCHEME.length() + 1);
        }
        Object result = shell.evaluate(expression);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("groovy expression: " + expression + " => " + result);
        }
        if (result != null) {
            return result.toString();
        }
        return "";
    } catch (Exception e) {
        throw FabricException.launderThrowable(e);
    }
}
Also used : Binding(groovy.lang.Binding) ZooKeeperFacade(io.fabric8.zookeeper.utils.ZooKeeperFacade) GroovyShell(groovy.lang.GroovyShell) FabricException(io.fabric8.api.FabricException)

Example 2 with ZooKeeperFacade

use of io.fabric8.core.jmx.ZooKeeperFacade in project fabric8 by jboss-fuse.

the class FabricMBeanRegistrationListener method registerFabricMBeans.

private void registerFabricMBeans() {
    this.healthCheck = new HealthCheck(fabricService.get());
    this.managerMBean = new FabricManager((FabricServiceImpl) fabricService.get());
    this.zooKeeperMBean = new ZooKeeperFacade((FabricServiceImpl) fabricService.get());
    this.fileSystemMBean = new FileSystem(runtimeProperties.get());
    healthCheck.registerMBeanServer(shutdownTracker, mbeanServer.get());
    managerMBean.registerMBeanServer(shutdownTracker, mbeanServer.get());
    fileSystemMBean.registerMBeanServer(shutdownTracker, mbeanServer.get());
    zooKeeperMBean.registerMBeanServer(shutdownTracker, mbeanServer.get());
}
Also used : FabricManager(io.fabric8.core.jmx.FabricManager) ZooKeeperFacade(io.fabric8.core.jmx.ZooKeeperFacade) FileSystem(io.fabric8.core.jmx.FileSystem) HealthCheck(io.fabric8.core.jmx.HealthCheck)

Aggregations

Binding (groovy.lang.Binding)1 GroovyShell (groovy.lang.GroovyShell)1 FabricException (io.fabric8.api.FabricException)1 FabricManager (io.fabric8.core.jmx.FabricManager)1 FileSystem (io.fabric8.core.jmx.FileSystem)1 HealthCheck (io.fabric8.core.jmx.HealthCheck)1 ZooKeeperFacade (io.fabric8.core.jmx.ZooKeeperFacade)1 ZooKeeperFacade (io.fabric8.zookeeper.utils.ZooKeeperFacade)1