2017-06-12 148 views

回答

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

我必須使用摩卡書寫它的測試。是否有nodetool的模塊或類似的nodejs? –

+0

類似'const {spawn} = require('child_process'); const ring = spawn('nodetool',['ring']);'?它是一個命令行工具。實際上我也用另一種機制進行了更新 –