admin@glassfish.java.net

Re: Getting started with CLI

From: Yamini K B <Yamini.Kb_at_Sun.COM>
Date: Mon, 24 May 2010 11:13:59 +0530

fyi, I'm able to run the command though its functionally incomplete. It turned out to be a workspace issue (and not my code), after I ran 'svn update' and 'mvn clean install', no hangs!

-Yamini


I'm trying to port one of the v2 commands onto v3. This is the first time I'm writing a command in v3 and have some general questions:

1. Is there any document regarding the practices to be followed while writing commands? Looks like the v3 CLI spec wasn't updated for the final release and it mainly talks about features that were dropped. I've seen the v3 engineer's guide CLI section, but that too contains a very simple example.
And I would like to know all the secrets for laying down a perfect tile floor but I can't find a really good book.  Why?  Because people that are really good at doing that usually suck at documenting it.

If you are writing a CLI command look at commands written by Bill Shannon they are as close to perfect as you're likely to find and then ask specific questions and pass your ideas for early review preferably to Bill for CLI and to Jerome for remote
Will start to looks at Bill's commands, thanks for the pointer.

2. Where can I find documentation for the various annotations?
Documentation?  We don't need no stinkin' documentation!  Hint:  monkey see monkey do ;-)
I generated javadocs in glassfish-api, that should suffice for a start. I will look at code for more details when needed.

3. From what I understand, there are 2 ways to introduce a command, one is by implementing the AdminCommand interface and other is writing a CRUD command, is that correct?
Don't even think about implementing a CRUD command unless you run it by Jerome and know exactly what you're doing.  CRUD is designed for things that have a 1:1 correspondence with elements in domain.xml  "start-instance" is not for CRUD.  create-instance IS.  CReate  Update  Delete. CRUD is designed (successfully) to stop the grudge work and unnecessary complexity of many almost-identical boiler-plated commands.

4. How/when to implement CRUD commands?
See above and more importantly look at the source

5. Whats the best way to debug any command? I made some changes in the config beans and now DAS isn't even starting, it just hangs after the launcher message. I'm at loss as to where to look! (Changing felix log level and admin logging to finest doesn't help since its in the very intial stage of startup)
QA and Managers use logging levels.  Engineers use debuggers and break points.  Set a breakpoint much earlier.  Go to ASMain in core/bootstrap  for extremely early debugging and in AppServerStartup (core/kernel) for "normal" early.  Run start-domain with the "--debug" arg.  Edit domain.xml and set 'suspend=y' in the java-options section then attach to your debugger as it sits there patiently waiting for you.
Not that I don't know how to use the debugger, I was hoping to get some clue from log messages, thats all. In v2, I know exactly where to set breakpoints whereas in v3, I don't know how the execution path is for any admin operation. Anyways, I figured that out by backing out all my changes and setting breakpoint in CreateHttpListener. Will keep in mind to look at the above mentioned classes for early debugging.

6. While porting a v2 command, I presume both the files, supported-legacy-command-names/unsupported-legacy-command-names need to be updated. Is that correct?
OK -- you have me confused now.  This is a question about **CLI** commands and your other questions sound like Remote AdminCommand's  which is it?  both?  What are you doing?
Actually both. I'm working on porting one of the load balancer commands. Next step is to figure out what mistake in my changes causes the startup hang, will get back in case I need help.

Thanks,
-Yamini
--------------------------------------------------------------------- To unsubscribe, e-mail: admin-unsubscribe@glassfish.dev.java.net For additional commands, e-mail: admin-help@glassfish.dev.java.net