ACLable<java.lang.String>, ACLBackgroundPathAndBytesable<java.lang.String>, ACLCreateModeBackgroundPathAndBytesable<java.lang.String>, Backgroundable<java.lang.String>, BackgroundPathAndBytesable<java.lang.String>, Compressible<java.lang.String>, CreateBuilder, CreateBuilder2, CreateBuilderMain, CreateModable<java.lang.String>, ErrorListenerPathAndBytesable<java.lang.String>, ParentACLable<java.lang.String>, PathAndBytesable<java.lang.String>, Statable<java.lang.String>public class CreateBuilderImpl extends java.lang.Object implements CreateBuilder, CreateBuilder2, ErrorListenerPathAndBytesable<java.lang.String>
| Constructor | Description |
|---|---|
CreateBuilderImpl(CuratorFrameworkImpl client,
org.apache.zookeeper.CreateMode createMode,
Backgrounding backgrounding,
boolean createParentsIfNeeded,
boolean createParentsAsContainers,
boolean doProtected,
boolean compress,
boolean setDataIfExists,
java.util.List<org.apache.zookeeper.data.ACL> aclList,
org.apache.zookeeper.data.Stat storingStat,
long ttl) |
| Modifier and Type | Method | Description |
|---|---|---|
CreateBackgroundModeStatACLable |
compressed() |
Cause the data to be compressed using the configured compression provider
|
ProtectACLCreateModeStatPathAndBytesable<java.lang.String> |
creatingParentContainersIfNeeded() |
Causes any parent nodes to get created using
CreateMode.CONTAINER if they haven't already been. |
ProtectACLCreateModeStatPathAndBytesable<java.lang.String> |
creatingParentsIfNeeded() |
Causes any parent nodes to get created if they haven't already been
|
java.lang.String |
forPath(java.lang.String path) |
Commit the currently building operation using the given path and the default data
for the client (usually a byte[0] unless changed via
CuratorFrameworkFactory.Builder.defaultData(byte[])). |
java.lang.String |
forPath(java.lang.String givenPath,
byte[] data) |
Commit the currently building operation using the given path and data
|
ErrorListenerPathAndBytesable<java.lang.String> |
inBackground() |
Perform the action in the background
|
ErrorListenerPathAndBytesable<java.lang.String> |
inBackground(java.lang.Object context) |
Perform the action in the background
|
ErrorListenerPathAndBytesable<java.lang.String> |
inBackground(BackgroundCallback callback) |
Perform the action in the background
|
ErrorListenerPathAndBytesable<java.lang.String> |
inBackground(BackgroundCallback callback,
java.lang.Object context) |
Perform the action in the background
|
ErrorListenerPathAndBytesable<java.lang.String> |
inBackground(BackgroundCallback callback,
java.lang.Object context,
java.util.concurrent.Executor executor) |
Perform the action in the background
|
ErrorListenerPathAndBytesable<java.lang.String> |
inBackground(BackgroundCallback callback,
java.util.concurrent.Executor executor) |
Perform the action in the background
|
CreateBuilder2 |
orSetData() |
If the ZNode already exists, Curator will instead call setData()
|
CreateBuilder2 |
orSetData(int version) |
If the ZNode already exists, Curator will instead call setData()
|
void |
performBackgroundOperation(org.apache.curator.framework.imps.OperationAndData<org.apache.curator.framework.imps.PathAndBytes> operationAndData) |
|
void |
setSetDataIfExistsVersion(int version) |
|
CreateProtectACLCreateModePathAndBytesable<java.lang.String> |
storingStatIn(org.apache.zookeeper.data.Stat stat) |
Have the operation fill the provided stat object
|
ACLBackgroundPathAndBytesable<java.lang.String> |
withACL(java.util.List<org.apache.zookeeper.data.ACL> aclList) |
Set an ACL list (default is
ZooDefs.Ids.OPEN_ACL_UNSAFE) |
ACLBackgroundPathAndBytesable<java.lang.String> |
withACL(java.util.List<org.apache.zookeeper.data.ACL> aclList,
boolean applyToParents) |
Set an ACL list (default is
ZooDefs.Ids.OPEN_ACL_UNSAFE). |
ACLBackgroundPathAndBytesable<java.lang.String> |
withMode(org.apache.zookeeper.CreateMode mode) |
Set a create mode - the default is
CreateMode.PERSISTENT |
ACLPathAndBytesable<java.lang.String> |
withProtectedEphemeralSequential() |
|
ACLCreateModeStatBackgroundPathAndBytesable<java.lang.String> |
withProtection() |
Hat-tip to https://github.com/sbridges for pointing this out
|
CreateBuilderMain |
withTtl(long ttl) |
Specify a TTL when mode is
CreateMode.PERSISTENT_WITH_TTL or
CreateMode.PERSISTENT_SEQUENTIAL_WITH_TTL. |
PathAndBytesable<java.lang.String> |
withUnhandledErrorListener(UnhandledErrorListener listener) |
Set an error listener for this background operation.
|
public CreateBuilderImpl(CuratorFrameworkImpl client, org.apache.zookeeper.CreateMode createMode, Backgrounding backgrounding, boolean createParentsIfNeeded, boolean createParentsAsContainers, boolean doProtected, boolean compress, boolean setDataIfExists, java.util.List<org.apache.zookeeper.data.ACL> aclList, org.apache.zookeeper.data.Stat storingStat, long ttl)
public void setSetDataIfExistsVersion(int version)
public CreateBuilder2 orSetData()
CreateBuilderorSetData in interface CreateBuilderpublic CreateBuilder2 orSetData(int version)
CreateBuilderorSetData in interface CreateBuilderversion - the version to use for CuratorFramework.setData()public CreateBuilderMain withTtl(long ttl)
CreateBuilderCreateMode.PERSISTENT_WITH_TTL or
CreateMode.PERSISTENT_SEQUENTIAL_WITH_TTL. If
the znode has not been modified within the given TTL, it will be deleted once it has no
children. The TTL unit is milliseconds and must be greater than 0 and less than or equal to
EphemeralType.MAX_TTL.withTtl in interface CreateBuilderwithTtl in interface CreateBuilder2ttl - the ttlpublic CreateBackgroundModeStatACLable compressed()
Compressiblecompressed in interface Compressible<java.lang.String>public ACLBackgroundPathAndBytesable<java.lang.String> withACL(java.util.List<org.apache.zookeeper.data.ACL> aclList)
ACLableZooDefs.Ids.OPEN_ACL_UNSAFE)public ACLBackgroundPathAndBytesable<java.lang.String> withACL(java.util.List<org.apache.zookeeper.data.ACL> aclList, boolean applyToParents)
ParentACLableZooDefs.Ids.OPEN_ACL_UNSAFE).
If applyToParents is true, then the aclList is applied to the created parents.
Existing parent nodes are not affected.withACL in interface ParentACLable<java.lang.String>aclList - the ACL list to useapplyToParents - if true, then the aclList is applied to the created parents.public ProtectACLCreateModeStatPathAndBytesable<java.lang.String> creatingParentContainersIfNeeded()
CreateBuilderMainCreateMode.CONTAINER if they haven't already been.
IMPORTANT NOTE: container creation is a new feature in recent versions of ZooKeeper.
If the ZooKeeper version you're using does not support containers, the parent nodes
are created as ordinary PERSISTENT nodes.creatingParentContainersIfNeeded in interface CreateBuilderMainpublic ProtectACLCreateModeStatPathAndBytesable<java.lang.String> creatingParentsIfNeeded()
CreateBuilderMaincreatingParentsIfNeeded in interface CreateBuilderMainpublic ACLCreateModeStatBackgroundPathAndBytesable<java.lang.String> withProtection()
CreateBuilderMainHat-tip to https://github.com/sbridges for pointing this out
It turns out there is an edge case that exists when creating sequential-ephemeral nodes. The creation can succeed on the server, but the server can crash before the created node name is returned to the client. However, the ZK session is still valid so the ephemeral node is not deleted. Thus, there is no way for the client to determine what node was created for them.
Even without sequential-ephemeral, however, the create can succeed on the sever but the client (for various reasons) will not know it.
Putting the create builder into protection mode works around this. The name of the node that is created is prefixed with a GUID. If node creation fails the normal retry mechanism will occur. On the retry, the parent path is first searched for a node that has the GUID in it. If that node is found, it is assumed to be the lost node that was successfully created on the first try and is returned to the caller.
withProtection in interface CreateBuilderMainpublic ACLPathAndBytesable<java.lang.String> withProtectedEphemeralSequential()
withProtectedEphemeralSequential in interface CreateBuilderMainpublic ACLBackgroundPathAndBytesable<java.lang.String> withMode(org.apache.zookeeper.CreateMode mode)
CreateModableCreateMode.PERSISTENTwithMode in interface CreateModable<java.lang.String>mode - new create modepublic ErrorListenerPathAndBytesable<java.lang.String> inBackground(BackgroundCallback callback, java.lang.Object context)
BackgroundableinBackground in interface Backgroundable<java.lang.String>callback - a functor that will get called when the operation has completedcontext - context object - will be available from the event sent to the listenerpublic ErrorListenerPathAndBytesable<java.lang.String> inBackground(BackgroundCallback callback, java.lang.Object context, java.util.concurrent.Executor executor)
BackgroundableinBackground in interface Backgroundable<java.lang.String>callback - a functor that will get called when the operation has completedcontext - context object - will be available from the event sent to the listenerexecutor - executor to use for the background callpublic ErrorListenerPathAndBytesable<java.lang.String> inBackground(BackgroundCallback callback)
BackgroundableinBackground in interface Backgroundable<java.lang.String>callback - a functor that will get called when the operation has completedpublic ErrorListenerPathAndBytesable<java.lang.String> inBackground(BackgroundCallback callback, java.util.concurrent.Executor executor)
BackgroundableinBackground in interface Backgroundable<java.lang.String>callback - a functor that will get called when the operation has completedexecutor - executor to use for the background callpublic ErrorListenerPathAndBytesable<java.lang.String> inBackground()
BackgroundableinBackground in interface Backgroundable<java.lang.String>public ErrorListenerPathAndBytesable<java.lang.String> inBackground(java.lang.Object context)
BackgroundableinBackground in interface Backgroundable<java.lang.String>context - context object - will be available from the event sent to the listenerpublic PathAndBytesable<java.lang.String> withUnhandledErrorListener(UnhandledErrorListener listener)
ErrorListenerPathAndBytesablewithUnhandledErrorListener in interface ErrorListenerPathAndBytesable<java.lang.String>listener - the listenerpublic java.lang.String forPath(java.lang.String path)
throws java.lang.Exception
PathAndBytesableCuratorFrameworkFactory.Builder.defaultData(byte[])).forPath in interface PathAndBytesable<java.lang.String>path - the pathjava.lang.Exception - errorspublic java.lang.String forPath(java.lang.String givenPath,
byte[] data)
throws java.lang.Exception
PathAndBytesableforPath in interface PathAndBytesable<java.lang.String>givenPath - the pathdata - the datajava.lang.Exception - errorspublic void performBackgroundOperation(org.apache.curator.framework.imps.OperationAndData<org.apache.curator.framework.imps.PathAndBytes> operationAndData)
throws java.lang.Exception
java.lang.Exceptionpublic CreateProtectACLCreateModePathAndBytesable<java.lang.String> storingStatIn(org.apache.zookeeper.data.Stat stat)
StatablestoringStatIn in interface Statable<java.lang.String>stat - the stat to have filled inCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.