Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Carbon application functionality is provided by the following feature in the WSO2 feature repository:

Name: WSO2 Carbon - Application Management Feature
Identifier: org.wso2.carbon.application.mgt.feature.group

If this capability is not included in your product by default, you can add it by installing the above feature using the instructions given in section, Feature Management.

Follow the instructions below to deploy a Carbon Application, also known as a C-App.

1. Log on to the product's management console and select "Add" under "Carbon Applications."

Image Removed

2. Select your CAR file by browsing the file system and click "Upload." For example,

Image Removed

3. A message appears if your CAR file gets uploaded successfully. Click "OK" and refresh the page to see the status of a new application.

Image Removed

4. The CAR files you deploy this way are dropped to the <PRODUCT_HOME>/repository/carbonapps/{tenant-ID}.

Info
titleNote

As an alternative to uploading the cApp using the management console, you can copy the CAR archive into <PRODUCT_HOME>/repository/carbonapps/{tenant-ID} manually and it will be deployed. {tenant-ID} is the ID of the tenant, which is 0 in a single-tenanted environment. 0 is the super tenant ID. Manual deployment in a multi-tenanted environment is not recommended if you are unaware of the tenant ID.

 5. If successfully deployed, the cApp should be listed on the "Applications List" window. For example,

Image Removed

If the Carbon application does not have artifacts which are applicable to the particular product you are using, nothing will be listed on this window.

...

hiddentrue

...

See the following topics for details:

Table of Contents
maxLevel3
minLevel3
 

C-App deployment methods

Anyone of the following methods can be used to deploy C-Apps:

  • Upload the C-App using the Management Console.

  • Directly add the artifact file to the < CARBON_HOME>/repository/deployment/server/carbonapps hot deployment directory.

C-App deployment process

The following are the steps that take place during the deployment of a C-App:

  1. Artifacts inside C-App get extracted to the temp location inside the <PRODUCT_HOME>/repository/carbonapps/work directory.

  2. The CappDeployer then reads the artifacts.xml file to get the list of artifacts contained in the C-App. In this process the C-App deployer builds a map containing all the required dependencies to deploy the artifacts.

  3. The C-App deployer iteratively deploys the artifacts and required dependencies. This is done by calling the CAppDeployer, which in-turn programmatically calls the relevant deployer of the artifacts based on the server role and the artifactType and thereafter it deploys the artifacts.

  4. When the C-App deployment process is completed all its artifacts relevant to the server role are up and running. However, if any issues are encountered during the deployment it rollbacks to the deployed artifact. 

Sample

The following sample code is based on the new implementation and is for a webapp deployment. The deployment of the other artifacts will be done in a similar manner except for Synapse artifacts.

Code Block
package org.wso2.carbon.application.deployer.webapp
 
/**
*  Check the artifact type and if it is a WAR, copy it to the WAR deployment hot folder
*/
 
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
 
// loop through all artifacts and deploy them iteratively
	for (Artifact.Dependency dep : artifacts) {
	Deployer deployer;
	Artifact artifact = dep.getArtifact();
	if (artifact == null) {
		continue;
	}
 
/**
* for each service type, select the correct deployer
* for this we need to provide the relevent deployment directory on carbon server and the extension of the artifact
* these details are read from the configurations for the corresponding artifact type
* since webapps may have two artifact types we should get the correct deployer
*/
	if (WAR_TYPE.equals(artifact.getType())) {
		deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, WAR_DIR, "war");
	} else if (JAX_WAR_TYPE.equals(artifact.getType())) {
		deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, JAX_WAR_DIR, "war");
	} else {
		continue;
	}
 
	// once the deployer gets called we execute the webapp deployer to deploy
	if (deployer != null) {
		String fileName = artifact.getFiles().get(0).getName();
		String artifactPath = artifact.getExtractedPath() + File.separator + fileName;  
	// extracted path is our artifact extracted temp location. These details are available is the artifact
	try {
		// deploy the artifact 
		deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer)); 
		// set the deployment state 
		artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);   
	} catch (DeploymentException e) {
		artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
	throw e;
	}
}

package org.wso2.carbon.application.deployer
 
/**
* Finds the correct deployer for the given directory and extension
*
* @param axisConfig - AxisConfiguration instance
* @param directory - Directory to retrieve the deployer
* @param extension - Extension of the deployable artifact
* @return Deployer instance
*
*/
public static Deployer getArtifactDeployer(AxisConfiguration axisConfig, String directory, String extension) {
	// access the deployment engine through axis config
	DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
	// return the corresponding deployer to the required artifact type
	return deploymentEngine.getDeployer(directory, extension); 
}

Evolution in C-App deployment model

Prior to WSO2 Carbon 4.2.0 Turing platform release, the process of C-App deployment was different from the current approach. In the previous approach during C-App deployment, the CappDeployer initially extracts all the CAR files to the <PRODUCT_HOME>/temp directory. Thereafter, based on the artifact type, the CappDeployer will copy the C-Apps to relevant hot deployment folders in the <PRODUCT_HOME>/repository/deployment/server directory. Due to this approach the C-App deployment prior to the Carbon 4.2.0 era was not synchronous. One major drawback of this approach was during runtime, if an artifact failed during its deployment, there was no direct way to check as to which C-App deployed these faulty artifacts. In many production systems this requirement was crucial, since they tend to deploy dozens of C-Apps at once.

In current approach during C-App deployment, the CappDeployer initially extracts all the CAR files to the <PRODUCT_HOME>/repository/carbonapps/work directory. Thereafter, the CappDeployer copies the the artifacts based on the artifact type, to the <PRODUCT_HOME>/repository/deployment/server/carbonapps hot deployment directory. The DeployerSchedulerTask will run periodically to identify all changes in the hot deployment directories. If there are any changes (such as new C-Apps, edited C-Apps and deleted C-Apps) in the carbonapps hot deployment directory, the DeployerSchedulerTask will deploy the artifacts immediately. Thereby, this process is synchronous and atomic in the new C-App deployment strategy and if the CApp gets successfully deployed, we can guarantee that all the artifacts have been successfully deployed.