Package com.netflix.curator.framework

Examples of com.netflix.curator.framework.CuratorFramework


        // Load the config.yaml file specified as the first argument.
        CalculatorConfiguration config = ConfigurationFactory
                .forClass(CalculatorConfiguration.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


    /**
     * 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 PORT;
    }

    public static IZkConnection createZkConnection(String connectString) {
        Timing                  timing = new Timing();
        CuratorFramework        client = CuratorFrameworkFactory.newClient(connectString, timing.session(), timing.connection(), new RetryOneTime(1));
        client.start();
        try
        {
            return new CuratorZKClientBridge(client);
        }
        catch ( Exception e )
View Full Code Here

    }

    public CuratorFramework newCurator(CuratorFrameworkFactory.Builder builder) throws Exception {
        assertNotNull("ZooKeeper testing server is null, did you forget to call super.setup()", _zooKeeperServer);

        CuratorFramework curator = builder.connectString(_instanceSpec.getConnectString()).build();
        curator.start();

        _curatorInstances.add(curator);

        return curator;
    }
View Full Code Here

  public static void initializeAndStartZkConfigSource() throws Exception {
        String zkConfigEnsemble = DynamicPropertyFactory.getInstance().getStringProperty(FluxConstants.ZK_CONFIG_ENSEMBLE, "not-found-in-flux-configuration").get();
        String zkConfigRootPath = DynamicPropertyFactory.getInstance().getStringProperty(FluxConstants.ZK_CONFIG_ROOT_PATH, "not-found-in-flux-configuration").get();

        // ZooKeeper Dynamic Override Properties
        CuratorFramework client = ZooKeeperClientFactory.getStartedZKClient(zkConfigEnsemble);
       
        if (client.getState() != CuratorFrameworkState.STARTED) {
          throw new RuntimeException("ZooKeeper located at " + zkConfigEnsemble + " is not started.");
        }
       
      ZooKeeperConfigurationSource zookeeperConfigSource = new ZooKeeperConfigurationSource(
                client, zkConfigRootPath);
View Full Code Here

        ZooKeeperClientCacheItem cachedItem = cache.getIfPresent(ensemble);
        if (cachedItem != null) {
            return cachedItem.client;
        }

        CuratorFramework client = CuratorFrameworkFactory.newClient(ensemble,
                DynamicPropertyFactory.getInstance().getIntProperty("zookeeper.session.timeout", Integer.MIN_VALUE).get(),
                DynamicPropertyFactory.getInstance().getIntProperty("zookeeper.connection.timeout", Integer.MIN_VALUE).get(),
                new ExponentialBackoffRetry(1000, 3));
      
        client.start();

        cache.put(ensemble, new ZooKeeperClientCacheItem(ensemble, client));

        logger.info("Created, started, and cached zk client [{}] for ensemble [{}]", client, ensemble);
View Full Code Here

        ConfigurationFactory<DictionaryConfiguration> configFactory = ConfigurationFactory.forClass(
                DictionaryConfiguration.class, new Validator());
        DictionaryConfiguration configuration = configFactory.build(new File(args[0]));

        CuratorFramework curator = newCurator(configuration.getZooKeeperConfiguration());

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

        ServicePoolProxies.close(service);
        Closeables.closeQuietly(curator);
    }

    private static CuratorFramework newCurator(ZooKeeperConfiguration config) {
        CuratorFramework curator = CuratorFrameworkFactory.newClient(config.getConnectString(), config.getRetry());
        curator.start();

        return curator.usingNamespace(config.getNamespace());
    }
View Full Code Here

        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument.
        DictionaryConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        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

                .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

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.