gpt4 book ai didi

com.netflix.curator.utils.ZKPaths.makePath()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:18:01 26 4
gpt4 key购买 nike

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

ZKPaths.makePath介绍

[英]Given a parent path and a child node, create a combined full path
[中]给定父路径和子节点,创建一个组合的完整路径

代码示例

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

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

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

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

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

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

代码示例来源: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-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);
}

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

private void addNewQueueIfNeeded(String newQueuePath) throws Exception
{
  if ( newQueuePath == null )
  {
    newQueuePath = ZKPaths.makePath(queuePath, QUEUE_PREFIX + UUID.randomUUID().toString());
  }
  if ( !queues.containsKey(newQueuePath) )
  {
    T                   queue = queueAllocator.allocateQueue(client, newQueuePath);
    if ( queues.putIfAbsent(newQueuePath, queue) == null )
    {
      queue.start();
      preferredQueues.add(newQueuePath);
    }
  }
}

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

/**
 * Return a list of all current nodes participating in the semaphore
 *
 * @return list of nodes
 * @throws Exception ZK errors, interruptions, etc.
 */
public Collection<String>   getParticipantNodes() throws Exception
{
  return client.getChildren().forPath(ZKPaths.makePath(leasesPath, LEASE_BASE_NAME));
}

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

NamespaceImpl(CuratorFrameworkImpl client, String namespace)
{
  if ( namespace != null )
  {
    try
    {
      PathUtils.validatePath("/" + namespace);
    }
    catch ( IllegalArgumentException e )
    {
      throw new IllegalArgumentException("Invalid namespace: " + namespace);
    }
  }
  this.client = client;
  this.namespace = namespace;
  ensurePath = (namespace != null) ? new EnsurePath(ZKPaths.makePath("/", namespace)) : null;
}

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

private InterProcessSemaphoreV2(CuratorFramework client, String path, int maxLeases, SharedCountReader count)
{
  this.client = client;
  lock = new InterProcessMutex(client, ZKPaths.makePath(path, LOCK_PARENT));
  this.maxLeases = (count != null) ? count.getCount() : maxLeases;
  leasesPath = ZKPaths.makePath(path, LEASE_PARENT);
  if ( count != null )
  {
    count.addListener
    (
      new SharedCountListener()
      {
        @Override
        public void countHasChanged(SharedCountReader sharedCount, int newCount) throws Exception
        {
          InterProcessSemaphoreV2.this.maxLeases = newCount;
        }
        @Override
        public void stateChanged(CuratorFramework client, ConnectionState newState)
        {
          // no need to handle this here - clients should set their own connection state listener
        }
      }
    );
  }
}

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

String fullPath = ZKPaths.makePath(path, name);

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

private void getInitialQueues() throws Exception
{
  List<String>        children = client.getChildren().forPath(queuePath);
  for ( String child : children )
  {
    String              queuePath = ZKPaths.makePath(this.queuePath, child);
    addNewQueueIfNeeded(queuePath);
  }
  if ( children.size() == 0 )
  {
    addNewQueueIfNeeded(null);
  }
}

代码示例来源: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-framework

if ( foundNode != null )
  foundNode = ZKPaths.makePath(pathAndNode.getPath(), foundNode);

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

/**
 * Inserts data into queue.
 *
 * @param data the data
 * @return true if data was successfully added
 * @throws Exception errors
 */
public boolean offer(byte[] data) throws Exception
{
  ensurePath.ensure(client.getZookeeperClient());
  String thisPath = ZKPaths.makePath(path, PREFIX);
  client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(thisPath, data);
  return true;
}

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

private void doWork()
  {
    try
    {
      List<String>        children = client.getChildren().forPath(path);
      for ( String name : children )
      {
        String  thisPath = ZKPaths.makePath(path, name);
        Stat    stat = client.checkExists().forPath(thisPath);
        if ( (stat != null) && (stat.getNumChildren() == 0) )
        {
          reaper.addPath(thisPath, mode);
        }
      }
    }
    catch ( Exception e )
    {
      log.error("Could not get children for path: " + path, e);
    }
  }
}

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

/**
 * NOTE: this is a BLOCKING method. Completely rebuild the internal cache by querying
 * for all needed data WITHOUT generating any events to send to listeners.
 *
 * @throws Exception errors
 */
public void rebuild() throws Exception
{
  Preconditions.checkState(!executorService.isShutdown(), "cache has been closed");
  ensurePath.ensure(client.getZookeeperClient());
  clear();
  List<String> children = client.getChildren().forPath(path);
  for ( String child : children )
  {
    String fullPath = ZKPaths.makePath(path, child);
    internalRebuildNode(fullPath);
    if ( rebuildTestExchanger != null )
    {
      rebuildTestExchanger.exchange(new Object());
    }
  }
  // this is necessary so that any updates that occurred while rebuilding are taken
  offerOperation(new RefreshOperation(this, RefreshMode.FORCE_GET_DATA_AND_STAT));
}

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

String  itemPath = ZKPaths.makePath(queuePath, itemNode);
Stat    stat = new Stat();

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

private void reset() throws Exception
{
  setLeadership(false);
  deleteNode();
  BackgroundCallback          callback = new BackgroundCallback()
  {
    @Override
    public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
    {
      if ( event.getResultCode() == KeeperException.Code.OK.intValue() )
      {
        ourPath = event.getName();
        getChildren();
      }
      else
      {
        log.error("getChildren() failed. rc = " + event.getResultCode());
      }
    }
  };
  client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).inBackground(callback).forPath(ZKPaths.makePath(latchPath, LOCK_NAME), LeaderSelector.getIdBytes(id));
}

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