gpt4 book ai didi

com.netflix.curator.utils.ZKPaths类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:17:41 28 4
gpt4 key购买 nike

本文整理了Java中com.netflix.curator.utils.ZKPaths类的一些代码示例,展示了ZKPaths类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKPaths类的具体详情如下:
包路径:com.netflix.curator.utils.ZKPaths
类名称:ZKPaths

ZKPaths介绍

暂无

代码示例

代码示例来源:origin: com.netflix.curator/curator-recipes

@Override
  public String apply(String child)
  {
    return ZKPaths.makePath(path, child);
  }
}

代码示例来源:origin: com.netflix.curator/curator-framework

private String  adjustPath(String path) throws Exception
  {
    if ( doProtected )
    {
      ZKPaths.PathAndNode     pathAndNode = ZKPaths.getPathAndNode(path);
      String                  name = getProtectedPrefix() + pathAndNode.getNode();
      path = ZKPaths.makePath(pathAndNode.getPath(), name);
    }
    return path;
  }
}

代码示例来源:origin: com.netflix.curator/curator-client

/**
 * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish
 * between directories and files. So, every node in the path is created. The data for each node is an empty blob
 *
 * @param zookeeper the client
 * @param path      path to ensure
 * @throws InterruptedException thread interruption
 * @throws org.apache.zookeeper.KeeperException
 *                              Zookeeper errors
 */
public static void mkdirs(ZooKeeper zookeeper, String path)
  throws InterruptedException, KeeperException
{
  mkdirs(zookeeper, path, true);
}

代码示例来源:origin: com.netflix.curator/curator-recipes

private void checkLeadership(List<String> children) throws Exception
  int             ourIndex = (ourPath != null) ? sortedChildren.indexOf(ZKPaths.getNodeFromPath(ourPath)) : -1;
  if ( ourIndex < 0 )
    client.checkExists().usingWatcher(watcher).inBackground(callback).forPath(ZKPaths.makePath(latchPath, watchPath));

代码示例来源:origin: com.netflix.curator/curator-framework

sendBackgroundResponse(KeeperException.Code.OK.intValue(), createdPath, backgrounding.getContext(), ZKPaths.getNodeFromPath(createdPath), this);

代码示例来源:origin: com.netflix.curator/curator-recipes

/**
 * NOTE: this is a BLOCKING method. Rebuild the internal cache for the given node by querying
 * for all needed data WITHOUT generating any events to send to listeners.
 *
 * @param fullPath full path of the node to rebuild
 * @throws Exception errors
 */
public void rebuildNode(String fullPath) throws Exception
{
  Preconditions.checkArgument(ZKPaths.getPathAndNode(fullPath).getPath().equals(path), "Node is not part of this cache: " + fullPath);
  Preconditions.checkState(!executorService.isShutdown(), "cache has been closed");
  ensurePath.ensure(client.getZookeeperClient());
  internalRebuildNode(fullPath);
  // this is necessary so that any updates that occurred while rebuilding are taken
  // have to rebuild entire tree in case this node got deleted in the interim
  offerOperation(new RefreshOperation(this, RefreshMode.FORCE_GET_DATA_AND_STAT));
}

代码示例来源:origin: com.netflix.curator/curator-framework

String    fixForNamespace(String path)
{
  if ( ensurePath != null )
  {
    try
    {
      ensurePath.ensure(client.getZookeeperClient());
    }
    catch ( Exception e )
    {
      client.logError("Ensure path threw exception", e);
    }
  }
  return ZKPaths.fixForNamespace(namespace, path);
}

代码示例来源:origin: com.netflix.curator/curator-recipes

private boolean internalLeave(long startMs, boolean hasMaxWait, long maxWaitMs) throws Exception
  String          ourPathName = ZKPaths.getNodeFromPath(ourPath);
  boolean         ourNodeShouldExist = true;
  boolean         result = true;
    if ( IsLowestNode )
      String  highestNodePath = ZKPaths.makePath(barrierPath, children.get(children.size() - 1));
      stat = client.checkExists().usingWatcher(watcher).forPath(highestNodePath);
      String  lowestNodePath = ZKPaths.makePath(barrierPath, children.get(0));
      stat = client.checkExists().usingWatcher(watcher).forPath(lowestNodePath);

代码示例来源:origin: com.netflix.curator/curator-recipes

private void applyNewData(String fullPath, int resultCode, Stat stat, byte[] bytes)
{
  if ( resultCode == KeeperException.Code.OK.intValue() ) // otherwise - node must have dropped or something - we should be getting another event
  {
    ChildData data = new ChildData(fullPath, stat, bytes);
    ChildData previousData = currentData.put(fullPath, data);
    if ( previousData == null ) // i.e. new
    {
      offerOperation(new EventOperation(this, new PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CHILD_ADDED, data)));
    }
    else if ( previousData.getStat().getVersion() != stat.getVersion() )
    {
      offerOperation(new EventOperation(this, new PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CHILD_UPDATED, data)));
    }
    updateInitialSet(ZKPaths.getNodeFromPath(fullPath), data);
  }
}

代码示例来源:origin: com.netflix.curator/curator-recipes

@Override
  public String apply(String name)
  {
    return ZKPaths.makePath(basePath, name);
  }
}

代码示例来源:origin: com.netflix.curator/curator-recipes

String                      path = (nodeData != null) ? createBuilder.forPath(ZKPaths.makePath(leasesPath, LEASE_BASE_NAME), nodeData) : createBuilder.forPath(ZKPaths.makePath(leasesPath, LEASE_BASE_NAME));
String                      nodeName = ZKPaths.getNodeFromPath(path);
builder.add(makeLease(path));

代码示例来源:origin: com.netflix.curator/curator-framework

try
  final ZKPaths.PathAndNode   pathAndNode = ZKPaths.getPathAndNode(path);
  List<String>                children = client.getZooKeeper().getChildren(pathAndNode.getPath(), false);
  if ( foundNode != null )
    foundNode = ZKPaths.makePath(pathAndNode.getPath(), foundNode);

代码示例来源:origin: com.netflix.curator/curator-client

@Override
  public Object call() throws Exception
  {
    ZKPaths.mkdirs(client.getZooKeeper(), path, makeLastNode);
    helper.set(doNothingHelper);
    isSet = true;
    return null;
  }
}

代码示例来源:origin: com.netflix.curator/curator-recipes

String makeItemPath()
{
  return ZKPaths.makePath(queuePath, QUEUE_ITEM_NAME);
}

代码示例来源:origin: com.netflix.curator/curator-framework

@Override
  public void performBackgroundOperation(OperationAndData<PathAndBytes> dummy) throws Exception
  {
    try
    {
      ZKPaths.mkdirs(client.getZooKeeper(), mainOperationAndData.getData().getPath(), false);
    }
    catch ( KeeperException e )
    {
      // ignore
    }
    client.queueOperation(mainOperationAndData);
  }
};

代码示例来源:origin: com.netflix.curator/curator-client

/**
 * Apply the namespace to the given path
 *
 * @param namespace namespace (can be null)
 * @param path path
 * @return adjusted path
 */
public static String    fixForNamespace(String namespace, String path)
{
  if ( namespace != null )
  {
    return makePath(namespace, path);
  }
  return path;
}

代码示例来源:origin: com.netflix.curator/curator-framework

ZKPaths.mkdirs(client.getZooKeeper(), path, false);
createdPath = client.getZooKeeper().create(path, data, acling.getAclList(path), createMode);

代码示例来源:origin: com.netflix.curator/curator-recipes

/**
 * 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 = barrierPath;
  this.memberQty = memberQty;
  ourPath = ZKPaths.makePath(barrierPath, UUID.randomUUID().toString());
  readyPath = ZKPaths.makePath(barrierPath, READY_NODE);
}

代码示例来源:origin: com.netflix.curator/curator-framework

String    unfixForNamespace(String path)
{
  if ( (namespace != null) && (path != null) )
  {
    String      namespacePath = ZKPaths.makePath(namespace, null);
    if ( path.startsWith(namespacePath) )
    {
      path = (path.length() > namespacePath.length()) ? path.substring(namespacePath.length()) : "/";
    }
  }
  return path;
}

代码示例来源:origin: com.netflix.curator/curator-recipes

LockInternals(CuratorFramework client, LockInternalsDriver driver, String path, String lockName, int maxLeases)
{
  this.driver = driver;
  this.lockName = lockName;
  this.maxLeases = maxLeases;
  PathUtils.validatePath(path);
  this.client = client;
  this.basePath = path;
  this.path = ZKPaths.makePath(path, lockName);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com