heesung-sn commented on code in PR #23301:
URL: https://github.com/apache/pulsar/pull/23301#discussion_r1766168434
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/store/TableViewLoadDataStoreImpl.java:
##########
@@ -65,48 +62,84 @@ public TableViewLoadDataStoreImpl(PulsarService pulsar,
String topic, Class<T> c
this.client = pulsar.getClient();
this.topic = topic;
this.clazz = clazz;
+ this.isShutdown = false;
} catch (Exception e) {
throw new LoadDataStoreException(e);
}
}
@Override
public synchronized CompletableFuture<Void> pushAsync(String key, T
loadData) {
- validateProducer();
- return
producer.newMessage().key(key).value(loadData).sendAsync().thenAccept(__ -> {});
+ String msg = validateProducer();
+ if (StringUtils.isNotBlank(msg)) {
+ return CompletableFuture.failedFuture(new
IllegalStateException(msg));
+ }
+ return producer.newMessage().key(key).value(loadData).sendAsync()
+ .thenAccept(__ -> producerLastPublishTimestamp =
System.currentTimeMillis());
}
@Override
public synchronized CompletableFuture<Void> removeAsync(String key) {
- validateProducer();
- return
producer.newMessage().key(key).value(null).sendAsync().thenAccept(__ -> {});
+ String msg = validateProducer();
+ if (StringUtils.isNotBlank(msg)) {
+ return CompletableFuture.failedFuture(new
IllegalStateException(msg));
+ }
+ return producer.newMessage().key(key).value(null).sendAsync()
+ .thenAccept(__ -> producerLastPublishTimestamp =
System.currentTimeMillis());
}
@Override
public synchronized Optional<T> get(String key) {
- validateTableView();
+ String msg = validateTableView();
+ if (StringUtils.isNotBlank(msg)) {
+ throw new IllegalStateException(msg);
+ }
return Optional.ofNullable(tableView.get(key));
}
@Override
public synchronized void forEach(BiConsumer<String, T> action) {
- validateTableView();
+ String msg = validateTableView();
+ if (StringUtils.isNotBlank(msg)) {
+ throw new IllegalStateException(msg);
Review Comment:
I think this can be a runtime exception. I dont think we need a checked one
here and make the caller explicitly catch this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]