cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] yifan-c commented on a change in pull request #388: CASSANDRA-15429: Support NodeTool in dtest
Date Wed, 11 Dec 2019 00:30:31 GMT
yifan-c commented on a change in pull request #388: CASSANDRA-15429: Support NodeTool in dtest
URL: https://github.com/apache/cassandra/pull/388#discussion_r356350343
 
 

 ##########
 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())
+        {
+            out.println("Resuming bootstrap");
+        }
+        else
+        {
+            out.println("Node is already bootstrapped.");
+        }
+    }
+
+    // dtest runs with disable_mbean_registration. No ColumnFamilyStoreMBean is registered,
thus not supporting get the MBean.
+    @Override
+    public ColumnFamilyStoreMBean getCfsProxy(String ks, String cf)
+    {
+        return Keyspace.open(ks).getColumnFamilyStore(cf);
+    }
+
+    @Override
+    // The below methods are only used by the commands (i.e. Info, TableHistogram, TableStats,
etc.) that display informations. Not useful for dtest, so disable it.
+    public Object getCacheMetric(String cacheType, String metricName)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> getColumnFamilyStoreMBeanProxies()
+    {
+        throw new UnsupportedOperationException();
 
 Review comment:
   Since it is only used for output stats, I will keep it as unsupported. But good to know
how to make a columnFamilyStoreIterator.

----------------------------------------------------------------
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