-
1. Re: jboss cli java client remote command
nickarls Aug 1, 2013 4:18 AM (in response to jsaura)Show you code. Working with the libraries are usually a bit more low-level (nodes and stuff) but I think there are helper functions somewhere(tm) that the CLI uses that parses stuff like that directly.
-
2. Re: jboss cli java client remote command
jsaura Aug 1, 2013 4:28 AM (in response to nickarls)hi, first of all thanks for answering
this is my code
i do not enclose all xml conf parse i have done to read controller ip, port , pass etc etc
connection part, working fine
public void setUp() throws Exception {
ctx = org.jboss.as.cli.CommandContextFactory.getInstance().newCommandContext(this.usuario, this.pass.toCharArray());
ctx.connectController(this.ip, Integer.parseInt(this.puerto));
}
sending command
public void testExecuteCLICommand() throws Exception {
String CLIcmd = "ls /host=master/server-config=server-one";
ModelControllerClient client = ctx.getModelControllerClient();
ModelNode commandRequest = ctx.buildRequest(CLIcmd);
ModelNode result;
result = client.execute(commandRequest);
System.out.println(result);
}
this throws this exception
org.jboss.as.cli.operation.OperationFormatException: The command does not translate to an operation request.
at org.jboss.as.cli.impl.CommandContextImpl.buildRequest(CommandContextImpl.java:955)
at org.jboss.as.cli.impl.CommandContextImpl.buildRequest(CommandContextImpl.java:916)
at TestBasicCLI.testExecuteCLICommand(TestBasicCLI.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
maybe is just i am using the wrong method to send this commands, seems it expects an operation
i also used dmr method
ModelNode deployRequest = ctx.buildRequest("ls /host=master/server-config=server-one");
no luck either
-
3. Re: jboss cli java client remote command
ctomc Aug 1, 2013 9:16 AM (in response to jsaura)Hi,
ls is high level command that only standalone CLI understands.
you should run
ModelNode deployRequest = ctx.buildRequest("/host=master/server-config=server-one:read-resource");
which is equivalent in dmr syntax
--
tomaz
-
4. Re: jboss cli java client remote command
jsaura Aug 1, 2013 10:22 AM (in response to ctomc)ahhh, ok i thought i could pass whatever command this way, i see that i need to pass it in other way
that works for stopping and starting the server, but i do not find anyway to check if is up or down with this dmr syntax
read-resource does not show me the status
/host=master/server-config=server-one:read-resource
{
"outcome" => "success",
"result" => {
"auto-start" => true,
"cpu-affinity" => undefined,
"group" => "main-server-group",
"interface" => undefined,
"name" => "server-one",
"path" => undefined,
"priority" => undefined,
"socket-binding-group" => undefined,
"socket-binding-port-offset" => 0,
"system-property" => undefined,
"jvm" => {"default" => undefined}
}
}
any idea how should i ask to see if is started or not? i do not find any combination to check if its up or not
thanks !
UPDATE :
nevermind, i found it
/host=master/server-config=server-one:read-resource(include-runtime=true)
{
"outcome" => "success",
"result" => {
"auto-start" => true,
"cpu-affinity" => undefined,
"group" => "main-server-group",
"interface" => undefined,
"name" => "server-one",
"path" => undefined,
"priority" => undefined,
"socket-binding-group" => undefined,
"socket-binding-port-offset" => 0,
"status" => "STARTED",
"system-property" => undefined,
"jvm" => {"default" => undefined}
}
}
just need to inclide runtime=true
thanks guys!