You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/12/12 14:43:56 UTC
stratos git commit: Rename missing classes
Repository: stratos
Updated Branches:
refs/heads/4.1.0-test 1ee248377 -> 5432c7130
Rename missing classes
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5432c713
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5432c713
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5432c713
Branch: refs/heads/4.1.0-test
Commit: 5432c713081172421bd4875c91f84695ce440d44
Parents: 1ee2483
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Fri Dec 12 19:15:52 2014 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Fri Dec 12 19:15:59 2014 +0530
----------------------------------------------------------------------
.../ClusterInstanceInActivateEventListener.java | 24 ----
.../ClusterInstanceInactivateEventListener.java | 24 ++++
.../GroupInstanceInActivateProcessor.java | 120 ----------------
.../GroupInstanceInactivateProcessor.java | 120 ++++++++++++++++
.../ClusterInstanceInActivateProcessor.java | 139 -------------------
.../ClusterInstanceInactivateProcessor.java | 139 +++++++++++++++++++
6 files changed, 283 insertions(+), 283 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/5432c713/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInActivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInActivateEventListener.java
deleted file mode 100644
index e5b9ee3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInActivateEventListener.java
+++ /dev/null
@@ -1,24 +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.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ClusterInstanceInactivateEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5432c713/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInactivateEventListener.java
new file mode 100644
index 0000000..e5b9ee3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInstanceInactivateEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * 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.messaging.listener.topology;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterInstanceInactivateEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5432c713/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInActivateProcessor.java
deleted file mode 100644
index df749ea..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInActivateProcessor.java
+++ /dev/null
@@ -1,120 +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.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.instance.GroupInstance;
-import org.apache.stratos.messaging.event.applications.GroupInstanceInactivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupInstanceInactivateProcessor extends MessageProcessor {
- private static final Log log = LogFactory.getLog(GroupInstanceInactivateProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- Applications applications = (Applications) object;
-
- if (GroupInstanceInactivatedEvent.class.getName().equals(type)) {
- // Return if applications has not been initialized
- if (!applications.isInitialized())
- return false;
-
- // Parse complete message and build event
- GroupInstanceInactivatedEvent event = (GroupInstanceInactivatedEvent) Util.
- jsonToObject(message, GroupInstanceInactivatedEvent.class);
-
- ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
-
- try {
- return doProcess(event, applications);
-
- } finally {
- ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
- }
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, applications);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-
- private boolean doProcess(GroupInstanceInactivatedEvent event, Applications applications) {
-
- // Validate event against the existing applications
- Application application = applications.getApplication(event.getAppId());
- if (application == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Application does not exist: [service] %s",
- event.getAppId()));
- }
- return false;
- }
- Group group = application.getGroupRecursively(event.getGroupId());
-
- if (group == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
- event.getGroupId()));
- return false;
- }
- } else {
- GroupInstance context = group.getInstanceContexts(event.getInstanceId());
- if(context == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Group Instance not exists in Group: [AppId] %s [groupId] %s " +
- "[instanceId] %s", event.getAppId(), event.getGroupId(),
- event.getInstanceId()));
- return false;
- }
- }
- // Apply changes to the topology
- GroupStatus status = GroupStatus.Inactive;
- if (!context.isStateTransitionValid(status)) {
- log.error("Invalid State Transition from " + context.getStatus() + " to " +
- status);
- return false;
- }
- context.setStatus(status);
- }
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5432c713/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInactivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInactivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInactivateProcessor.java
new file mode 100644
index 0000000..df749ea
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInstanceInactivateProcessor.java
@@ -0,0 +1,120 @@
+/*
+ * 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.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.domain.instance.GroupInstance;
+import org.apache.stratos.messaging.event.applications.GroupInstanceInactivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupInstanceInactivateProcessor extends MessageProcessor {
+ private static final Log log = LogFactory.getLog(GroupInstanceInactivateProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ Applications applications = (Applications) object;
+
+ if (GroupInstanceInactivatedEvent.class.getName().equals(type)) {
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
+ return false;
+
+ // Parse complete message and build event
+ GroupInstanceInactivatedEvent event = (GroupInstanceInactivatedEvent) Util.
+ jsonToObject(message, GroupInstanceInactivatedEvent.class);
+
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
+
+ try {
+ return doProcess(event, applications);
+
+ } finally {
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
+ }
+
+ } else {
+ if (nextProcessor != null) {
+ // ask the next processor to take care of the message.
+ return nextProcessor.process(type, message, applications);
+ } else {
+ throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+
+ private boolean doProcess(GroupInstanceInactivatedEvent event, Applications applications) {
+
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
+ if (application == null) {
+ if (log.isWarnEnabled()) {
+ log.warn(String.format("Application does not exist: [service] %s",
+ event.getAppId()));
+ }
+ return false;
+ }
+ Group group = application.getGroupRecursively(event.getGroupId());
+
+ if (group == null) {
+ if (log.isWarnEnabled()) {
+ log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+ event.getGroupId()));
+ return false;
+ }
+ } else {
+ GroupInstance context = group.getInstanceContexts(event.getInstanceId());
+ if(context == null) {
+ if (log.isWarnEnabled()) {
+ log.warn(String.format("Group Instance not exists in Group: [AppId] %s [groupId] %s " +
+ "[instanceId] %s", event.getAppId(), event.getGroupId(),
+ event.getInstanceId()));
+ return false;
+ }
+ }
+ // Apply changes to the topology
+ GroupStatus status = GroupStatus.Inactive;
+ if (!context.isStateTransitionValid(status)) {
+ log.error("Invalid State Transition from " + context.getStatus() + " to " +
+ status);
+ return false;
+ }
+ context.setStatus(status);
+ }
+
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5432c713/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInActivateProcessor.java
deleted file mode 100644
index 69dadfa..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInActivateProcessor.java
+++ /dev/null
@@ -1,139 +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.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.instance.ClusterInstance;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterInstanceInactivateEvent;
-import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
-import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the cluster activated event
- */
-public class ClusterInstanceInactivateProcessor extends MessageProcessor {
- private static final Log log = LogFactory.getLog(ClusterInstanceInactivateProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
-
- Topology topology = (Topology) object;
-
- if (ClusterInstanceInactivateEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized()) {
- return false;
- }
-
- // Parse complete message and build event
- ClusterInstanceInactivateEvent event = (ClusterInstanceInactivateEvent) Util.
- jsonToObject(message, ClusterInstanceInactivateEvent.class);
-
- TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
- try {
- return doProcess(event, topology);
-
- } finally {
- TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId());
- }
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-
- private boolean doProcess(ClusterInstanceInactivateEvent event, Topology topology) {
-// Apply service filter
- if (TopologyServiceFilter.getInstance().isActive()) {
- if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
- // Service is excluded, do not update topology or fire event
- if (log.isDebugEnabled()) {
- log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
- }
- return false;
- }
- }
-
- // Apply cluster filter
- if (TopologyClusterFilter.getInstance().isActive()) {
- if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) {
- // Cluster is excluded, do not update topology or fire event
- if (log.isDebugEnabled()) {
- log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId()));
- }
- return false;
- }
- }
-
- // Validate event against the existing topology
- Service service = topology.getService(event.getServiceName());
- if (service == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Service does not exist: [service] %s",
- event.getServiceName()));
- }
- return false;
- }
- Cluster cluster = service.getCluster(event.getClusterId());
-
- if (cluster == null) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(),
- event.getClusterId()));
- }
- } else {
- // Apply changes to the topology
- ClusterInstance context = cluster.getInstanceContexts(event.getInstanceId());
- if(context == null) {
- log.warn("Cluster Instance Context is not found for [cluster] " +
- event.getClusterId() + " [instance-id] " +
- event.getInstanceId());
- }
- ClusterStatus status = ClusterStatus.Inactive;
- if (!context.isStateTransitionValid(status)) {
- log.error("Invalid State Transition from " + context.getStatus() + " to " + status);
- }
- context.setStatus(status);
-
- }
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5432c713/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
new file mode 100644
index 0000000..69dadfa
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
@@ -0,0 +1,139 @@
+/*
+ * 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.messaging.message.processor.topology;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.instance.ClusterInstance;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ClusterInstanceInactivateEvent;
+import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
+import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the cluster activated event
+ */
+public class ClusterInstanceInactivateProcessor extends MessageProcessor {
+ private static final Log log = LogFactory.getLog(ClusterInstanceInactivateProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+
+ Topology topology = (Topology) object;
+
+ if (ClusterInstanceInactivateEvent.class.getName().equals(type)) {
+ // Return if topology has not been initialized
+ if (!topology.isInitialized()) {
+ return false;
+ }
+
+ // Parse complete message and build event
+ ClusterInstanceInactivateEvent event = (ClusterInstanceInactivateEvent) Util.
+ jsonToObject(message, ClusterInstanceInactivateEvent.class);
+
+ TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
+ try {
+ return doProcess(event, topology);
+
+ } finally {
+ TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId());
+ }
+
+ } else {
+ if (nextProcessor != null) {
+ // ask the next processor to take care of the message.
+ return nextProcessor.process(type, message, topology);
+ } else {
+ throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+
+ private boolean doProcess(ClusterInstanceInactivateEvent event, Topology topology) {
+// Apply service filter
+ if (TopologyServiceFilter.getInstance().isActive()) {
+ if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
+ // Service is excluded, do not update topology or fire event
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
+ }
+ return false;
+ }
+ }
+
+ // Apply cluster filter
+ if (TopologyClusterFilter.getInstance().isActive()) {
+ if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) {
+ // Cluster is excluded, do not update topology or fire event
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId()));
+ }
+ return false;
+ }
+ }
+
+ // Validate event against the existing topology
+ Service service = topology.getService(event.getServiceName());
+ if (service == null) {
+ if (log.isWarnEnabled()) {
+ log.warn(String.format("Service does not exist: [service] %s",
+ event.getServiceName()));
+ }
+ return false;
+ }
+ Cluster cluster = service.getCluster(event.getClusterId());
+
+ if (cluster == null) {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(),
+ event.getClusterId()));
+ }
+ } else {
+ // Apply changes to the topology
+ ClusterInstance context = cluster.getInstanceContexts(event.getInstanceId());
+ if(context == null) {
+ log.warn("Cluster Instance Context is not found for [cluster] " +
+ event.getClusterId() + " [instance-id] " +
+ event.getInstanceId());
+ }
+ ClusterStatus status = ClusterStatus.Inactive;
+ if (!context.isStateTransitionValid(status)) {
+ log.error("Invalid State Transition from " + context.getStatus() + " to " + status);
+ }
+ context.setStatus(status);
+
+ }
+
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ }
+}