SO having some issues with trying to debug a program that I'm using, and wondered if anyone could help me out.
The current environment is I'm running Cassandra (v2), using cqlsh (v3) that comes with it. I'm making changes to some of it's functionality, and then using cqlsh to test commands to see if my changes are working as intended, or if not what the input looks like as I step through the program. I start up a debugging session (either in eclipse of IntelJ, doesn't really matter), firing up the server code to accept connections/input. I then load up cqlsh, and specify the keyspace that I want to use. This seems to work fine. I then execute a line of cql to test my changes via command line. What I expect to see is the command line entry being caught by the debugger in my IDE, where I can see how the input is handled by my code changes. What I'm seeing is nothing happening at all, as if no command was submitted.
So my questions would be the following:
1) Should I see anything in my debugging IDE when executing commands as described above? 2) If not, how would you debug a server based application that has this configuration, especially in the realm of handling user input? 3) If so, what settings should I check to see if I have set correctly, or what processes should be followed to view and debug said submissions?
I figure there has to be a better way then having 50,000 System.out.println() all over the place (assuming they'd even work), or at least, I hope there is.
Thanks for anyone that reads this. Any questions (which I'm sure there may be since I'm probably not using the right descriptors) please ask away.
I've had success with the following approach.
-g
(use like: javac -g
) to enable generation of all debugging information.java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414
, the number is the port you connect to) to start a debugging server. Note that you can debug from a remote host (debugger will connect using hostname:port syntax). You don't need to type this all up for Cassandra; you can simply uncomment a relevant line in cassandra-env.sh
(in Windows, look in bin/Cassandra.bat
or if running Datastax distro, under registry key HKLM\SOFTWARE\[optionally Wow6432Node\]Apache Software Foundation\[Procrun node]\[Cassandra node]\Parameters\Java:Options
).In your case, because you can successfully specify the keyspace, I believe everything is working, and then there is a silent failure when you try to do other steps, possibly introduced by your modifications. To confirm, I would recommend rolling back all your changes and first testing the debugger setup on a clean build.
Lastly, and this may be superfluous, CQLSH is a program written in Python, and runs separate from Cassandra in a different process. Therefore you cannot see the actual "command line entry" from a Java debugger. The closest you can get to your raw input is by putting breakpoints somewhere in cql3
package to see CQL statements get passed in (hopefully). Of course you can use a Python debugger to debug CQLSH if this is what you want.