Search in sources :

Example 1 with InMemoryAPIDeployer

use of org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer in project carbon-apimgt by wso2.

the class GatewayStartupListener method cleanDeployment.

private void cleanDeployment(String artifactRepositoryPath) {
    InMemoryAPIDeployer inMemoryAPIDeployer = new InMemoryAPIDeployer();
    inMemoryAPIDeployer.cleanDeployment(artifactRepositoryPath);
}
Also used : InMemoryAPIDeployer(org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer)

Example 2 with InMemoryAPIDeployer

use of org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer in project carbon-apimgt by wso2.

the class RedeployApiApiServiceImpl method redployAPI.

public Response redployAPI(String apiName, String version, String tenantDomain, MessageContext messageContext) {
    tenantDomain = RestApiCommonUtil.getValidateTenantDomain(tenantDomain);
    InMemoryAPIDeployer inMemoryApiDeployer = new InMemoryAPIDeployer();
    try {
        inMemoryApiDeployer.reDeployAPI(apiName, version, tenantDomain);
        if (debugEnabled) {
            log.debug("Successfully deployed " + apiName + " in gateway");
        }
        DeployResponseDTO responseDTO = new DeployResponseDTO();
        responseDTO.setDeployStatus(DeployResponseDTO.DeployStatusEnum.DEPLOYED);
        responseDTO.setJsonPayload(apiName + " redeployed from the gateway");
        return Response.ok().entity(responseDTO).build();
    } catch (ArtifactSynchronizerException e) {
        String errorMessage = "Error in fetching artifacts from storage";
        log.error(errorMessage, e);
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}
Also used : ArtifactSynchronizerException(org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException) InMemoryAPIDeployer(org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer) DeployResponseDTO(org.wso2.carbon.apimgt.rest.api.gateway.dto.DeployResponseDTO)

Example 3 with InMemoryAPIDeployer

use of org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer in project carbon-apimgt by wso2.

the class UndeployApiApiServiceImpl method undeployAPI.

public Response undeployAPI(String apiName, String version, String tenantDomain, MessageContext messageContext) {
    InMemoryAPIDeployer inMemoryApiDeployer = new InMemoryAPIDeployer();
    tenantDomain = RestApiCommonUtil.getValidateTenantDomain(tenantDomain);
    try {
        inMemoryApiDeployer.unDeployAPI(apiName, version, tenantDomain);
        if (debugEnabled) {
            log.debug("Successfully undeployed " + apiName + " in gateway");
        }
        DeployResponseDTO deployResponseDTO = new DeployResponseDTO();
        deployResponseDTO.setDeployStatus(DeployResponseDTO.DeployStatusEnum.UNDEPLOYED);
        deployResponseDTO.setJsonPayload(apiName + " Undeployed from the gateway");
        return Response.ok().entity(deployResponseDTO).build();
    } catch (ArtifactSynchronizerException e) {
        String errorMessage = "Error in fetching artifacts from storage";
        log.error(errorMessage, e);
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}
Also used : ArtifactSynchronizerException(org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException) InMemoryAPIDeployer(org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer) DeployResponseDTO(org.wso2.carbon.apimgt.rest.api.gateway.dto.DeployResponseDTO)

Example 4 with InMemoryAPIDeployer

use of org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer in project carbon-apimgt by wso2.

the class GatewayStartupListener method deployArtifactsAtStartup.

private boolean deployArtifactsAtStartup(String tenantDomain) throws ArtifactSynchronizerException {
    GatewayArtifactSynchronizerProperties gatewayArtifactSynchronizerProperties = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration().getGatewayArtifactSynchronizerProperties();
    boolean flag = false;
    long waitTime = System.currentTimeMillis() + 60 * 1000;
    long retryDuration = 5000;
    if (gatewayArtifactSynchronizerProperties.isRetrieveFromStorageEnabled()) {
        InMemoryAPIDeployer inMemoryAPIDeployer = new InMemoryAPIDeployer();
        while (waitTime > System.currentTimeMillis() && !flag) {
            flag = inMemoryAPIDeployer.deployAllAPIsAtGatewayStartup(gatewayArtifactSynchronizerProperties.getGatewayLabels(), tenantDomain);
            if (!flag) {
                log.error("Unable to deploy synapse artifacts at gateway. Next retry in " + (retryDuration / 1000) + " seconds");
                try {
                    Thread.sleep(retryDuration);
                } catch (InterruptedException ignore) {
                }
            }
        }
    }
    return flag;
}
Also used : GatewayArtifactSynchronizerProperties(org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties) InMemoryAPIDeployer(org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer)

Aggregations

InMemoryAPIDeployer (org.wso2.carbon.apimgt.gateway.InMemoryAPIDeployer)4 ArtifactSynchronizerException (org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException)2 DeployResponseDTO (org.wso2.carbon.apimgt.rest.api.gateway.dto.DeployResponseDTO)2 GatewayArtifactSynchronizerProperties (org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties)1