From 69a977007bb32c64e10ebf31769f98c90210724b Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Tue, 28 May 2024 19:30:57 +0800 Subject: [PATCH 1/4] fix telnet list command, the service list is displayed unordered fixes #14249 --- .../main/java/org/apache/dubbo/qos/command/impl/Ls.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java index b9043ecc5c7..830356129bf 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java @@ -26,6 +26,8 @@ import org.apache.dubbo.rpc.model.ProviderModel; import java.util.Collection; +import java.util.Comparator; +import java.util.stream.Collectors; @Cmd( name = "ls", @@ -53,6 +55,9 @@ public String listProvider() { Collection providerModelList = frameworkModel.getServiceRepository().allProviderModels(); + // fix: Fix: Originally, providers were stored in ConcurrentHashMap, Disordered display of servicekey list + providerModelList = providerModelList.stream().sorted(Comparator.comparing(ProviderModel::getServiceKey)).collect(Collectors.toList()); + TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) }); @@ -81,6 +86,9 @@ public String listConsumer() { Collection consumerModelList = frameworkModel.getServiceRepository().allConsumerModels(); + // fix: Fix: Originally, consumers were stored in ConcurrentHashMap, Disordered display of servicekey list + consumerModelList = consumerModelList.stream().sorted(Comparator.comparing(ConsumerModel::getServiceKey)).collect(Collectors.toList()); + TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) }); From 23bc79fd6a8b14e740ce6f29765acc8851bd6a78 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Tue, 28 May 2024 19:36:31 +0800 Subject: [PATCH 2/4] format code --- .../main/java/org/apache/dubbo/qos/command/impl/Ls.java | 8 ++++++-- .../java/org/apache/dubbo/qos/command/impl/LsTest.java | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java index 830356129bf..260e64b3733 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java @@ -56,7 +56,9 @@ public String listProvider() { frameworkModel.getServiceRepository().allProviderModels(); // fix: Fix: Originally, providers were stored in ConcurrentHashMap, Disordered display of servicekey list - providerModelList = providerModelList.stream().sorted(Comparator.comparing(ProviderModel::getServiceKey)).collect(Collectors.toList()); + providerModelList = providerModelList.stream() + .sorted(Comparator.comparing(ProviderModel::getServiceKey)) + .collect(Collectors.toList()); TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) @@ -87,7 +89,9 @@ public String listConsumer() { frameworkModel.getServiceRepository().allConsumerModels(); // fix: Fix: Originally, consumers were stored in ConcurrentHashMap, Disordered display of servicekey list - consumerModelList = consumerModelList.stream().sorted(Comparator.comparing(ConsumerModel::getServiceKey)).collect(Collectors.toList()); + consumerModelList = consumerModelList.stream() + .sorted(Comparator.comparing(ConsumerModel::getServiceKey)) + .collect(Collectors.toList()); TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) diff --git a/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java b/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java index 369008d7c0a..c4c6741262a 100644 --- a/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java +++ b/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java @@ -105,4 +105,7 @@ private void registerConsumer() { referenceConfig.getInterfaceClassLoader()); repository.registerConsumer(consumerModel); } + + @Test + public void testExecute() { } From ce9809934dc87296b3568c24f8456f785f1f9090 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Tue, 28 May 2024 19:52:09 +0800 Subject: [PATCH 3/4] remove useless code --- .../test/java/org/apache/dubbo/qos/command/impl/LsTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java b/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java index c4c6741262a..369008d7c0a 100644 --- a/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java +++ b/dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/LsTest.java @@ -105,7 +105,4 @@ private void registerConsumer() { referenceConfig.getInterfaceClassLoader()); repository.registerConsumer(consumerModel); } - - @Test - public void testExecute() { } From 56d36d9eee37fe07f32feb0848e2253ba6fbaa2f Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Tue, 28 May 2024 20:03:42 +0800 Subject: [PATCH 4/4] remove useless code --- .../src/main/java/org/apache/dubbo/qos/command/impl/Ls.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java index 260e64b3733..f4a49fbedb7 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java @@ -55,7 +55,7 @@ public String listProvider() { Collection providerModelList = frameworkModel.getServiceRepository().allProviderModels(); - // fix: Fix: Originally, providers were stored in ConcurrentHashMap, Disordered display of servicekey list + // Fix: Originally, providers were stored in ConcurrentHashMap, Disordered display of servicekey list providerModelList = providerModelList.stream() .sorted(Comparator.comparing(ProviderModel::getServiceKey)) .collect(Collectors.toList()); @@ -88,7 +88,7 @@ public String listConsumer() { Collection consumerModelList = frameworkModel.getServiceRepository().allConsumerModels(); - // fix: Fix: Originally, consumers were stored in ConcurrentHashMap, Disordered display of servicekey list + // Fix: Originally, consumers were stored in ConcurrentHashMap, Disordered display of servicekey list consumerModelList = consumerModelList.stream() .sorted(Comparator.comparing(ConsumerModel::getServiceKey)) .collect(Collectors.toList());