This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new 4b0be436 fix: return unavailable for consumer group providers (#787)
4b0be436 is described below
commit 4b0be436e1f8970acf2487ac9eb061b1dcfa4018
Author: aias00 <[email protected]>
AuthorDate: Tue Aug 4 03:03:07 2026 -0700
fix: return unavailable for consumer group providers (#787)
---
.../instance/topic/CloudMetadataProvider.java | 11 +++--
.../studio/instance/topic/NameSrvAdminClient.java | 13 ++++--
.../instance/topic/CloudMetadataProviderTest.java | 43 +++++++++++++++++++
.../instance/topic/NameSrvAdminClientTest.java | 48 ++++++++++++++++++++++
4 files changed, 108 insertions(+), 7 deletions(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProvider.java
b/server/src/main/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProvider.java
index a0053447..7ca6e000 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProvider.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProvider.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.studio.instance.topic;
+import org.apache.rocketmq.studio.common.exception.BusinessException;
import org.apache.rocketmq.studio.instance.group.ConsumerGroupVO;
import org.apache.rocketmq.studio.instance.group.QueueProgressVO;
import org.apache.rocketmq.studio.instance.group.SubscriptionEntryVO;
@@ -37,7 +38,7 @@ public class CloudMetadataProvider implements
MetadataProvider {
@Override
public List<ConsumerGroupVO> listConsumerGroups(String clusterId, String
search) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupProviderUnavailable();
}
@Override
@@ -52,11 +53,15 @@ public class CloudMetadataProvider implements
MetadataProvider {
@Override
public List<QueueProgressVO> getGroupProgress(String name) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupProviderUnavailable();
}
@Override
public List<SubscriptionEntryVO> getGroupSubscriptions(String name) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupProviderUnavailable();
+ }
+
+ private BusinessException consumerGroupProviderUnavailable() {
+ return new BusinessException(501, "Consumer group metadata provider is
not configured");
}
}
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClient.java
b/server/src/main/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClient.java
index 60f05a34..3fe8c189 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClient.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClient.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.studio.instance.topic;
+import org.apache.rocketmq.studio.common.exception.BusinessException;
import org.apache.rocketmq.studio.instance.group.ConsumerGroupVO;
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +34,7 @@ public class NameSrvAdminClient implements AdminClient {
@Override
public ConsumerGroupVO getConsumerGroup(String name) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupAdminUnavailable();
}
@Override
@@ -58,16 +59,20 @@ public class NameSrvAdminClient implements AdminClient {
@Override
public ConsumerGroupVO createConsumerGroup(ConsumerGroupVO group) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupAdminUnavailable();
}
@Override
public void deleteConsumerGroup(String name) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupAdminUnavailable();
}
@Override
public void resetOffset(String name, long timestamp, String topic) {
- throw new UnsupportedOperationException("Not implemented");
+ throw consumerGroupAdminUnavailable();
+ }
+
+ private BusinessException consumerGroupAdminUnavailable() {
+ return new BusinessException(501, "Consumer group admin client is not
configured");
}
}
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProviderTest.java
b/server/src/test/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProviderTest.java
new file mode 100644
index 00000000..81b82889
--- /dev/null
+++
b/server/src/test/java/org/apache/rocketmq/studio/instance/topic/CloudMetadataProviderTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.studio.instance.topic;
+
+import org.apache.rocketmq.studio.common.exception.BusinessException;
+import org.assertj.core.api.ThrowableAssert;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class CloudMetadataProviderTest {
+
+ private final CloudMetadataProvider provider = new CloudMetadataProvider();
+
+ @Test
+ void consumerGroupQueriesShouldReturnProviderUnavailable() {
+ assertUnavailable(() -> provider.listConsumerGroups("cluster-1",
"order"));
+ assertUnavailable(() -> provider.getGroupProgress("cg-order"));
+ assertUnavailable(() -> provider.getGroupSubscriptions("cg-order"));
+ }
+
+ private void assertUnavailable(ThrowableAssert.ThrowingCallable callable) {
+ assertThatThrownBy(callable)
+ .isInstanceOf(BusinessException.class)
+ .hasMessage("Consumer group metadata provider is not
configured")
+ .satisfies(ex -> assertThat(((BusinessException)
ex).getCode()).isEqualTo(501));
+ }
+}
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClientTest.java
b/server/src/test/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClientTest.java
new file mode 100644
index 00000000..0b7f1928
--- /dev/null
+++
b/server/src/test/java/org/apache/rocketmq/studio/instance/topic/NameSrvAdminClientTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.studio.instance.topic;
+
+import org.apache.rocketmq.studio.common.exception.BusinessException;
+import org.apache.rocketmq.studio.instance.group.ConsumerGroupVO;
+import org.assertj.core.api.ThrowableAssert;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class NameSrvAdminClientTest {
+
+ private final NameSrvAdminClient adminClient = new NameSrvAdminClient();
+
+ @Test
+ void consumerGroupOperationsShouldReturnAdminUnavailable() {
+ ConsumerGroupVO group = new ConsumerGroupVO();
+ group.setName("cg-order");
+
+ assertUnavailable(() -> adminClient.getConsumerGroup("cg-order"));
+ assertUnavailable(() -> adminClient.createConsumerGroup(group));
+ assertUnavailable(() -> adminClient.deleteConsumerGroup("cg-order"));
+ assertUnavailable(() -> adminClient.resetOffset("cg-order",
1784246400000L, "order-topic"));
+ }
+
+ private void assertUnavailable(ThrowableAssert.ThrowingCallable callable) {
+ assertThatThrownBy(callable)
+ .isInstanceOf(BusinessException.class)
+ .hasMessage("Consumer group admin client is not configured")
+ .satisfies(ex -> assertThat(((BusinessException)
ex).getCode()).isEqualTo(501));
+ }
+}