Managing Server Roles
A server role is a parameter that is mentioned in <PRODUCT_HOME>/repository/conf/carbon.xmlÂ
file of all WSO2 products. When a C-App is being deployed, it reads the ServerRoles property from the carbon.xml
 and deploys only the resources that match the server-role value in the file. Each product has a different default ServerRoles property as follows:
- WSO2 Application Server - "ApplicationServer"
- WSO2 Business Activity Monitor - "BusinessActivityMonitor"
- WSO2 Business Process Server - "BusinessProcessServer"
- WSO2 Business Rules Server - "BusinessRulesServer"
- WSO2 Data Services Server - "DataServicesServer"
- WSO2 Enterprise Service Bus - "EnterpriseServiceBus"
- WSO2 Gadget Server - "GadgetServer"
- WSO2 Governance Registry - "GovernanceRegistry"
- WSO2 Identity Server - "IdentityServer"
- WSO2 Mashup Server - "MashupServer"
The following is an example list of C-App resources that map to default server roles.
- ApplicationServer -Â
foo.aar, jax-wx.war
- EnterpriseServiceBus -Â
proxy.xml
- BusinessProcessServer -Â
my_bpel.zip
- JaggeryServer -Â
jaggery_app.jag
In C-App development time, you can specify a server role for each and every artifact in the C-App. For example, say you are developing an Axis2 service and planning to deploy all your services in a single Application Server instance in the production setup. You can set the server role as appserver1
.
Server Roles Manager
Server roles manager is a component to manage the server roles property for WSO2 Carbon based products. Due to the functionality of the server roles manager, users do not have to manually modify the carbon.xml
 to include the server-roles related to the product feature that they have added to a Carbon product instance. The server roles manager stores both carbon.xml
 file's default product roles as well as the user/tenant specific server roles in the configuration registry. So, when a C-App is deployed in Carbon, the C-App deployer checks for auto-mentioned server roles from the registry instead of the carbon.xml
 file. Â
In the server roles manager, the ServerRoles
 properties are of two types:
- Default - All the server roles picked from that particular product instance'sÂ
carbon.xml
. - Custom - All other server roles added by the users.
The following methods can be used to set the ServerRole:
Using the management console to set the ServerRole property
This is the easiest and the most recommended way to configure your server roles.   Follow the instructions below to add a new server role:
- Log in to the management console of your product and  click Server Roles menu under the Configure menu. Â
- Click Add New Server Role,  enter the Role Name and click Add . You can add any textual name as a server role without special characters except underscore.
  The newly added server role is displayed in the server roles list.Â
  You can delete the server role using the Deleteicon associated with it.You cannot undo a deletion once performed. Users can even delete a default server role. Once deleted, the server role manager will not pick up the deleted server role from the
carbon.xml
file, next time the server starts.
Using carbon.xml file to set the ServerRole property
Find the ServerRoles element in <PRODUCT_HOME>/repository/conf/carbon.xml
 file. For example,
<ServerRoles> <Role>DataServicesServer</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 C-App 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 to set the ServerRole property
You can use the system property ServerRolesÂ
to specify the server roles that can be acted by the current product instance. When you start the server, pass the server roles as a comma separated list. For example,
sh wso2server.sh -DserverRoles=appserver1,dataservices1
Once you use the management console to set 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.