Interface ModeledFramework<T>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      static <T> ModeledFrameworkBuilder<T> builder()
      Start a new ModeledFrameworkBuilder.
      static <T> ModeledFrameworkBuilder<T> builder​(AsyncCuratorFramework client, ModelSpec<T> model)
      Start a new ModeledFrameworkBuilder for the given model
      CachedModeledFramework<T> cached()
      Use an internally created cache as a front for this modeled instance.
      CachedModeledFramework<T> cached​(java.util.concurrent.ExecutorService executor)
      Same as cached() but allows for providing an executor service
      AsyncStage<org.apache.zookeeper.data.Stat> checkExists()
      Check to see if the ZNode at this instance's path exists
      org.apache.curator.framework.api.transaction.CuratorOp checkExistsOp()
      Check exists operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      org.apache.curator.framework.api.transaction.CuratorOp checkExistsOp​(int version)
      Check exists operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      ModeledFramework<T> child​(java.lang.Object child)
      Return a new Modeled Curator instance with all the same options but applying to the given child node of this Modeled Curator's path.
      AsyncStage<java.util.List<ZPath>> children()
      Return the child paths of this instance's path (in no particular order)
      AsyncStage<java.util.List<ZNode<T>>> childrenAsZNodes()
      Return the child paths of this instance's path (in no particular order) and deserialize into a models.
      org.apache.curator.framework.api.transaction.CuratorOp createOp​(T model)
      Create operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      AsyncStage<java.lang.Void> delete()
      Delete the ZNode at this instance's path passing -1 for the delete version
      AsyncStage<java.lang.Void> delete​(int version)
      Delete the ZNode at this instance's path passing the given delete version
      org.apache.curator.framework.api.transaction.CuratorOp deleteOp()
      Delete operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      org.apache.curator.framework.api.transaction.CuratorOp deleteOp​(int version)
      Delete operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      AsyncStage<java.util.List<org.apache.curator.framework.api.transaction.CuratorTransactionResult>> inTransaction​(java.util.List<org.apache.curator.framework.api.transaction.CuratorOp> operations)
      Invoke ZooKeeper to commit the given operations as a single transaction.
      ModelSpec<T> modelSpec()
      Return the model being used
      ModeledFramework<T> parent()
      Return a new Modeled Curator instance with all the same options but applying to the parent node of this Modeled Curator's path.
      AsyncStage<T> read()
      Read the ZNode at this instance's path and deserialize into a model
      AsyncStage<T> read​(org.apache.zookeeper.data.Stat storingStatIn)
      Read the ZNode at this instance's path and deserialize into a model
      AsyncStage<ZNode<T>> readAsZNode()
      Read the ZNode at this instance's path and deserialize into a model
      AsyncStage<java.lang.String> set​(T model)
      Create (or update depending on build options) a ZNode at this instance's path with a serialized version of the given model
      AsyncStage<java.lang.String> set​(T model, int version)
      Create (or update depending on build options) a ZNode at this instance's path with a serialized version of the given model
      AsyncStage<java.lang.String> set​(T model, org.apache.zookeeper.data.Stat storingStatIn)
      Create (or update depending on build options) a ZNode at this instance's path with a serialized form of the given model
      AsyncStage<java.lang.String> set​(T model, org.apache.zookeeper.data.Stat storingStatIn, int version)
      Create (or update depending on build options) a ZNode at this instance's path with a serialized form of the given model
      AsyncCuratorFramework unwrap()
      Returns the client that was originally passed to wrap(org.apache.curator.x.async.AsyncCuratorFramework, ModelSpec) or the builder.
      AsyncStage<org.apache.zookeeper.data.Stat> update​(T model)
      Update the ZNode at this instance's path with a serialized form of the given model passing "-1" for the update version
      AsyncStage<org.apache.zookeeper.data.Stat> update​(T model, int version)
      Update the ZNode at this instance's path with a serialized form of the given model passing the given update version
      org.apache.curator.framework.api.transaction.CuratorOp updateOp​(T model)
      Update operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      org.apache.curator.framework.api.transaction.CuratorOp updateOp​(T model, int version)
      Create operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
      VersionedModeledFramework<T> versioned()
      Return mutator APIs that work with Versioned containers
      ModeledFramework<T> withPath​(ZPath path)
      Return a Modeled Curator instance with all the same options but using the given path.
      static <T> ModeledFramework<T> wrap​(AsyncCuratorFramework client, ModelSpec<T> model)
      Return a new ModeledFramework for the given model
    • Method Detail

      • wrap

        static <T> ModeledFramework<T> wrap​(AsyncCuratorFramework client,
                                            ModelSpec<T> model)
        Return a new ModeledFramework for the given model
        Parameters:
        client - Curator client
        model - the model
        Returns:
        new Modeled Curator instance
      • cached

        CachedModeledFramework<T> cached()

        Use an internally created cache as a front for this modeled instance. All read APIs use the internal cache. i.e. read calls always use the cache instead of making direct queries. Note: you must call CachedModeledFramework.start() and CachedModeledFramework.close() to start/stop

        Note: the root node (the main path of the model) is not cached. i.e. only nodes below the root are cached.

        Note: this method internally allocates an Executor for the cache and read methods. Use cached(java.util.concurrent.ExecutorService) if you'd like to provide your own executor service.

        Returns:
        wrapped instance
      • cached

        CachedModeledFramework<T> cached​(java.util.concurrent.ExecutorService executor)
        Same as cached() but allows for providing an executor service
        Parameters:
        executor - thread pool to use for the cache and for read operations
        Returns:
        wrapped instance
      • modelSpec

        ModelSpec<T> modelSpec()
        Return the model being used
        Returns:
        model
      • child

        ModeledFramework<T> child​(java.lang.Object child)

        Return a new Modeled Curator instance with all the same options but applying to the given child node of this Modeled Curator's path. E.g. if this Modeled Curator instance applies to "/a/b", calling modeled.at("c") returns an instance that applies to "/a/b/c".

        The replacement is the toString() value of child or, if it implements NodeName, the value of nodeName().

        Parameters:
        child - child node.
        Returns:
        new Modeled Curator instance
      • parent

        ModeledFramework<T> parent()

        Return a new Modeled Curator instance with all the same options but applying to the parent node of this Modeled Curator's path. E.g. if this Modeled Curator instance applies to "/a/b/c", calling modeled.parent() returns an instance that applies to "/a/b".

        The replacement is the toString() value of child or, if it implements NodeName, the value of nodeName().

        Returns:
        new Modeled Curator instance
      • withPath

        ModeledFramework<T> withPath​(ZPath path)
        Return a Modeled Curator instance with all the same options but using the given path.
        Parameters:
        path - new path
        Returns:
        new Modeled Curator instance
      • set

        AsyncStage<java.lang.String> set​(T model)
        Create (or update depending on build options) a ZNode at this instance's path with a serialized version of the given model
        Parameters:
        model - model to write
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • set

        AsyncStage<java.lang.String> set​(T model,
                                         int version)
        Create (or update depending on build options) a ZNode at this instance's path with a serialized version of the given model
        Parameters:
        model - model to write
        version - if data is being set instead of creating the node, the data version to use
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • set

        AsyncStage<java.lang.String> set​(T model,
                                         org.apache.zookeeper.data.Stat storingStatIn)
        Create (or update depending on build options) a ZNode at this instance's path with a serialized form of the given model
        Parameters:
        model - model to write
        storingStatIn - the stat for the new ZNode is stored here
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • set

        AsyncStage<java.lang.String> set​(T model,
                                         org.apache.zookeeper.data.Stat storingStatIn,
                                         int version)
        Create (or update depending on build options) a ZNode at this instance's path with a serialized form of the given model
        Parameters:
        model - model to write
        version - if data is being set instead of creating the node, the data version to use
        storingStatIn - the stat for the new ZNode is stored here
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • read

        AsyncStage<T> read()
        Read the ZNode at this instance's path and deserialize into a model
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • read

        AsyncStage<T> read​(org.apache.zookeeper.data.Stat storingStatIn)
        Read the ZNode at this instance's path and deserialize into a model
        Parameters:
        storingStatIn - the stat for the new ZNode is stored here
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • readAsZNode

        AsyncStage<ZNode<T>> readAsZNode()
        Read the ZNode at this instance's path and deserialize into a model
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • update

        AsyncStage<org.apache.zookeeper.data.Stat> update​(T model)
        Update the ZNode at this instance's path with a serialized form of the given model passing "-1" for the update version
        Parameters:
        model - model to write
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • update

        AsyncStage<org.apache.zookeeper.data.Stat> update​(T model,
                                                          int version)
        Update the ZNode at this instance's path with a serialized form of the given model passing the given update version
        Parameters:
        model - model to write
        version - update version to use
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • delete

        AsyncStage<java.lang.Void> delete()
        Delete the ZNode at this instance's path passing -1 for the delete version
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • delete

        AsyncStage<java.lang.Void> delete​(int version)
        Delete the ZNode at this instance's path passing the given delete version
        Parameters:
        version - update version to use
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • checkExists

        AsyncStage<org.apache.zookeeper.data.Stat> checkExists()
        Check to see if the ZNode at this instance's path exists
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • children

        AsyncStage<java.util.List<ZPath>> children()
        Return the child paths of this instance's path (in no particular order)
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • childrenAsZNodes

        AsyncStage<java.util.List<ZNode<T>>> childrenAsZNodes()
        Return the child paths of this instance's path (in no particular order) and deserialize into a models. IMPORTANT: this results in a ZooKeeper query for each child node returned. i.e. if the initial children() call returns 10 nodes an additional 10 ZooKeeper queries are made to get the data. Note: cannot be used if any of the ModeledFrameworkBuilder.watched() modes are used.
        Returns:
        AsyncStage
        See Also:
        AsyncStage
      • createOp

        org.apache.curator.framework.api.transaction.CuratorOp createOp​(T model)
        Create operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction. Note: due to ZooKeeper transaction limits, this is a _not_ a "set or update" operation but only a create operation and will generate an error if the node already exists.
        Parameters:
        model - the model
        Returns:
        operation
      • updateOp

        org.apache.curator.framework.api.transaction.CuratorOp updateOp​(T model)
        Update operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
        Parameters:
        model - the model
        Returns:
        operation
      • updateOp

        org.apache.curator.framework.api.transaction.CuratorOp updateOp​(T model,
                                                                        int version)
        Create operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
        Parameters:
        model - the model
        version - update version to use
        Returns:
        operation
      • deleteOp

        org.apache.curator.framework.api.transaction.CuratorOp deleteOp()
        Delete operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
        Returns:
        operation
      • deleteOp

        org.apache.curator.framework.api.transaction.CuratorOp deleteOp​(int version)
        Delete operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
        Parameters:
        version - delete version to use
        Returns:
        operation
      • checkExistsOp

        org.apache.curator.framework.api.transaction.CuratorOp checkExistsOp()
        Check exists operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
        Returns:
        operation
      • checkExistsOp

        org.apache.curator.framework.api.transaction.CuratorOp checkExistsOp​(int version)
        Check exists operation instance that can be passed among other operations to inTransaction(java.util.List) to be executed as a single transaction.
        Parameters:
        version - version to use
        Returns:
        operation
      • inTransaction

        AsyncStage<java.util.List<org.apache.curator.framework.api.transaction.CuratorTransactionResult>> inTransaction​(java.util.List<org.apache.curator.framework.api.transaction.CuratorOp> operations)
        Invoke ZooKeeper to commit the given operations as a single transaction.
        Parameters:
        operations - operations that make up the transaction.
        Returns:
        AsyncStage instance for managing the completion