Java Code Examples for org.apache.curator.utils.PathUtils#validatePath()
The following examples show how to use
org.apache.curator.utils.PathUtils#validatePath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZookeeperWatcher.java From Thunder with Apache License 2.0 | 6 votes |
public void usingWatcher(ZookeeperWatcherType watcherType, String path) throws Exception { if (watcherType == null) { throw new ZookeeperException("Watcher type is null"); } PathUtils.validatePath(path); this.watcherType = watcherType; this.path = path; switch (watcherType) { case EXISTS: usingWatcher(client.checkExists().usingWatcher(this), path); break; case GET_CHILDREN: usingWatcher(client.getChildren().usingWatcher(this), path); break; case GET_DATA: usingWatcher(client.getData().usingWatcher(this), path); break; } }
Example 2
Source File: DefaultZooKeeperClient.java From helios with Apache License 2.0 | 6 votes |
@Override /** {@inheritDoc} */ public void ensurePath(final String path, final boolean excludingLast) throws KeeperException { PathUtils.validatePath(path); assertClusterIdFlagTrue(); final String[] parts = path.substring(1).split(Pattern.quote("/")); final int end = excludingLast ? parts.length - 1 : parts.length; String current = ""; for (int i = 0; i < end; i++) { current += "/" + parts[i]; if (exists(current) == null) { create(current); } } }
Example 3
Source File: NamespaceImpl.java From curator with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: ZookeeperInvoker.java From Thunder with Apache License 2.0 | 5 votes |
public Stat getPathStat(String path) throws Exception { validateStartedStatus(); PathUtils.validatePath(path); ExistsBuilder builder = client.checkExists(); if (builder == null) { return null; } Stat stat = builder.forPath(path); return stat; }
Example 5
Source File: SimpleDistributedQueue.java From curator with Apache License 2.0 | 5 votes |
/** * @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); }
Example 6
Source File: NodeCache.java From curator with Apache License 2.0 | 5 votes |
/** * @param client curator 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; }
Example 7
Source File: SharedValue.java From curator with Apache License 2.0 | 5 votes |
@VisibleForTesting protected SharedValue(WatcherRemoveCuratorFramework client, String path, byte[] seedValue, CuratorWatcher watcher) { this.client = client; this.path = PathUtils.validatePath(path); this.seedValue = Arrays.copyOf(seedValue, seedValue.length); // inject watcher for testing this.watcher = watcher; currentValue = new AtomicReference<VersionedValue<byte[]>>(new VersionedValue<byte[]>(UNINITIALIZED_VERSION, Arrays.copyOf(seedValue, seedValue.length))); }
Example 8
Source File: ZookeeperInvoker.java From Thunder with Apache License 2.0 | 5 votes |
public void createPath(String path, Serializable object, CreateMode mode) throws Exception { validateStartedStatus(); PathUtils.validatePath(path); byte[] data = getData(object); client.create().creatingParentsIfNeeded().withMode(mode).forPath(path, data); }
Example 9
Source File: NodeCache.java From xian with Apache License 2.0 | 5 votes |
/** * @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; this.path = PathUtils.validatePath(path); this.dataIsCompressed = dataIsCompressed; }
Example 10
Source File: ChildData.java From curator with Apache License 2.0 | 4 votes |
public ChildData(String path, Stat stat, byte[] data) { this.path = PathUtils.validatePath(path); this.stat = stat; this.data = data; }
Example 11
Source File: QueueSafety.java From curator with Apache License 2.0 | 4 votes |
QueueSafety(String lockPath, BlockingQueue<T> queue) { this.lockPath = PathUtils.validatePath(lockPath); this.consumer = null; this.queue = queue; }
Example 12
Source File: ZookeeperInvoker.java From Thunder with Apache License 2.0 | 4 votes |
public void createPath(String path) throws Exception { validateStartedStatus(); PathUtils.validatePath(path); client.create().creatingParentsIfNeeded().forPath(path, null); }
Example 13
Source File: RefreshableTransportPool.java From jigsaw-payment with Apache License 2.0 | 4 votes |
public void setPath(String path) { this.path = PathUtils.validatePath(path); }
Example 14
Source File: GetDataOperation.java From curator with Apache License 2.0 | 4 votes |
GetDataOperation(PathChildrenCache cache, String fullPath) { this.cache = cache; this.fullPath = PathUtils.validatePath(fullPath); }
Example 15
Source File: ZookeeperInvoker.java From Thunder with Apache License 2.0 | 4 votes |
public void createPath(String path, byte[] data, CreateMode mode) throws Exception { validateStartedStatus(); PathUtils.validatePath(path); client.create().creatingParentsIfNeeded().withMode(mode).forPath(path, data); }
Example 16
Source File: CuratorSingletonService.java From attic-aurora with Apache License 2.0 | 4 votes |
Advertiser(CuratorFramework client, String groupPath, String memberToken) { this.client = requireNonNull(client); this.groupPath = PathUtils.validatePath(groupPath); this.memberToken = MorePreconditions.checkNotBlank(memberToken); }
Example 17
Source File: DistributedAtomicValue.java From curator with Apache License 2.0 | 3 votes |
/** * Creates in mutex promotion mode. The optimistic lock will be tried first using * the given retry policy. If the increment does not succeed, a {@link InterProcessMutex} will be tried * with its own retry policy * * @param client the client * @param path path to hold the value * @param retryPolicy the retry policy to use * @param promotedToLock the arguments for the mutex promotion */ public DistributedAtomicValue(CuratorFramework client, String path, RetryPolicy retryPolicy, PromotedToLock promotedToLock) { this.client = client; this.path = PathUtils.validatePath(path); this.retryPolicy = retryPolicy; this.promotedToLock = promotedToLock; mutex = (promotedToLock != null) ? new InterProcessMutex(client, promotedToLock.getPath()) : null; }
Example 18
Source File: CuratorSingletonService.java From attic-aurora with Apache License 2.0 | 2 votes |
/** * 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. */ CuratorSingletonService(CuratorFramework client, String groupPath, String memberToken) { advertiser = new Advertiser(client, groupPath, memberToken); this.client = client; this.groupPath = PathUtils.validatePath(groupPath); }
Example 19
Source File: PromotedToLock.java From xian with Apache License 2.0 | 2 votes |
/** * Set the path for the mutex lock (required) * * @param path path * @return this */ public Builder lockPath(String path) { instance = new PromotedToLock(PathUtils.validatePath(path), instance.maxLockTime, instance.maxLockTimeUnit, instance.retryPolicy); return this; }
Example 20
Source File: QueueBuilder.java From curator with Apache License 2.0 | 2 votes |
/** * <p>Without a lock set, queue items are removed before being sent to the queue consumer. This can result in message * loss if the consumer fails to complete the message or the process dies.</p> * * <p>Use a lock to make the message recoverable. A lock is held while * the message is being processed - this prevents other processes from taking the message. The message will not be removed * from the queue until the consumer functor returns. Thus, if there is a failure or the process dies, * the message will get sent to another process. There is a small performance penalty for this behavior however. * * @param path path for the lock * @return this */ public QueueBuilder<T> lockPath(String path) { lockPath = PathUtils.validatePath(path); return this; }