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) class
ZKRegistrationClient.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 int
ZK_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 void
close()
(package private) static BookieServiceInfo
deserializeBookieServiceInfo(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.WatchTask
getWatchReadOnlyBookiesTask()
(package private) ZKRegistrationClient.WatchTask
getWatchWritableBookiesTask()
java.util.concurrent.CompletableFuture<Versioned<java.util.Set<BookieId>>>
getWritableBookies()
Get the list of writable bookie identifiers.org.apache.zookeeper.ZooKeeper
getZk()
boolean
isBookieAddressTracking()
void
unwatchReadOnlyBookies(RegistrationClient.RegistrationListener listener)
Unwatch the changes of bookies.void
unwatchWritableBookies(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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in 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:RegistrationClient
Get the list of writable bookie identifiers.- Specified by:
getWritableBookies
in 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:RegistrationClient
Get the list of all bookies identifiers.- Specified by:
getAllBookies
in 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:RegistrationClient
Get the list of readonly bookie identifiers.- Specified by:
getReadOnlyBookies
in 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:RegistrationClient
Get detailed information about the services exposed by a Bookie. For old bookies it is expected to return an empty BookieServiceInfo structure.- Specified by:
getBookieServiceInfo
in 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:RegistrationClient
Watch the changes of bookies.The topology changes of bookies will be propagated to the provided listener.
- Specified by:
watchWritableBookies
in 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:RegistrationClient
Unwatch the changes of bookies.- Specified by:
unwatchWritableBookies
in 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:RegistrationClient
Watch the changes of bookies.The topology changes of bookies will be propagated to the provided listener.
- Specified by:
watchReadOnlyBookies
in 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:RegistrationClient
Unwatch the changes of bookies.- Specified by:
unwatchReadOnlyBookies
in interfaceRegistrationClient
- Parameters:
listener
- listener to receive the topology changes of bookies.
-
getWatchWritableBookiesTask
ZKRegistrationClient.WatchTask getWatchWritableBookiesTask()
-
getWatchReadOnlyBookiesTask
ZKRegistrationClient.WatchTask getWatchReadOnlyBookiesTask()
-
-