cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] dcapwell commented on a change in pull request #388: CASSANDRA-15429: Support NodeTool in dtest
Date Tue, 10 Dec 2019 23:51:40 GMT
dcapwell commented on a change in pull request #388: CASSANDRA-15429: Support NodeTool in dtest
URL: https://github.com/apache/cassandra/pull/388#discussion_r356331972
 
 

 ##########
 File path: test/distributed/org/apache/cassandra/distributed/mock/nodetool/InternalNodeProbe.java
 ##########
 @@ -0,0 +1,202 @@
+/*
+ * 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.distributed.mock.nodetool;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.management.ManagementFactory;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.MalformedObjectNameException;
+
+import com.google.common.collect.Multimap;
+
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.ColumnFamilyStoreMBean;
+import org.apache.cassandra.db.HintedHandOffManager;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.db.compaction.CompactionManager;
+import org.apache.cassandra.gms.FailureDetector;
+import org.apache.cassandra.gms.FailureDetectorMBean;
+import org.apache.cassandra.gms.Gossiper;
+import org.apache.cassandra.locator.EndpointSnitchInfo;
+import org.apache.cassandra.locator.EndpointSnitchInfoMBean;
+import org.apache.cassandra.metrics.CassandraMetricsRegistry;
+import org.apache.cassandra.metrics.DefaultNameFactory;
+import org.apache.cassandra.metrics.MetricNameFactory;
+import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.service.CacheService;
+import org.apache.cassandra.service.CacheServiceMBean;
+import org.apache.cassandra.service.GCInspector;
+import org.apache.cassandra.service.StorageProxy;
+import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.streaming.StreamManager;
+import org.apache.cassandra.tools.NodeProbe;
+import org.apache.cassandra.tools.RepairRunner;
+
+public class InternalNodeProbe extends NodeProbe
+{
+    // dummy constructors
+    public InternalNodeProbe(String host, int port, String username, String password) throws
IOException
+    {
+        super(host, port, username, password);
+    }
+
+    public InternalNodeProbe(String host, int port) throws IOException
+    {
+        super(host, port);
+    }
+
+    protected void connect() throws IOException
+    {
+        // note that we are not connecting via JMX for testing
+        mbeanServerConn = null;
+        jmxc = null;
+
+        ssProxy = StorageService.instance;
+        msProxy = MessagingService.instance();
+        streamProxy = StreamManager.instance;
+        compactionProxy = CompactionManager.instance;
+        fdProxy = (FailureDetectorMBean) FailureDetector.instance;
+        cacheService = CacheService.instance;
+        spProxy = StorageProxy.instance;
+        hhProxy = HintedHandOffManager.instance;
+        gcProxy = new GCInspector();
+        gossProxy = Gossiper.instance;
+        memProxy = ManagementFactory.getMemoryMXBean();
+        runtimeProxy = ManagementFactory.getRuntimeMXBean();
+    }
+
+    @Override
+    public void close() throws IOException
+    {
+        // nothing to close. no-op
+    }
+
+    @Override
+    // overrides all the methods referenced mbeanServerConn/jmxc in super
+    public EndpointSnitchInfoMBean getEndpointSnitchInfoProxy()
+    {
+        return new EndpointSnitchInfo();
+    }
+
+    @Override
+    public CacheServiceMBean getCacheServiceMBean()
+    {
+        return cacheService;
+    }
+
+    @Override
+    public void repairAsync(final PrintStream out, final String keyspace, Map<String,
String> options) throws IOException
+    {
+        RepairRunner runner = new RepairRunner(out, ssProxy, keyspace, options);
+        try
+        {
+            ssProxy.addNotificationListener(runner, null, null);
+            runner.run();
+        }
+        catch (Exception e)
+        {
+            throw new IOException(e) ;
+        }
+        finally
+        {
+            try
+            {
+                ssProxy.removeNotificationListener(runner);
+            }
+            catch (Throwable e)
+            {
+                out.println("Exception occurred during clean-up. " + e);
+            }
+        }
+    }
+
+    @Override
+    // simply resume bootstrap, instead of streaming the JMX notification to stdout
+    public void resumeBootstrap(PrintStream out) throws IOException
+    {
+        if (ssProxy.resumeBootstrap())
 
 Review comment:
   can we refactor `NodeProbe` so `ssProxy` is a function call?  That way this method doesn't
need to be overridden

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message