Created
May 4, 2015 02:41
-
-
Save nobusue/1145707084ac55cfcba4 to your computer and use it in GitHub Desktop.
localhostのCassandraにJava Driverで接続してクラスタ名やホスト名を取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grapes( | |
@Grab(group='com.datastax.cassandra', module='cassandra-driver-core', version='2.1.5') | |
) | |
import com.datastax.driver.core.* | |
def cluster = Cluster.builder().addContactPoint('127.0.0.1').build() | |
def metadata = cluster.getMetadata() | |
println "Connected to cluster: ${metadata.getClusterName()}" | |
metadata.getAllHosts().each { host -> | |
println "Datacenter: ${host.getDatacenter()}; Host: ${host.getAddress()}, Rack: ${host.getRack()}" | |
} | |
cluster.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment