-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][broker][PIP-149]Make getList async #16221
Conversation
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@@ -4251,7 +4243,7 @@ private RestException topicNotFoundReason(TopicName topicName) { | |||
== null ? "has no metadata" : "has zero partitions"; | |||
return new RestException(Status.NOT_FOUND, String.format( | |||
"Partitioned Topic not found: %s %s", topicName.toString(), topicErrorType)); | |||
} else if (!internalGetList(Optional.empty()).contains(topicName.toString())) { | |||
} else if (!internalGetListAsync(Optional.empty()).join().contains(topicName.toString())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to avoid using the join()
and get()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep both internalGetList
and internalGetListAsync
? @nodece
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you need to make the topicNotFoundReason
to async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There has existed a method topicNotFoundReasonAsync
, but topicNotFoundReason
are still invoked by getTopicReference
, which appears in many methods. I think it's better to cleanup topicNotFoundReason
when other methods have replaced getTopicReference
with getTopicReferenceAsync
.So it's looks OK using join
here @nodece
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's better using get(pulsar().getConfiguration().getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS)
instead of join()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sync(() -> topicNotFoundReasonAsync()
@@ -4271,7 +4263,7 @@ private CompletableFuture<Topic> topicNotFoundReasonAsync(TopicName topicName) { | |||
== null ? "has no metadata" : "has zero partitions"; | |||
throw new RestException(Status.NOT_FOUND, String.format( | |||
"Partitioned Topic not found: %s %s", topicName.toString(), topicErrorType)); | |||
} else if (!internalGetList(Optional.empty()).contains(topicName.toString())) { | |||
} else if (!internalGetListAsync(Optional.empty()).join().contains(topicName.toString())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to avoid using the join()
and get()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nodece , I removed join
in topicNotFoundReasonAsync
. PTAL
return new RestException(Status.NOT_FOUND, "Topic partitions were not yet created"); | ||
} | ||
} catch (Exception e) { | ||
// failed to get reason, so fall through coarse reason |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should throw an error, or return return new RestException(Status.NOT_FOUND, e.getMessage());
You can look at other people's opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en...It seems that e.getMessage
is not the real reason I think @nodece , Please take a look also @Technoboy- @Jason918
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can add a new sync method called internalGetList
like getPartitionedTopicMetadata
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks bettter to keep the original internalGetList
, and cleanup it until making all other methods async @Technoboy-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to reduce the duplicated codes, you can do it like sync(() -> internalGetListAsync()
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: congbobo184 <[email protected]>
Master Issue: #14365
Motivation
Modifications
Verifying this change
Documentation
doc-not-needed