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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With