我可以像nodetool那样从C/C++驱动程序强制刷新Cassandra表吗

Can I force a Cassandra table flush from the C/C++ driver like nodetool does?

本文关键字:驱动程序 刷新 表吗 Cassandra C++ nodetool 我可以      更新时间:2023-10-16

我想知道是否可以从Cassandra的C/C++驱动程序复制nodetool实用程序中的forceKeyspaceFlush()函数。

nodetool函数如下所示:

public class Flush extends NodeToolCmd
{
    @Arguments(usage = "[<keyspace> <tables>...]", description = "The keyspace followed by one or many tables")
    private List<String> args = new ArrayList<>();
    @Override
    public void execute(NodeProbe probe)
    {
        List<String> keyspaces = parseOptionalKeyspace(args, probe);
        String[] tableNames = parseOptionalTables(args);
        for (String keyspace : keyspaces)
        {
            try
            {
                probe.forceKeyspaceFlush(keyspace, tableNames);
            } catch (Exception e)
            {
                throw new RuntimeException("Error occurred during flushing", e);
            }
        }
    }
}

我想在我的C++软件中复制的是这一行:

probe.forceKeyspaceFlush(keyspace, tableNames);

有可能吗?

这是一个不寻常的请求,主要是因为Cassandra是分布式的,所以如果您正在执行查询,您需要对每个(可能有很多)副本执行阻塞清除。与其让你相信你真的不需要这个,我不如试着回答你的问题——然而,你可能真的并不需要这个。

Nodetool正在使用JMX接口(在tcp/7199上)来强制刷新-您的c/c++驱动程序通过本机协议(在tcp/9042上)进行对话。此时,无法通过本机协议进行刷新。

绕过这个限制,您需要执行一个支持jmx的命令行实用程序(nodetool或其他),用c++实现jmx客户端(已经完成),或者扩展本机协议。这些都不是特别令人愉快的选项,但我认为执行jmx CLI实用程序要比其他两个容易得多。