You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/03/21 12:21:11 UTC
[3/3] stratos git commit: Implementing stratos component startup
synchronizer
Implementing stratos component startup synchronizer
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c6e8359d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c6e8359d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c6e8359d
Branch: refs/heads/master
Commit: c6e8359d5dd561ac3c5b268d19e6aa8d725a9681
Parents: 42f4390
Author: Imesh Gunaratne <im...@apache.org>
Authored: Sat Mar 21 16:50:51 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Mar 21 16:50:51 2015 +0530
----------------------------------------------------------------------
.../org.apache.stratos.autoscaler/pom.xml | 1 +
.../autoscaler/context/AutoscalerContext.java | 15 +-
.../internal/AutoscalerServiceComponent.java | 121 ++--
.../autoscaler/pojo/policy/PolicyManager.java | 2 +-
.../autoscaler/registry/RegistryManager.java | 599 ++++++++++---------
.../autoscaler/util/ServiceReferenceHolder.java | 24 +-
.../context/CloudControllerContext.java | 2 +-
.../CloudControllerServiceComponent.java | 94 ++-
.../internal/ServiceReferenceHolder.java | 12 +-
.../axiom/CloudControllerContextTest.java | 2 +-
components/org.apache.stratos.common/pom.xml | 2 +-
.../org/apache/stratos/common/Component.java | 27 +
.../clustering/DistributedObjectProvider.java | 73 ---
.../HazelcastDistributedObjectProvider.java | 6 +-
.../common/internal/CommonServiceComponent.java | 179 ++++++
.../ComponentStartUpSynchronizerImpl.java | 124 ++++
.../common/internal/ServiceReferenceHolder.java | 11 +
.../internal/StratosCommonServiceComponent.java | 167 ------
.../services/ComponentStartUpSynchronizer.java | 37 ++
.../services/DistributedObjectProvider.java | 73 +++
.../common/services/PackageInfoService.java | 35 --
.../apache/stratos/common/util/CommonUtil.java | 1 -
.../load/balancer/context/AlgorithmContext.java | 2 +-
.../internal/LoadBalancerServiceComponent.java | 4 +-
.../internal/ServiceReferenceHolder.java | 2 +-
.../manager/context/StratosManagerContext.java | 4 +-
.../internal/ServiceReferenceHolder.java | 13 +-
.../StratosManagerServiceComponent.java | 116 ++--
.../handlers/ComponentSynchronizerHandler.java | 47 ++
.../webapp/api-test/WEB-INF/cxf-servlet.xml | 1 +
.../src/main/webapp/api/WEB-INF/cxf-servlet.xml | 4 +
.../src/main/resources/AutoscalerService.wsdl | 262 ++++----
.../main/resources/CloudControllerService.wsdl | 180 +++---
33 files changed, 1310 insertions(+), 932 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml
index 355aec6..3f0527c 100644
--- a/components/org.apache.stratos.autoscaler/pom.xml
+++ b/components/org.apache.stratos.autoscaler/pom.xml
@@ -224,6 +224,7 @@
</Export-Package>
<Import-Package>
org.osgi.framework.*;resolution:=optional,
+ org.apache.stratos.common.services.*; version="${project.version}",
*;resolution:=optional
</Import-Package>
<Bundle-Activator>org.apache.stratos.autoscaler.internal.ASBundleActivater</Bundle-Activator>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
index af75545..0760e5f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
@@ -27,13 +27,11 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
import org.apache.stratos.autoscaler.exception.AutoScalerException;
-import org.apache.stratos.autoscaler.exception.policy.InvalidPolicyException;
import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
-import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
import org.apache.stratos.autoscaler.registry.RegistryManager;
import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import java.util.Collection;
import java.util.List;
@@ -54,7 +52,7 @@ public class AutoscalerContext {
private boolean clustered;
private boolean coordinator;
- private static final AutoscalerContext INSTANCE = new AutoscalerContext();
+ private static volatile AutoscalerContext instance;
private final transient DistributedObjectProvider distributedObjectProvider;
// Map<ApplicationId, ApplicationContext>
@@ -103,7 +101,14 @@ public class AutoscalerContext {
}
public static AutoscalerContext getInstance() {
- return INSTANCE;
+ if(instance == null) {
+ synchronized (AutoscalerContext.class) {
+ if(instance == null) {
+ instance = new AutoscalerContext();
+ }
+ }
+ }
+ return instance;
}
public void addClusterMonitor(ClusterMonitor clusterMonitor) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
index 3929853..9fd9b68 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
@@ -18,6 +18,7 @@
*/
package org.apache.stratos.autoscaler.internal;
+import com.hazelcast.core.HazelcastInstance;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,7 +38,9 @@ import org.apache.stratos.autoscaler.status.processor.group.GroupStatusProcessor
import org.apache.stratos.autoscaler.util.AutoscalerConstants;
import org.apache.stratos.autoscaler.util.ConfUtil;
import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.ntask.core.service.TaskService;
@@ -45,8 +48,6 @@ import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.utils.ConfigurationContextService;
-import com.hazelcast.core.HazelcastInstance;
-
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
@@ -59,8 +60,10 @@ import java.util.concurrent.ExecutorService;
* cardinality="1..1" policy="dynamic" bind="setTaskService" unbind="unsetTaskService"
* @scr.reference name="hazelcast.instance.service" interface="com.hazelcast.core.HazelcastInstance"
* cardinality="0..1"policy="dynamic" bind="setHazelcastInstance" unbind="unsetHazelcastInstance"
- * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.clustering.DistributedObjectProvider"
+ * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
* cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
+ * @scr.reference name="componentStartUpSynchronizer" interface="org.apache.stratos.common.services.ComponentStartUpSynchronizer"
+ * cardinality="1..1" policy="dynamic" bind="setComponentStartUpSynchronizer" unbind="unsetComponentStartUpSynchronizer"
* @scr.reference name="config.context.service" interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
*/
@@ -77,45 +80,63 @@ public class AutoscalerServiceComponent {
protected void activate(ComponentContext componentContext) throws Exception {
try {
-
- XMLConfiguration conf = ConfUtil.getInstance(AutoscalerConstants.COMPONENTS_CONFIG).getConfiguration();
+ XMLConfiguration conf = ConfUtil.getInstance(AutoscalerConstants.COMPONENTS_CONFIG).getConfiguration();
int threadPoolSize = conf.getInt(AutoscalerConstants.THREAD_POOL_SIZE_KEY,
AutoscalerConstants.AUTOSCALER_THREAD_POOL_SIZE);
- executorService = StratosThreadPool.getExecutorService(AutoscalerConstants.AUTOSCALER_THREAD_POOL_ID,
+ executorService = StratosThreadPool.getExecutorService(AutoscalerConstants.AUTOSCALER_THREAD_POOL_ID,
threadPoolSize);
- ServiceReferenceHolder.getInstance().setExecutorService(executorService);
-
- if(AutoscalerContext.getInstance().isClustered()) {
- Thread coordinatorElectorThread = new Thread() {
- @Override
- public void run() {
- ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getLock(AUTOSCALER_COORDINATOR_LOCK).lock();
-
- log.info("Elected this member [" + ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getCluster().getLocalMember().getUuid() + "] " +
- "as the autoscaler coordinator for the cluster");
-
- AutoscalerContext.getInstance().setCoordinator(true);
- try {
- executeCoordinatorTasks();
- } catch (Exception e) {
- log.error("Error in activating the autoscaler component ", e);
+ Runnable autoscalerActivator = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ ServiceReferenceHolder.getInstance().getComponentStartUpSynchronizer();
+ // Wait for cloud controller component to start
+ componentStartUpSynchronizer.waitForComponentActivation(Component.Autoscaler,
+ Component.CloudController);
+
+ ServiceReferenceHolder.getInstance().setExecutorService(executorService);
+
+ if (AutoscalerContext.getInstance().isClustered()) {
+ Thread coordinatorElectorThread = new Thread() {
+ @Override
+ public void run() {
+ ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getLock(AUTOSCALER_COORDINATOR_LOCK).lock();
+
+ log.info("Elected this member [" + ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getCluster().getLocalMember().getUuid() + "] " +
+ "as the autoscaler coordinator for the cluster");
+
+ AutoscalerContext.getInstance().setCoordinator(true);
+ try {
+ executeCoordinatorTasks();
+ } catch (Exception e) {
+ log.error("Error in activating the autoscaler component ", e);
+ }
+ }
+ };
+ coordinatorElectorThread.setName("Autoscaler coordinator elector thread");
+ executorService.submit(coordinatorElectorThread);
+ } else {
+ executeCoordinatorTasks();
}
- }
- };
- coordinatorElectorThread.setName("Autoscaler coordinator elector thread");
- executorService.submit(coordinatorElectorThread);
- } else {
- executeCoordinatorTasks();
- }
- if (log.isInfoEnabled()) {
- log.info("Autoscaler service component activated");
- }
+ componentStartUpSynchronizer.waitForWebServiceActivation("AutoscalerService");
+ componentStartUpSynchronizer.setComponentStatus(Component.Autoscaler, true);
+ if (log.isInfoEnabled()) {
+ log.info("Autoscaler service component activated");
+ }
+ } catch (Exception e) {
+ log.error("Error in activating autoscaler service component ", e);
+ }
+ }
+ };
+ Thread autoscalerActivatorThread = new Thread(autoscalerActivator);
+ autoscalerActivatorThread.start();
} catch (Exception e) {
- log.error("Error in activating the autoscaler service component ", e);
+ log.error("Error in activating autoscaler service component ", e);
}
}
@@ -179,16 +200,20 @@ public class AutoscalerServiceComponent {
}
protected void deactivate(ComponentContext context) {
- try {
- asTopologyReceiver.terminate();
- } catch (Exception e) {
- log.warn("An error occurred while terminating autoscaler topology event receiver", e);
+ if(asTopologyReceiver != null) {
+ try {
+ asTopologyReceiver.terminate();
+ } catch (Exception e) {
+ log.warn("An error occurred while terminating autoscaler topology event receiver", e);
+ }
}
- try {
- autoscalerHealthStatEventReceiver.terminate();
- } catch (Exception e) {
- log.warn("An error occurred while terminating autoscaler health statistics event receiver", e);
+ if(autoscalerHealthStatEventReceiver != null) {
+ try {
+ autoscalerHealthStatEventReceiver.terminate();
+ } catch (Exception e) {
+ log.warn("An error occurred while terminating autoscaler health statistics event receiver", e);
+ }
}
// Shutdown executor service
@@ -289,5 +314,13 @@ public class AutoscalerServiceComponent {
protected void unsetDistributedObjectProvider(DistributedObjectProvider distributedObjectProvider) {
ServiceReferenceHolder.getInstance().setDistributedObjectProvider(null);
}
+
+ protected void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(componentStartUpSynchronizer);
+ }
+
+ protected void unsetComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(null);
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
index a5ca3b4..8406549 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
@@ -28,7 +28,7 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
import org.apache.stratos.autoscaler.registry.RegistryManager;
import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index b60fe2c..b1ae493 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -1,6 +1,4 @@
-package org.apache.stratos.autoscaler.registry;
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -17,9 +15,9 @@ package org.apache.stratos.autoscaler.registry;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
-*/
+ */
+package org.apache.stratos.autoscaler.registry;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -46,43 +44,92 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Autoscaler registry manager.
+ */
public class RegistryManager {
private final static Log log = LogFactory.getLog(RegistryManager.class);
+
private static Registry registryService;
- private static RegistryManager registryManager;
+ private static volatile RegistryManager instance;
private RegistryManager() {
try {
- if (!registryService.resourceExists(AutoscalerConstants.AUTOSCALER_RESOURCE)) {
- registryService.put(AutoscalerConstants.AUTOSCALER_RESOURCE,
- registryService.newCollection());
+ registryService = ServiceReferenceHolder.getInstance().getRegistry();
+ try {
+ startTenantFlow();
+ if (!registryService.resourceExists(AutoscalerConstants.AUTOSCALER_RESOURCE)) {
+ registryService.put(AutoscalerConstants.AUTOSCALER_RESOURCE, registryService.newCollection());
+ }
+ } finally {
+ endTenantFlow();
}
} catch (RegistryException e) {
- String msg =
- "Failed to create the registry resource " +
- AutoscalerConstants.AUTOSCALER_RESOURCE;
+ String msg = "Failed to create the registry resource " + AutoscalerConstants.AUTOSCALER_RESOURCE;
log.error(msg, e);
throw new AutoScalerException(msg, e);
}
}
public static RegistryManager getInstance() {
+ if (instance == null) {
+ synchronized (RegistryManager.class) {
+ if (instance == null) {
+ instance = new RegistryManager();
+ }
+ }
+ }
+ return instance;
+ }
- registryService = ServiceReferenceHolder.getInstance().getRegistry();
+ private Object retrieve(String resourcePath) {
+ try {
+ Resource resource = registryService.get(resourcePath);
+ return resource.getContent();
+ } catch (ResourceNotFoundException ignore) {
+ // this means, we've never persisted info in registry
+ return null;
+ } catch (RegistryException e) {
+ String msg = "Failed to retrieve data from registry.";
+ log.error(msg, e);
+ throw new AutoScalerException(msg, e);
+ }
+ }
- synchronized (RegistryManager.class) {
- if (registryManager == null) {
- if (registryService == null) {
- // log.warn("Registry Service is null. Hence unable to fetch data from registry.");
- return registryManager;
+ private void delete(String resourcePath) {
+ try {
+ registryService.beginTransaction();
+ registryService.delete(resourcePath);
+ registryService.commitTransaction();
+ } catch (RegistryException e) {
+ try {
+ registryService.rollbackTransaction();
+ } catch (RegistryException e1) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not rollback transaction", e);
}
- registryManager = new RegistryManager();
}
+ String message = "Could not delete resource at " + resourcePath;
+ log.error(message);
+ throw new AutoScalerException(message, e);
}
- return registryManager;
}
+ private void startTenantFlow() {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+ carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+ }
+
+ private void endTenantFlow() {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+
+ private boolean resourceExist(String resourcePath) {
+ return retrieve(resourcePath) != null;
+ }
/**
* Persist an object in the local registry.
@@ -91,10 +138,6 @@ public class RegistryManager {
* @param resourcePath resource path to be persisted.
*/
private void persist(Object dataObj, String resourcePath) throws AutoScalerException {
- PrivilegedCarbonContext ctx = PrivilegedCarbonContext
- .getThreadLocalCarbonContext();
- ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
- ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
try {
registryService.beginTransaction();
@@ -118,6 +161,7 @@ public class RegistryManager {
public void persistAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
try {
+ startTenantFlow();
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
persist(autoscalePolicy, resourcePath);
@@ -128,17 +172,14 @@ public class RegistryManager {
} catch (Exception e) {
throw new AutoScalerException((String.format("Unable to persist autoscaler policy [autoscaler-policy-id] %s"
, autoscalePolicy.getId())), e);
+ } finally {
+ endTenantFlow();
}
}
public void persistApplication(Application application) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATIONS_RESOURCE +
"/" + application.getUniqueIdentifier();
persist(application, resourcePath);
@@ -147,17 +188,13 @@ public class RegistryManager {
" ] persisted successfully in the Autoscaler Registry");
}
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public String[] getApplicationResourcePaths() {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATIONS_RESOURCE);
@@ -165,14 +202,13 @@ public class RegistryManager {
if (obj instanceof String[]) {
return (String[]) obj;
} else {
- log.warn("Expected object type not found for Applications in Registry");
- return null;
+ log.warn("Expected object type not found for applications in registry");
}
}
+ return null;
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
- return null;
}
public Application getApplication(String applicationId) {
@@ -182,75 +218,55 @@ public class RegistryManager {
}
public Application getApplicationByResourcePath(String applicationResourcePath) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(applicationResourcePath);
if (obj != null) {
try {
Object dataObj = Deserializer.deserializeFromByteArray((byte[]) obj);
if (dataObj instanceof Application) {
return (Application) dataObj;
- } else {
- return null;
}
} catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical data will not get reflected.";
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + applicationResourcePath;
log.warn(msg, e);
}
}
+ return null;
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
- return null;
}
public void removeApplication(String applicationId) {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
delete(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATIONS_RESOURCE +
"/" + applicationId);
-
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public void persistApplicationContext(ApplicationContext applicationContext) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE + "/" + applicationContext.getApplicationId();
persist(applicationContext, resourcePath);
if (log.isDebugEnabled()) {
log.debug("Application context [" + applicationContext.getApplicationId() + "] " +
- "persisted successfully in the Autoscaler Registry");
+ "persisted successfully in the autoscaler registry");
}
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public String[] getApplicationContextResourcePaths() {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE);
@@ -258,40 +274,30 @@ public class RegistryManager {
if (obj instanceof String[]) {
return (String[]) obj;
} else {
- log.warn("Expected object type not found for Applications in Registry");
+ log.warn("Expected object type not found for applications in registry");
return null;
}
}
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
return null;
}
public ApplicationContext getApplicationContext(String applicationId) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
String applicationResourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE + "/" + applicationId;
return getApplicationContextByResourcePath(applicationResourcePath);
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public ApplicationContext getApplicationContextByResourcePath(String resourcePath) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(resourcePath);
if (obj != null) {
try {
@@ -302,297 +308,310 @@ public class RegistryManager {
}
return null;
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public void removeApplicationContext(String applicationId) {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
delete(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE +
"/" + applicationId);
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public void persistServiceGroup(ServiceGroup servicegroup) {
- if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) {
- throw new IllegalArgumentException("Cartridge group or group name can not be null");
- }
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
- persist(servicegroup, resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Persisted cartridge group %s at path %s", servicegroup.getName(), resourcePath));
+ try {
+ startTenantFlow();
+ if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) {
+ throw new IllegalArgumentException("Cartridge group or group name can not be null");
+ }
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
+ persist(servicegroup, resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Persisted cartridge group %s at path %s", servicegroup.getName(), resourcePath));
+ }
+ } finally {
+ endTenantFlow();
}
}
public boolean serviceGroupExist(String serviceGroupName) {
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + serviceGroupName;
- return this.resourceExist(resourcePath);
- }
-
- private Object retrieve(String resourcePath) {
- try {
- Resource resource = registryService.get(resourcePath);
- return resource.getContent();
- } catch (ResourceNotFoundException ignore) {
- // this means, we've never persisted info in registry
- return null;
- } catch (RegistryException e) {
- String msg = "Failed to retrieve data from registry.";
- log.error(msg, e);
- throw new AutoScalerException(msg, e);
- }
- }
-
- private boolean resourceExist(String resourcePath) {
- return this.retrieve(resourcePath) != null;
+ return resourceExist(resourcePath);
}
public List<AutoscalePolicy> retrieveASPolicies() {
- List<AutoscalePolicy> asPolicyList = new ArrayList<AutoscalePolicy>();
- RegistryManager registryManager = RegistryManager.getInstance();
- String[] partitionsResourceList = (String[]) registryManager.retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE);
-
- if (partitionsResourceList != null) {
- AutoscalePolicy asPolicy;
- for (String resourcePath : partitionsResourceList) {
- Object serializedObj = registryManager.retrieve(resourcePath);
- if (serializedObj != null) {
- try {
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof AutoscalePolicy) {
- asPolicy = (AutoscalePolicy) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Autoscaler policy read from registry: [id] %s [name] %s [description] %s",
- asPolicy.getId(), asPolicy.getDisplayName(), asPolicy.getDescription()));
+ try {
+ startTenantFlow();
+ List<AutoscalePolicy> asPolicyList = new ArrayList<AutoscalePolicy>();
+ String[] partitionsResourceList = (String[]) retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE);
+
+ if (partitionsResourceList != null) {
+ AutoscalePolicy asPolicy;
+ for (String resourcePath : partitionsResourceList) {
+ Object serializedObj = retrieve(resourcePath);
+ if (serializedObj != null) {
+ try {
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof AutoscalePolicy) {
+ asPolicy = (AutoscalePolicy) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Autoscaler policy read from registry: [id] %s [name] %s [description] %s",
+ asPolicy.getId(), asPolicy.getDisplayName(), asPolicy.getDescription()));
+ }
+ asPolicyList.add(asPolicy);
+ } else {
+ return null;
}
- asPolicyList.add(asPolicy);
- } else {
- return null;
+ } catch (Exception e) {
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + resourcePath;
+ log.warn(msg, e);
}
- } catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical autoscaler policies will not get reflected.";
- log.warn(msg, e);
}
}
}
+ return asPolicyList;
+ } finally {
+ endTenantFlow();
}
- return asPolicyList;
}
public List<ApplicationPolicy> retrieveApplicationPolicies() {
- List<ApplicationPolicy> applicationPolicyList = new ArrayList<ApplicationPolicy>();
- RegistryManager registryManager = RegistryManager.getInstance();
- String[] applicationPoliciesResourceList = (String[]) registryManager.retrieve(
- AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE);
-
- if (applicationPoliciesResourceList != null) {
- ApplicationPolicy applicationPolicy;
- for (String resourcePath : applicationPoliciesResourceList) {
- Object serializedObj = registryManager.retrieve(resourcePath);
- if (serializedObj != null) {
- try {
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof ApplicationPolicy) {
- applicationPolicy = (ApplicationPolicy) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Application policy read from registry %s", applicationPolicy.toString()));
+ try {
+ startTenantFlow();
+ List<ApplicationPolicy> applicationPolicyList = new ArrayList<ApplicationPolicy>();
+ String[] applicationPoliciesResourceList = (String[]) retrieve(
+ AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE);
+
+ if (applicationPoliciesResourceList != null) {
+ ApplicationPolicy applicationPolicy;
+ for (String resourcePath : applicationPoliciesResourceList) {
+ Object serializedObj = instance.retrieve(resourcePath);
+ if (serializedObj != null) {
+ try {
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof ApplicationPolicy) {
+ applicationPolicy = (ApplicationPolicy) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Application policy read from registry %s",
+ applicationPolicy.toString()));
+ }
+ applicationPolicyList.add(applicationPolicy);
+ } else {
+ return null;
}
- applicationPolicyList.add(applicationPolicy);
- } else {
- return null;
+ } catch (Exception e) {
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + resourcePath;
+ log.warn(msg, e);
}
- } catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical application policies will not get reflected.";
- log.warn(msg, e);
}
}
}
+ return applicationPolicyList;
+ } finally {
+ endTenantFlow();
}
- return applicationPolicyList;
}
public List<NetworkPartitionAlgorithmContext> retrieveNetworkPartitionAlgorithmContexts() {
- List<NetworkPartitionAlgorithmContext> algorithmContexts = new ArrayList<NetworkPartitionAlgorithmContext>();
- RegistryManager registryManager = RegistryManager.getInstance();
- String[] networkPartitionAlgoCtxtResourceList = (String[]) registryManager.retrieve(
- AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE);
-
- if (networkPartitionAlgoCtxtResourceList != null) {
- NetworkPartitionAlgorithmContext algorithmContext;
- for (String resourcePath : networkPartitionAlgoCtxtResourceList) {
- Object serializedObj = registryManager.retrieve(resourcePath);
- if (serializedObj != null) {
- try {
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof NetworkPartitionAlgorithmContext) {
- algorithmContext = (NetworkPartitionAlgorithmContext) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Network partition algorithm context read from registry %s", algorithmContext.toString()));
+ try {
+ startTenantFlow();
+ List<NetworkPartitionAlgorithmContext> algorithmContexts = new ArrayList<NetworkPartitionAlgorithmContext>();
+ String[] networkPartitionAlgoCtxtResourceList = (String[]) retrieve(
+ AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE);
+
+ if (networkPartitionAlgoCtxtResourceList != null) {
+ NetworkPartitionAlgorithmContext algorithmContext;
+ for (String resourcePath : networkPartitionAlgoCtxtResourceList) {
+ Object serializedObj = retrieve(resourcePath);
+ if (serializedObj != null) {
+ try {
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof NetworkPartitionAlgorithmContext) {
+ algorithmContext = (NetworkPartitionAlgorithmContext) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Network partition algorithm context read from registry %s", algorithmContext.toString()));
+ }
+ algorithmContexts.add(algorithmContext);
+ } else {
+ return null;
}
- algorithmContexts.add(algorithmContext);
- } else {
- return null;
+ } catch (Exception e) {
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + resourcePath;
+ log.warn(msg, e);
}
- } catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical application policies will not get reflected.";
- log.warn(msg, e);
}
}
}
+ return algorithmContexts;
+ } finally {
+ endTenantFlow();
}
- return algorithmContexts;
}
public ServiceGroup getServiceGroup(String name) throws Exception {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + name;
- Object serializedObj = registryManager.retrieve(resourcePath);
- ServiceGroup group = null;
- if (serializedObj != null) {
-
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof ServiceGroup) {
- group = (ServiceGroup) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(group.toString());
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + name;
+ Object serializedObj = instance.retrieve(resourcePath);
+ ServiceGroup group = null;
+ if (serializedObj != null) {
+
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof ServiceGroup) {
+ group = (ServiceGroup) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(group.toString());
+ }
+ } else {
+ return null;
}
- } else {
- return null;
}
+ return group;
+ } finally {
+ endTenantFlow();
}
-
- return group;
}
public ServiceGroup[] getServiceGroups() {
- Object serializedObj;
- List<ServiceGroup> serviceGroupList = new ArrayList<ServiceGroup>();
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP;
- if (registryManager.resourceExist(resourcePath)) {
- serializedObj = registryManager.retrieve(resourcePath);
- } else {
- return null;
- }
+ try {
+ startTenantFlow();
+ Object serializedObj;
+ List<ServiceGroup> serviceGroupList = new ArrayList<ServiceGroup>();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP;
+ if (instance.resourceExist(resourcePath)) {
+ serializedObj = instance.retrieve(resourcePath);
+ } else {
+ return null;
+ }
- String[] groupPathList = (String[]) serializedObj;
-
- if (groupPathList != null) {
- ServiceGroup serviceGroup;
- for (String groupPath : groupPathList) {
- serializedObj = registryManager.retrieve(groupPath);
- if (serializedObj != null) {
- Object dataObj = null;
- try {
- dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof ServiceGroup) {
- serviceGroup = (ServiceGroup) dataObj;
- serviceGroupList.add(serviceGroup);
+ String[] groupPathList = (String[]) serializedObj;
+
+ if (groupPathList != null) {
+ ServiceGroup serviceGroup;
+ for (String groupPath : groupPathList) {
+ serializedObj = instance.retrieve(groupPath);
+ if (serializedObj != null) {
+ Object dataObj = null;
+ try {
+ dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof ServiceGroup) {
+ serviceGroup = (ServiceGroup) dataObj;
+ serviceGroupList.add(serviceGroup);
+ }
+ } catch (IOException e) {
+ throw new AutoScalerException("Error occurred while retrieving cartridge group from registry");
+ } catch (ClassNotFoundException e) {
+ throw new AutoScalerException("Error occurred while retrieving cartridge group from registry");
}
- } catch (IOException e) {
- throw new AutoScalerException("Error occurred while retrieving cartridge group from Registry");
- } catch (ClassNotFoundException e) {
- throw new AutoScalerException("Error occurred while retrieving cartridge group from Registry");
}
-
}
}
- }
- ServiceGroup[] groupArr = new ServiceGroup[serviceGroupList.size()];
- groupArr = serviceGroupList.toArray(groupArr);
- return groupArr;
+ ServiceGroup[] serviceGroups = new ServiceGroup[serviceGroupList.size()];
+ serviceGroups = serviceGroupList.toArray(serviceGroups);
+ return serviceGroups;
+ } finally {
+ endTenantFlow();
+ }
}
public void removeServiceGroup(String name) throws RegistryException {
- if (StringUtils.isEmpty(name)) {
- throw new IllegalArgumentException("Name of the cartridge group can not be empty");
- }
+ try {
+ startTenantFlow();
+ if (StringUtils.isEmpty(name)) {
+ throw new IllegalArgumentException("Name of the cartridge group can not be empty");
+ }
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
- AutoscalerConstants.SERVICE_GROUP + "/" + name;
- if (registryService.resourceExists(resourcePath)) {
- registryService.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Cartridge group %s is removed from registry", name));
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
+ AutoscalerConstants.SERVICE_GROUP + "/" + name;
+ if (registryService.resourceExists(resourcePath)) {
+ registryService.delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Cartridge group %s is removed from registry", name));
+ }
+ } else {
+ throw new AutoScalerException("No cartridge group is found with name" + name);
}
- } else {
- throw new AutoScalerException("No cartridge group is found with name" + name);
+ } finally {
+ endTenantFlow();
}
}
public void removeAutoscalerPolicy(String policyID) {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE + "/" +
- policyID;
- this.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Autoscaler policy deleted from registry: [id]",policyID));
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE + "/" +
+ policyID;
+ delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Autoscaler policy deleted from registry: [id]", policyID));
+ }
+ } finally {
+ endTenantFlow();
}
-
}
public void removeApplicationPolicy(String applicationPolicyId) {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" +
- applicationPolicyId;
- this.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Application policy deleted from registry [application-policy-id] %s", applicationPolicyId));
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" +
+ applicationPolicyId;
+ delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Application policy deleted from registry [application-policy-id] %s", applicationPolicyId));
+ }
+ } finally {
+ endTenantFlow();
}
-
}
public void removeNetworkPartitionAlgorithmContext(String applicationPolicyId) {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" +
- applicationPolicyId;
- this.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Network partition algorithm context deleted from registry [application-policy-id] %s", applicationPolicyId));
- }
-
- }
-
- private void delete(String resourcePath) {
try {
- registryService.beginTransaction();
- registryService.delete(resourcePath);
- registryService.commitTransaction();
- } catch (RegistryException e) {
- try {
- registryService.rollbackTransaction();
- } catch (RegistryException e1) {
- if (log.isErrorEnabled()) {
- log.error("Could not rollback transaction", e);
- }
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" +
+ applicationPolicyId;
+ delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Network partition algorithm context deleted from registry [application-policy-id] %s", applicationPolicyId));
}
- log.error("Could not delete resource at " + resourcePath);
- throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e);
+ } finally {
+ endTenantFlow();
}
-
}
public void persistApplicationPolicy(ApplicationPolicy applicationPolicy) {
-
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
- AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" + applicationPolicy.getId();
- persist(applicationPolicy, resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Application policy written to registry : %s", applicationPolicy.getId()));
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
+ AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" + applicationPolicy.getId();
+ persist(applicationPolicy, resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Application policy written to registry : %s", applicationPolicy.getId()));
+ }
+ } finally {
+ endTenantFlow();
}
-
}
public void persistNetworkPartitionAlgorithmContext(NetworkPartitionAlgorithmContext algorithmContext) {
- String applicationId = algorithmContext.getApplicationId();
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
- AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" + applicationId;
- persist(algorithmContext, resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Network partition algorithm context written to registry : %s", applicationId));
+ try {
+ startTenantFlow();
+ String applicationId = algorithmContext.getApplicationId();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
+ AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" + applicationId;
+ persist(algorithmContext, resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Network partition algorithm context written to registry : %s", applicationId));
+ }
+ } finally {
+ endTenantFlow();
}
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
index 9d1fa9c..d351fef 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
@@ -24,7 +24,8 @@ package org.apache.stratos.autoscaler.util;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.stratos.autoscaler.status.processor.cluster.ClusterStatusProcessorChain;
import org.apache.stratos.autoscaler.status.processor.group.GroupStatusProcessorChain;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.session.UserRegistry;
@@ -44,15 +45,20 @@ public class ServiceReferenceHolder {
private DistributedObjectProvider distributedObjectProvider;
private HazelcastInstance hazelcastInstance;
private ExecutorService executorService;
+ private ComponentStartUpSynchronizer componentStartUpSynchronizer;
private ServiceReferenceHolder() {
}
public static ServiceReferenceHolder getInstance() {
- if (instance == null) {
- instance = new ServiceReferenceHolder();
- }
- return instance;
+ if(instance == null) {
+ synchronized (ServiceReferenceHolder.class) {
+ if (instance == null) {
+ instance = new ServiceReferenceHolder();
+ }
+ }
+ }
+ return instance;
}
public void setAxisConfiguration(AxisConfiguration axisConfiguration) {
@@ -118,4 +124,12 @@ public class ServiceReferenceHolder {
public ExecutorService getExecutorService() {
return executorService;
}
+
+ public void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ this.componentStartUpSynchronizer = componentStartUpSynchronizer;
+ }
+
+ public ComponentStartUpSynchronizer getComponentStartUpSynchronizer() {
+ return componentStartUpSynchronizer;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
index 8543810..c503c02 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
@@ -37,7 +37,7 @@ import org.apache.stratos.cloud.controller.exception.NonExistingKubernetesHostEx
import org.apache.stratos.cloud.controller.internal.ServiceReferenceHolder;
import org.apache.stratos.cloud.controller.registry.RegistryManager;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java
index 75a88ff..87928cd 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java
@@ -1,4 +1,3 @@
-package org.apache.stratos.cloud.controller.internal;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,6 +19,8 @@ package org.apache.stratos.cloud.controller.internal;
*
*/
+package org.apache.stratos.cloud.controller.internal;
+
import com.hazelcast.core.HazelcastInstance;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -32,7 +33,9 @@ import org.apache.stratos.cloud.controller.messaging.receiver.cluster.status.Clu
import org.apache.stratos.cloud.controller.messaging.receiver.instance.status.InstanceStatusTopicReceiver;
import org.apache.stratos.cloud.controller.services.CloudControllerService;
import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceImpl;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.util.MessagingUtil;
@@ -52,8 +55,10 @@ import java.util.concurrent.ExecutorService;
* @scr.component name="org.apache.stratos.cloud.controller" immediate="true"
* @scr.reference name="hazelcast.instance.service" interface="com.hazelcast.core.HazelcastInstance"
* cardinality="0..1"policy="dynamic" bind="setHazelcastInstance" unbind="unsetHazelcastInstance"
- * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.clustering.DistributedObjectProvider"
+ * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
* cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
+ * @scr.reference name="componentStartUpSynchronizer" interface="org.apache.stratos.common.services.ComponentStartUpSynchronizer"
+ * cardinality="1..1" policy="dynamic" bind="setComponentStartUpSynchronizer" unbind="unsetComponentStartUpSynchronizer"
* @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService"
* cardinality="1..1" policy="dynamic" bind="setTaskService" unbind="unsetTaskService"
* @scr.reference name="registry.service" interface="org.wso2.carbon.registry.core.service.RegistryService"
@@ -74,38 +79,53 @@ public class CloudControllerServiceComponent {
private static final int THREAD_POOL_SIZE = 10;
private static final String CLOUD_CONTROLLER_COORDINATOR_LOCK = "CLOUD_CONTROLLER_COORDINATOR_LOCK";
- protected void activate(ComponentContext context) {
+ protected void activate(final ComponentContext context) {
try {
- executorService = StratosThreadPool.getExecutorService(DEFAULT_IDENTIFIER, THREAD_POOL_SIZE);
-
- // Register cloud controller service
- BundleContext bundleContext = context.getBundleContext();
- bundleContext.registerService(CloudControllerService.class.getName(),
- new CloudControllerServiceImpl(), null);
-
- if(CloudControllerContext.getInstance().isClustered()) {
- Thread coordinatorElectorThread = new Thread() {
- @Override
- public void run() {
- ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getLock(CLOUD_CONTROLLER_COORDINATOR_LOCK).lock();
-
- String localMemberId = ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getCluster().getLocalMember().getUuid();
- log.info("Elected this member [" + localMemberId + "] " +
- "as the cloud controller coordinator for the cluster");
-
- CloudControllerContext.getInstance().setCoordinator(true);
- executeCoordinatorTasks();
+ executorService = StratosThreadPool.getExecutorService(DEFAULT_IDENTIFIER, THREAD_POOL_SIZE);
+ Runnable cloudControllerActivator = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ ServiceReferenceHolder.getInstance().getComponentStartUpSynchronizer();
+
+ // Register cloud controller service
+ BundleContext bundleContext = context.getBundleContext();
+ bundleContext.registerService(CloudControllerService.class.getName(),
+ new CloudControllerServiceImpl(), null);
+
+ if(CloudControllerContext.getInstance().isClustered()) {
+ Thread coordinatorElectorThread = new Thread() {
+ @Override
+ public void run() {
+ ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getLock(CLOUD_CONTROLLER_COORDINATOR_LOCK).lock();
+
+ String localMemberId = ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getCluster().getLocalMember().getUuid();
+ log.info("Elected member [" + localMemberId + "] " +
+ "as the cloud controller coordinator of the cluster");
+
+ CloudControllerContext.getInstance().setCoordinator(true);
+ executeCoordinatorTasks();
+ }
+ };
+ coordinatorElectorThread.setName("Cloud controller coordinator elector thread");
+ executorService.submit(coordinatorElectorThread);
+ } else {
+ executeCoordinatorTasks();
+ }
+
+ componentStartUpSynchronizer.waitForWebServiceActivation("CloudControllerService");
+ componentStartUpSynchronizer.setComponentStatus(Component.CloudController, true);
+ log.info("Cloud controller service component activated");
+ } catch (Exception e) {
+ log.error("Could not activate cloud controller service component", e);
}
- };
- coordinatorElectorThread.setName("Cloud controller coordinator elector thread");
- executorService.submit(coordinatorElectorThread);
- } else {
- executeCoordinatorTasks();
- }
-
- log.info("Cloud controller service component activated");
+ }
+ };
+ Thread cloudControllerActivatorThread = new Thread(cloudControllerActivator);
+ cloudControllerActivatorThread.start();
} catch (Exception e) {
log.error("Could not activate cloud controller service component", e);
}
@@ -206,6 +226,14 @@ public class CloudControllerServiceComponent {
ServiceReferenceHolder.getInstance().setDistributedObjectProvider(null);
}
+ protected void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(componentStartUpSynchronizer);
+ }
+
+ protected void unsetComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(null);
+ }
+
protected void deactivate(ComponentContext ctx) {
// Close event publisher connections to message broker
try {
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
index ef4015a..f26bd79 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
@@ -20,7 +20,8 @@ package org.apache.stratos.cloud.controller.internal;
import com.hazelcast.core.HazelcastInstance;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.session.UserRegistry;
@@ -37,6 +38,7 @@ public class ServiceReferenceHolder {
private AxisConfiguration axisConfiguration;
private DistributedObjectProvider distributedObjectProvider;
private HazelcastInstance hazelcastInstance;
+ private ComponentStartUpSynchronizer componentStartUpSynchronizer;
private ServiceReferenceHolder() {
}
@@ -91,4 +93,12 @@ public class ServiceReferenceHolder {
public HazelcastInstance getHazelcastInstance() {
return hazelcastInstance;
}
+
+ public void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ this.componentStartUpSynchronizer = componentStartUpSynchronizer;
+ }
+
+ public ComponentStartUpSynchronizer getComponentStartUpSynchronizer() {
+ return componentStartUpSynchronizer;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
index b48055f..91be61b 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
@@ -18,10 +18,10 @@
*/
package org.apache.cartridge.autoscaler.service.axiom;
+import junit.framework.TestCase;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.stratos.cloud.controller.context.CloudControllerContext;
import org.apache.stratos.cloud.controller.domain.MemberContext;
-import junit.framework.TestCase;
import org.apache.stratos.cloud.controller.internal.ServiceReferenceHolder;
import org.apache.stratos.common.clustering.impl.HazelcastDistributedObjectProvider;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/pom.xml b/components/org.apache.stratos.common/pom.xml
index 5a01de6..74fc755 100644
--- a/components/org.apache.stratos.common/pom.xml
+++ b/components/org.apache.stratos.common/pom.xml
@@ -47,7 +47,7 @@
<Export-Package>
org.apache.stratos.common.*,
org.apache.stratos.common.client.*,
- org.apache.stratos.common.clustering.*,
+ org.apache.stratos.common.services.*,
org.apache.stratos.common.statistics.publisher.*,
org.apache.stratos.common.concurrent.locks.*,
</Export-Package>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java
new file mode 100644
index 0000000..28f5341
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.common;
+
+/**
+ * Stratos components enumeration.
+ */
+public enum Component {
+ MessageBroker, StratosManager, CloudController, Autoscaler, ComplexEventProcessor
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java
deleted file mode 100644
index 6caa3a1..0000000
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.common.clustering;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-
-/**
- * Distributed object provider service interface.
- * Caution! When using distributed maps and lists, please note that changes done to an item in a map/list
- * after adding them to the map/list will not be replicated in the cluster. If a modification of an item
- * needs to be replicated, that item needs to be put() to the map or set() back in the list.
- */
-public interface DistributedObjectProvider extends Serializable {
- /**
- * Returns a distributed map if clustering is enabled, else returns a local hash map.
- * @param name
- * @return
- */
- Map getMap(String name);
-
- /**
- * Removes a map from the object provider.
- * @param name
- */
- void removeMap(String name);
-
- /**
- * Returns a distributed list if clustering is enabled, else returns a local array list.
- * @param name
- * @return
- */
- List getList(String name);
-
- /**
- * Remove a list from the object provider.
- * @param name
- */
- void removeList(String name);
-
- /**
- * Acquires a distributed lock if clustering is enabled, else acquires a local reentrant lock and
- * returns the lock object.
- * @param object
- * @return
- */
- Lock acquireLock(Object object);
-
- /**
- * Releases a given distributed/local lock.
- * @param lock
- */
- void releaseLock(Lock lock);
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
index f7ff50e..14c1d08 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
@@ -26,7 +26,7 @@ import com.hazelcast.core.IMap;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.internal.ServiceReferenceHolder;
import org.wso2.carbon.caching.impl.MapEntryListener;
import org.wso2.carbon.core.clustering.hazelcast.HazelcastDistributedMapProvider;
@@ -39,9 +39,11 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
- * Provides objects to be managed in distributed and non-distributed environments.
+ * Implements DistributedObjectProvider osgi service interface for providing objects to be managed
+ * in distributed and non-distributed environments.
*/
public class HazelcastDistributedObjectProvider implements DistributedObjectProvider {
+
private static final Log log = LogFactory.getLog(HazelcastDistributedObjectProvider.class);
private HazelcastDistributedMapProvider mapProvider;