用法
创建一个DistributedAtomicLong
乐观模式:
public DistributedAtomicLong(CuratorFramework client,
String counterPath,
RetryPolicy retryPolicy)
Creates the counter in optimistic mode only - i.e. the promotion to a mutex is not done
Parameters:
client - the client
counterPath - path to hold the counter value
retryPolicy - the retry policy to use
互斥促进模式:
public DistributedAtomicLong(CuratorFramework client,
String counterPath,
RetryPolicy retryPolicy,
PromotedToLock promotedToLock)
Creates the counter in mutex promotion mode. The optimistic lock will be tried first using
the given retry policy. If the increment does not succeed, a InterProcessMutex will be
tried with its own retry policy
Parameters:
client - the client
counterPath - path to hold the counter value
retryPolicy - the retry policy to use
promotedToLock - the arguments for the mutex promotion