Merge "Omaha #3622 Fix duplicate SiteActivationNotifications." into omaha_14.4.1
Former-commit-id: acbc667cfeab1ab6449a93967896e6e303bb238d
This commit is contained in:
commit
23747ad042
2 changed files with 65 additions and 51 deletions
|
@ -1,7 +0,0 @@
|
||||||
#Thu Mar 26 10:17:50 CDT 2009
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
|
@ -19,6 +19,8 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.site;
|
package com.raytheon.uf.edex.site;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -28,6 +30,9 @@ import java.util.Set;
|
||||||
import com.raytheon.uf.common.site.notify.ClusterActivationNotification;
|
import com.raytheon.uf.common.site.notify.ClusterActivationNotification;
|
||||||
import com.raytheon.uf.common.site.notify.SiteActivationNotification;
|
import com.raytheon.uf.common.site.notify.SiteActivationNotification;
|
||||||
import com.raytheon.uf.common.site.notify.SiteActivationNotification.ACTIVATIONSTATUS;
|
import com.raytheon.uf.common.site.notify.SiteActivationNotification.ACTIVATIONSTATUS;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.edex.core.EdexException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors site activation across all JVMs on all cluster members
|
* Monitors site activation across all JVMs on all cluster members
|
||||||
|
@ -48,6 +53,9 @@ import com.raytheon.uf.common.site.notify.SiteActivationNotification.ACTIVATIONS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SiteActivationMonitor {
|
public class SiteActivationMonitor {
|
||||||
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(SiteActivationMonitor.class);
|
||||||
|
|
||||||
private Map<String, Map<String, Set<String>>> activationMap = new HashMap<String, Map<String, Set<String>>>();
|
private Map<String, Map<String, Set<String>>> activationMap = new HashMap<String, Map<String, Set<String>>>();
|
||||||
|
|
||||||
private Map<String, Map<String, Set<String>>> deactivationMap = new HashMap<String, Map<String, Set<String>>>();
|
private Map<String, Map<String, Set<String>>> deactivationMap = new HashMap<String, Map<String, Set<String>>>();
|
||||||
|
@ -56,10 +64,18 @@ public class SiteActivationMonitor {
|
||||||
|
|
||||||
private ACTIVATIONSTATUS status = ACTIVATIONSTATUS.SUCCESS;
|
private ACTIVATIONSTATUS status = ACTIVATIONSTATUS.SUCCESS;
|
||||||
|
|
||||||
private SiteActivationMonitor() {
|
private String myHost;
|
||||||
|
|
||||||
|
private SiteActivationMonitor() throws EdexException {
|
||||||
|
try {
|
||||||
|
this.myHost = InetAddress.getLocalHost().getCanonicalHostName();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
statusHandler.error("Error resolving localhost name", e);
|
||||||
|
throw new EdexException("Error resolving localhost name", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SiteActivationMonitor getInstance() {
|
public static SiteActivationMonitor getInstance() throws EdexException {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new SiteActivationMonitor();
|
instance = new SiteActivationMonitor();
|
||||||
}
|
}
|
||||||
|
@ -104,9 +120,7 @@ public class SiteActivationMonitor {
|
||||||
|
|
||||||
public SiteActivationNotification handleNotification(
|
public SiteActivationNotification handleNotification(
|
||||||
SiteActivationNotification notification) {
|
SiteActivationNotification notification) {
|
||||||
if (notification instanceof ClusterActivationNotification) {
|
if (!(notification instanceof ClusterActivationNotification)) {
|
||||||
return notification;
|
|
||||||
}
|
|
||||||
|
|
||||||
String plugin = notification.getPluginName();
|
String plugin = notification.getPluginName();
|
||||||
String modifiedSite = notification.getModifiedSite();
|
String modifiedSite = notification.getModifiedSite();
|
||||||
|
@ -116,7 +130,8 @@ public class SiteActivationMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activationMap.get(plugin).containsKey(modifiedSite)) {
|
if (!activationMap.get(plugin).containsKey(modifiedSite)) {
|
||||||
activationMap.get(plugin).put(modifiedSite, new HashSet<String>());
|
activationMap.get(plugin).put(modifiedSite,
|
||||||
|
new HashSet<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deactivationMap.containsKey(plugin)) {
|
if (!deactivationMap.containsKey(plugin)) {
|
||||||
|
@ -124,13 +139,14 @@ public class SiteActivationMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deactivationMap.get(plugin).containsKey(modifiedSite)) {
|
if (!deactivationMap.get(plugin).containsKey(modifiedSite)) {
|
||||||
deactivationMap.get(plugin)
|
deactivationMap.get(plugin).put(modifiedSite,
|
||||||
.put(modifiedSite, new HashSet<String>());
|
new HashSet<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification.isBegin()) {
|
if (notification.isBegin()) {
|
||||||
if (notification.isActivation()) {
|
if (notification.isActivation()) {
|
||||||
activationMap.get(plugin).get(modifiedSite).add(serverAndMode);
|
activationMap.get(plugin).get(modifiedSite)
|
||||||
|
.add(serverAndMode);
|
||||||
} else if (notification.isDeactivation()) {
|
} else if (notification.isDeactivation()) {
|
||||||
deactivationMap.get(plugin).get(modifiedSite)
|
deactivationMap.get(plugin).get(modifiedSite)
|
||||||
.add(serverAndMode);
|
.add(serverAndMode);
|
||||||
|
@ -147,7 +163,12 @@ public class SiteActivationMonitor {
|
||||||
status = ACTIVATIONSTATUS.FAILURE;
|
status = ACTIVATIONSTATUS.FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification.getServerName().equals(myHost)) {
|
||||||
return notification;
|
return notification;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue