Example usage for org.apache.zookeeper Op check

List of usage examples for org.apache.zookeeper Op check

Introduction

In this page you can find the example usage for org.apache.zookeeper Op check.

Prototype

public static Op check(String path, int version) 

Source Link

Document

Constructs an version check operation.

Usage

From source file:com.netflix.curator.framework.imps.CuratorTransactionImpl.java

License:Apache License

@Override
public TransactionCheckBuilder check() {
    Preconditions.checkState(!isCommitted, "transaction already committed");

    return new TransactionCheckBuilder() {
        private int version = -1;

        @Override/*from   w  ww.  j a  va2 s. co  m*/
        public CuratorTransactionBridge forPath(String path) throws Exception {
            String fixedPath = client.fixForNamespace(path);
            transaction.add(Op.check(fixedPath, version), OperationType.CHECK, path);

            return CuratorTransactionImpl.this;
        }

        @Override
        public Pathable<CuratorTransactionBridge> withVersion(int version) {
            this.version = version;
            return this;
        }
    };
}

From source file:com.tdunning.graph.Node.java

License:Apache License

/**
 * Creates an check operation that can be put into a transaction with other operations.
 * This check will verify that this node has not been changed in ZK since it was read.
 * @param root  The root directory used to store the graph.
 * @return The Op that will check the vesion of this node in ZK.
 *///w w w.  java  2s. c o  m
public Op checkOp(String root) {
    return Op.check(path(root), version);
}