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


Java PathUtils类代码示例

本文整理汇总了Java中org.apache.zookeeper.common.PathUtils的典型用法代码示例。如果您正苦于以下问题:Java PathUtils类的具体用法?Java PathUtils怎么用?Java PathUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PathUtils类属于org.apache.zookeeper.common包,在下文中一共展示了PathUtils类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * The asynchronous version of create.
 *
 * @see #create(String, byte[], List, CreateMode)
 */

public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode,  StringCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.create);
    CreateRequest request = new CreateRequest();
    CreateResponse response = new CreateResponse();
    ReplyHeader r = new ReplyHeader();
    request.setData(data);
    request.setFlags(createMode.toFlag());
    request.setPath(serverPath);
    request.setAcl(acl);
    cnxn.queuePacket(h, r, request, response, cb, clientPath,
            serverPath, ctx, null);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:27,代码来源:ZooKeeper.java

示例2: exists

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * The asynchronous version of exists.
 *
 * @see #exists(String, Watcher)
 */
public void exists(final String path, Watcher watcher,
        StatCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new ExistsWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.exists);
    ExistsRequest request = new ExistsRequest();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    SetDataResponse response = new SetDataResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:29,代码来源:ZooKeeper.java

示例3: getData

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * The asynchronous version of getData.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new DataWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getData);
    GetDataRequest request = new GetDataRequest();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    GetDataResponse response = new GetDataResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:29,代码来源:ZooKeeper.java

示例4: setData

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * The asynchronous version of setData.
 *
 * @see #setData(String, byte[], int)
 */
public void setData(final String path, byte data[], int version,
        StatCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setData);
    SetDataRequest request = new SetDataRequest();
    request.setPath(serverPath);
    request.setData(data);
    request.setVersion(version);
    SetDataResponse response = new SetDataResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, null);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:ZooKeeper.java

示例5: getACL

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * Return the ACL and stat of the node of the given path.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @param path
 *                the given path for the node
 * @param stat
 *                the stat of the node will be copied to this parameter if
 *                not null.
 * @return the ACL array of the given node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public List<ACL> getACL(final String path, Stat stat)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getACL);
    GetACLRequest request = new GetACLRequest();
    request.setPath(serverPath);
    GetACLResponse response = new GetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    return response.getAcl();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:40,代码来源:ZooKeeper.java

示例6: setACL

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * Set the ACL for the node of the given path if such a node exists and the
 * given version matches the version of the node. Return the stat of the
 * node.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given version does not match the node's version.
 *
 * @param path
 * @param acl
 * @param version
 * @return the stat of the node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws org.apache.zookeeper.KeeperException.InvalidACLException If the acl is invalide.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat setACL(final String path, List<ACL> acl, int version)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setACL);
    SetACLRequest request = new SetACLRequest();
    request.setPath(serverPath);
    if (acl != null && acl.size() == 0) {
        throw new KeeperException.InvalidACLException(clientPath);
    }
    request.setAcl(acl);
    request.setVersion(version);
    SetACLResponse response = new SetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getStat();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:46,代码来源:ZooKeeper.java

示例7: getChildren

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * The asynchronous version of getChildren.
 *
 * @see #getChildren(String, Watcher)
 */
public void getChildren(final String path, Watcher watcher,
        ChildrenCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new ChildWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getChildren);
    GetChildrenRequest request = new GetChildrenRequest();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    GetChildrenResponse response = new GetChildrenResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:29,代码来源:ZooKeeper.java

示例8: create

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * The asynchronous version of create.
 *
 * @see #create(String, byte[], List, CreateMode)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, StringCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    EphemeralType.validateTTL(createMode, -1);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : ZooDefs.OpCode.create);
    CreateRequest request = new CreateRequest();
    CreateResponse response = new CreateResponse();
    ReplyHeader r = new ReplyHeader();
    request.setData(data);
    request.setFlags(createMode.toFlag());
    request.setPath(serverPath);
    request.setAcl(acl);
    cnxn.queuePacket(h, r, request, response, cb, clientPath,
            serverPath, ctx, null);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:27,代码来源:ZooKeeper.java

示例9: setACL

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
/**
 * Set the ACL for the node of the given path if such a node exists and the
 * given aclVersion matches the acl version of the node. Return the stat of the
 * node.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given aclVersion does not match the node's aclVersion.
 *
 * @param path the given path for the node
 * @param acl the given acl for the node
 * @param aclVersion the given acl version of the node
 * @return the stat of the node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws org.apache.zookeeper.KeeperException.InvalidACLException If the acl is invalide.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat setACL(final String path, List<ACL> acl, int aclVersion)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);
    validateACL(acl);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setACL);
    SetACLRequest request = new SetACLRequest();
    request.setPath(serverPath);
    request.setAcl(acl);
    request.setVersion(aclVersion);
    SetACLResponse response = new SetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getStat();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:44,代码来源:ZooKeeper.java

示例10: removeWatches

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
private void removeWatches(int opCode, String path, Watcher watcher,
        WatcherType watcherType, boolean local)
        throws InterruptedException, KeeperException {
    PathUtils.validatePath(path);
    final String clientPath = path;
    final String serverPath = prependChroot(clientPath);
    WatchDeregistration wcb = new WatchDeregistration(clientPath, watcher,
            watcherType, local, watchManager);

    RequestHeader h = new RequestHeader();
    h.setType(opCode);
    Record request = getRemoveWatchesRequest(opCode, watcherType,
            serverPath);

    ReplyHeader r = cnxn.submitRequest(h, request, null, null, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:ZooKeeper.java

示例11: createDynamicFile

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
private String createDynamicFile(String quorumCfgSection, String version)
        throws IOException {
    String filename = "zoo.cfg.dynamic";
    if( version != null ){
        filename = filename + "." + version;
    }

    File dynamicConfigFile = new File(tmpDir, filename);
    String dynamicConfigFilename = PathUtils.normalizeFileSystemPath(dynamicConfigFile.toString());

    FileWriter fDynamicConfigWriter = new FileWriter(dynamicConfigFile);
    fDynamicConfigWriter.write(quorumCfgSection);
    fDynamicConfigWriter.flush();
    fDynamicConfigWriter.close();

    return dynamicConfigFilename;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:18,代码来源:QuorumPeerTestBase.java

示例12: MainThread

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
public MainThread(int clientPort) throws IOException {
    super("Standalone server with clientPort:" + clientPort);
    File tmpDir = ClientBase.createTmpDir();
    confFile = new File(tmpDir, "zoo.cfg");

    FileWriter fwriter = new FileWriter(confFile);
    fwriter.write("tickTime=2000\n");
    fwriter.write("initLimit=10\n");
    fwriter.write("syncLimit=5\n");
    fwriter.write("snapCount=1\n");

    File dataDir = new File(tmpDir, "data");
    if (!dataDir.mkdir()) {
        throw new IOException("unable to mkdir " + dataDir);
    }
    
    // Convert windows path to UNIX to avoid problems with "\"
    String dir = PathUtils.normalizeFileSystemPath(dataDir.toString());
    fwriter.write("dataDir=" + dir + "\n");
    
    fwriter.write("clientPort=" + clientPort + "\n");
    fwriter.flush();
    fwriter.close();

    main = new TestMain();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:27,代码来源:InvalidSnapCountTest.java

示例13: removeWatches

import org.apache.zookeeper.common.PathUtils; //导入依赖的package包/类
private void removeWatches(int opCode, String path, Watcher watcher,
        WatcherType watcherType, boolean local, VoidCallback cb, Object ctx) {
    PathUtils.validatePath(path);
    final String clientPath = path;
    final String serverPath = prependChroot(clientPath);
    WatchDeregistration wcb = new WatchDeregistration(clientPath, watcher,
            watcherType, local, watchManager);

    RequestHeader h = new RequestHeader();
    h.setType(opCode);
    Record request = getRemoveWatchesRequest(opCode, watcherType,
            serverPath);

    cnxn.queuePacket(h, new ReplyHeader(), request, null, cb, clientPath,
            serverPath, ctx, null, wcb);
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:17,代码来源:ZooKeeper.java


注:本文中的org.apache.zookeeper.common.PathUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。