Example usage for org.apache.zookeeper ZooKeeper getTestable

List of usage examples for org.apache.zookeeper ZooKeeper getTestable

Introduction

In this page you can find the example usage for org.apache.zookeeper ZooKeeper getTestable.

Prototype

public Testable getTestable() 

Source Link

Usage

From source file:org.apache.curator.utils.Compatibility.java

License:Apache License

/**
 * For ZooKeeper 3.5.x, use the supported <code>zooKeeper.getTestable().injectSessionExpiration()</code>.
 * For ZooKeeper 3.4.x do the equivalent via reflection
 *
 * @param zooKeeper client/*from  w w  w.j  a  va  2s.  c  o m*/
 */
public static void injectSessionExpiration(ZooKeeper zooKeeper) {
    if (isZK34()) {
        InjectSessionExpiration.injectSessionExpiration(zooKeeper);
    } else {
        // LOL - this method was proposed by me (JZ) in 2013 for totally unrelated reasons
        // it got added to ZK 3.5 and now does exactly what we need
        // https://issues.apache.org/jira/browse/ZOOKEEPER-1730
        zooKeeper.getTestable().injectSessionExpiration();
    }
}