本文整理汇总了Java中org.apache.curator.utils.PathUtils类的典型用法代码示例。如果您正苦于以下问题:Java PathUtils类的具体用法?Java PathUtils怎么用?Java PathUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathUtils类属于org.apache.curator.utils包,在下文中一共展示了PathUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NamespaceImpl
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
NamespaceImpl(CuratorFrameworkImpl client, String namespace)
{
if ( namespace != null )
{
try
{
PathUtils.validatePath("/" + namespace);
}
catch ( IllegalArgumentException e )
{
throw new IllegalArgumentException("Invalid namespace: " + namespace + ", " + e.getMessage());
}
}
this.client = client;
this.namespace = namespace;
ensurePathNeeded = new AtomicBoolean(namespace != null);
}
示例2: LeaderSelector
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param client the client
* @param leaderPath the path for this leadership group
* @param executorService thread pool to use
* @param listener listener
*/
public LeaderSelector(CuratorFramework client, String leaderPath, CloseableExecutorService executorService, LeaderSelectorListener listener)
{
Preconditions.checkNotNull(client, "client cannot be null");
PathUtils.validatePath(leaderPath);
Preconditions.checkNotNull(listener, "listener cannot be null");
this.client = client;
this.listener = new WrappedListener(this, listener);
hasLeadership = false;
this.executorService = executorService;
mutex = new InterProcessMutex(client, leaderPath)
{
@Override
protected byte[] getLockNodeBytes()
{
return (id.length() > 0) ? getIdBytes(id) : null;
}
};
}
示例3: pathExist
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* 检查数据数据节点是否存在
*
* @param path 数据节点路径
* @return 存在返回true,否则返回false
*/
private boolean pathExist(final String path) {
try {
PathUtils.validatePath(path);
return null != client.checkExists().forPath(path);
} catch (Exception e) {
log.error(String.format("zKManager.pathExist error , path:%s", path), e);
return false;
}
}
示例4: Advertiser
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
Advertiser(
CuratorFramework client,
String groupPath,
String memberToken,
Codec<ServiceInstance> codec) {
this.client = requireNonNull(client);
this.groupPath = PathUtils.validatePath(groupPath);
this.memberToken = MorePreconditions.checkNotBlank(memberToken);
this.codec = requireNonNull(codec);
}
示例5: CuratorSingletonService
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* Creates a {@code SingletonService} backed by Curator.
*
* @param client A client to interact with a ZooKeeper ensemble.
* @param groupPath The root ZooKeeper path service members advertise their presence under.
* @param memberToken A token used to form service member node names.
* @param codec A codec that can be used to deserialize group member {@link ServiceInstance} data.
*/
CuratorSingletonService(
CuratorFramework client,
String groupPath,
String memberToken,
Codec<ServiceInstance> codec) {
leaderLatch = new LeaderLatch(client, groupPath);
advertiser = new Advertiser(client, groupPath, memberToken, codec);
this.groupPath = PathUtils.validatePath(groupPath);
}
示例6: SharedValue
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param client the client
* @param path the shared path - i.e. where the shared value is stored
* @param seedValue the initial value for the value if/f the path has not yet been created
*/
public SharedValue(CuratorFramework client, String path, byte[] seedValue)
{
this.client = client.newWatcherRemoveCuratorFramework();
this.path = PathUtils.validatePath(path);
this.seedValue = Arrays.copyOf(seedValue, seedValue.length);
this.watcher = new SharedValueCuratorWatcher();
currentValue = new AtomicReference<VersionedValue<byte[]>>(new VersionedValue<byte[]>(UNINITIALIZED_VERSION, Arrays.copyOf(seedValue, seedValue.length)));
}
示例7: PersistentNode
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param givenClient client instance
* @param mode creation mode
* @param useProtection if true, call {@link CreateBuilder#withProtection()}
* @param basePath the base path for the node
* @param initData data for the node
* @param ttl for ttl modes, the ttl to use
*/
public PersistentNode(CuratorFramework givenClient, final CreateMode mode, boolean useProtection, final String basePath, byte[] initData, long ttl)
{
this.useProtection = useProtection;
this.client = Preconditions.checkNotNull(givenClient, "client cannot be null").newWatcherRemoveCuratorFramework();
this.basePath = PathUtils.validatePath(basePath);
this.mode = Preconditions.checkNotNull(mode, "mode cannot be null");
this.ttl = ttl;
final byte[] data = Preconditions.checkNotNull(initData, "data cannot be null");
backgroundCallback = new BackgroundCallback()
{
@Override
public void processResult(CuratorFramework dummy, CuratorEvent event) throws Exception
{
if ( isActive() )
{
processBackgroundCallback(event);
}
else
{
processBackgroundCallbackClosedState(event);
}
}
};
this.data.set(Arrays.copyOf(data, data.length));
}
示例8: PathChildrenCache
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param client the client
* @param path path to watch
* @param cacheData if true, node contents are cached in addition to the stat
* @param dataIsCompressed if true, data in the path is compressed
* @param executorService Closeable ExecutorService to use for the PathChildrenCache's background thread. This service should be single threaded, otherwise the cache may see inconsistent results.
*/
public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, final CloseableExecutorService executorService)
{
this.client = client.newWatcherRemoveCuratorFramework();
this.path = PathUtils.validatePath(path);
this.cacheData = cacheData;
this.dataIsCompressed = dataIsCompressed;
this.executorService = executorService;
ensureContainers = new EnsureContainers(client, path);
}
示例9: NodeCache
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param client curztor client
* @param path the full path to the node to cache
* @param dataIsCompressed if true, data in the path is compressed
*/
public NodeCache(CuratorFramework client, String path, boolean dataIsCompressed)
{
this.client = client.newWatcherRemoveCuratorFramework();
this.path = PathUtils.validatePath(path);
this.dataIsCompressed = dataIsCompressed;
}
示例10: QueueSafety
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param lockPath ZKPath to use for locking purposes
* @param consumer the message consumer
*/
public QueueSafety(String lockPath, QueueConsumer<T> consumer)
{
this.lockPath = PathUtils.validatePath(lockPath);
this.consumer = consumer;
this.queue = null;
}
示例11: QueueBuilder
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
private QueueBuilder(CuratorFramework client, QueueConsumer<T> consumer, QueueSerializer<T> serializer, String queuePath)
{
this.client = client;
this.consumer = consumer;
this.serializer = serializer;
this.queuePath = PathUtils.validatePath(queuePath);
factory = defaultThreadFactory;
executor = MoreExecutors.directExecutor();
}
示例12: SimpleDistributedQueue
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param client the client
* @param path path to store queue nodes
*/
public SimpleDistributedQueue(CuratorFramework client, String path)
{
this.client = client;
this.path = PathUtils.validatePath(path);
ensureContainers = new EnsureContainers(client, path);
}
示例13: LeaderLatch
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* @param client the client
* @param latchPath the path for this leadership group
* @param id participant ID
* @param closeMode behaviour of listener on explicit close.
*/
public LeaderLatch(CuratorFramework client, String latchPath, String id, CloseMode closeMode)
{
this.client = Preconditions.checkNotNull(client, "client cannot be null").newWatcherRemoveCuratorFramework();
this.latchPath = PathUtils.validatePath(latchPath);
this.id = Preconditions.checkNotNull(id, "id cannot be null");
this.closeMode = Preconditions.checkNotNull(closeMode, "closeMode cannot be null");
}
示例14: LockInternals
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
LockInternals(CuratorFramework client, LockInternalsDriver driver, String path, String lockName, int maxLeases)
{
this.driver = driver;
this.lockName = lockName;
this.maxLeases = maxLeases;
this.client = client.newWatcherRemoveCuratorFramework();
this.basePath = PathUtils.validatePath(path);
this.path = ZKPaths.makePath(path, lockName);
}
示例15: DistributedDoubleBarrier
import org.apache.curator.utils.PathUtils; //导入依赖的package包/类
/**
* Creates the barrier abstraction. <code>memberQty</code> is the number of members in the
* barrier. When {@link #enter()} is called, it blocks until all members have entered. When
* {@link #leave()} is called, it blocks until all members have left.
*
* @param client the client
* @param barrierPath path to use
* @param memberQty the number of members in the barrier. NOTE: more than <code>memberQty</code>
* can enter the barrier. <code>memberQty</code> is a threshold, not a limit
*/
public DistributedDoubleBarrier(CuratorFramework client, String barrierPath, int memberQty)
{
Preconditions.checkState(memberQty > 0, "memberQty cannot be 0");
this.client = client;
this.barrierPath = PathUtils.validatePath(barrierPath);
this.memberQty = memberQty;
ourPath = ZKPaths.makePath(barrierPath, UUID.randomUUID().toString());
readyPath = ZKPaths.makePath(barrierPath, READY_NODE);
}