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 final String
     
    static final String
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addServiceGroupToTransitMap(org.apache.axis2.description.AxisServiceGroup serviceGroup, org.apache.axis2.engine.AxisConfiguration axisConfig)
    Adds the given service group to the transit map
    static String
    calculateGhostFileName(String fileName, String repoPath)
    Calculate the ghost file name using the original file name.
    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.
    static org.apache.axis2.description.AxisService
    deployActualService(org.apache.axis2.engine.AxisConfiguration axisConfig, org.apache.axis2.description.AxisService ghostService)
    Removes the given ghost service and deploys the actual service.
    static void
    deployGhostArtifacts(org.apache.axis2.engine.AxisConfiguration axisConfig)
     
    static void
    deployGhostServiceGroup(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 group
    static org.apache.axis2.description.AxisService
    dispatchServiceFromTransitGhosts(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.
    getGhostArtifactRepository(org.apache.axis2.engine.AxisConfiguration axisConfig)
    get the ghost registry that store @DeploymentFileData objects of services that are in ghost state.
    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..
    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 boolean
    Read the "Enabled" property under "GhostDeployment" config from the carbon.xml and return the boolean value
    static boolean
    isGhostService(org.apache.axis2.description.AxisService axisService)
    Checks if the given Axis service is a ghost service.
    static boolean
    Deprecated.
    static void
    removeGhostFile(String filePath, org.apache.axis2.engine.AxisConfiguration axisConfig)
     
    static void
    removeServiceGroupFromTransitMap(org.apache.axis2.description.AxisServiceGroup serviceGroup, org.apache.axis2.engine.AxisConfiguration axisConfig)
    Removes given service group from transit map
    static String
     
    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.
    static void
    setGhostArtifactRepository(GhostArtifactRepository ghostArtifactRepository, org.apache.axis2.engine.AxisConfiguration axisConfig)
    ghost registry stores @DeploymentFileData objects of services that are in ghost state.
    static void
    updateLastUsedTime(org.apache.axis2.description.AxisService service)
    Updates the last used timestamp of the given service.
    static void
    waitForServiceToLeaveTransit(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • 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.AxisFault
      Removes 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 instance
      ghostService - - 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.AxisFault
      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. 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 service
      axisConfig - - 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 instance
      ghostFile - - Ghost metadata file
      originalFile - - 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 serialized
      deploymentFileData - - Absolute path to the service artifact
      axisConfig - - 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 name
      repoPath - - 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 name
      axisConfig - - 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.AxisFault
      Adds the given service group to the transit map
      Parameters:
      serviceGroup - - to be added to transit map
      axisConfig - - 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.AxisFault
      Removes given service group from transit map
      Parameters:
      serviceGroup - - to be removed from transit map
      axisConfig - - 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 tenant
      axisConfig - 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
    • separatorsToUnix

      public static String separatorsToUnix(String path)
    • 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 service
      deploymentFileData - The deployment file data of the artifact we are about to deploy
      axisConfig - The axis configuration of the tenant
      Throws:
      org.apache.axis2.deployment.DeploymentException