Wednesday Sep 09, 2009
The monitoring funcationality including attaching btrace-agent is done based on the 'monitoring-enabled' attribute of 'monitoring-service' element. If monitoring-enabled is true then the btrace-agent is attached as part of startup. When monitoring-enabled is false, btrace-agent is not attached at startup time. However when user changes monitoring-enabled to true while the server is running, it should be possible to attach the btrace-agent and start monitoring functionality.
Purpose of this pair of commands is to provide enable /disable monitoring during run time without having to restart the server (Alternatively user should be able to use asadmin set command to enbale/disable the monitoring-enabled flag, but have to restart the server to take effect). It does attach btrace-agent based on the given pid and optionally sets the monitoring level for given modules.
enable-monitoring
enable-monitoring [--mbean=false] [--dtrace*=true] [--level web-container="LOW":ejb-container="HIGH"] [--options="debug=true"] [--pid=<pid>]
enable-monitoring
sets the attribute 'monitoring-enabled' to 'true'
enable-monitoring --mbean=true --dtrace*=false
sets the attribute 'monitoring-enabled' to 'true', mbean-enabled to true and dtrace-enabled to false
enable-monitoring --options="debug=true" --pid=<pid>
sets the attribute 'monitoring-enabled' to 'true' and attaches btrace agent using --options
enable-monitoring --level web-container="LOW":ejb="HIGH"
sets the levels for given modules in addition to 'monitoring-enabled'
disable-monitoring
disable-monitoring --modules="web-container,ejb-container"
disable-monitoring
sets the attribute 'monitoring-enabled' to 'false'
disable-monitoring --modules="web-container,ejb-container"
this command will just set the levels for given modules to 'OFF' and it does not change the value for 'monitoring-enabled'
*- Available as a value-add feature, made available only to the paid customers.
Above also caters an important use case of adhoc monitoring, i.e. turning monitoring on in production while server is running, for ex. enable dtrace on the fly.
Sunday Mar 08, 2009
bootcamp_10mar09_mnm
Sreenivas
Munnangi & Anissa Lam
The lab consists of 4 tasks and it starts with an easy one :-)
Prior to starting the lab, install and start application server. Call
the install location of
application server as <as-root>
Task_1:
webservices sample deployment and testing
download
pkghello-web.war
and save it under, let us say <sample-root> directory
01 Connect to admin console from a browser using http://localhost:4848/
02 Deploy webservices application
- select 'Web Applications' from the left navigation menu
- Click <Deploy> button on the right
- provide location of the sample file pkghello-web.war
- scroll down and select 'server' as target
- click on <OK> for deployment
- observe the server.log
<install_root>/domains/domain1/logs/server.log
03 Test the deployed webservices application
- select 'Web Services', 'Hello' from the left navigation
menu
- click on <Test> button in the right window
- above action pops up a window with links
- click on the first link which points to 8080
- experiment with the sample by inputting appropriate
values
Task_2:
webservices sample monitoring
01 Turn on monitoring for webservices
- select 'Web Services', 'Hello' from the left navigation
menu
- select 'Monitor' tab in the right window
- select 'Configuration' tab underneath 'Monitor' tab
- change 'Monitoring Level' to 'High' and click on
<Save> button
02 Monitor webservices application
- gather monitoring data by experimenting with webservices
application as described in item 03 above under task_1
- select 'Statistics' tab underneath 'Monitor' tab
- observe different monitoring stats
- select 'Messages' tab underneath 'Monitor' tab
- click on 'Time Stamp' url and notice the
request/response messages
Task_3:Deploy,
manage and Monitor using CLI
01 Define environment variables
AS_ADMIN_HOST=localhost
AS_ADMIN_PORT=4848
AS_ADMIN_USER=admin
02 Remember that the default admin password is 'adminadmin'
03 Deploy web application
download
cli-hello.war
and save it under, let us say <sample-root> directory
> cd <as-root>/bin
> asadmin deploy <sample-root>/cli-hello.war
> asadmin list-components
04 Turn the monitoring on for web applications
> asadmin get "server-config.monitoring-service.module-monitoring-levels.*"
> asadmin set "server-config.monitoring-service.module-monitoring-levels.http-service=HIGH"
> asadmin set "server-config.monitoring-service.module-monitoring-levels.web-container=HIGH"
05 Monitor the web application similar to 'top' in unix
> asadmin monitor --type
webmodule --filter //server/cli-hello server
use key <h> for help on column titles
use key <q> to quit
> access the web application using a browser
> http://localhost:8080/cli-hello, as you experiment
with the application, notice how the asadmin monitor values change
Task_4:
Create a cluster and deploy a web application
01 Create and start node agent in a terminal using CLI
> asadmin create-node-agent agent1
> asadmin start-node-agent agent1
02 Create and start a cluster using Admin Console
> click on 'Create New Cluster' in the Common Tasks Page
> enter name of the cluster
> click <New...> in the Server Instances table,
enter
instance name and node agent
> click <New...> again to add another server instance
> click <OK> button to create this cluster with 2
instances
> in the Clusters table, select this cluster and press 'Start
Cluster'
button.
03 Deploy Web Application
> expand 'Clusters' in tree node and select the cluster
> go to Applications tab and click <Deploy...> button
> scroll down and observe that this cluster is preselected as
the
'target'.
> enter application location and press <OK> button.
Thursday Feb 19, 2009
comet_client
There are many examples illustrating the usage of
Grizzly Comet for Web
Client but not for Stand alone java client. I needed one and with help
from Jeanfrancois Arcand, users@grizzly.dev.java.net and my colleague Prashant
Abbagani, I came up with the following example.
Conventionally the client either polls or pulls the message from server
periodically, the draw back with this approach is that the client
wastes the resources and the messages may not be received in real time.
Instead, in comet approach, the server pushes the messages to client in
real time. For this example, I have used GlassFish v3 which comes
bundled with Grizzly and Comet. Here are the steps:
-
Download and install GlassFish v3.
-
Enable comet support in GlassFish v3.
...
<http-listener port="8080" id="http-listener-1" address="0.0.0.0" default-virtual-server="server" server-name="">
<property name="cometSupport" value="true" />
<http-listener>
...
-
Develop and deploy comet.war to push messages from server to client. You may like to refer to MyCometServlet.java source code.
 
-
Code the client CometClient.java and listen for server messages.
Start the client.
punit[105]: java CometClient
init ...
-
Simulate posting messages to server using Post2CometServlet.java.
Post message to server
punit[54]: java Post2CometServlet
punit[55]: java Post2CometServlet
punit[56]: java Post2CometServlet
punit[57]: java Post2CometServlet
punit[58]: java Post2CometServlet
The client output gets updated in real time as the messages are posted to the servlet.
punit[105]: java CometClient
init ...my message sent at 1235082867986
my message sent at 1235082891002
my message sent at 1235082892018
my message sent at 1235082893714
my message sent at 1235082894420