Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Temporary Framework

Randgalt edited this page · 4 revisions

Temporary CuratorFramework instances are meant for single requests to ZooKeeper ensembles over a failure prone network such as a WAN. The APIs available from CuratorTempFramework are limited. Further, the connection will be closed after a period of inactivity.

This is based on an idea mentioned in a post by Camille Fournier: http://whilefalse.blogspot.com/2012/12/building-global-highly-available.html

Creating a CuratorTempFramework

CuratorTempFramework instances are created via the CuratorFrameworkFactory just like normal CuratorFramework instances. However, instead of calling the build() method, call buildTemp(). buildTemp() creates a CuratorTempFramework instance that closes itself after 3 minutes of inactivity. There is an alternate version of buildTemp() that allows you to specify the inactivity period.

Limited API

CuratorTempFramework instances provide the following methods:

  /**
   * Stop the client
   */
  public void     close();

  /**
   * Start a transaction builder
   *
   * @return builder object
   * @throws Exception errors
   */
  public CuratorTransaction inTransaction() throws Exception;

  /**
   * Start a get data builder
   *
   * @return builder object
   * @throws Exception errors
   */
  public TempGetDataBuilder getData() throws Exception;
Something went wrong with that request. Please try again.