Package org.wso2.carbon.utils.deployment
Class GhostDeployerUtils
- java.lang.Object
-
- org.wso2.carbon.utils.deployment.GhostDeployerUtils
-
public class GhostDeployerUtils extends Object
A collection of utility methods which are used by the Ghost Deployer
-
-
Field Summary
Fields Modifier and Type Field Description static StringENABLEDstatic StringGHOST_DEPLOYMENTstatic StringPARTIAL_UPDATE_MODE
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddServiceGroupToTransitMap(org.apache.axis2.description.AxisServiceGroup serviceGroup, org.apache.axis2.engine.AxisConfiguration axisConfig)Adds the given service group to the transit mapstatic StringcalculateGhostFileName(String fileName, String repoPath)Calculate the ghost file name using the original file name.static org.apache.axis2.description.AxisServiceGroupcreateGhostServiceGroup(org.apache.axis2.engine.AxisConfiguration axisConfig, File ghostFile, URL originalFile)Creates the Ghost ServiceGroup by reading the ghost metadata file.static org.apache.axis2.description.AxisServicedeployActualService(org.apache.axis2.engine.AxisConfiguration axisConfig, org.apache.axis2.description.AxisService ghostService)Removes the given ghost service and deploys the actual service.static voiddeployGhostArtifacts(org.apache.axis2.engine.AxisConfiguration axisConfig)static voiddeployGhostServiceGroup(File ghostFile, org.apache.axis2.deployment.repository.util.DeploymentFileData deploymentFileData, org.apache.axis2.engine.AxisConfiguration axisConfig)Load ghost services corresponding to a given axis2 service groupstatic org.apache.axis2.description.AxisServicedispatchServiceFromTransitGhosts(org.apache.axis2.context.MessageContext msgCtx)When a ghost service is removed from the axisConfig and the corresponding actual service is deployed, there's a time interval in which there's no AxisService in the AxisConfiguration for the particular service name.static GhostArtifactRepositorygetGhostArtifactRepository(org.apache.axis2.engine.AxisConfiguration axisConfig)get the ghost registry that store @DeploymentFileData objects of services that are in ghost state.static FilegetGhostFile(String fileName, org.apache.axis2.engine.AxisConfiguration axisConfig)Creates a File instance for the ghost service according to the original file name..static Map<String,org.apache.axis2.description.AxisService>getTransitGhostServicesMap(org.apache.axis2.engine.AxisConfiguration axisConfig)Get the map of services which are in transit.static booleanisGhostOn()Read the "Enabled" property under "GhostDeployment" config from the carbon.xml and return the boolean valuestatic booleanisGhostService(org.apache.axis2.description.AxisService axisService)Checks if the given Axis service is a ghost service.static booleanisPartialUpdateEnabled()Deprecated.static voidremoveGhostFile(String filePath, org.apache.axis2.engine.AxisConfiguration axisConfig)static voidremoveServiceGroupFromTransitMap(org.apache.axis2.description.AxisServiceGroup serviceGroup, org.apache.axis2.engine.AxisConfiguration axisConfig)Removes given service group from transit mapstatic StringseparatorsToUnix(String path)static voidserializeServiceGroup(Set<org.apache.axis2.description.AxisService> services, org.apache.axis2.deployment.repository.util.DeploymentFileData deploymentFileData, org.apache.axis2.engine.AxisConfiguration axisConfig)Creates the ghost file for the current service group.static voidsetGhostArtifactRepository(GhostArtifactRepository ghostArtifactRepository, org.apache.axis2.engine.AxisConfiguration axisConfig)ghost registry stores @DeploymentFileData objects of services that are in ghost state.static voidupdateLastUsedTime(org.apache.axis2.description.AxisService service)Updates the last used timestamp of the given service.static voidwaitForServiceToLeaveTransit(String serviceName, org.apache.axis2.engine.AxisConfiguration axisConfig)When a ghost service is removed from the AxisConfiguration, name of that service is kept temporary in a map.
-
-
-
Field Detail
-
GHOST_DEPLOYMENT
public static final String GHOST_DEPLOYMENT
- See Also:
- Constant Field Values
-
ENABLED
public static final String ENABLED
- See Also:
- Constant Field Values
-
PARTIAL_UPDATE_MODE
public static final String PARTIAL_UPDATE_MODE
- See Also:
- Constant Field Values
-
-
Method Detail
-
deployActualService
public static org.apache.axis2.description.AxisService deployActualService(org.apache.axis2.engine.AxisConfiguration axisConfig, org.apache.axis2.description.AxisService ghostService) throws org.apache.axis2.AxisFaultRemoves the given ghost service and deploys the actual service. Service file name is extracted from the Ghost Service and then the actual service is deployed. Finally the actual service is returned.- Parameters:
axisConfig- - AxisConfiguration instanceghostService- - Existing Ghost service- Returns:
- - newly deployed real service
- Throws:
org.apache.axis2.AxisFault- - On errors while removing existing service
-
updateLastUsedTime
public static void updateLastUsedTime(org.apache.axis2.description.AxisService service)
Updates the last used timestamp of the given service. A new Paramter is created if it doesn't already exists..- Parameters:
service- - AxisService instance
-
isGhostOn
public static boolean isGhostOn()
Read the "Enabled" property under "GhostDeployment" config from the carbon.xml and return the boolean value- Returns:
- - true if the property is set to true. otherwise false
-
isPartialUpdateEnabled
@Deprecated public static boolean isPartialUpdateEnabled()
Deprecated.Read the "PartialUpdate" property under "GhostDeployment" config from the carbon.xml and return the boolean value- Returns:
- - true if the property is set to true. otherwise false
-
getTransitGhostServicesMap
public static Map<String,org.apache.axis2.description.AxisService> getTransitGhostServicesMap(org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.AxisFault
Get the map of services which are in transit. A particular service will be in this map from the time the ghost service is removed from AxisConfig and the actual service is deployed..- Parameters:
axisConfig- - AxisConfiguration instance- Returns:
- returns a map of strings which are the names of the services
- Throws:
org.apache.axis2.AxisFault- - on error while getting or setting map
-
dispatchServiceFromTransitGhosts
public static org.apache.axis2.description.AxisService dispatchServiceFromTransitGhosts(org.apache.axis2.context.MessageContext msgCtx) throws org.apache.axis2.AxisFaultWhen a ghost service is removed from the axisConfig and the corresponding actual service is deployed, there's a time interval in which there's no AxisService in the AxisConfiguration for the particular service name. Within this interval, if a request comes in to the service, we have to somehow dispatch the service. Within the above mentioned time interval, service is kept in a map. This method checks whether the relevant service is available in that map and if it is found, returns the name of the service. IMPORTANT : This method assumes that the service name can be figured out using the To EPR of the MessageContext. But it's only valid for HTTP/S transport. For other transports like JMS, this won't work.- Parameters:
msgCtx- - MessageContext for the current request- Returns:
- - Service if found, else null
- Throws:
org.apache.axis2.AxisFault- - on errors while calling Axis2 APIs
-
waitForServiceToLeaveTransit
public static void waitForServiceToLeaveTransit(String serviceName, org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.AxisFault
When a ghost service is removed from the AxisConfiguration, name of that service is kept temporary in a map. This method waits until the provided service name is removed from that map. In other words, it waits until the actual service is deployed. After the actual service is deployed, it is safe to forward the request further..- Parameters:
serviceName- - name of the serviceaxisConfig- - current axisConfig instance- Throws:
org.apache.axis2.AxisFault- - on errors while reading ghost map
-
isGhostService
public static boolean isGhostService(org.apache.axis2.description.AxisService axisService)
Checks if the given Axis service is a ghost service.- Parameters:
axisService- - The AxisService object to be checked if it's a ghost service- Returns:
- - true if the service is a ghost service
-
createGhostServiceGroup
public static org.apache.axis2.description.AxisServiceGroup createGhostServiceGroup(org.apache.axis2.engine.AxisConfiguration axisConfig, File ghostFile, URL originalFile)Creates the Ghost ServiceGroup by reading the ghost metadata file. The created object will contain the basic metadata of the service group which are enough to dispatch a request.- Parameters:
axisConfig- - AxisConfiguration instanceghostFile- - Ghost metadata fileoriginalFile- - URL of the original service artifact- Returns:
- - AxisServiceGroup object which is created
-
serializeServiceGroup
public static void serializeServiceGroup(Set<org.apache.axis2.description.AxisService> services, org.apache.axis2.deployment.repository.util.DeploymentFileData deploymentFileData, org.apache.axis2.engine.AxisConfiguration axisConfig)
Creates the ghost file for the current service group. Basically this ghost file contains basic metadata about the service group. Service name, operations, service type, MEP and all endpoints are stored for each service found under the given service group.- Parameters:
services- - Services to be serializeddeploymentFileData- - Absolute path to the service artifactaxisConfig- - AxisConfiguration instance
-
calculateGhostFileName
public static String calculateGhostFileName(String fileName, String repoPath)
Calculate the ghost file name using the original file name. This should be unique across all service types and hierarchical services.- Parameters:
fileName- - original file namerepoPath- - path of the axis2 repository- Returns:
- - derived ghost file name
-
getGhostFile
public static File getGhostFile(String fileName, org.apache.axis2.engine.AxisConfiguration axisConfig)
Creates a File instance for the ghost service according to the original file name..- Parameters:
fileName- - original service file nameaxisConfig- - AxisConfiguration instance- Returns:
- - File instance created
-
addServiceGroupToTransitMap
public static void addServiceGroupToTransitMap(org.apache.axis2.description.AxisServiceGroup serviceGroup, org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.AxisFaultAdds the given service group to the transit map- Parameters:
serviceGroup- - to be added to transit mapaxisConfig- - current axis configuration- Throws:
org.apache.axis2.AxisFault- - on error
-
removeServiceGroupFromTransitMap
public static void removeServiceGroupFromTransitMap(org.apache.axis2.description.AxisServiceGroup serviceGroup, org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.AxisFaultRemoves given service group from transit map- Parameters:
serviceGroup- - to be removed from transit mapaxisConfig- - current axis configuration- Throws:
org.apache.axis2.AxisFault- - on error
-
deployGhostArtifacts
public static void deployGhostArtifacts(org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.deployment.DeploymentException- Throws:
org.apache.axis2.deployment.DeploymentException
-
removeGhostFile
public static void removeGhostFile(String filePath, org.apache.axis2.engine.AxisConfiguration axisConfig)
-
setGhostArtifactRepository
public static void setGhostArtifactRepository(GhostArtifactRepository ghostArtifactRepository, org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.deployment.DeploymentException
ghost registry stores @DeploymentFileData objects of services that are in ghost state.- Parameters:
ghostArtifactRepository- Set the ghost artifact registry for this tenantaxisConfig- The axis configuration of the tenant- Throws:
org.apache.axis2.deployment.DeploymentException- if error occurred while saving the ghost artifact registry
-
getGhostArtifactRepository
public static GhostArtifactRepository getGhostArtifactRepository(org.apache.axis2.engine.AxisConfiguration axisConfig)
get the ghost registry that store @DeploymentFileData objects of services that are in ghost state.- Parameters:
axisConfig- The axis configuration of the tenant
-
deployGhostServiceGroup
public static void deployGhostServiceGroup(File ghostFile, org.apache.axis2.deployment.repository.util.DeploymentFileData deploymentFileData, org.apache.axis2.engine.AxisConfiguration axisConfig) throws org.apache.axis2.deployment.DeploymentException
Load ghost services corresponding to a given axis2 service group- Parameters:
ghostFile- The ghost file that contains meta information to deploy a ghost servicedeploymentFileData- The deployment file data of the artifact we are about to deployaxisConfig- The axis configuration of the tenant- Throws:
org.apache.axis2.deployment.DeploymentException
-
-