From 0c0739bd72966b21bfaadfec1bc135ee2d15df79 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Wed, 9 Jul 2014 12:41:47 -0500 Subject: [PATCH] Issue #3146 Added check for duplicate smartInit. Added alertViz message for GFE site activation failure Change-Id: I68a2b995922ac9ba7e75d02f317357fddde7f004 Former-commit-id: eafc406ec75d5e1a1bbc93bb0b472a053922eb3a --- .../plugin/gfe/config/GFESiteActivation.java | 23 +++++++----- .../gfe/config/IFPServerConfigManager.java | 5 ++- .../edex_static/base/config/gfe/doConfig.py | 36 +++++++++++++++++-- .../base/config/gfe/serverConfig.py | 9 ++--- 4 files changed, 55 insertions(+), 18 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java index 938f49ac8f..44625782df 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java @@ -19,6 +19,8 @@ **/ package com.raytheon.edex.plugin.gfe.config; +import java.io.PrintWriter; +import java.io.StringWriter; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashMap; @@ -73,7 +75,9 @@ import com.raytheon.uf.edex.site.notify.SendSiteActivationNotifications; * May 02, 2013 #1969 randerso Moved updateDbs method into IFPGridDatabase * Jun 13, 2013 #2044 randerso Refactored to use IFPServer * Oct 16, 2013 #2475 dgilling Better error handling for IRT activation. - * Mar 21, 2014 2726 rjpeter Updated wait for running loop. + * Mar 21, 2014 #2726 rjpeter Updated wait for running loop. + * Jul 09, 2014 #3146 randerso Eliminated redundant evaluation of serverConfig + * Sent activation failure message to alertViz * * * @author njensen @@ -231,13 +235,6 @@ public class GFESiteActivation implements ISiteActivationListener { } try { - - IFPServerConfig config = IFPServerConfigManager - .initializeConfig(siteID); - if (config == null) { - throw new GfeConfigurationException( - "Error validating configuration for " + siteID); - } internalActivateSite(siteID); } catch (GfeMissingConfigurationException e) { sendActivationFailedNotification(siteID); @@ -247,7 +244,15 @@ public class GFESiteActivation implements ISiteActivationListener { throw e; } catch (Exception e) { sendActivationFailedNotification(siteID); - statusHandler.error(siteID + " Error activating site " + siteID, e); + String message = "Error activating IFPServer for site " + siteID + + ". GFE will be unavailable for this site!"; + statusHandler.error(message, e); + + StringWriter stackTrace = new StringWriter(); + e.printStackTrace(new PrintWriter(stackTrace)); + EDEXUtil.sendMessageAlertViz(Priority.ERROR, + "com.raytheon.edex.plugin.gfe", "GFE", "GFE", message, + stackTrace.toString(), null); throw e; } sendActivationCompleteNotification(siteID); diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/IFPServerConfigManager.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/IFPServerConfigManager.java index 3449230837..ed34c5b43f 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/IFPServerConfigManager.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/IFPServerConfigManager.java @@ -25,8 +25,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import jep.JepException; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -56,6 +54,7 @@ import com.raytheon.uf.common.util.FileUtil; * Dec 11, 2012 14360 ryu Throw specific exception for missing configuration. * Feb 20, 2014 #2824 randerso Fixed import of localVTECPartners to use siteID * Added common python path for LogStream + * Jul 09, 2014 #3146 randerso Improved exception handling * * * @@ -178,7 +177,7 @@ public class IFPServerConfigManager { SimpleServerConfig simpleConfig = (SimpleServerConfig) py.execute( "getSimpleConfig", null); siteConfig = new IFPServerConfig(simpleConfig); - } catch (JepException e) { + } catch (Throwable e) { throw new GfeConfigurationException( "Exception occurred while processing serverConfig for site " + siteID, e); diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/doConfig.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/doConfig.py index 42d6d43356..b3d13c7c01 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/doConfig.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/doConfig.py @@ -30,6 +30,7 @@ # ------------ ---------- ----------- -------------------------- # 08/09/2013 #1571 randerso Changed projections to use the Java # ProjectionType enumeration +# 07/09/2014 #3146 randerso Added check for duplicate smartInit # ######################################################################## import types @@ -438,7 +439,7 @@ def otherParse(serverhost, mhsid, port, "not an int: " + `vtecRequestTime` if type(port) != int: raise TypeError, "GFESUITE_PORT not an int: " + `port` - initmodules = dictCheck(initmodules, list, str, "INITMODULES") + javainitmodules = dictCheck(initmodules, list, str, "INITMODULES") accumElem = dictCheck(accumElem, list, str, "D2DAccumulativeElements") initskips = dictCheck(initskips, list, int, "INITSKIPS") d2ddbver = dictCheck(d2ddbver, int, None, "D2DDBVERSIONS") @@ -507,9 +508,40 @@ def otherParse(serverhost, mhsid, port, raise TypeError, "TRANSMIT_SCRIPT not None or str: " + `transmitScript` elif transmitScript is None: transmitScript = "" + + # build model to init mapping + modelToInit = {} + for module in initmodules: + for model in initmodules[module]: + if modelToInit.has_key(model): + modelToInit[model].append(module) + else: + modelToInit[model] = [module] + + # check for duplicate init modules + for model in modelToInit: + modules = modelToInit[model] + if len(modules) > 1: + message = "Multiple smartInit modules " + str(modules) + \ + " are enabled for D2D model: " + model + ". " + str(modules[1:]) + \ + " will be disabled. Please edit your localConfig.py file and disable all but one." + + # log error message to edex log + import LogStream + LogStream.logProblem(message); + + # log error to alertViz + from ufpy import NotificationMessage + nfm = NotificationMessage.NotificationMessage(message=message, + category="GFE", priority=1, source="GFE") + nfm.send() + + # remove duplicate + for module in modules[1:]: + javainitmodules.remove(module) return serverhost, mhsid, \ - port, initmodules, accumElem, \ + port, javainitmodules, accumElem, \ initskips, d2ddbver, logfilepurge, prddir, home,\ extraWEPrecision, vtecRequestTime, \ autoConfigureNotifyTextProd, \ diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/serverConfig.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/serverConfig.py index 2392747191..e5ea48091a 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/serverConfig.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/config/gfe/serverConfig.py @@ -39,10 +39,11 @@ # 02/20/2014 #2824 randerso Added log message when local override files are not found # 03/11/2014 #2897 dgilling Add new MHWM databases to default configuration. # 03/20/2014 #2418 dgilling Remove unneeded D2D source PHISH. -# 04/17/14 2934 dgilling Remove alias for TPCSurgeProb D2D database. -# 05/09/2014 3148 randerso Add tpHPCndfd to D2DAccumulativeElements for HPCERP +# 04/17/2014 #2934 dgilling Remove alias for TPCSurgeProb D2D database. +# 05/09/2014 #3148 randerso Add tpHPCndfd to D2DAccumulativeElements for HPCERP # -# 05/29/2014 3224 randerso Added "SPC":8 to D2DDBVERSIONS +# 05/29/2014 #3224 randerso Added "SPC":8 to D2DDBVERSIONS +# 07/09/2014 #3146 randerso Removed unused import ######################################################################## #---------------------------------------------------------------------------- @@ -1985,7 +1986,7 @@ DATABASES.append((ISC, ISCPARMS)) #---------------------------------------------------------------------------- # Server settings DO NOT CHANGE THESE DEFINITIONS #---------------------------------------------------------------------------- -from com.raytheon.edex.plugin.gfe.config import IFPServerConfig, SimpleServerConfig +from com.raytheon.edex.plugin.gfe.config import SimpleServerConfig IFPConfigServer = SimpleServerConfig() #IFPConfigServer.allowedNodes = [] IFPConfigServer.allowTopoBelowZero = 1