AS7 and CLI
-
Upload
jbug-italy -
Category
Technology
-
view
2.449 -
download
0
description
Transcript of AS7 and CLI
![Page 1: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/1.jpg)
![Page 2: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/2.jpg)
Who is Stefano?
● JBoss WS[1] committer since early 2007
● Committer of various Jboss projects
● JBoss / Red Hat employee since July 2010
● JBoss AS7[2] team memeber
● IronJacamar[4] team member
● Wise[3] project leader
● Follow me: www.javalinux.it, www.twitter.com/maeste https://plus.google.com/102371438013760231375/about
https://github.com/maeste http://www.linkedin.com/in/maeste [1] http://www.jboss.org/jbossws [2] http://www.jboss.org/jbossas
[3] http://www.jboss.org/wise [4] http://www.jboss.org/ironjcamar
![Page 3: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/3.jpg)
AS7 in a nutshell
●Blazingly fast (<3s startup)●Lightweight●Modular core●Hot, parallel deployment●Elegant administration●Domain management●Easy testable
![Page 4: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/4.jpg)
Dynamic Model Representation (DMR)
● Central detyped management API● All management operations with/on DMR● Backwards compatible
● Can be used to control standalone or domain
● Detyped (i.e. string based) API uses small set of Java classes
● Various transports (Java, remoting, JSON/HTTP)
![Page 5: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/5.jpg)
Dynamic Model Representation (DMR)
![Page 6: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/6.jpg)
What is CLI?
● Command Line Interface● Easy to use both for standalone and
domain mode● Scriptable● Low level management of DMR resource
and/or high level user friendly command● Manage deployement and “special
deployment”● Provide also a simple GUI
![Page 7: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/7.jpg)
Why CLI instead of Web Console?
● Both have valid use cases● CLI could be helpful in complex
management but requiring programming skills (almost)
● Web console give an advanced interface for complex operation and give a cooked view of resources
![Page 8: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/8.jpg)
CLI Feature includes (1/2):
● connect to the specific controller or server instance by specifying the host and the port;
● send operation requests (providing the managed component's address, attribute or operation name and parameters) following the AS7 detyped management model;
● view the available managed components, their attributes and operations;
● tab-completion for commands and operation requests;
● history of the executed commands and operation requests;
● deploy and undeploy standard packages at runtime in standalone and domain modes;
● CLI deployment archives;
![Page 9: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/9.jpg)
CLI Feature includes (2/2):
● batch mode;
● non-interactive mode;
● generic resource type commands and custom commands;
● GUI mode;
● CLI public API;
● system properties in operations and commands;
● try-catch-finally control flow;
● if-else control flow
● Single jar for remote clients
● Advanced CLI scripting with Groovy, Rhino, Jython, etc.
![Page 10: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/10.jpg)
connect to the specific controller or server instance by specifying the host and the port;
DEMO(execute cli an connect)
![Page 11: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/11.jpg)
send operation requests
● Address (node path)node_type=node_name (, node_type=node_name)*/subsystem=datasources/subsystem=datasources/data-source=ExampleDS
● Operations:operation-name ['(' [name=value [, name=value]*] ')']:shutdown:shutdown():shutdown(restart=true)/subsystem=datasources/data-source=ExampleDS:write-attribute(name=min-pool-size,value=5)
![Page 12: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/12.jpg)
A demo of some other features
● view the available managed components, their attributes and operations;
● tab-completion for commands and operation requests;
● history of the executed commands and operation requests;
![Page 13: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/13.jpg)
Deploy and Undeploy standard packages
● Standalone mode● Deploy/undeploy a package● Deploy –disabled● Undeploy --keep-content
● Domain mode● Specify a server group (or --all-server-
groups)● Undeploy from relevant server groups● Deply/undeploy on specific server group
and disabled deployments
![Page 14: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/14.jpg)
CLI deployment archive
● Standard Jar containing archives to deploy
● A deploy.scr containing commands to execute in cli when archive is deployed
● A undeploy.scr to rollback on undeploy● Multiple deploy/undeploy script can exist
and they are addressed by --script option in deploy/undeploy command
![Page 15: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/15.jpg)
Batch mode
● The batch mode allows one to group commands and operations and execute them together as an atomic unit
● Build them from scratch (entering batch mode w/ “batch” command)...demo
● Execute (eventually modify) batch stored in file
● Batches with properties (./jboss-cli --properties=script.properties)
![Page 16: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/16.jpg)
Non interective
● ./jboss-cli.sh -c –file=test.cli● ./jboss-cli.sh -c --commands="cd
subsystem=web,ls"● Why? Cron for example, or in any case
you need to run scripts triggered from operating system
![Page 17: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/17.jpg)
Generic type CLI commands
● is a command that is assigned to a specific node type
● Data-source example● Add a new command (only in current
session...but you can create a batch for your own commands...)
![Page 18: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/18.jpg)
CLI GUI
● Browse the domain model● To see the operations available for a
node, right-click the node.● Context-sensitive help is available
throughout the Command Builder● You can also edit the command line
manually and submit a command at any time
![Page 19: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/19.jpg)
Public API (Since JBoss AS 7.1.1)
final CommandContext ctx;
try { ctx = CommandContextFactory.getInstance().newCommandContext(); } catch(CliInitializationException e) { throw new IllegalStateException("Failed to initialize CLI context", e); }
try { // connect to the server controller ctx.connectController();
// execute commands and operations ctx.handle(":take-snapshot"); ctx.handle("deploy myapp.ear"); } catch (CommandLineException e) { // the operation or the command has failed } finally { // terminate the session and // close the connection to the controller ctx.terminateSession();
}
![Page 20: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/20.jpg)
try-catch-finally control flow
Try /subsystem=datasources/data-source=myds:add(connection-url=xxx,jndi-name=java:/myds,driver-name=h2)catch /subsystem=datasources/data-source=myds:remove /subsystem=datasources/data-source=myds:add(connection-url=xxx,jndi-name=java:/myds,driver-name=h2)finally /subsystem=datasources/data-source=myds:enable
end-try
![Page 21: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/21.jpg)
if-else control flow
if (outcome != success) of /system-property=test:read-resource /system-property=test:add(value=true)end-if
[standalone@localhost:9999 /] /system-property=test:read-resource{ "outcome" => "failed", "failure-description" => "JBAS014807: Management resource '[(\"system-property\" => \"test\")]' not found", "rolled-back" => true}
[standalone@localhost:9999 /] /system-property=test:read-resource{ "outcome" => "success", "result" => {"value" => "true"}}
![Page 22: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/22.jpg)
Scripting with Groovy(and all Java lib enabled scripting language)
groovy -cp jboss-cli-client.jar uptime.groovy
import org.jboss.as.cli.scriptsupport.* cli = CLI.newInstance()cli.connect() if (cli.getCommandContext().isDomainMode()) { cli.cmd("cd /host=master/core-service=platform-mbean/type=runtime")} else { cli.cmd("cd /core-service=platform-mbean/type=runtime")} result = cli.cmd(":read-attribute(name=start-time)")response = result.getResponse()startTime = response.get("result").asLong() result = cli.cmd(":read-attribute(name=uptime)")response = result.getResponse()serveruptime = response.get("result").asString() println()println("The server was started on " + new Date(startTime))println("It has been running for " + serveruptime + "ms") cli.disconnect()
![Page 23: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/23.jpg)
Community
● Get involved !● Base for JBoss Enterprise Application
Platform 6.x
● Download● http://www.jboss.org/jbossas/downloads
● Forum● http://community.jboss.org/en/jbossas/as7_us
ers
![Page 24: AS7 and CLI](https://reader034.fdocuments.in/reader034/viewer/2022050815/548c46c5b47959ce0c8b6378/html5/thumbnails/24.jpg)
Community
● Hacking on AS 7● http://community.jboss.org/wiki/HackingonAS
7
● Command Line Interface● https://community.jboss.org/wiki/CommandLineInterface
● Operations, Administration & Management of JBoss AS7
● http://vimeo.com/25855285