-
1. Re: How to locate Domain Controller from a WildFly instance.
ksreen Dec 11, 2014 12:19 AM (in response to bluemoon)1 of 1 people found this helpfulFor (1) In order to locate a server instance in CLI or Web Management GUI, you would have to traverse through it's Domain/Host Controller. The Runtime Tab -> Server Instances page displays the Host Controller name at the top of the page. You can also use the Server Dropdown at the top left hand corner to check the list of HC and server associated. On CLI the following command might be useful /host=master/server-config=*:read-resource For (2), have you tried the CLI and Web Management GUI? The Server Group Deployments should give the information of running Apps. On CLI you can try the following command /server-group=*/deployment=*/:read-resource(recursive=false,proxies=true,include-runtime=true,include-defaults=true)
-
2. Re: How to locate Domain Controller from a WildFly instance.
bluemoon Dec 18, 2014 9:04 AM (in response to ksreen)Thank you ksreen.
I'm looking for a way to do this programmatically, and from one of the apps deployed on a wildfly instance. I found out the DC can be looked up from the JVM Environment Properties. I believe both CLI and GUI use interfaces that accept queries from outside the deployment environment and login credentials must be supplied, but since we're already inside this environment I'm looking for a shortcut way to do this without passing in any login information.
-
3. Re: Re: How to locate Domain Controller from a WildFly instance.
jaysensharma Dec 18, 2014 9:20 AM (in response to bluemoon)You mentioned:
I'm looking for a way to do this programmatically,
Yes, you can run the same commands using java program as well.
import java.io.IOException; // CLI API import org.jboss.as.cli.CommandContext; import org.jboss.as.cli.CommandContextFactory; import org.jboss.as.cli.CommandLineException; import org.jboss.as.cli.CommandFormatException; import org.jboss.as.controller.client.ModelControllerClient; // DMR API import org.jboss.dmr.ModelNode; public class Main { public static void main(String[] args) throws CommandLineException, IOException { String host = args[0];; int port = Integer.parseInt(args[1]); String appPath=args[2]; Main main=new Main(); CommandContext ctx = CommandContextFactory.getInstance().newCommandContext("admin","admin@123".toCharArray()); ctx.connectController(host, port); ModelNode deployRequest = null; try { String request="/server-group=*/deployment=*/:read-resource(recursive=false,proxies=true,include-runtime=true,include-defaults=true)"; //String request="/host=master/server-config=*:read-resource"; deployRequest = ctx.buildRequest(request); } catch (CommandFormatException e) { e.printStackTrace(); } main.runCommands(ctx,deployRequest); ctx.disconnectController(); } public void runCommands(CommandContext ctx,ModelNode modelNode) { System.out.println("Running command ---- "); ModelControllerClient client = ctx.getModelControllerClient(); if(client != null) { try { ModelNode response = client.execute(modelNode); System.out.println("\n\t response = > "+response); } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("the client (ModelControllerClient) is not available. Connection error"); } } }
NOTE: Name sure to add the "$WILDFLY_HOME/bin/client" JAR in the client class-path while compiling and running the above code.
Above program shows that your client can connect to WildFly remotely. But it is also possible to connect to WildFly from within the same container. (no need to pass URL and credentials)