1. Executing Commands Using JSON
If a JSON message, which requests command execution, is sent as a HTTP POST request to a server, the server handles the request and then sends a JSON message, which contains the result, as the HTTP response.
For more information about JSON, refer to www.json.org. |
1.1. Executing Regular Commands
The following is a command used as an example in this section.
serverinfo -server server1 -state
The following is the process of executing a command using JSON.
-
Create a JSON message that executes a command.
The following is a JSON message that executes the example command.
{ "jeusadmin": { "command": "server-info", "options":[ "-server server1", "-state" ], "argument": null } }
Convention Description command
Name of the command to be executed.
options
Options and parameters of the command.
argument
Arguments of the command.
-
Send the JSON message to the server to request command execution. Set HTTP as the protocol and POST as the method.
The following is a URL that receives requests for executing JSON messages in JEUS.
http://${SERVER_HOST}:${SERVER_BASE_PORT}/jsonCommand/command.json
To execute a command on a JEUS server, user authentication is required. Use HTTP Basic Authentication for user authentication.
-
The server interprets and executes the JSON message. The JSON result message is then sent as a HTTP response. The execution result differs depending on the individual command.
The following is an example of a result that can be received as a server response. The result may change according to the JEUS domain configuration.
{ "jeusadmin-result": { "message":"", "data":[ { "title":"Information of Domain (domain1)", "header":null, "column-names":[ "Server","Status","Node Name","PID","Cluster", "Latest StartTime/ShutdownTime","Need to Restart", "Listen Ports","Running Engines" ], "rows":[ { "row-key":"0", "values":[ "server1(*)","RUNNING (284sec)","N/A","2151","N/A", ... (Omitted) ] } ], "footer":null } [, "post-message":"" } }
The following comprise a JSON result message.
-
message
Message displayed at the top. If there are multiple messages, a list of messages is displayed. Depending on the command, a message may not exist.
-
data
Object that contains the execution result. Depending on the command, an object may not exist. A table is a regular data structure and comprised of the following.
Convention Description title
Table title.
header
Table header.
column-names
Table column names.
rows
Table rows.
A row is comprised of two elements.
-
row-key: Row name.
-
values: Row value.
footer
Table footer.
-
-
post-message
Message displayed at the bottom. If there are multiple post-messages, a list is displayed. Depending on the command, a message may not exist.
-
1.2. Application deploy
This section describes how to install and distribute an application using JSON. Unlike other commands, to install or distribute an application, the application must be sent along with the JSON message.
The following describes the process of installing or distributing an application using JSON.
-
Create a JSON message that requests command execution. The following is the command used to distribute the Hello.war application to 'server1'.
{ "jeusadmin": { "command": "deploy-application", "options":[ "-servers server1", "-path Hello.war" ], "argument": null } }
-
Send the written JSON message and files as a multi-part type to the server to request command execution. Multi-part consists of a command part, which contains the JSON command written in the step 1, and a file part, which sets the application archive to be distributed.
The following is a URL that receives application deployment requests using a JSON message in the JEUS server.
http://${SERVER_HOST}:${SERVER_BASE_PORT}/jsonCommand/install.json
To execute a command on a JEUS server, user authentication is required. Use HTTP Basic Authentication for user authentication.
-
The server interprets and executes the JSON message. The JSON result message is then sent as a HTTP response. This part is same as executing regular commands. For more information, refer to Executing Regular Commands.
For more information about application installation and deployment, refer to install-application, deploy-application, and distribute-application. |