If you run Runtime.exec() directly it is
very easy to deadlock
and hang both DAS and the spawned asadmin process. I have the scars to
prove it.
Use this -- it's easy and safe -- and handles all the intricate details
for you
[common/common-util] com.sun.enterprise.universal.process.ProcessManager
On 6/4/2010 1:37 PM, Bill Shannon wrote:
If a
remote command wants to execute a local command on the same
machine that the remote command is running on, use Runtime.exec.
I think there's some helper classes that make it easier to use
Runtime.exec.
It was a goal to *not* load the local asadmin commands in the server
JVM, they're not designed to work in that environment.
Joe Di Pol wrote on 06/ 4/10 12:20 PM:
Bill,
The one case not mentioned below is a remote command executing
a local command. After talking with Vijay we are thinking this
is probably not supported since the local command won't be in
the DAS's habitat.
Does that sound right?
This then brings us back to refactoring the command to
share code between the CLI and the DAS.
Joe
Bill Shannon wrote:
As Tim described, one option is always to
refactor the commands so that
the common code is in a non-command shared class.
But, really, there should be a straightforward way to invoke one
command
from another, both local commands and remote commands. Some of the
challenges are... how do you want to supply the parameters, and what
do you want to do with the results?
For a remote command executing a remote command, I believe you should
be able to use the CommandRunner API.
For a local command executing either a local or remote command, you
should be able to do this:
@Inject
Habitat habitat;
...
CLICommand cmd = CLICommand.getCommand(habitat, "command-name");
String[] argv = ...; // just like asadmin command line
int rc = cmd.execute(argv); // argv[0] is command-name
// note that output goes to System.out
If a local command needs to execute a command that is know to be a
remote command, you can construct a RemoteCommand object directly.
There are a variety of constructors and execute methods that offer
more control over the arguments and output.
If a remote command wants to call a local command on another node,
well, I believe that's the "remote command execution facility" that
*you* are building! :-)
Joe Di Pol wrote on 06/03/2010 01:00 PM:
I'm looking for a little push in the right direction.
If there are existing commands that do this feel free
to point me at them.
Case 1
------
I have a remote command that as part of it's processing
wants to invoke another remote command. For example
start-cluster will likely loop through the instances
and call start-instance on each instance.
What is the suggested way to have a remote command
execute another remote command locally? Seems like I
want a variation of enterprise.admin.cli.remote.RemoteCommand
that operates directly on the command class (instead
of remotely over HTTP).
Case 2
-------
Same as Case 1 except I want to call a local command.
For example start-instance may want to call
start-local-instance if the instance is local to the DAS.
Thanks,
Joe
---------------------------------------------------------------------
To unsubscribe, e-mail: admin-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: admin-help@glassfish.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: admin-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: admin-help@glassfish.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: admin-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: admin-help@glassfish.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: admin-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: admin-help@glassfish.dev.java.net
--
Byron Nevins - Oracle Corporation
Home: 650-359-1290
Cell: 650-784-4123
Sierra: 209-295-2188