forked from apache/cassandra-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.scala
More file actions
38 lines (33 loc) · 1.49 KB
/
console.scala
File metadata and controls
38 lines (33 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Allows quick manual tests from the Scala console:
*
* cd core/
* mvn scala:console
*
* The script below is run at init, then you can do `val cluster = builder.build()` and play with
* it.
*
* Note: on MacOS, the Scala plugin seems to break the terminal if you exit the console with `:q`.
* Use Ctrl+C instead.
*/
import com.datastax.oss.driver.api.core._
import com.datastax.oss.driver.internal.core.metadata.TopologyEvent
import com.datastax.oss.driver.internal.core.context.InternalDriverContext
import java.net.InetSocketAddress
import scala.collection.JavaConversions._
// Heartbeat logs every 30 seconds are annoying in the console, raise the interval
System.setProperty("datastax-java-driver.connection.heartbeat.interval", "1 hour")
val address1 = new InetSocketAddress("127.0.0.1", 9042)
val address2 = new InetSocketAddress("127.0.0.2", 9042)
val address3 = new InetSocketAddress("127.0.0.3", 9042)
val address4 = new InetSocketAddress("127.0.0.4", 9042)
val address5 = new InetSocketAddress("127.0.0.5", 9042)
val address6 = new InetSocketAddress("127.0.0.6", 9042)
val builder = Cluster.builder().addContactPoint(address1)
println("********************************************")
println("* To start a driver instance, run: *")
println("* implicit val cluster = builder.build *")
println("********************************************")
def fire(event: AnyRef)(implicit cluster: Cluster): Unit = {
cluster.getContext.asInstanceOf[InternalDriverContext].eventBus().fire(event)
}