In a series of blogs I will deal with different aspects/features of JBoss AS7. This is first blog of the series. In this blog I will discuss a new feature in AS-7 called Managed Domain. After reading this blog readers should have good understanding of the managed domain, its use and advantages.
Before I start the discussion on Managed Domain, it is important to have a good understanding of the directory structure of AS7 server. To read about directory structure click here.
What is a domain
As developers all of us know that a single instance of JBoss server can be started by starting the JBoss installation in standalone mode. This is true for AS7 also. But the real world UAT or Production setup almost always has a cluster of JBoss application servers running from JBoss installations in different virtual/physical machines. The collection of such JBoss AS servers is called a domain.
What is a managed domain
If all the servers of a domain have to be managed independently then tasks like app deployment, configuration fine tuning, starting/stopping the server will have to be done for each servers individually. Suppose the servers in the domain are divided into two groups, and say group-1 should have common apps deployed and a common start-up configuration then it becomes the responsibility of the administrator to ensure the details.
Managed Domain is one of the primary new features of AS7 which provides a single point of control to all application servers in the domain. Before we see how Managed Domain simplifies the task of managing the servers in a domain let us first understand how Managed Domain works on JBoss AS7.
What is Domain Mode
If there is a need for a mutliple JBoss installation - multi server setup and want them to be Domain Managed then the JBoss installation should be started in Domain mode. To do that go to <JBoss Home>/bin folder and run domain.bat or domain.sh. Definitely some configuration information will have to be fed into some configuration file before you run the domain.sh. I will discuss the configuration details in my next blog.
When the JBoss instance is started in Domain mode then the processes HostController and the DomainController come into existence. HostController and Domain Controller are the basic processes which manage the server instances and help create a managed domain.
Summarily it can be said that HostControllers are responsible for managing all the server instances created from a single JBoss installation. Whereas the DomainController manages the complete domain that includes all the servers in the domain by talking to all the HostControllers (one per JBoss installation) . Which means all the HostControllers act as slaves to the DomainController.
When you run the domain.sh/bat file the second line of info log will be
12:08:25,543 INFO [org.jboss.as.process.Host Controller.status] (main) Starting process 'Host Controller'.
Which means that one of the first few process which start as part of domain mode start-up is the HostController.
What is a HostController
HostController is the process which is responsible for
- Starting up the servers it is supposed to start.
- Provide the start up options and configuration information to each server it has started.
- Expose the management and public interface to the servers started by it.
- Administer the servers under its purview through the management interfaces.
- Start up as Domain controller or register with the DomainController of the domain, as slave (Please wait till we discuss the DomainController).
Starting up the servers it is supposed to start????? What does that mean? To understand this we will have to navigate to <JBoss Home>/domain/configuration folder. There you will find the file named host.xml. When the HostController starts up it refers to this file to take instructions/configuration information which you as administrator have provided. So let us take a brief look at what is host.xml all about:
- Listing of servers - which the HostController should start. In the server element the name attribute uniquely identifies the server. 'group' attribute groups the servers of a domain into different groups. Just keep this in mind. We will discuss the grouping in detail when we discuss the DomainController. The auto-start attribute tells the HostController to auto-start the server on start-up or to suspend starting till it is explicitly instructed to start the server through the management interface. And other start up parameters can be passed to each server element which will be passed on by HostController to servers while starting them up.
<servers> <server name="server-one" group="main-server-group" auto-start="true"> <jvm name="default"/> </server> <server name="server-two" group="main-server-group" auto-start="true"> <jvm name="default"> <heap size="64m" max-size="256m"/> </jvm> <socket-binding-group ref="standard-sockets" port-offset="150"/> </server> <servers>
- Management interface - Host controller also exposes the management interfaces. Management interface can be native or HTTP. Exposing the native interface is mandatory, because the DomainController uses the native interface to interact with the HostController and pass on the admin instructions to HostController. More on this when we discuss the DomainController.
- Master/Slave configuration - The host controller can be configured to act as the DomainController or the Master HostController of the Domain. To do that just add a <local/> element to the domain-controller declaration. Look at Listing 1-2. To make all other HostController in the domain slave HostControllers just add a remote element in the domain-controller declaration. The remote element provides the inet-addr of the DomainController and the port at which it is available. Please look at Listing 1-3. HostController uses these details to register itself with the domain controller at start up.
<domain-controller> <local/> </domain-controller>
<domain-controller> <remote host="192.168.1.143" port="9999"/> </domain-controller>
- Every installation of JBoss servers when started in domain mode will have one HostController per host machine.
- HostController can start zero, one or many servers, based on the server declarations in host.xml.
- One HostController in a domain acts as DomainController(Master).
- All other HostControllers act as slaves to the DomainController.
- The HostControllers expose a native management interface so that the HostControllers can communicate with the DomainController and vice-versa.
You might have already taken a hint by now that one of the HostControllers in domain rises upto the situation and starts acting as the DomainController. Listing 1-2 and Master/Slave configuration section of host.xml explains how that happens. Let me repeat that DomainController is the single point of control for all the server instances in a domain. The instructions/configuration information are passed from administrator to the DomainController with the help of domain.xml which can be found in <JBossHome>/domain/configuration folder.
- Server groups - Server groups is logical way of grouping the servers in a domain. In domain.xml admin can define some server groups and assign the desired default settings to each server group. When defining the server elements in host.xml the value for attribute group (Please refer to Listing 1-1 ) should be name of one of these server-groups defined in domain.xml. Why do we want to group the servers at all? We may want to group the servers for following reasons
- If there are groups defined in the domain.xml then DomainController has the option to deploy different set of applications on different group of servers.
- Admin can assign different set of capabilities to the groups of servers by assigning them different server profiles.
- With groups DomainController can assign different set of socket bindings to the server groups.
- Many more such fine tuning can be done at the group level which makes the tasks of the Administrator very simple. Like by deploying a content to one group using the management interface the admin effectively deploys the content to all the servers of the group.
- DomainController also takes care of the integrity of the group of servers and if some action fails on any one node of the group, if required the DomainController can roll back the action on all other nodes of the group.
- Profiles & Socket Binding Groups - Discussion on these profiles and Socket Binding Groups is beyond the scope of this blog.
- deployments - Whenever a content is uploaded through the management interface a deployment declaration is added to the deployments declaration of domain.xml. And if the content is added to any of the server group then a deployment declaration is added to the deployments declaration of the server group.
<deployments> <deployment name="secured-app.war" runtime-name="secured-app.war"> <content sha1="b3fe2821a04a54b5000c9b0413f007e3c12cd099"/> </deployment> </deployments>
<server-group name="main-server-group" profile="default"> ......... <deployments> <deployment name="secured-app.war" runtime-name="secured-app.war"/> </deployments </server-group>
DomainController is the single point of control of all the admin aspects of all servers in a domain.
One of the HostControllers in the domain acts as the DomainController and acts as the master of all the other HostControllers in the domain.
domain.xml is used as the configuration repository for the DomainController. Any changes made to the domain configuration through the management interface are persisted in the domain.xml and is available when the DomainController starts up again.
DomainController uses the concept of server groups to make the administration of similar servers in the domain even simpler.
Deployment of the content to the group is also simplified due the comcept of groups.