2017-06-12 6 views
1

私は、cassandraキースペースとテーブルのメタデータ情報をチェックするためのテストを書いています。 また、クラスタ内のどのノードが稼動しているか、どのノードが稼働停止しているかをチェックしたいと考えています。どうすればいい?すべてのcassandraノードの健全性をチェック

答えて

5

nodetoolユーティリティを使用すると、診断および運用情報にアクセスできます。

nodetool ring

あなたのリングとその状態にあるノードのリストが表示されます。

node.jsドライバから、情報を取得することもできます。 Clientにはhostsという属性があります。各ホストにはisUp機能があります。 exampleは、メタデータを使用して表示します。

"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(); 
    }); 
+0

私はmochaを使用してテストを作成する必要があります。 nodeodsにnodetoolなどのモジュールがありますか? –

+0

'const {spawn} = require( 'child_process')のようなものです。 const ring = spawn( 'nodetool'、['ring']); '?そのコマンドラインユーティリティです。実際にはもう一つのメカニズムで上記の更新ができない –

関連する問題