Repository: stratos Updated Branches: refs/heads/master 0a969200d -> 7bc7b4dd4
changing one thread pool size and fixing restart issue with the group scaling Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/1a7ea1a9 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/1a7ea1a9 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/1a7ea1a9 Branch: refs/heads/master Commit: 1a7ea1a9bc0c29640dde664ee6853bb9efe10eb9 Parents: 0a96920 Author: reka <[email protected]> Authored: Tue Jun 23 18:57:14 2015 +0530 Committer: reka <[email protected]> Committed: Tue Jun 23 18:57:14 2015 +0530 ---------------------------------------------------------------------- .../internal/AutoscalerServiceComponent.java | 8 +----- .../autoscaler/monitor/MonitorFactory.java | 26 ++++++++++++++++---- .../monitor/cluster/ClusterMonitor.java | 4 +-- .../monitor/component/ApplicationMonitor.java | 25 +++++++++++++++++-- .../monitor/component/GroupMonitor.java | 4 +-- .../autoscaler/util/AutoscalerConstants.java | 10 +++----- 6 files changed, 52 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/1a7ea1a9/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 7d1afb9..b5fd144 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 @@ -265,16 +265,10 @@ public class AutoscalerServiceComponent { shutdownScheduledExecutorService(AutoscalerConstants.AUTOSCALER_SCHEDULER_ID); // Shutdown application monitor executor service - shutdownExecutorService(AutoscalerConstants.APPLICATION_MONITOR_THREAD_POOL_ID); - - // Shutdown group monitor executor service - shutdownExecutorService(AutoscalerConstants.GROUP_MONITOR_THREAD_POOL_ID); + shutdownExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID); // Shutdown cluster monitor scheduler executor service shutdownScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID); - - // Shutdown cluster monitor executor service - shutdownExecutorService(AutoscalerConstants.CLUSTER_MONITOR_THREAD_POOL_ID); } private void shutdownExecutorService(String executorServiceId) { http://git-wip-us.apache.org/repos/asf/stratos/blob/1a7ea1a9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java index 0589546..0ceac21 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java @@ -42,15 +42,15 @@ import org.apache.stratos.common.partition.PartitionRef; import org.apache.stratos.messaging.domain.application.Application; import org.apache.stratos.messaging.domain.application.Group; import org.apache.stratos.messaging.domain.application.ScalingDependentList; +import org.apache.stratos.messaging.domain.instance.ClusterInstance; +import org.apache.stratos.messaging.domain.instance.GroupInstance; +import org.apache.stratos.messaging.domain.instance.Instance; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Properties; +import java.util.*; /** * Factory class to get the Monitors. @@ -147,6 +147,15 @@ public class MonitorFactory { Group group = application.getGroupRecursively(context.getId()); + //Find whether any other instances exists in group + // which has not been added to in-memory model in the restart + Collection<Instance> instances = parentMonitor.getInstances(); + for(Instance instance : instances) { + if(!instanceIds.contains(instance.getInstanceId())) { + instanceIds.add(instance.getInstanceId()); + } + } + // Starting the minimum dependencies groupMonitor.createInstanceAndStartDependencyAtStartup(group, instanceIds); @@ -226,7 +235,14 @@ public class MonitorFactory { serviceName, clusterId); throw new RuntimeException(msg); } - + //Find whether any other instances exists in group + // which has not been added to in-memory model in the restart + Collection<Instance> instances = parentMonitor.getInstances(); + for(Instance instance : instances) { + if(!parentInstanceIds.contains(instance.getInstanceId())) { + parentInstanceIds.add(instance.getInstanceId()); + } + } // deployment policy validation String deploymentPolicyId = AutoscalerUtil.getDeploymentPolicyIdByAlias(parentMonitor.appId, http://git-wip-us.apache.org/repos/asf/stratos/blob/1a7ea1a9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 945c3e1..309fe12 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -109,9 +109,9 @@ public class ClusterMonitor extends Monitor { String deploymentPolicyId) { scheduler = StratosThreadPool.getScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID, 50); - int threadPoolSize = Integer.getInteger(AutoscalerConstants.CLUSTER_MONITOR_THREAD_POOL_SIZE, 50); + int threadPoolSize = Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_SIZE, 100); executorService = StratosThreadPool.getExecutorService( - AutoscalerConstants.CLUSTER_MONITOR_THREAD_POOL_ID, threadPoolSize); + AutoscalerConstants.MONITOR_THREAD_POOL_ID, threadPoolSize); this.clusterId = cluster.getClusterId(); readConfigurations(); this.groupScalingEnabledSubtree = groupScalingEnabledSubtree; http://git-wip-us.apache.org/repos/asf/stratos/blob/1a7ea1a9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java index d7fd545..df972f0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java @@ -48,6 +48,7 @@ import org.apache.stratos.messaging.domain.application.Application; import org.apache.stratos.messaging.domain.application.ApplicationStatus; import org.apache.stratos.messaging.domain.application.GroupStatus; import org.apache.stratos.messaging.domain.instance.ApplicationInstance; +import org.apache.stratos.messaging.domain.instance.ClusterInstance; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; @@ -77,9 +78,9 @@ public class ApplicationMonitor extends ParentComponentMonitor { TopologyInConsistentException { super(application); - int threadPoolSize = Integer.getInteger(AutoscalerConstants.APPLICATION_MONITOR_THREAD_POOL_SIZE, 20); + int threadPoolSize = Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_ID, 100); this.executorService = StratosThreadPool.getExecutorService( - AutoscalerConstants.APPLICATION_MONITOR_THREAD_POOL_ID, threadPoolSize); + AutoscalerConstants.MONITOR_THREAD_POOL_ID, threadPoolSize); //setting the appId for the application this.appId = application.getUniqueIdentifier(); @@ -475,6 +476,26 @@ public class ApplicationMonitor extends ParentComponentMonitor { networkPartitionIds + " [appInstanceId] " + instanceId); } + //Find whether any other instances exists in cluster + // which has not been added to in-memory model in the restart + Map<String, ApplicationInstance> instanceMap = application.getInstanceIdToInstanceContextMap(); + for(ApplicationInstance instance : instanceMap.values()) { + if(!instanceIds.contains(instance.getInstanceId())) { + ParentLevelNetworkPartitionContext context = + new ParentLevelNetworkPartitionContext(instance.getNetworkPartitionId()); + //If application instances found in the ApplicationsTopology, + // then have to add them first before creating new one + ApplicationInstance appInstance = (ApplicationInstance) application. + getInstanceByNetworkPartitionId(context.getId()); + //use the existing instance in the Topology to create the data + handleApplicationInstanceCreation(application, context, appInstance); + instanceIds.add(instance.getInstanceId()); + log.info("Burst Application instance has been added in the restart for " + + "the [network partition] " + instance.getNetworkPartitionId() + + " [appInstanceId] " + instance.getInstanceId()); + } + } + startDependency(application, instanceIds); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/stratos/blob/1a7ea1a9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java index 7b91205..2d25e97 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java @@ -85,9 +85,9 @@ public class GroupMonitor extends ParentComponentMonitor { TopologyInConsistentException { super(group); - int threadPoolSize = Integer.getInteger(AutoscalerConstants.GROUP_MONITOR_THREAD_POOL_SIZE, 20); + int threadPoolSize = Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_SIZE, 100); this.executorService = StratosThreadPool.getExecutorService( - AutoscalerConstants.GROUP_MONITOR_THREAD_POOL_ID, threadPoolSize); + AutoscalerConstants.MONITOR_THREAD_POOL_ID, threadPoolSize); this.groupScalingEnabled = group.isGroupScalingEnabled(); this.appId = appId; http://git-wip-us.apache.org/repos/asf/stratos/blob/1a7ea1a9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java index 839dd5a..788c79b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java @@ -71,13 +71,9 @@ public final class AutoscalerConstants { */ public static final String PAYLOAD_DEPLOYMENT = "default"; - public static final String APPLICATION_MONITOR_THREAD_POOL_ID = "application.monitor.thread.pool"; - public static final String APPLICATION_MONITOR_THREAD_POOL_SIZE = "application.monitor.thread.pool.size"; - public static final String GROUP_MONITOR_THREAD_POOL_ID = "group.monitor.thread.pool"; - public static final String GROUP_MONITOR_THREAD_POOL_SIZE = "group.monitor.thread.pool.size"; + public static final String MONITOR_THREAD_POOL_ID = "monitor.thread.pool"; + public static final String MONITOR_THREAD_POOL_SIZE = "monitor.thread.pool.size"; public static final String CLUSTER_MONITOR_SCHEDULER_ID = "cluster.monitor.scheduler"; - public static final String CLUSTER_MONITOR_THREAD_POOL_ID = "cluster.monitor.thread.pool"; - public static final String CLUSTER_MONITOR_THREAD_POOL_SIZE = "cluster.monitor.thread.pool.size"; public static final String MEMBER_FAULT_EVENT_NAME = "member_fault"; //scheduler public static final int SCHEDULE_DEFAULT_INITIAL_DELAY = 30; @@ -122,4 +118,4 @@ public final class AutoscalerConstants { public static final String IDENTITY_APPLICATION_SERVICE_SFX = "services/IdentityApplicationManagementService"; public static final String TOKEN_ENDPOINT_SFX = "oauth2/token"; public static final String TERMINATE_DEPENDENTS = "terminate-dependents"; -} \ No newline at end of file +}
