Monday Feb 28, 2011

GlassFish 3.1 and Manual Synchronization

If you need to setup a GlassFish cluster on machines which are unable to talk to each other, you can do so with the new manual synchronization commands introduced in GlassFish 3.1: export-sync-bundle and import-sync-bundle

Machine A = DAS
Machine B = remote machine

You have an existing cluster cluster1 with instance1 which you want to synchronize on to machine B.
instance1 has already been registered in DAS domain.xml on machine A using create-local-instance.

1. Export cluster1 on machine A
asadmin export-sync-bundle cluster1

This will create the sync bundle which contains the cluster configuration:
glassfish3/glassfish/domains/domain1/sync/cluster1-sync-bundle.zip

2. Copy cluster1-sync-bundle.zip to machine B.

If machine B can talk to machine A, you can use the --retrieve option.
On machine B do

asadmin --host machineA export-sync-bundle --target cluster1 --retrieve=true

This will download the sync bundle from machine A onto machine B.

3. On machine B import the sync bundle

asadmin import-sync-bundle --instance instance1 cluster1-sync-bundle.zip

The instance1 filesystem is created using the sync bundle under the node that is provided in the domain.xml. You can specify a different node by using the --node option.

instance1 must already have been registered on DAS domain.xml on machine A, using create-local-instance or create-instance. If it is not registered, import-sync-bundle will give an error.

GlassFish 3.1 and create-local-instance

GlassFish Server Open Source Edition 3.1 is just released with clustering capability! If you have SSH setup on your machines, you can create the clusters and instances just from the DAS (Domain Administration Server) machine using the asadmin commands: create-cluster and create-instance. However, if you don't have SSH setup, you can still create a cluster. You will need to go to each machine and run the create-local-instance command locally.

The create-local-instance command is actually a hybrid command, meaning it's a local command which creates the local filesystem structure, then calls a remote hidden command (_register-instance) to register the instance with the DAS. Registering the instance with the DAS entails creating a server element in the DAS domain.xml.

For example if you want to setup a clustered instance on machine B with the DAS on machine A,

0. Make sure you can ping machine A from machine B. Note the host name or IP address you use for this.

1. Install GlassFish on each machine, machine A and machine B.

Machine A = DAS
Machine B = remote instance

2. Start DAS on Machine A
glassfish3/glassfish/bin/asadmin start-domain

3. On DAS (machine A) create cluster1
glassfish3/glassfish/bin/asadmin create-cluster cluster1

4. On machine B create instance1 (The default das port is 4848. Specify --port to use a different port.)
glassfish3/glassfish/bin/asadmin --host machineA create-local-instance --cluster cluster1 instance1

A few things will happen...

1. This will create a node, machineB.

a) On machine B, a directory for machineB is created under
glassfish3/glassfish/nodes/machineB (if the instance is on the same machine as DAS this will be localhost-domain1).

b) A node element for machineB is created in DAS domain.xml.

<node node-host="machineB" name="machineB" type="CONFIG" install-dir="${com.sun.aas.productRoot}"></node>

2. The DAS connection properties for node machineB is created

Under directory machineB is agent and instance1. Under agent is the config/das.properties. The das.properties holds the DAS host and port information used by the node, machineB, to connect to the DAS.

In das.properties:
agent.das.port=4848
agent.das.host=machineA

The das.properties is created the first time an instance is created for a particular node. The node machineB will now always connect to the DAS using this das.properties. Any instance which uses this node machineB, will talk to the same DAS using the same host and port. If you want to connect to a different DAS, you can either edit das.properties manually (all instances under that node would be affected), or create a new node using create-node-config and calling create-local-instance with a different DAS host/port.

3. A directory for instance is created under node machineB.

The directory for instance 1 is created at glassfish3/glassfish/nodes/machineB/instance1. The instance1/config will contain the keystore information. Once you start the instance using start-local-instance, this instance1 directory will get synchronized with the DAS.

4. The instance1 is registered on DAS.

In DAS domain.xml:

<server name="instance1" node-ref="machineB" config-ref="cluster1-config">

5. The instance1 is also registered to all the other instance within the cluster.

The instance1 is also registered to all the other instances in the cluster if they are up and running. All the instances in the cluster will know about each other.

Now you can start the newly created instance1 on machineB
asadmin start-local-instance instance1

Performance Tuner in Oracle GlassFish Server 3.1

The Performance Tuner is now again available in Oracle GlassFish Server 3.1 (docs). This handy tool was first introduced in GlassFish v2.1 as one of the value-add features. You'll enjoy the same performance gains as before. Quoting from previous Ken's previous blog, "The Tuner typically improves performance by 300% or more, and on Oracle's T-Series hardware the performance gain can be greater than 600%!" Wow! The code was ported over from v2.1 with some refactoring to get it working for 3.1.

To really get the best performance out of GlassFish Server 3.1, I recommend getting the Performance Tuner. It is very easy to use. The first page will ask you 7 questions about your particular system and resource usage. There is both inline help and online help to guide you. If you need more detailed information about each of the questions, click the Help button in the upper right of the Admin Console to open the online help.

To starting using the Performance Tuner, first, you decide which configuration you want to tune. This could be the DAS ("server"), a cluster, or a stand-alone instance. For example, let's say I have a cluster with several instances, each running on the new SPARC T3-4 server which I would like to tune. First I make sure the cluster is running. Then I gather some information about my system and the application I'm running.

The SPARC T3-4 server has 64 cores - that's 4 SPARC T3 processors with 16 cores each, and up to 512 GB of memory. I'll allocate something less than 64 cores for the GlassFish server instances - let's say 32 cores, so I enter 32 for the Number of Threads (Logical CPUs).

And I'll specify the heap memory for the GlassFish Server's JVM server instance, to be something less than 512 GB. Let's say 12 GB.

Let's also say the application deployed on the cluster spends a lot of time in the database tier, so I'll select 'HIGH {>=20%) for Allocation Time for Database Access.

I'll keep the default Garbage Collection Strategy of Maximum Peak Throughput (Higher GC Pause.)

The next two questions only apply if the Security Manager or Access Logger is enabled. Since I already have Security Manager and Access Logger disabled, those checkboxes are greyed out.

Since I'm running on a SPARC T-Series Server, I can check the last box.

When I click on the Next button, the second page will display the proposed configuration changes. The table will show what would be added, removed, or changed. If you do not want the Performance Tuner to apply all the changes for you, you can selectively make manual updates using the manual instructions that is provided for each proposed configuration change. If you are satisfied with the proposed changes and want the Performance Tuner to apply the changes click on the Confirm button. For the new changes to take effect the cluster needs to be restarted. A backup of the domain.xml is made in domain1/config/tuner should you need to revert the changes. Just copy the domain_1.xml to domain1/config to go back to the original configuration.

Here's what the first page looks like:

Here's what the second page looks like:

This second page is a table of all the items to be added, removed, or changed. From here you can see the first two items to be changed: Maximum Connections attribute of the http element. If we confirm to apply the changes, the value of Maximum Connections attribute would change from 256 to 10000.

Also, you will see on the right-hand column, the manual steps if you want to do this yourself using either the Admin Console or the asadmin set command.

Once we confirm to apply the changes, we can see that the DAS domain.xml has been updated. The max-connections for http-listener-1 and http-listener-2 are "10000".

<config name="cluster1-config"> ............................... <network-config> <protocols> <protocol name="http-listener-1"> <http max-connections="10000" default-virtual-server="server"> <file-cache></file-cache> </http> </protocol> <protocol security-enabled="true" name="http-listener-2"> <http max-connections="10000" default-virtual-server="server"> <file-cache></file-cache> </http> <ssl ssl3-enabled="false" classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as"></ssl> </protocol> <protocol name="admin-listener"> <http max-connections="250" default-virtual-server="__asadmin"> <file-cache></file-cache> </http> </protocol> </protocols> .................................. </network-config>

Restart the cluster for changes to take effect.

Another tip is that if one of the instance's configuration in the cluster needs to be tweaked for JVM Heap size, GC threads, or max-thread-pool-size, you can override the value that was set by the Performance Tuner easily. The Performance Tuner creates a system property in both the server and the cluster config elements. The system properties in the server will override the system properties in the cluster config. If we need to tweak the JVM Heap size for instance1, we can do it here

<server name="instance1" node-ref="localhost-domain1" config-ref="cluster1-config"> <system-property name="JVM_HEAP_SIZE" value="1200m"></system-property> <system-property name="JVM_HEAP_SIZE_XMN" value="600m"></system-property> <system-property name="JVM_PARALLEL_GC_THREADS" value="24"></system-property> <system-property name="MAX_THREAD_POOL_SIZE" value="128"></system-property> </server>

You can watch a brief video of the Performance Tuner - Performance Tuner Demo.

Thursday Dec 10, 2009

Yet another way to view v3 monitoring data - REST

I just covered viewing monitoring data with...
CLI
AMX MBeans (viewed with JConsole)
Admin Console

Here's yet a 4th way to get/view the v3 monitoring data - through the REST interface.

If you followed the earlier 1-2-3 steps,
in a browser, go to http://localhost:4848/monitoring/domain.

Start clicking through and you'll come to the same JVM statistics again...

v3 Monitoring with Admin Console

Here's what the JVM monitoring looks like through the Admin Console.
By the way, the Admin Console uses the AMX monitoring MBeans, as shown previously, to retrieve the data.

In the browser, go to http://localhost:4848.
Select Enterprise Server in the Tree on the left.
Click on the Monitor tab.
Click on Server sub-tab.
Click on JVM: Memory Statistics in the table to expand.

Here's a snapshot.

View AMX Monitoring MBeans in JConsole

Building on the previous entry '1-2-3 Monitoring', you can see the generated AMX Monitoring MBeans with JConsole.

If you have java in the system path, just type 'jconsole' on the command line.
In the 'New Connection' dialog, select 'Remote Process' and type in 'localhost:8686'.
Leave the Username and Password blank.

Now select the MBeans tab.
Expand the 'amx' folder. Any folder with a '-mon' suffix, will be a monitoring MBean. If you followed the previous steps to turn on JVM monitoring, you should see the JVM monitoring MBeans.
Expand the 'memory-mon' folder and '/mon/server-mon[server]' subfolder.
Click on 'jvm/memory'. You can see the ObjectName on the right side:
amx:pp=/mon/server-mon[server],type=memory-mon,name=jvm/memory.

Then select Attributes and on the right, double-click on one of the values 'javax.management.openmbean.CompositeDataSupport'. You will see the details of that statistic.

Here's a snapshot.

The ObjectNames for all the JVM Monitoring MBeans:
amx:pp=/mon/server-mon[server],type=class-loading-system-mon,name=jvm/class-loading-system
amx:pp=/mon/server-mon[server],type=memory-mon,name=jvm/memory
amx:pp=/mon/server-mon[server],type=compilation-system-mon,name=jvm/compilation-system
amx:pp=/mon/server-mon[server],type=garbage-collector-mon,name=jvm/garbage-collectors/Copy
amx:pp=/mon/server-mon[server],type=operating-system-mon,name=jvm/operating-system
amx:pp=/mon/server-mon[server],type=runtime-mon,name=jvm/runtime
amx:pp=/mon/server-mon[server],type=thread-system-mon,name=jvm/thread-system
amx:pp=/mon/server-mon[server],type=threadinfo-mon,name=jvm/thread-system/thread-10

The monitoring MBeans are created using the gmbal API (http://kenai.com/projects/gmbal).

The MBeans don't get created unless there's an RMI connection, such as when viewing through JConsole or using the Admin Console.

Easy 1-2-3 Monitoring in v3

1. See what's available for monitoring:
asadmin get server.monitoring-service.\*

2. Turn on monitoring (the output from step #1 will tell you the proper syntax for this set command):
asadmin set server.monitoring-service.module-monitoring-levels.{component}=HIGH

where {component} can be
connector-connection-pool
connector-service
ejb-container
http-service
jdbc-connection-pool
jersey
jms-service
jvm
orb
security
thread-pool
transaction-service
web-container

Example:
asadmin set server.monitoring-service.module-monitoring-levels.jvm=HIGH

Note: either LOW or HIGH will turn on monitoring; use OFF to disable it. Currently, only jvm will give different output for LOW vs. HIGH mode.

3. View statistics
asadmin get -m "\*"

You will see all the JVM statistics. If you don't want all the thread info, set the jvm level to LOW.
To see a subset of the JVM statistics, for example 'memory', you can refine the output:

asadmin get -m "server.jvm.memory.\*"

Thursday Feb 05, 2009

Use CommandExecutor to run asadmin commands in Embedded GlassFish

CommandExecutor is a general API to programmatically run asadmin commands in Embedded GlassFish.
See javadocs. I'll show how you can use it.

You will need the glassfish-embedded-all-v3-prelude-\*.jar. You can download the latest nightly build and use latest.jar.

Before you use CommandExecutor, you must first start Server:

EmbeddedInfo ei = new EmbeddedInfo();
Server server = new Server(ei);
server.start();
CommandExecutor ce = server.getCommandExecutor();

Look-up a command you want to try from the Administration Commands section of the Sun GlassFish Enterprise Server v3 Prelude Reference Manual

Let's try create-system-properties.
The command name is create-system-properties.
The default operand is one or more name-value pairs.

If you are familiar with asadmin commands, it would like this if you were running from the asadmin command line.

asadmin create-system-properties HTTP_LISTENER_PORT=38080:HTTP_SSL_LISTENER_PORT=38181

Using the CommandExecutor, the above would translate to

Properties options = new Properties();
options.setProperty("DEFAULT", "HTTP_LISTENER_PORT=38080:HTTP_SSL_LISTENER_PORT=38181");
ce.execute("create-system-properties", options);

Always use "DEFAULT" as the property name of the default operand. In addition to the default operand, other commands may have additional required options. For example, create-jdbc-connection-pool has datasourceclassname as a required option and connectionpoolid as the default operand.

asadmin create-jdbc-connection-pool --datasourceclassname myDataSourceClass myConnPool

becomes

options.setProperty("datasourceclassname", "myDataSourceClass");
options.setProperty("DEFAULT", "myConnPool");
ce.execute("create-jdbc-connection-pool", options);

Use options.clear() between different command executions.

You can also deploy a war.

asadmin deploy c:\\samples\\hello.war

becomes

options.setProperty("DEFAULT", "c:\\\\samples\\\\hello.war");
ce.execute("deploy", options);

Run your test class that deploys your war. The default port is 8888.

java -cp latest.jar;TestCommandExecutor.jar testcommandexecutor.Main

Check your web application. http://localhost:8888/hello/

I haven't tested all the commands that are supported in GlassFish v3 Prelude, but most should work. I do know that start-database and stop-database will not work because Embedded GlassFish does not bundle JavaDB.

Thursday Nov 06, 2008

Monitor GlassFish v3 Prelude with the Admin Console

GlassFish v3 Prelude has just been released. Download it here.
Basic monitoring for the web has been added in this release. It is based on a new lightweight framework.
Go ahead and try it out. Here are the steps to monitor from the Admin Console.

1. Start up GlassFish

2. Open the Administration Console in a browser at http://localhost:4848

3. Turn on Monitoring by setting Monitoring Service levels for a component to HIGH and Save. (No difference between HIGH and LOW for this release)
Configuration > Monitoring > Monitoring Service tab

4. Deploy and launch a web application.
Applications > Web Applications > Deploy
Click on Launch link to launch the application

5. View the monitoring statistics
Application Server > Monitor
Web Container tab: request, session, servlet, and JSP statistics
HTTP Service tab: error counts
JVM tab: stats on memory, OS, compilation, garbage collectors, runtime

Friday May 16, 2008

Fish Stick Anyone?

GlassFish™:  Fast, Easy & Reliable <script type="text/javascript" language="JavaScript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/popUp.js"></script> <script language="javascript1.2" type="text/javascript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/sniff.js"></script> <script language="javascript1.2" type="text/javascript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/menucontent.js"></script> <script language="javascript1.2" type="text/javascript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/menucode.js"></script> <script language="javascript1.2" type="text/javascript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/developer.js"></script>
1 GB GlassFish stick was a hot item
at JavaOne and CommunityOne

About a week or so before JavaOne, my boss asked me to put together the GlassFish memory sticks. I said ok. I didn't know what I was getting into exactly, but it sounded simple enough - load it with GlassFish related bits and create a landing page that talks about GlassFish.

What and how much to put onto the sticks? Some felt less is better, so people wouldn't just delete everythying. Some felt it better to have more bits, in the hopes that people flying back home from JavaOne would start playing with GlassFish. This sounded good too. And also because my boss told me to, I went with the second option. And since we had 1 GB to work with we did end up loading everything but the kitchen sink, about 840 MB in total. It's chock full of goodies - installers/zips for GlassFish, NetBeans IDE, & MySQL, demo from Project WebSynergy, screencasts, and hands-on labs.

How to create the landing page? A savvy web designer I am not. So I started out with the landing page we had from last year - a basic html page with plain text. I dressed it up with a dash of orange and lots of fish for fun. I thought it was kinda cute, and maybe could capture people's attention. It was definitely amateurish and casual. Some liked it. But my boss didn't. He was like 'Can you reformat it better like the Sun Java site?'. Hmm.. ok. I'll try my best. I used the 'Save As' of the Sun site as my template. I was more comfortable editing the html manually then trying to learn how to use one of the fancier html editors. I'm sure somebody who knows how to use one of those tools could have whipped something up in no time. I used StarOffice and edited the html in the HTML Source View. It took many hours wading through the hairy html code to make it look decent. I ended up with something that looks almost professional - an accomplishment for me considering my lack of web design skills. See my landing page below.

I had hoped to have content finalized by Wednesday evening, so we could copy the content onto the sticks on Thursday and Friday. But a critical piece - the GlassFish installer/zip, along with other demos and screencasts, were not ready yet until late Thursday evening. Needless to say I was a bit antsy about getting all the copying done. We were suppose to copy 1000 sticks!! And when we timed it, it took 15 minutes for a single stick. You do the math - my weekend was looking very busy. On Friday, we got a bit of a reprieve - we only had 500 sticks. And of course Nazrul and I were still making edits to the landing page up until the last minute on Friday. After we were done editing, we decided to do spell check. Spell check messed up the entire page! yikes!. For a second, we thought we had lost everything. But fortunately, I had a recent back-up. phew! We started copying around 2 on Friday. Nazrul went all around the office looking for people to help copy. It took about 18 people, 20-30 sticks each. Done by 6 pm Friday. yay! Thank you!

I enjoyed talking to people at the GlassFish booth. We had no problem, of course, handing out all the memory sticks. It was a popular item.

Here's the landing page I created for the memory sticks. I made all the links work here too.


 

GlassFish™:  Fast, Easy & Reliable

GlassFish is the fastest open-source application server, with clustering and centralized administration. Deploy using GlassFish v2 UR2, a production-ready Java EE 5 compatible application server. Join our community to learn more about the new features in Java EE 6 and GlassFish v3 TP2.

» GlassFish at a Glance    » GlassFish @ JavaOne    » Create a plugin for a chance to win a digital camera!


What's New

 
  • Supports OSGi
  • Provides an open, modular, and extensible platform
  • Supports dynamic languages such as Ruby and Groovy
  • Reference Implementation for Java EE 6
  • Currently available as a technology preview
 

Install

 
GlassFish v2 UR2 with NetBeans 6.1
  • Fastest open-source application server, with clustering and centralized administration
  • Includes EJB 3.0, JSF 1.2, JSP 2.1, Java Servlet 2.5, JAX-WS 2.1, and JAXB 2.1 specifications
  • Commercially supported
  • Provides next-generation Web features with Ajax, Scripting, and REST-based services
  • Includes a complete Web services stack with Microsoft .NET 3.0 interoperability
»  Windows installer
»  Linux installer
»  Mac installer

GlassFish v3 Technology Preview 2
Highly Modular and Lightweight!
»  Windows installer
»  Multi-platform zip

MySQL 5.0
The world's most popular open source database
»  Windows installer
»  Linux installer
»  Mac installer

Download sites:
»  GlassFish
»  NetBeans 6.1
»  MySQL 5.0
 

Licensing

 
Available under both the Common Development and Distribution License (CDDL) and GNU Public License (GPL V2 with the Classpath Exception) to maximize compatibility with other open source middleware projects and with GNU/Linux distributions.

 
    

Try it Out

 
Featured App
 
Project WebSynergy on GlassFish - Try this executable demo of our next generation application aggregation and presentation platform!
    »  More Info
    »  Project Links


Watch Screencasts

 

Support & Services

 
Get the most out of your GlassFish software with Sun's enterprise-class support and services!
 
»  Special Offer - Buy a subscription and get 1 year of Developer Expert Assistance at no extra charge!
 

Training

 
Develop your skills! See application server Course List.
 
Thrive with proper direction.
»  Java EE Training and Certification
GlassFish logo
 
GlassFish logo
 
 
 



<script language="JavaScript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/s_code_remote.js"></script><script language="JavaScript" src="http://wiki.glassfish.java.net/attach/JavaOne2008/metrics_group1.js"></script>

Friday Feb 01, 2008

Glassfish V3 - Getting Started, Setting up the Environment

Sreeni gave me instructions on how to get started and setup with Glassfish V3. It worked like a charm so I thought I would post it here. Thanks Sreeni!

1. Download and install Java SE 6.latest:
http://java.sun.com/javase/downloads/index.jsp
• Set the system/user variable JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_04
• Add %JAVA_HOME%\\bin to your system path.

2. Download and install SVN:
http://downloads.open.collab.net/collabnet-subversion.html
http://wiki.glassfish.java.net/attach/V3BrownBags/GFV3Intro2svn.pdf
• Add the svn directory to your system path.

3. Download and install Maven2:
http://maven.apache.org/download.html
• Add the system/user variable M2_HOME
• Add $M2_HOME/bin directory to your system path.
• Type the following:
mvn –version
You should see: Maven version: 2.0.8
http://wiki.glassfish.java.net/attach/V3BrownBags/GFv3Intro2Maven2.pdf

4. Checkout code:
svn checkout https://svn.dev.java.net/svn/glassfish-svn/trunk/v3

5. Build:
cd ${GFSRCDIR}/v3
mvn -U install

6. Install app server:
Expand glassfish.zip $GFv3\\v3\\distributions\\glassfish\\target\\glassfish.zip

7. Start app server
cd /glassfish/bin
./asadmin start-domain

For additional info.
http://wiki.glassfish.java.net/Wiki.jsp?page=V3FullBuildInstructions

About

Jennifer Chou

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today