Gerrrr commented on a change in pull request #1232: URL: https://github.com/apache/cassandra/pull/1232#discussion_r720677689
########## File path: src/java/org/apache/cassandra/tools/nodetool/ListEndpointsPendingHints.java ########## @@ -0,0 +1,90 @@ +/* + * 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.cassandra.tools.nodetool; + +import java.net.UnknownHostException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import io.airlift.airline.Command; +import org.apache.cassandra.hints.PendingHintsInfo; +import org.apache.cassandra.locator.EndpointSnitchInfoMBean; +import org.apache.cassandra.locator.InetAddressAndPort; +import org.apache.cassandra.tools.NodeProbe; +import org.apache.cassandra.tools.NodeTool; +import org.apache.cassandra.tools.nodetool.formatter.TableBuilder; + +@Command(name = "listendpointspendinghints", description = "Print all the endpoints that this node has hints for") +public class ListEndpointsPendingHints extends NodeTool.NodeToolCmd +{ + @Override + public void execute(NodeProbe probe) + { + List<PendingHintsInfo> pendingHints = probe.listPendingHints(); + if(pendingHints.isEmpty()) + { + probe.output().out.println("This node does not have hints for other endpoints"); + } + else + { + Map<String, String> endpointMap = probe.getHostIdToEndpointWithPort(); + Map<String, String> simpleStates = probe.getSimpleStatesWithPort(); + EndpointSnitchInfoMBean epSnitchInfo = probe.getEndpointSnitchInfoProxy(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); Review comment: Even though I also find this datetime format... unconventional, I think consistency in nodetool commands' output is more important. In my view, all commands should use the same format for datetime. If we want to change this format, then we should open a separate issue for that. As of now, the output looks like the following: ``` ✗ ccm node1 nodetool listpendinghints Host ID Address Rack DC Status Total files Newest Oldest 26a8a1cc-fcb4-465b-953f-eaec936b8b04 127.0.0.2:7000 rack1 datacenter1 DOWN 6 2021-10-02 12:36:57,801 2021-10-02 12:23:01,923 ✗ ccm node1 cqlsh cqlsh> select * from system_views.pending_hints ; host_id | address | dc | files | newest | oldest | port | rack | status --------------------------------------+-----------+-------------+-------+---------------------------------+---------------------------------+------+-------+-------- 26a8a1cc-fcb4-465b-953f-eaec936b8b04 | 127.0.0.2 | datacenter1 | 2 | 2021-10-02 12:36:42.005000+0000 | 2021-10-02 12:23:01.923000+0000 | 7000 | rack1 | DOWN (1 rows) ``` I also replaced `SimpleDateFormat` with `DateTimeFormatter` in af9e91019775d70871f112e2807b91bec44c39d5. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

