Package com.netflix.curator.framework

Examples of com.netflix.curator.framework.CuratorFramework


    private ObjectMapper getJson(Environment env) {
        return env.getObjectMapperFactory().build();
    }

    private static CuratorFramework newCurator(ZooKeeperConfiguration config, Environment env) {
        CuratorFramework curator = CuratorFrameworkFactory.newClient(config.getConnectString(), config.getRetry());
        if (!Strings.isNullOrEmpty(config.getNamespace())) {
            curator = curator.usingNamespace(config.getNamespace());
        }

        env.manage(new ManagedCuratorFramework(curator));
        return curator;
    }
View Full Code Here


                .withServiceName(env.getName())
                .withId(host + ":" + port)
                .withPayload(getJson(env).writeValueAsString(payload))
                .build();

        final CuratorFramework curator = config.getZooKeeperConfiguration().newManagedCurator(env);
        env.manage(new Managed() {
            ZooKeeperServiceRegistry registry = new ZooKeeperServiceRegistry(curator);

            @Override
            public void start() throws Exception {
View Full Code Here

    /**
     * Return a managed Curator connection.  This created connection will be wrapped in a
     * {@link ManagedCuratorFramework} and offered to the provided {@link Environment} parameter.
     */
    public CuratorFramework newManagedCurator(Environment env) {
        CuratorFramework curator = newCurator();
        env.manage(new ManagedCuratorFramework(curator));
        return curator;
    }
View Full Code Here

    /**
     * Return a managed Curator connection.  This created connection will be wrapped in a
     * {@link ManagedCuratorFramework} and offered to the provided {@link Environment} parameter.
     */
    public CuratorFramework newManagedCurator(Environment env) {
        CuratorFramework curator = newCurator();
        env.manage(new ManagedCuratorFramework(curator));
        return curator;
    }
View Full Code Here

        // Load the config.yaml file specified as the first argument.
        DictionaryConfiguration config = ConfigurationFactory
                .forClass(DictionaryConfiguration.class, new Validator())
                .build(new File(args[0]));

        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();

        // Connection caching is optional, but included here for the sake of demonstration.
        ServiceCachingPolicy cachingPolicy = new ServiceCachingPolicyBuilder()
                .withMaxNumServiceInstances(10)
                .withMaxNumServiceInstancesPerEndPoint(1)
View Full Code Here

        final ZooKeeperConfiguration.Auth auth = zkConfiguration.getAuth();
        if (auth != null) {
            builder.authorization(auth.getScheme(), auth.getId());
        }

        final CuratorFramework framework = builder.build();

        environment.addHealthCheck(new CuratorHealthCheck(framework, name));
        environment.manage(new ManagedCuratorFramework(framework));

        return framework;
View Full Code Here

                .withServiceName(env.getName())
                .withId(host + ":" + port)
                .withPayload(getJson(env).writeValueAsString(payload))
                .build();

        final CuratorFramework curator = newCurator(config.getZooKeeperConfiguration(), env);
        env.manage(new Managed() {
            ZooKeeperServiceRegistry registry = new ZooKeeperServiceRegistry(curator);

            @Override
            public void start() throws Exception {
View Full Code Here

    private ObjectMapper getJson(Environment env) {
        return env.getObjectMapperFactory().build();
    }

    private static CuratorFramework newCurator(ZooKeeperConfiguration config, Environment env) {
        CuratorFramework curator = CuratorFrameworkFactory.newClient(config.getConnectString(), config.getRetry());
        if (!Strings.isNullOrEmpty(config.getNamespace())) {
            curator = curator.usingNamespace(config.getNamespace());
        }

        env.manage(new ManagedCuratorFramework(curator));
        return curator;
    }
View Full Code Here

        try {
            conf = new HashMap(conf);
            String rootDir = conf.get(Config.TRANSACTIONAL_ZOOKEEPER_ROOT) + "/" + id + "/" + subroot;
            List<String> servers = (List<String>) getWithBackup(conf, Config.TRANSACTIONAL_ZOOKEEPER_SERVERS, Config.STORM_ZOOKEEPER_SERVERS);
            Object port = getWithBackup(conf, Config.TRANSACTIONAL_ZOOKEEPER_PORT, Config.STORM_ZOOKEEPER_PORT);
            CuratorFramework initter = Utils.newCuratorStarted(conf, servers, port);
            try {
                initter.create().creatingParentsIfNeeded().forPath(rootDir);
            } catch(KeeperException.NodeExistsException e)  {
               
            }
           
            initter.close();
                                   
            _curator = Utils.newCuratorStarted(conf, servers, port, rootDir);
        } catch (Exception e) {
           throw new RuntimeException(e);
        }
View Full Code Here

    public static CuratorFramework newCurator(Map conf, List<String> servers, Object port) {
        return newCurator(conf, servers, port, "");
    }

    public static CuratorFramework newCuratorStarted(Map conf, List<String> servers, Object port, String root) {
        CuratorFramework ret = newCurator(conf, servers, port, root);
        ret.start();
        return ret;
    }
View Full Code Here

TOP

Related Classes of com.netflix.curator.framework.CuratorFramework

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.