Search in sources :

Example 6 with BootstrapException

use of com.kixeye.chassis.bootstrap.BootstrapException in project chassis by Kixeye.

the class DynamicZookeeperConfigurationSource method initializeZookeeperConfigurationSource.

private void initializeZookeeperConfigurationSource() {
    if (running) {
        LOGGER.warn("Detected creation of node {}, but zookeeper configuration source already running. This should not happen. Ignoring event...", instanceConfigPath);
        return;
    }
    this.zooKeeperConfigurationSource = new ZooKeeperConfigurationSource(curatorFramework, instanceConfigPath);
    listeners.forEach(new Function<WatchedUpdateListener, Void>() {

        @Nullable
        @Override
        public Void apply(@Nullable WatchedUpdateListener watchedUpdateListener) {
            zooKeeperConfigurationSource.addUpdateListener(watchedUpdateListener);
            return null;
        }
    });
    try {
        zooKeeperConfigurationSource.start();
    } catch (Exception e) {
        LOGGER.error("errro starting zookeeper configuration source", e);
        throw new BootstrapException("Error initializing zookeeper configuration source", e);
    }
    running = true;
}
Also used : ZooKeeperConfigurationSource(com.netflix.config.source.ZooKeeperConfigurationSource) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) WatchedUpdateListener(com.netflix.config.WatchedUpdateListener) Nullable(javax.annotation.Nullable) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) IOException(java.io.IOException)

Example 7 with BootstrapException

use of com.kixeye.chassis.bootstrap.BootstrapException in project chassis by Kixeye.

the class ServerInstanceContext method initExhibitor.

private void initExhibitor() {
    LOGGER.info("Initializing exhibitor info...");
    List<LoadBalancerDescription> loadBalancers = AwsUtils.findLoadBalancers(amazonElasticLoadBalancing, new ZookeeperElbFilter(environment));
    if (loadBalancers.size() == 0) {
        LOGGER.info("No Zookeeper ELBs for environment " + environment);
        return;
    } else if (loadBalancers.size() != 1) {
        throw new BootstrapException("Found multiple Zookeeper ELBs for environment " + environment);
    }
    LoadBalancerDescription loadBalancer = loadBalancers.get(0);
    ListenerDescription exhibitorListenerDescription = getExhibitorListenerDescription(loadBalancer);
    this.exhibitorHost = loadBalancer.getDNSName();
    this.exhibitorPort = exhibitorListenerDescription.getListener().getLoadBalancerPort();
    LOGGER.info("Initialized exhibitor info with: exhibitorHost: {}, exhibitorPort: {}", exhibitorHost, exhibitorPort);
}
Also used : ListenerDescription(com.amazonaws.services.elasticloadbalancing.model.ListenerDescription) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)

Example 8 with BootstrapException

use of com.kixeye.chassis.bootstrap.BootstrapException in project chassis by Kixeye.

the class ZookeeperConfigurationWriter method deleteKey.

private void deleteKey(String key) {
    try {
        LOGGER.info("deleting key {}...", key);
        curatorFramework.delete().forPath(key);
    } catch (Exception e) {
        throw new BootstrapException("Failed to delete key " + key, e);
    }
}
Also used : BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) NodeExistsException(org.apache.zookeeper.KeeperException.NodeExistsException)

Aggregations

BootstrapException (com.kixeye.chassis.bootstrap.BootstrapException)8 IOException (java.io.IOException)4 CuratorFramework (org.apache.curator.framework.CuratorFramework)3 NodeExistsException (org.apache.zookeeper.KeeperException.NodeExistsException)2 ListenerDescription (com.amazonaws.services.elasticloadbalancing.model.ListenerDescription)1 LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)1 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)1 WatchedUpdateListener (com.netflix.config.WatchedUpdateListener)1 ZooKeeperConfigurationSource (com.netflix.config.source.ZooKeeperConfigurationSource)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 StringTokenizer (java.util.StringTokenizer)1 TreeSet (java.util.TreeSet)1 Nullable (javax.annotation.Nullable)1 ExhibitorEnsembleProvider (org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider)1 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)1 PathChildrenCacheEvent (org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent)1 PathChildrenCacheListener (org.apache.curator.framework.recipes.cache.PathChildrenCacheListener)1 ConnectionState (org.apache.curator.framework.state.ConnectionState)1