zrlw commented on code in PR #15590:
URL: https://github.com/apache/dubbo/pull/15590#discussion_r2238354838


##########
dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/DiscoveryTimelineCommand.java:
##########
@@ -0,0 +1,349 @@
+/*
+ * 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.dubbo.qos.command.impl;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.qos.api.BaseCommand;
+import org.apache.dubbo.qos.api.Cmd;
+import org.apache.dubbo.qos.api.CommandContext;
+import org.apache.dubbo.registry.client.ServiceDiscovery;
+import org.apache.dubbo.registry.client.ServiceInstance;
+import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
+import 
org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener;
+import org.apache.dubbo.registry.support.RegistryManager;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+import org.apache.dubbo.rpc.model.FrameworkServiceRepository;
+import org.apache.dubbo.rpc.model.ProviderModel;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@Cmd(
+        name = "discovery-timeline",
+        summary = "Show service discovery timeline",
+        example = {
+            "discovery-timeline",
+            "discovery-timeline service=com.example.Service",
+            "discovery-timeline registry=zookeeper://localhost:2181",
+            "discovery-timeline page=2",
+            "discovery-timeline limit=5"
+        })
+public class DiscoveryTimelineCommand implements BaseCommand {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(DiscoveryTimelineCommand.class);
+    private final FrameworkModel frameworkModel;
+    private static final int DEFAULT_LIMIT = 10;
+    private static final Map<String, Long> globalProviderRegistrationTimes = 
new HashMap<>();
+    private static final String TIMESTAMP_KEY = "timestamp";
+
+    public DiscoveryTimelineCommand(FrameworkModel frameworkModel) {
+        this.frameworkModel = frameworkModel;
+    }
+
+    @Override
+    public String execute(CommandContext commandContext, String[] args) {
+        logger.debug("DiscoveryTimelineCommand started");
+
+        try {
+            ApplicationModel applicationModel = 
frameworkModel.defaultApplication();
+            if (applicationModel == null) {
+                throw new IllegalStateException("No ApplicationModel 
available");
+            }
+
+            RegistryManager registryManager = 
applicationModel.getBeanFactory().getBean(RegistryManager.class);
+            if (registryManager == null) {
+                logger.warn("RegistryManager not available");

Review Comment:
   All warning or error log info should logged by ErrorTypeAwareLogger.



-- 
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: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to