2

我正在编写测试来检查 cassandra 键空间和表的元数据信息。我还想检查集群中哪个节点启动或哪个节点关闭。我该怎么做?

4

1 回答 1

5

nodetool 实用程序使您可以访问诊断和操作信息。

nodetool ring

将为您提供环中节点及其状态的列表。

您还可以从 node.js 驱动程序中获取信息。客户端有一个hosts属性。每个主机都有一个可以使用的isUp函数。使用元数据的示例

"use strict";
const cassandra = require('cassandra-driver');

const client = new cassandra.Client({ contactPoints: ['127.0.0.1'] });
client.connect()
  .then(function () {
    console.log('Connected to cluster with %d host(s): %j', client.hosts.length);
    client.hosts.forEach(function (host) {
      console.log('Host %s v%s on rack %s, dc %s, isUp: %s', host.address, host.cassandraVersion, host.rack, host.datacenter, host.isUp());
    });
    console.log('Shutting down');
    return client.shutdown();
  })
  .catch(function (err) {
    console.error('There was an error when connecting', err);
    return client.shutdown();
  });
于 2017-06-12T13:54:27.663 回答