Author Archives: tobias
Apache Cassandra Secondary Indices
How are Secondary Indices really stored ? This is based on the article from Datastax found here; https://www.datastax.com/blog/2016/04/cassandra-native-secondary-index-deep-dive Let’s just create a simple table
1 2 3 4 5 |
CREATE TABLE customer ( id int PRIMARY KEY, city text, name text ) |
Or visualized as a table : Column Type Key id int Primary Key city text name … Continue reading
Print stacktraces for all threads on shutdown
If your microservice stops responding from time to time, and they only way out is to kill it with SIGINT or SIGTERM then adding a shutdown hook might be the way to go. Do note that this will not work … Continue reading
Apache Zeppelin, with Spark and Cassandra, the perfect tool
Zeppelin has become one of my favourite tools in my toolbox. I am heavily designing stuff for Cassandra and in Scala, and even though I love Cassandra there are times when things just gets so complicated with the CQL command … Continue reading
Remove the cardo-updater agent from OSX
I have the intercom from Cardo Systems, and it is really good BUT when I updated the firmware some time agoe, it decided to install some software that takes port 8080, which is one of those really common ports used … Continue reading
SQL LIKE operation in Cassandra, is possible in v3.4+
For a long time it has not been possible to do a SELECT * FROM table WHERE firstname like ‘t%’; in Cassandra like you could in eg.. MySQL or any other Relation Database for that matter. In Cassandra v3.4 this … Continue reading
UDF/User Defined Functions in Cassandra 3.x
I was just playing around with Cassandra WRITETIME and thought it was somewhat difficult to figure out the date / timestamp of a number like this (microseconds since EPOC) 1470645914253000. So in my example it looked like this
1 2 3 4 5 6 7 8 9 10 11 |
cqlsh:bth> select id, writetime(dateofbirth) from bth.employee; id | writetime(dateofbirth) ----+------------------------ 1 | 1470645914253000 2 | 1470645977177000 7 | 1470948508799001 3 | 1470645977178000 (4 rows) cqlsh:bth> |
So … Continue reading
Cassandra set the writetime explicitly with a PreparedStatement
This is a quick one, I wanted to set the writetime of a row explicitly when I populate the database for testing purposes. We use the writetime of a column to filter them out. It required some looking around to … Continue reading
Apache SPARK and Cassandra and SQL
This is a short intro to start using Apache SPARK with Cassandra, running SQL on the Cassandra tables. Note that I am not running a SPARK cluster, I am running “local”, to me this is really convenient, not having to … Continue reading
SBT Good to know…
Dependecy problems I have been having some difficulties figuring out what depends on what. I found the following set plugins which I think can be really helpful; https://github.com/jrudolph/sbt-dependency-graph and https://github.com/gilt/sbt-dependency-graph-sugar Be sure to install GraphWiz first, I used Homebrew on … Continue reading
Create an MBean (JMX) in Scala
Create the MBean like this
1 2 3 4 5 6 7 8 9 10 11 12 13 |
trait OrderTrackerMBean { def getOrderId : Int def setOrderId(orderId:Int) } class OrderTracker extends OrderTrackerMBean { var orderId = 0 override def getOrderId: Int = orderId override def setOrderId(_orderId: Int)= { orderId = _orderId } } |
NOTE, that the interface/trait must end with MBean in the name And this is how you register your MBean
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package com.tsoft.playingWithLogback import java.lang.management.ManagementFactory import javax.management.{ObjectName, MBeanServer} import org.slf4j.{MarkerFactory, Marker, LoggerFactory} import org.slf4j.MDC import scala.concurrent.{Await, Future} import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global object LotsOfLogOutput { val logger = LoggerFactory.getLogger(this.getClass) val orderTrackerBean = new OrderTracker val mbs:MBeanServer = ManagementFactory.getPlatformMBeanServer(); val mBeanName:ObjectName = new ObjectName("com.tsoft.playingWithLogback:type=Tracking"); mbs.registerMBean( orderTrackerBean, mBeanName); ... |
And the simply launch Java Mission Control (imc), attach to the JVM, and modify … Continue reading