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);
}
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;
}
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;
}
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;
}
Aggregations