go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Create Keyspace
 
Subject: Create Keyspace
Author: EricJ
In response to: Establish Connection
Posted on: 11/13/2016 10:33:29 PM

	// keyspace: simplex
	session.execute(
               "CREATE KEYSPACE IF NOT EXISTS simplex " +
               "WITH replication " +
	       "= {'class':'SimpleStrategy', 'replication_factor':3};"  // redundancy : 3
        );



 

> On 11/13/2016 10:27:04 PM EricJ wrote:


	Cluster cluster = Cluster.builder().
				addContactPoint("10.11.12.13").
				build();
	
	Session session = cluster.connect();
	
	Metadata metadata = cluster.getMetadata();
	
	System.out.printf("Connected to cluster: %s\n",	metadata.getClusterName());
	
	for (Host host : metadata.getAllHosts()) {

   	    System.out.printf("Datatacenter: %s; Host: %s; Rack: %s --> Is up? : %s\n",
			host.getDatacenter(), host.getAddress(), host.getRack(), host.isUp());
	}



OUTPUT:
Connected to cluster: Test Cluster
Datatacenter: datacenter1; Host: /10.11.12.13; Rack: rack1 --> Is up? : true
Datatacenter: datacenter1; Host: /10.11.12.123; Rack: rack1 --> Is up? : false


Note: The second instance of this cluster is not running.






References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.