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


Java InterProcessReadWriteLock类代码示例

本文整理汇总了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;未经允许,请勿转载。