Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Fixing STRATOS-1647 - Application deployment fails due to a bug in Ax…
Browse files Browse the repository at this point in the history
…is2 level. Making service interface void type methods to non-void as a workaround
  • Loading branch information
ravihansa3000 committed Jun 17, 2016
1 parent f1e0045 commit b063eb4
Show file tree
Hide file tree
Showing 10 changed files with 1,132 additions and 970 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@

package org.apache.stratos.autoscaler.client;

import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext;
Expand All @@ -47,23 +53,43 @@
* This class will call cloud controller web service to take the action decided by Autoscaler
*/
public class AutoscalerCloudControllerClient {

private static final Log log = LogFactory.getLog(AutoscalerCloudControllerClient.class);

private static final String AS_CC_CLIENT_MAX_CONNECTIONS_PER_HOST_KEY =
"autoscaler.cloud.controller.client.max.connections.per.host";
private static final String AS_CC_CLIENT_MAX_TOTAL_CONNECTIONS_KEY =
"autoscaler.cloud.controller.client.max.total.connections";
private static final int AS_CC_CLIENT_MAX_CONNECTIONS_PER_HOST = Integer.getInteger
(AS_CC_CLIENT_MAX_CONNECTIONS_PER_HOST_KEY, 25);
private static final int AS_CC_CLIENT_MAX_TOTAL_CONNECTIONS = Integer.getInteger
(AS_CC_CLIENT_MAX_TOTAL_CONNECTIONS_KEY, 30);
private static CloudControllerServiceStub stub;

private AutoscalerCloudControllerClient() {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(AS_CC_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(AS_CC_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);

try {
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants.CLOUD_CONTROLLER_DEFAULT_PORT);
int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants
.CLOUD_CONTROLLER_DEFAULT_PORT);
String hostname = conf.getString("autoscaler.cloudController.hostname", "localhost");
String epr = "https://" + hostname + ":" + port + "/" + AutoscalerConstants.CLOUD_CONTROLLER_SERVICE_SFX;
int cloudControllerClientTimeout = conf.getInt("autoscaler.cloudController.clientTimeout", 180000);

stub = new CloudControllerServiceStub(epr);
stub = new CloudControllerServiceStub(ctx, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, cloudControllerClientTimeout);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
cloudControllerClientTimeout);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (Exception e) {
log.error("Could not initialize cloud controller client", e);
}
Expand Down Expand Up @@ -217,7 +243,8 @@ public void terminateInstanceForcefully(String memberId) throws Exception {
public void terminateAllInstances(String clusterId) throws RemoteException,
CloudControllerServiceInvalidClusterExceptionException {
if (log.isInfoEnabled()) {
log.info(String.format("Terminating all instances of cluster via cloud controller: [cluster] %s", clusterId));
log.info(String.format("Terminating all instances of cluster via cloud controller: [cluster] %s",
clusterId));
}
long startTime = System.currentTimeMillis();
stub.terminateInstances(clusterId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
package org.apache.stratos.common.client;

import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.stub.*;
Expand All @@ -34,13 +40,20 @@
import java.rmi.RemoteException;

public class AutoscalerServiceClient {

private AutoscalerServiceStub stub;

private static final Log log = LogFactory.getLog(AutoscalerServiceClient.class);
private static volatile AutoscalerServiceClient instance;
private AutoscalerServiceStub stub;

private AutoscalerServiceClient(String epr) throws AxisFault {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(StratosConstants.AUTOSCALER_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(StratosConstants.AUTOSCALER_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);

String autosclaerSocketTimeout = System.getProperty(StratosConstants.AUTOSCALER_CLIENT_SOCKET_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_SOCKET_TIMEOUT :
Expand All @@ -49,14 +62,15 @@ private AutoscalerServiceClient(String epr) throws AxisFault {
String autosclaerConnectionTimeout = System.getProperty(StratosConstants.AUTOSCALER_CLIENT_CONNECTION_TIMEOUT)
== null ? StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
System.getProperty(StratosConstants.AUTOSCALER_CLIENT_CONNECTION_TIMEOUT);

try {
stub = new AutoscalerServiceStub(epr);
stub = new AutoscalerServiceStub(ctx, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,
Integer.valueOf(autosclaerSocketTimeout));
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
Integer.valueOf(autosclaerConnectionTimeout));

stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (AxisFault axisFault) {
String msg = "Could not initialize autoscaler service client";
log.error(msg, axisFault);
Expand Down Expand Up @@ -176,7 +190,8 @@ public boolean updateAutoscalingPolicy(AutoscalePolicy autoScalePolicy) throws R
}

public boolean removeAutoscalingPolicy(String autoScalePolicyId) throws RemoteException,
AutoscalerServicePolicyDoesNotExistExceptionException, AutoscalerServiceUnremovablePolicyExceptionException {
AutoscalerServicePolicyDoesNotExistExceptionException,
AutoscalerServiceUnremovablePolicyExceptionException {
return stub.removeAutoScalingPolicy(autoScalePolicyId);
}

Expand All @@ -188,7 +203,8 @@ public ServiceGroup[] getServiceGroups() throws RemoteException, AutoscalerServi
return stub.getServiceGroups();
}

public void addServiceGroup(ServiceGroup serviceGroup) throws AutoscalerServiceInvalidServiceGroupExceptionException,
public void addServiceGroup(ServiceGroup serviceGroup) throws
AutoscalerServiceInvalidServiceGroupExceptionException,
RemoteException {
stub.addServiceGroup(serviceGroup);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
package org.apache.stratos.common.client;

import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -35,12 +41,20 @@

public class CloudControllerServiceClient {

private CloudControllerServiceStub stub;

private static final Log log = LogFactory.getLog(CloudControllerServiceClient.class);
private static volatile CloudControllerServiceClient instance;
private CloudControllerServiceStub stub;

private CloudControllerServiceClient(String epr) throws AxisFault {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(StratosConstants.CLOUD_CONTROLLER_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(StratosConstants.CLOUD_CONTROLLER_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);

String ccSocketTimeout = System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_SOCKET_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_SOCKET_TIMEOUT :
Expand All @@ -50,14 +64,15 @@ private CloudControllerServiceClient(String epr) throws AxisFault {
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT);

try {
stub = new CloudControllerServiceStub(epr);
stub = new CloudControllerServiceStub(ctx, epr);
stub._getServiceClient().getOptions()
.setProperty(HTTPConstants.SO_TIMEOUT, Integer.valueOf(ccSocketTimeout));
stub._getServiceClient().getOptions()
.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(ccConnectionTimeout));

stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (AxisFault axisFault) {
String msg = "Could not initialize cloud controller service client";
log.error(msg, axisFault);
Expand All @@ -84,15 +99,15 @@ public static CloudControllerServiceClient getInstance() throws AxisFault {

public void addCartridge(Cartridge cartridgeConfig)
throws RemoteException, CloudControllerServiceCartridgeAlreadyExistsExceptionException,
CloudControllerServiceInvalidCartridgeDefinitionExceptionException,
CloudControllerServiceInvalidIaasProviderExceptionException {
CloudControllerServiceInvalidCartridgeDefinitionExceptionException,
CloudControllerServiceInvalidIaasProviderExceptionException {
stub.addCartridge(cartridgeConfig);
}

public void updateCartridge(Cartridge cartridgeConfig)
throws RemoteException, CloudControllerServiceInvalidCartridgeDefinitionExceptionException,
CloudControllerServiceInvalidIaasProviderExceptionException,
CloudControllerServiceCartridgeDefinitionNotExistsExceptionException {
CloudControllerServiceInvalidIaasProviderExceptionException,
CloudControllerServiceCartridgeDefinitionNotExistsExceptionException {
stub.updateCartridge(cartridgeConfig);
}

Expand Down Expand Up @@ -142,20 +157,20 @@ public boolean updateKubernetesCluster(KubernetesCluster kubernetesCluster)

public boolean deployKubernetesCluster(KubernetesCluster kubernetesCluster)
throws RemoteException, CloudControllerServiceInvalidKubernetesClusterExceptionException,
CloudControllerServiceKubernetesClusterAlreadyExistsExceptionException {
CloudControllerServiceKubernetesClusterAlreadyExistsExceptionException {
return stub.addKubernetesCluster(kubernetesCluster);
}

public boolean addKubernetesHost(String kubernetesClusterId, KubernetesHost kubernetesHost)
throws RemoteException, CloudControllerServiceInvalidKubernetesHostExceptionException,
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
CloudControllerServiceNonExistingKubernetesClusterExceptionException {

return stub.addKubernetesHost(kubernetesClusterId, kubernetesHost);
}

public boolean updateKubernetesMaster(KubernetesMaster kubernetesMaster)
throws RemoteException, CloudControllerServiceInvalidKubernetesMasterExceptionException,
CloudControllerServiceNonExistingKubernetesMasterExceptionException {
CloudControllerServiceNonExistingKubernetesMasterExceptionException {
return stub.updateKubernetesMaster(kubernetesMaster);
}

Expand All @@ -170,7 +185,7 @@ public KubernetesCluster getKubernetesCluster(String kubernetesClusterId)

public void undeployKubernetesCluster(String kubernetesClusterId)
throws RemoteException, CloudControllerServiceNonExistingKubernetesClusterExceptionException,
CloudControllerServiceKubernetesClusterAlreadyUsedExceptionException {
CloudControllerServiceKubernetesClusterAlreadyUsedExceptionException {
stub.removeKubernetesCluster(kubernetesClusterId);
}

Expand All @@ -191,19 +206,19 @@ public KubernetesMaster getKubernetesMaster(String kubernetesClusterId)

public boolean updateKubernetesHost(KubernetesHost kubernetesHost)
throws RemoteException, CloudControllerServiceInvalidKubernetesHostExceptionException,
CloudControllerServiceNonExistingKubernetesHostExceptionException {
CloudControllerServiceNonExistingKubernetesHostExceptionException {
return stub.updateKubernetesHost(kubernetesHost);
}

public void validateNetworkPartitionOfDeploymentPolicy(String cartridgeType, String networkPartitionId)
throws RemoteException, CloudControllerServiceInvalidPartitionExceptionException,
CloudControllerServiceInvalidCartridgeTypeExceptionException {
CloudControllerServiceInvalidCartridgeTypeExceptionException {
stub.validateDeploymentPolicyNetworkPartition(cartridgeType, networkPartitionId);
}

public void addNetworkPartition(NetworkPartition networkPartition)
throws RemoteException, CloudControllerServiceNetworkPartitionAlreadyExistsExceptionException,
CloudControllerServiceInvalidNetworkPartitionExceptionException {
CloudControllerServiceInvalidNetworkPartitionExceptionException {
stub.addNetworkPartition(networkPartition);
}

Expand All @@ -226,7 +241,7 @@ public NetworkPartition getNetworkPartition(String networkPartitionId) throws Re
}

public void createClusterInstance(String serviceType, String clusterId, String alias, String instanceId,
String partitionId, String networkPartitionId) throws RemoteException {
String partitionId, String networkPartitionId) throws RemoteException {
try {
stub.createClusterInstance(serviceType, clusterId, alias, instanceId, partitionId, networkPartitionId);

Expand Down
Loading

0 comments on commit b063eb4

Please sign in to comment.