• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java InterProcessReadWriteLock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock的典型用法代码示例。如果您正苦于以下问题:Java InterProcessReadWriteLock类的具体用法?Java InterProcessReadWriteLock怎么用?Java InterProcessReadWriteLock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InterProcessReadWriteLock类属于org.apache.curator.framework.recipes.locks包,在下文中一共展示了InterProcessReadWriteLock类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: CacheClusterViewer

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
public CacheClusterViewer(Config config) throws RuntimeException {
    try {
        if (config == null) {
            config = ConfigFactory.load();
        }

        this.zookeeperConnectionUrl = config.getString("zookeeper.connection_url");

        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        zkClient = CuratorFrameworkFactory.newClient(zookeeperConnectionUrl, retryPolicy);
        zkClient.start();

        clusterGlobalLock = new InterProcessReadWriteLock(zkClient, Constants.CACHE_CLUSTER_PATH);

        cacheCluster = doGetCacheClusterMeta();

        monitorThread = new Thread(new ClusterStatusMonitor());
        monitorThread.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:alain898,项目名称:distributed-search-cache,代码行数:23,代码来源:CacheClusterViewer.java


示例2: CacheClusterService

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
private CacheClusterService(Config config) {
    try {
        if (config == null) {
            config = ConfigFactory.load();
        }

        this.zookeeperConnectionUrl = config.getString("zookeeper.connection_url");

        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        zkClient = CuratorFrameworkFactory.newClient(zookeeperConnectionUrl, retryPolicy);
        zkClient.start();

        clusterGlobalLock = new InterProcessReadWriteLock(zkClient, Constants.CACHE_CLUSTER_PATH);

        cacheClusterViewer = CacheClusterViewerFactory.getCacheClusterViewer();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:alain898,项目名称:distributed-search-cache,代码行数:20,代码来源:CacheClusterService.java


示例3: ZkConfig

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
public ZkConfig(String connectStr,String baseDir,boolean readonly){
    this.readonly = readonly;
    client = CuratorFrameworkFactory.builder().connectString(connectStr)
            .namespace(baseDir).retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
            .connectionTimeoutMs(5000).build();
    client.start();
    try {
        client.blockUntilConnected();
        nameslock = new ZkDistributedRwLock( new InterProcessReadWriteLock(client, STORE_NAMES_Lock_PATH));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:linsongze,项目名称:consistent_config,代码行数:14,代码来源:ZkConfig.java


示例4: configure

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
/**
 * this function will lock the cache cluster to guarantee the integrity of CacheClusterMeta
 * in CacheClusterViewer, so must not call it during the cluster is locked.
 * <p>
 * on cache cluster servers, this function should be called before starting cache services to
 * make sure the deadlock dose not happen.
 * <p>
 * on cache cluster clients, it's recommend this method called only once before getInstance
 * called, then all calls of getInstance will return the same CacheClusterViewer instance.
 */
public static void configure(Config config) throws Exception {
    if (config == null) {
        config = ConfigFactory.load();
    }

    String zookeeperConnectionUrl = config.getString("zookeeper.connection_url");
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    CuratorFramework zkClient = CuratorFrameworkFactory.newClient(zookeeperConnectionUrl, retryPolicy);
    zkClient.start();

    InterProcessReadWriteLock clusterGlobalLock =
            new InterProcessReadWriteLock(zkClient, Constants.CACHE_CLUSTER_PATH);
    clusterGlobalLock.readLock().acquire();
    try {
        cacheClusterViewer = new CacheClusterViewer(config);
    } finally {
        try {
            clusterGlobalLock.readLock().release();
        } catch (Exception e) {
            logger.error(String.format("failed to release clusterGlobalLock on zknode[%s]",
                    Constants.CACHE_CLUSTER_PATH), e);
        }
    }

    zkClient.close();
}
 
开发者ID:alain898,项目名称:distributed-search-cache,代码行数:37,代码来源:CacheClusterViewerFactory.java


示例5: ZooKeeperServiceRegistry

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
/**
 * This establishes the connection to zookeeper so that we can look up services.
 */
public ZooKeeperServiceRegistry(String zookeeperConnectString) {
    // We don't use .namespace() since we need the data stored in its own
    // path to maintain backwards-compatibility. We fake namespaces on our
    // own in formatZooKeeperApplicationPath.
    client = CuratorFrameworkFactory.builder()
            .connectString(zookeeperConnectString)
            .retryPolicy(new RetryNTimes(DEFAULT_MAX_NUM_OF_TRIES, DEFAULT_TIMEOUT))
            .build();
    client.start();

    readWriteLock = new InterProcessReadWriteLock(client, GLOBAL_LOCK_PATH);
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:16,代码来源:ZooKeeperServiceRegistry.java


示例6: ExampleClientReadWriteLocks

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
public ExampleClientReadWriteLocks(CuratorFramework client, String lockPath, FakeLimitedResource resource, String clientName) {
	this.resource = resource;
	this.clientName = clientName;
	lock = new InterProcessReadWriteLock(client, lockPath);
	readLock = lock.readLock();
	writeLock = lock.writeLock();
}
 
开发者ID:smallnest,项目名称:ZKRecipesByExample,代码行数:8,代码来源:ExampleClientReadWriteLocks.java


示例7: ZkDistributedRwLock

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
public ZkDistributedRwLock(InterProcessReadWriteLock readWriteLock){
   this.readWriteLock = readWriteLock;
}
 
开发者ID:linsongze,项目名称:consistent_config,代码行数:4,代码来源:ZkDistributedRwLock.java


示例8: InternalReadWriteLock

import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; //导入依赖的package包/类
private InternalReadWriteLock(InterProcessReadWriteLock delegate) {
    this.delegate = delegate;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:4,代码来源:ContainerLockManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ThaiAnalyzer类代码示例发布时间:1970-01-01
下一篇:
Java ParserFactory类代码示例发布时间:1970-01-01
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap