Question : You can also specify specific IP addresses of Cassandra cluster nodes, so that you will hit to only specific node in cluster, initially 1. True 2. False
Correct Answer : 1 Explanation: You can also specify a list of IP addresses for nodes in your cluster:
from cassandra.cluster import Cluster
cluster = Cluster(['192.168.0.1', '192.168.0.2']) The set of IP addresses we pass to the Cluster is simply an initial set of contact points. After the driver connects to one of these nodes it will automatically discover the rest of the nodes in the cluster and connect to them, so you donat need to list every node in your cluster.
Question : As soon as you create Cluster instance, you are connected to Cassandra cluster 1. True 2. False
Correct Answer : 2 Explanation: Instantiating a Cluster does not actually connect us to any nodes. To establish connections and begin executing queries we need a Session, which is created by calling Cluster.connect():
cluster = Cluster() session = cluster.connect() The connect() method takes an optional keyspace argument which sets the default keyspace for all queries made through that Session:
cluster = Cluster() session = cluster.connect('mykeyspace') You can always change a Sessions keyspace using set_keyspace() or by executing a USE query:
session.set_keyspace('users') # or you can do this instead session.execute('USE users')
Now that we have a Session we can begin to execute queries. The simplest way to execute a query is to use execute():
rows = session.execute('SELECT name, age, email FROM users') for user_row in rows: print user_row.name, user_row.age, user_row.email This will transparently pick a Cassandra node to execute the query against and handle any retries that are necessary if the operation fails.
Question : . You should always prefer to use SSD storage on Cassandra node? 1. True 2. False
Correct Answer : 1 Explanation: Yes, SSD's are faster and it is recommended.