1

I'm writing a Java client to connect to Cassandra. When I deliberately kill Cassandra server, the client's JVM immediately exits with 143.

It's the same result when doing the same experiment on Apache kafka. I quickly grep and see neither the Java driver nor Netty calls System.exit.

Is killing the JVM done somewhere in the Cassandra or the Kafka Java driver? If so, is there a particular reason why?(JDBC driver throws a SQLException in that situation which might be better.)

If JVM shutdown is unavoidable and I want my service keep running, I would isolate the cassandra/kafka clients in another JVM, e.g. using Akka remote. Is it a good idea?

P.S. I'm using cassandra-driver-core:3.0.0-rc1 and kafka-clients:0.9.0.0

[EDIT] I knew addShutdownHook, but that's not what I'm looking for, because JVM is going to die anyway. My application connects to Cassandra and provides other services. I don't want the application dies because the connection to Cassandra lost.

[EDIT] Also I'm curious about two more things than adding a hook:

  1. Why the JVM aborts. Is it coming from Cassandra java driver?
  2. Is a good idea to put the Cassandra-client logic in another JVM like, for example, Akka remote.
cfchou
  • 1,239
  • 1
  • 11
  • 25
  • what do you think `C*` means? because it is not a standard representation of anything –  Mar 02 '16 at 16:17
  • it is also unclear what you are doing and what you expect to be happening, you reference servers and drivers and clients all mixed together in the same context. –  Mar 02 '16 at 16:19
  • In Cassandra community, C* refers to Cassandra, but I'll edit my post to write it in full name. – cfchou Mar 02 '16 at 16:36
  • @JarrodRoberson I don't think it's a duplicate question. Please see my edit. And if you agree please remove the duplicate mark. – cfchou Mar 02 '16 at 16:46
  • I agree, this doesn't seem like a duplicate. His client should not get killed when killing the server. – Andy Tolbert Mar 02 '16 at 16:56
  • Do you have any daemon threads? – Richard Mar 03 '16 at 03:48
  • @Richard I did a little test and got the same result regardless whether there's a daemon thread. – cfchou Mar 03 '16 at 15:33

0 Answers0