hangc0276 commented on a change in pull request #14259:
URL: https://github.com/apache/pulsar/pull/14259#discussion_r805495292
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -993,10 +994,12 @@ private void
internalUnloadTransactionCoordinatorAsync(AsyncResponse asyncRespon
asyncResponse.resume(Response.noContent().build());
}))
.exceptionally(ex -> {
- Throwable cause = ex.getCause();
- log.error("[{}] Failed to unload tc {},{}", clientAppId(),
- topicName.getPartitionIndex(), cause);
- resumeAsyncResponseExceptionally(asyncResponse, cause);
+ // If the exception is not redirect exception we need to
log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to unload tc {},{}",
clientAppId(),
+ topicName.getPartitionIndex(), ex);
+ }
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
Review comment:
the same above
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -753,22 +751,23 @@ protected void internalUnloadTopic(AsyncResponse
asyncResponse, boolean authorit
} else {
internalUnloadNonPartitionedTopicAsync(asyncResponse, authoritative);
}
- }).exceptionally(t -> {
- log.error("[{}] Failed to get partitioned metadata
while unloading topic {}",
- clientAppId(), topicName, t);
- if (t instanceof WebApplicationException) {
- asyncResponse.resume(t);
- } else {
- asyncResponse.resume(new RestException(t));
+ }).exceptionally(ex -> {
+ // If the exception is not redirect exception we
need to log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to get partitioned
metadata while unloading topic {}",
+ clientAppId(), topicName, ex);
}
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});
}
}).exceptionally(ex -> {
- Throwable cause = ex.getCause();
- log.error("[{}] Failed to validate the global namespace ownership
while unloading topic {}",
- clientAppId(), topicName, cause);
- resumeAsyncResponseExceptionally(asyncResponse, cause);
+ // If the exception is not redirect exception we need to log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to validate the global namespace
ownership while unloading topic {}",
+ clientAppId(), topicName, ex);
+ }
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
Review comment:
ex.getCause()?
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -1753,19 +1760,12 @@ protected void internalSkipAllMessages(AsyncResponse
asyncResponse, String subNa
}
})
.exceptionally(ex -> {
- Throwable cause = FutureUtil.unwrapCompletionException(ex);
- if (cause instanceof WebApplicationException) {
- if (log.isDebugEnabled()) {
- log.debug("[{}] Failed to skip all messages for
subscription on topic {},"
- + " redirecting to other brokers.",
- clientAppId(), topicName, cause);
- }
- resumeAsyncResponseExceptionally(asyncResponse, cause);
- } else {
+ // If the exception is not redirect exception we need to
log it.
+ if (!isRedirectException(ex)) {
log.error("[{}] Failed to skip all messages for
subscription {} on topic {}",
- clientAppId(), subName, topicName, cause);
+ clientAppId(), subName, topicName, ex);
}
- resumeAsyncResponseExceptionally(asyncResponse, cause);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
Review comment:
`FutureUtil.unwrapCompletionException(ex)` instead of `ex`?
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
##########
@@ -851,4 +851,17 @@ protected void
validatePersistencePolicies(PersistencePolicies persistence) {
persistence.getBookkeeperAckQuorum()));
}
+
+ /**
+ * Check current exception whether is redirect exception.
+ *
+ * @param ex The throwable.
+ * @return Whether is redirect exception
+ */
+ protected static boolean isRedirectException(Throwable ex) {
+ Throwable realCause = FutureUtil.unwrapCompletionException(ex);
+ return realCause instanceof WebApplicationException
Review comment:
Do we need to add debug log here?
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -753,22 +751,23 @@ protected void internalUnloadTopic(AsyncResponse
asyncResponse, boolean authorit
} else {
internalUnloadNonPartitionedTopicAsync(asyncResponse, authoritative);
}
- }).exceptionally(t -> {
- log.error("[{}] Failed to get partitioned metadata
while unloading topic {}",
- clientAppId(), topicName, t);
- if (t instanceof WebApplicationException) {
- asyncResponse.resume(t);
- } else {
- asyncResponse.resume(new RestException(t));
+ }).exceptionally(ex -> {
+ // If the exception is not redirect exception we
need to log it.
+ if (!isRedirectException(ex)) {
Review comment:
Does it ok to change the original logic here?
--
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]