Package org.apache.bookkeeper.discover
Class ZKRegistrationClient
- java.lang.Object
-
- org.apache.bookkeeper.discover.ZKRegistrationClient
-
- All Implemented Interfaces:
java.lang.AutoCloseable,RegistrationClient
public class ZKRegistrationClient extends java.lang.Object implements RegistrationClient
ZooKeeper basedRegistrationClient.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classZKRegistrationClient.WatchTask-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.discover.RegistrationClient
RegistrationClient.RegistrationListener
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intZK_CONNECT_BACKOFF_MS
-
Constructor Summary
Constructors Constructor Description ZKRegistrationClient(org.apache.zookeeper.ZooKeeper zk, java.lang.String ledgersRootPath, java.util.concurrent.ScheduledExecutorService scheduler, boolean bookieAddressTracking)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()(package private) static BookieServiceInfodeserializeBookieServiceInfo(BookieId bookieId, byte[] bookieServiceInfo)java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>>getAllBookies()Get the list of all bookies identifiers.java.util.concurrent.CompletableFuture<Versioned<BookieServiceInfo>>getBookieServiceInfo(BookieId bookieId)Get detailed information about the services exposed by a Bookie.java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>>getReadOnlyBookies()Get the list of readonly bookie identifiers.(package private) ZKRegistrationClient.WatchTaskgetWatchReadOnlyBookiesTask()(package private) ZKRegistrationClient.WatchTaskgetWatchWritableBookiesTask()java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>>getWritableBookies()Get the list of writable bookie identifiers.org.apache.zookeeper.ZooKeepergetZk()booleanisBookieAddressTracking()voidunwatchReadOnlyBookies(RegistrationClient.RegistrationListener listener)Unwatch the changes of bookies.voidunwatchWritableBookies(RegistrationClient.RegistrationListener listener)Unwatch the changes of bookies.java.util.concurrent.CompletableFuture<java.lang.Void>watchReadOnlyBookies(RegistrationClient.RegistrationListener listener)Watch the changes of bookies.java.util.concurrent.CompletableFuture<java.lang.Void>watchWritableBookies(RegistrationClient.RegistrationListener listener)Watch the changes of bookies.
-
-
-
Field Detail
-
ZK_CONNECT_BACKOFF_MS
static final int ZK_CONNECT_BACKOFF_MS
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceRegistrationClient
-
isBookieAddressTracking
public boolean isBookieAddressTracking()
-
getZk
public org.apache.zookeeper.ZooKeeper getZk()
-
getWritableBookies
public java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>> getWritableBookies()
Description copied from interface:RegistrationClientGet the list of writable bookie identifiers.- Specified by:
getWritableBookiesin interfaceRegistrationClient- Returns:
- a future represents the list of writable bookies.
-
getAllBookies
public java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>> getAllBookies()
Description copied from interface:RegistrationClientGet the list of all bookies identifiers.- Specified by:
getAllBookiesin interfaceRegistrationClient- Returns:
- a future represents the list of all bookies.
-
getReadOnlyBookies
public java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>> getReadOnlyBookies()
Description copied from interface:RegistrationClientGet the list of readonly bookie identifiers.- Specified by:
getReadOnlyBookiesin interfaceRegistrationClient- Returns:
- a future represents the list of readonly bookies.
-
getBookieServiceInfo
public java.util.concurrent.CompletableFuture<Versioned<BookieServiceInfo>> getBookieServiceInfo(BookieId bookieId)
Description copied from interface:RegistrationClientGet detailed information about the services exposed by a Bookie. For old bookies it is expected to return an empty BookieServiceInfo structure.- Specified by:
getBookieServiceInfoin interfaceRegistrationClient- Parameters:
bookieId- this is the id of the bookie, it can be computed from aBookieId- Returns:
- a future represents the available information.
-
deserializeBookieServiceInfo
static BookieServiceInfo deserializeBookieServiceInfo(BookieId bookieId, byte[] bookieServiceInfo) throws java.io.IOException
- Throws:
java.io.IOException
-
watchWritableBookies
public java.util.concurrent.CompletableFuture<java.lang.Void> watchWritableBookies(RegistrationClient.RegistrationListener listener)
Description copied from interface:RegistrationClientWatch the changes of bookies.The topology changes of bookies will be propagated to the provided listener.
- Specified by:
watchWritableBookiesin interfaceRegistrationClient- Parameters:
listener- listener to receive the topology changes of bookies.- Returns:
- a future which completes when the bookies have been read for the first time
-
unwatchWritableBookies
public void unwatchWritableBookies(RegistrationClient.RegistrationListener listener)
Description copied from interface:RegistrationClientUnwatch the changes of bookies.- Specified by:
unwatchWritableBookiesin interfaceRegistrationClient- Parameters:
listener- listener to receive the topology changes of bookies.
-
watchReadOnlyBookies
public java.util.concurrent.CompletableFuture<java.lang.Void> watchReadOnlyBookies(RegistrationClient.RegistrationListener listener)
Description copied from interface:RegistrationClientWatch the changes of bookies.The topology changes of bookies will be propagated to the provided listener.
- Specified by:
watchReadOnlyBookiesin interfaceRegistrationClient- Parameters:
listener- listener to receive the topology changes of bookies.- Returns:
- a future which completes when the bookies have been read for the first time
-
unwatchReadOnlyBookies
public void unwatchReadOnlyBookies(RegistrationClient.RegistrationListener listener)
Description copied from interface:RegistrationClientUnwatch the changes of bookies.- Specified by:
unwatchReadOnlyBookiesin interfaceRegistrationClient- Parameters:
listener- listener to receive the topology changes of bookies.
-
getWatchWritableBookiesTask
ZKRegistrationClient.WatchTask getWatchWritableBookiesTask()
-
getWatchReadOnlyBookiesTask
ZKRegistrationClient.WatchTask getWatchReadOnlyBookiesTask()
-
-