This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Configuring Server Roles

The Server Roles

A server role is a parameter that is mentioned in carbon.xml for all WSO2 Carbon-based products. Generally a cApp consists of a set of resources that is to be deployed in different products. Therefore, when a user deploys a cApp in a carbon product, all the resources cannot be deployed in that particular product instance. To sort out which can be deployed and which cannot, the ServerRole property is used. When a cApp is being deployed, it reads the ServerRoles property in carbon.xml and deploys only the resources which match the ServerRole value in there.

Each product has a different default ServerRoles property in its carbon.xml. For the WSO2 Gadget Server, it is as follows.

  • WSO2 Gadget Server - "GadgetServer"

This property value is used for the deployment of cApp archives.

In cApp development time, you have to specify a server role for each and every artifact in the cApp. It assigns a logical ServerRole to each and every artifact since, at development time, we are aware of the physical server in which a particular artifact will be deployed.

For example, say you are developing an Axis2 service and planning to deploy all your services in a single Gadget Server instance in the production setup. You may set the server role as "gadgetserver1". At the deployment time of the cApp, you have to set the server roles for each and every Carbon instance in your setup. You can set one or more roles which can be assigned to the current Carbon instance. The product name is set as the default value for the server role of each product. The following three methods can be used to set the ServerRole.

Using the Gadget Server Management Console

This is the easiest way to set the server role of your Carbon instance. See in configuration section for information on adding and removing server roles using the Management Console. This is the most recommended way to configure your server roles.

Using carbon.xml File

You can find the following element in 'CARBON_HOME/repository/conf/carbon.xml' file.

<ServerRoles>
     <Role>GadgetServer</Role>
</ServerRoles>

You can set multiple Role elements here to specify the roles acted by the current server. For example, if you want this server to act as appserver1 and dataservices1 servers, configuration is as follows.

<ServerRoles>
     <Role>appserver1</Role>    
     <Role>dataservices1</Role>
</ServerRoles>

Before setting the above, ensure that the current server has capability to deploy Axis2 services and data services. When you deploy a cApp artifact on this server, all artifacts which have the above two server roles will be deployed on the current instance. Others will be ignored.

Using a system property

You can use the system property "serverRoles" to specify the server roles that can be acted by the current Carbon instance. When you start the server, pass the server roles as a comma separated list. Example is shown below. 

sh wso2server.sh -DserverRoles=appserver1,dataservices1


Once you use the management console for server roles, you can't change that configuration using the other two methods. Server roles are stored in the Registry when they are configured through the management console. Values in the Registry are always given priority over others.