Class ServiceUnitStateTableViewImpl
java.lang.Object
org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateTableViewImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,ServiceUnitStateTableView
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the tableview.Tries to delete the item from the persistent store.entrySet()Returns the entry set of the items in the local tableview.voidflush(long waitDurationInMillis) Tries to flush any batched or buffered updates.Gets one item from the local tableview.protected voidinit(PulsarService pulsar) Returns service units (namespace bundles) owned by this broker.put(String key, ServiceUnitStateData value) Tries to put the item in the persistent store.voidstart(PulsarService pulsar, BiConsumer<String, ServiceUnitStateData> tailItemListener, BiConsumer<String, ServiceUnitStateData> existingItemListener) Starts the tableview.protected void
-
Field Details
-
TOPIC
-
MSG_COMPRESSION_TYPE
public static final org.apache.pulsar.client.api.CompressionType MSG_COMPRESSION_TYPE -
INVALID_STATE_ERROR_MSG
- See Also:
-
-
Constructor Details
-
ServiceUnitStateTableViewImpl
public ServiceUnitStateTableViewImpl()
-
-
Method Details
-
start
public void start(PulsarService pulsar, BiConsumer<String, ServiceUnitStateData> tailItemListener, BiConsumer<String, throws IOExceptionServiceUnitStateData> existingItemListener) Description copied from interface:ServiceUnitStateTableViewStarts the tableview. It initially populates its local table view by scanning existing items in the remote store, and it starts listening to service unit ownership changes from the remote store.- Parameters:
pulsar- pulsar service referencetailItemListener- listener to listen tail(newly updated) itemsexistingItemListener- listener to listen existing items- Throws:
IOException- if it fails to init the tableview.
-
close
Description copied from interface:ServiceUnitStateTableViewCloses the tableview.- Throws:
IOException- if it fails to close the tableview.
-
get
Description copied from interface:ServiceUnitStateTableViewGets one item from the local tableview.- Parameters:
key- the key to get- Returns:
- value if exists. Otherwise, null.
-
put
Description copied from interface:ServiceUnitStateTableViewTries to put the item in the persistent store. If it completes, all peer tableviews (including the local one) will be notified and be eventually consistent with this put value. It ignores put operation if the input value conflicts with the existing one in the persistent store.- Parameters:
key- the key to putvalue- the value to put- Returns:
- a future to track the completion of the operation
-
flush
public void flush(long waitDurationInMillis) throws InterruptedException, TimeoutException, ExecutionException Description copied from interface:ServiceUnitStateTableViewTries to flush any batched or buffered updates.- Parameters:
waitDurationInMillis- time to wait until complete.- Throws:
InterruptedExceptionTimeoutExceptionExecutionException
-
delete
Description copied from interface:ServiceUnitStateTableViewTries to delete the item from the persistent store. All peer tableviews (including the local one) will be notified and be eventually consistent with this deletion. It ignores delete operation if the key is not present in the persistent store.- Parameters:
key- the key to delete- Returns:
- a future to track the completion of the operation
-
entrySet
Description copied from interface:ServiceUnitStateTableViewReturns the entry set of the items in the local tableview.- Returns:
- entry set
-
init
protected void init(PulsarService pulsar) throws org.apache.pulsar.metadata.api.MetadataStoreException - Throws:
org.apache.pulsar.metadata.api.MetadataStoreException
-
ownedServiceUnits
Description copied from interface:ServiceUnitStateTableViewReturns service units (namespace bundles) owned by this broker.- Specified by:
ownedServiceUnitsin interfaceServiceUnitStateTableView- Returns:
- a set of owned service units (namespace bundles)
-
updateOwnedServiceUnits
-