当前位置: 首页>>代码示例>>Java>>正文


Java CuratorFrameworkFactory.Builder方法代码示例

本文整理汇总了Java中org.apache.curator.framework.CuratorFrameworkFactory.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java CuratorFrameworkFactory.Builder方法的具体用法?Java CuratorFrameworkFactory.Builder怎么用?Java CuratorFrameworkFactory.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.curator.framework.CuratorFrameworkFactory的用法示例。


在下文中一共展示了CuratorFrameworkFactory.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: curatorFramework

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
@Bean(destroyMethod = "close")
@ConditionalOnMissingBean
public CuratorFramework curatorFramework(AlbedoRpcProperties albedoRpcProperties, RetryPolicy retryPolicy) throws InterruptedException {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
    String namespace = environment.getProperty("albedo.rpc.namespace", albedoRpcProperties.getNamespace());
    AlbedoRpcProperties.Zookeeper zookeeper = albedoRpcProperties.getZookeeper();
    String connectString = environment.getProperty("albedo.rpc.zookeeper.connectString", zookeeper.getConnectString());
    Integer blockUntilConnectedWait = Integer.parseInt(environment.getProperty("albedo.rpc.zookeeper.blockUntilConnectedWait",
            zookeeper.getBlockUntilConnectedWait()+""));
    logger.info("CuratorFramework namespace {}", namespace);
    CuratorFramework curator = builder
            .retryPolicy(retryPolicy)
            .canBeReadOnly(true)
            .namespace(namespace)
            .connectString(connectString)
            .defaultData(null)
            .build();
    curator.blockUntilConnected(blockUntilConnectedWait,
            TimeUnit.SECONDS);
    curator.start();
    return curator;
}
 
开发者ID:somewhereMrli,项目名称:albedo-thrift,代码行数:23,代码来源:CommonAutoConfiguration.java

示例2: curatorFramework

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "close")
@Lazy(false)
public CuratorFramework curatorFramework() {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory
            .builder();
    int sessionTimeoutMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.session.timeout.ms", "5000"));
    int connectionTimeoutMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.connection.timeout.ms", "5000"));
    builder.connectString(
            env.getProperty("rpc.client.zookeeper.connect.string"))
            .sessionTimeoutMs(sessionTimeoutMs)
            .connectionTimeoutMs(connectionTimeoutMs)
           
            .retryPolicy(this.retryPolicy());
            //.aclProvider(this.aclProvider()).authorization(this.authInfo());
    return builder.build();
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:19,代码来源:HelloClientConfig.java

示例3: curatorFramework

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "close")
public CuratorFramework curatorFramework() {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory
            .builder();
    int sessionTimeoutMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.session.timeout.ms", "5000"));
    int connectionTimeoutMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.connection.timeout.ms", "5000"));
    builder.connectString(
            env.getProperty("rpc.client.zookeeper.connect.string"))
            .sessionTimeoutMs(sessionTimeoutMs)
            .connectionTimeoutMs(connectionTimeoutMs)	               
            .retryPolicy(this.retryPolicy())
            .aclProvider(this.aclProvider()).authorization(this.authInfo());
    return builder.build();
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:17,代码来源:HelloClientConfig.java

示例4: ZkService

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
/**
 * 创建ZK连接
 * @param connectString  ZK服务器地址列表
 * @param sessionTimeout   Session超时时间
 */
public ZkService(String connectString, int sessionTimeout) throws Exception {
    CuratorFrameworkFactory.Builder builder;
    builder = CuratorFrameworkFactory.builder()
            .connectString(connectString)
            .namespace("")
            .authorization("digest", auth.getBytes())
            .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
            .connectionTimeoutMs(sessionTimeout);

    client = builder.build();
    client.start();
    if(!client.blockUntilConnected(20, TimeUnit.SECONDS)) {
        throw new Exception("zookeeper connected failed!");
    }

    tableVersions = new HashMap<>();
    cache = new HashMap<>();
}
 
开发者ID:BriData,项目名称:DBus,代码行数:24,代码来源:ZkService.java

示例5: verifyZkStore

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
@Test
public void verifyZkStore() throws Exception {
  DrillConfig config = getConfig();
  String connect = config.getString(ExecConstants.ZK_CONNECTION);
  CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
  .namespace(config.getString(ExecConstants.ZK_ROOT))
  .retryPolicy(new RetryNTimes(1, 100))
  .connectionTimeoutMs(config.getInt(ExecConstants.ZK_TIMEOUT))
  .connectString(connect);

  try(CuratorFramework curator = builder.build()){
    curator.start();
    ZkPStoreProvider provider = new ZkPStoreProvider(config, curator);
    PStoreTestUtil.test(provider);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:TestPStoreProviders.java

示例6: applySecurityEnvironment

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
/**
 * Apply the security environment to this curator instance. This
 * may include setting up the ZK system properties for SASL
 * @param builder curator builder
 */
public void applySecurityEnvironment(CuratorFrameworkFactory.Builder builder) {

  if (isSecureRegistry()) {
    switch (access) {
      case anon:
        clearZKSaslClientProperties();
        break;

      case digest:
        // no SASL
        clearZKSaslClientProperties();
        builder.authorization(SCHEME_DIGEST, digestAuthData);
        break;

      case sasl:
        // bind to the current identity and context within the JAAS file
        setZKSaslClientProperties(jaasClientIdentity, jaasClientContext);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:RegistrySecurity.java

示例7: curatorFramework

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
@Bean
public CuratorFramework curatorFramework() {
    ZKConfig config = config();

    if (config.useZooKeeperWaitTimePolicy()) {
        return new RedirectorCuratorFramework(config);
    }

    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
            .connectString(config.getZooKeeperConnection())
            .connectionTimeoutMs(config.getZooKeeperConnectionTimeout())
            .sessionTimeoutMs(config.getZooKeeperSessionTimeout())
            .retryPolicy(new RetryNTimes(config.getZooKeeperRetryAttempts(), config.getZooKeeperRetryInterval()))
            .compressionProvider(new GzipCompressionProvider());

    return builder.build();
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:18,代码来源:AbstractCommonBeans.java

示例8: createConnection

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
private void createConnection() throws Exception {
  // Curator connection
  CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
  builder = builder.connectString(zkHostPort)
      .connectionTimeoutMs(zkSessionTimeout)
      .retryPolicy(new RetryNTimes(numRetries, zkRetryInterval));

  // Set up authorization based on fencing scheme
  List<AuthInfo> authInfos = new ArrayList<>();
  for (ZKUtil.ZKAuthInfo zkAuth : zkAuths) {
    authInfos.add(new AuthInfo(zkAuth.getScheme(), zkAuth.getAuth()));
  }
  if (useDefaultFencingScheme) {
    byte[] defaultFencingAuth =
        (zkRootNodeUsername + ":" + zkRootNodePassword).getBytes(
            Charset.forName("UTF-8"));
    authInfos.add(new AuthInfo(zkRootNodeAuthScheme, defaultFencingAuth));
  }
  builder = builder.authorization(authInfos);

  // Connect to ZK
  curatorFramework = builder.build();
  curatorFramework.start();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:25,代码来源:ZKRMStateStore.java

示例9: cleanUpZK

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
private void cleanUpZK() {
    String[] pathsTobeCleaned = {"/pravega", "/hostIndex", "/store", "/taskIndex"};

    RetryPolicy rp = new ExponentialBackoffRetry(1000, 3);
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
            .connectString(zkUrl)
            .connectionTimeoutMs(5000)
            .sessionTimeoutMs(5000)
            .retryPolicy(rp);
    @Cleanup
    CuratorFramework zclient = builder.build();
    zclient.start();
    for ( String path : pathsTobeCleaned ) {
        try {
            zclient.delete().guaranteed().deletingChildrenIfNeeded()
                    .forPath(path);
        } catch (Exception e) {
            log.warn("Not able to delete path {} . Exception {}", path, e.getMessage());
        }
    }
    zclient.close();
}
 
开发者ID:pravega,项目名称:pravega,代码行数:23,代码来源:InProcPravegaCluster.java

示例10: getLocalConnection

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
/**
 * Return a connection ot the ZK instance (creating it if needed)
 *
 * @return connection
 * @throws IOException errors
 */
public synchronized CuratorFramework getLocalConnection() throws IOException
{
    if ( localConnection == null )
    {
        CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
            .connectString("localhost:" + configManager.getConfig().getInt(IntConfigs.CLIENT_PORT))
            .sessionTimeoutMs(arguments.connectionTimeOutMs * 10)
            .connectionTimeoutMs(arguments.connectionTimeOutMs)
            .retryPolicy(new ExponentialBackoffRetry(1000, 3));

        if ( arguments.aclProvider != null )
        {
            builder = builder.aclProvider(arguments.aclProvider);
        }

        localConnection = builder.build();
        localConnection.start();
    }
    return localConnection;
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:27,代码来源:Exhibitor.java

示例11: start

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
public void start() {
	CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
	zkClient = builder.connectString(getServerConnectionString()).namespace(ZK_NAMESPACE)
			.retryPolicy(new RetryOneTime(1)).connectionTimeoutMs(1).sessionTimeoutMs(140).build();
	zkClient.start();
	RegistryContext.clientCache.putIfAbsent("curatorClient", zkClient);
}
 
开发者ID:polarcoral,项目名称:monica,代码行数:8,代码来源:ZookeeperMonicaClient.java

示例12: init

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
@Override
public void init() {
	logger.debug("init zookeeper registry, connect to servers : {}", zkConfig.getServerLists());
	CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(zkConfig.getServerLists()).retryPolicy(new ExponentialBackoffRetry(zkConfig.getBaseSleepTimeMilliseconds(), zkConfig.getMaxRetries(), zkConfig.getMaxSleepTimeMilliseconds())).namespace(zkConfig.getNamespace());
	if (0 != zkConfig.getSessionTimeoutMilliseconds()) {
		builder.sessionTimeoutMs(zkConfig.getSessionTimeoutMilliseconds());
	}
	if (0 != zkConfig.getConnectionTimeoutMilliseconds()) {
		builder.connectionTimeoutMs(zkConfig.getConnectionTimeoutMilliseconds());
	}
	if (zkConfig.getDigest() != null && !zkConfig.getDigest().isEmpty()) {
		builder.authorization("digest", zkConfig.getDigest().getBytes(StandardCharsets.UTF_8)).aclProvider(new ACLProvider() {

			@Override
			public List<ACL> getDefaultAcl() {
				return ZooDefs.Ids.CREATOR_ALL_ACL;
			}

			@Override
			public List<ACL> getAclForPath(final String path) {
				return ZooDefs.Ids.CREATOR_ALL_ACL;
			}
		});
	}
	client = builder.build();
	client.start();
	try {
		if (!client.blockUntilConnected(zkConfig.getMaxSleepTimeMilliseconds() * zkConfig.getMaxRetries(), TimeUnit.MILLISECONDS)) {
			client.close();
			throw new KeeperException.OperationTimeoutException();
		}
	} catch (final Exception ex) {
		RegExceptionHandler.handleException(ex);
	}
}
 
开发者ID:imadcn,项目名称:idworker,代码行数:36,代码来源:ZookeeperRegistryCenter.java

示例13: createCurator

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
private CuratorFramework createCurator(ZKConfig config) {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(config.getZooKeeperConnection())
        .connectionTimeoutMs(config.getZooKeeperConnectionTimeout())
        .sessionTimeoutMs(config.getZooKeeperSessionTimeout())
        .retryPolicy(new RetryNTimes(config.getZooKeeperRetryAttempts(), config.getZooKeeperRetryInterval()));

    builder.compressionProvider(new GzipCompressionProvider());
    return builder.build();
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:11,代码来源:DataStoreSupport.java

示例14: buildCuratorFramework

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
private synchronized CuratorFramework buildCuratorFramework(final ZKConfig config) {

        CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
                .connectString(config.getZooKeeperConnection())
                .connectionTimeoutMs(config.getZooKeeperConnectionTimeout())
                .sessionTimeoutMs(config.getZooKeeperSessionTimeout())
                .retryPolicy(new RetryNTimes(config.getZooKeeperRetryAttempts(), config.getZooKeeperRetryInterval()))
                .compressionProvider(new GzipCompressionProvider());

        CuratorFramework framework = builder.build();
        listenerStateProxy.updateCurator(framework);
        listenerProxy.updateCurator(framework);
        return framework;
    }
 
开发者ID:Comcast,项目名称:redirector,代码行数:15,代码来源:RedirectorCuratorFramework.java

示例15: newCurator

import org.apache.curator.framework.CuratorFrameworkFactory; //导入方法依赖的package包/类
public static CuratorFramework newCurator(Map conf , List<String> servers , Object port, String root, ZookeeperAuthInfo info)
{
	List<String> serverPorts = new ArrayList<>();
	for(String zkServer : servers)
	{
		serverPorts.add(zkServer + ":" + Utils.getInt(port));
	}
	String zkStr = StringUtils.join(serverPorts,',') + PathUtils.normalize_path(root);
	CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();

	setupBuilder(builder,zkStr,conf,info);

	return builder.build();
}
 
开发者ID:weizhenyi,项目名称:leaf-snowflake,代码行数:15,代码来源:Utils.java


注:本文中的org.apache.curator.framework.CuratorFrameworkFactory.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。