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


Java DeleteRequest类代码示例

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


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

示例1: delete

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
/**
 * Delete the node with the given path. The call will succeed if such a node
 * exists, and the given version matches the node's version (if the given
 * version is -1, it matches any node's versions).
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if the nodes does not exist.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given version does not match the node's version.
 * <p>
 * A KeeperException with error code KeeperException.NotEmpty will be thrown
 * if the node has children.
 * <p>
 * This operation, if successful, will trigger all the watches on the node
 * of the given path left by exists API calls, and the watches on the parent
 * node left by getChildren API calls.
 *
 * @param path
 *                the path of the node to be deleted.
 * @param version
 *                the expected node version.
 * @throws InterruptedException IF the server transaction is interrupted
 * @throws KeeperException If the server signals an error with a non-zero
 *   return code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public void delete(final String path, int version)
    throws InterruptedException, KeeperException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath;

    // maintain semantics even in chroot case
    // specifically - root cannot be deleted
    // I think this makes sense even in chroot case.
    if (clientPath.equals("/")) {
        // a bit of a hack, but delete(/) will never succeed and ensures
        // that the same semantics are maintained
        serverPath = clientPath;
    } else {
        serverPath = prependChroot(clientPath);
    }

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

示例2: deleteNodeFailSilent

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
private static void deleteNodeFailSilent(ZooKeeperWatcher zkw,
    DeleteNodeFailSilent dnfs) throws KeeperException {
  DeleteRequest delete = (DeleteRequest)toZooKeeperOp(zkw, dnfs).toRequestRecord();
  try {
    zkw.getRecoverableZooKeeper().delete(delete.getPath(), delete.getVersion());
  } catch(KeeperException.NoNodeException nne) {
  } catch(InterruptedException ie) {
    zkw.interruptedException(ie);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:ZKUtil.java

示例3: checkType

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
private EventType checkType(Record response) {

        if (response == null) {
            return EventType.other;
        } else if (response instanceof ConnectRequest) {
            return EventType.write;
        } else if (response instanceof CreateRequest) {
            return EventType.write;
        } else if (response instanceof DeleteRequest) {
            return EventType.write;
        } else if (response instanceof SetDataRequest) {
            return EventType.write;
        } else if (response instanceof SetACLRequest) {
            return EventType.write;
        } else if (response instanceof SetMaxChildrenRequest) {
            return EventType.write;
        } else if (response instanceof SetSASLRequest) {
            return EventType.write;
        } else if (response instanceof SetWatches) {
            return EventType.write;
        } else if (response instanceof SyncRequest) {
            return EventType.write;
        } else if (response instanceof ExistsRequest) {
            return EventType.read;
        } else if (response instanceof GetDataRequest) {
            return EventType.read;
        } else if (response instanceof GetMaxChildrenRequest) {
            return EventType.read;
        } else if (response instanceof GetACLRequest) {
            return EventType.read;
        } else if (response instanceof GetChildrenRequest) {
            return EventType.read;
        } else if (response instanceof GetChildren2Request) {
            return EventType.read;
        } else if (response instanceof GetSASLRequest) {
            return EventType.read;
        } else {
            return EventType.other;
        }
    }
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:41,代码来源:ClientCnxnAspect.java

示例4: deleteNodeFailSilent

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
private static void deleteNodeFailSilent(ZKWatcher zkw,
    DeleteNodeFailSilent dnfs) throws KeeperException {
  DeleteRequest delete = (DeleteRequest)toZooKeeperOp(zkw, dnfs).toRequestRecord();
  try {
    zkw.getRecoverableZooKeeper().delete(delete.getPath(), delete.getVersion());
  } catch(KeeperException.NoNodeException nne) {
  } catch(InterruptedException ie) {
    zkw.interruptedException(ie);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:11,代码来源:ZKUtil.java

示例5: toRequestRecord

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
@Override
public Record toRequestRecord() {
    return new DeleteRequest(getPath(), version);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:5,代码来源:Op.java

示例6: forOperations

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
@Override
public List<CuratorTransactionResult> forOperations(List<CuratorOp> operations) throws Exception
{
    operations = Preconditions.checkNotNull(operations, "operations cannot be null");
    Preconditions.checkArgument(!operations.isEmpty(), "operations list cannot be empty");

    CuratorMultiTransactionRecord record = new CuratorMultiTransactionRecord();
    for ( CuratorOp curatorOp : operations )
    {
        Schema schema = client.getSchemaSet().getSchema(curatorOp.getTypeAndPath().getForPath());
        record.add(curatorOp.get(), curatorOp.getTypeAndPath().getType(), curatorOp.getTypeAndPath().getForPath());
        if ( (curatorOp.get().getType() == ZooDefs.OpCode.create) || (curatorOp.get().getType() == ZooDefs.OpCode.createContainer) )
        {
            CreateRequest createRequest = (CreateRequest)curatorOp.get().toRequestRecord();
            CreateMode createMode;
            if ( client.isZk34CompatibilityMode() )
            {
                try
                {
                    createMode = CreateMode.fromFlag(createRequest.getFlags());
                }
                catch ( KeeperException.BadArgumentsException dummy )
                {
                    createMode = CreateMode.PERSISTENT;
                }
            }
            else
            {
                createMode = CreateMode.fromFlag(createRequest.getFlags(), CreateMode.PERSISTENT);
            }
            schema.validateCreate(createMode, createRequest.getPath(), createRequest.getData(), createRequest.getAcl());
        }
        else if ( (curatorOp.get().getType() == ZooDefs.OpCode.delete) || (curatorOp.get().getType() == ZooDefs.OpCode.deleteContainer) )
        {
            DeleteRequest deleteRequest = (DeleteRequest)curatorOp.get().toRequestRecord();
            schema.validateDelete(deleteRequest.getPath());
        }
        else if ( curatorOp.get().getType() == ZooDefs.OpCode.setData )
        {
            SetDataRequest setDataRequest = (SetDataRequest)curatorOp.get().toRequestRecord();
            schema.validateGeneral(setDataRequest.getPath(), setDataRequest.getData(), null);
        }
    }

    if ( backgrounding.inBackground() )
    {
        client.processBackgroundOperation(new OperationAndData<>(this, record, backgrounding.getCallback(), null, backgrounding.getContext(), null), null);
        return null;
    }
    else
    {
        return forOperationsInForeground(record);
    }
}
 
开发者ID:apache,项目名称:curator,代码行数:55,代码来源:CuratorMultiTransactionImpl.java

示例7: IDeleteRequest

import org.apache.zookeeper.proto.DeleteRequest; //导入依赖的package包/类
public IDeleteRequest() {
    this(new DeleteRequest());
}
 
开发者ID:lisaglendenning,项目名称:zookeeper-lite,代码行数:4,代码来源:IDeleteRequest.java


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