Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically flush data to cassandra every time before cassandra shut down

I am using embedded Cassandra. When I shut down and restart my Cassandra service data is lost. I think decent data are not properly flushed into the disk. So I tried using nodetool to flush data manually and check if data are available. But nodetool doesn't seem to work properly for embedded Cassandra service. I get the following error:

c:\vijay\cassandra\bin>nodetool -host 192.168.2.86 -p 7199 drain

Starting NodeTool

Failed to connect to '192.168.2.86:7199': Connection refused: connect

I tried setting jmx properties still I am getting error. I added following lines to my code:

System.setProperty("com.sun.management.jmxremote", "true");
System.setProperty("com.sun.management.jmxremote.port", "7197");
System.setProperty("com.sun.management.jmxremote.authenticate", "false");
System.setProperty("com.sun.management.jmxremote.ssl", "false");
System.setProperty("java.rmi.server.hostname", "my ip");

So, is there any way to manually flush data to Cassandra without using nodetool?

Edit 1:
After hours of trying I am now able to run nodetool (instead of adding jmx configurations to the code I added to Eclipse debug configurations and it worked). I ran drain command now the data is properly flushed to the disk. So now my question is: why isn't data properly flushed? Every time when I restart Cassandra service recent changes are gone.

like image 280
Vijay Avatar asked Dec 11 '13 13:12

Vijay


2 Answers

How are you stopping and starting the Cassandra server? The call to stopServer on the Cassandra daemon should be flushing any outstanding writes to the commit log. The thread will continue to do some processing even after the method returns, so if you're killing the JVM after stopServer() then you might be preventing the data from being written.

like image 52
Jeff Avatar answered Oct 17 '22 07:10

Jeff


Commitlogs are not properly flushed in cassandra versions 1.1.0 to 1.1.4 This is a open issue. Please refer the following jira ticket.

Commitlog not replayed after restart

like image 1
Vijay Avatar answered Oct 17 '22 06:10

Vijay