diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/.classpath b/edexOsgi/com.raytheon.edex.monitorsrv/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/.project b/edexOsgi/com.raytheon.edex.monitorsrv/.project deleted file mode 100644 index ea8410cea0..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.edex.monitorsrv - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.edex.monitorsrv/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index e285a6d271..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Thu Mar 26 09:21: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 diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.monitorsrv/META-INF/MANIFEST.MF deleted file mode 100644 index e99033801c..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Monitorsrv Plug-in -Bundle-SymbolicName: com.raytheon.edex.monitorsrv -Bundle-Version: 1.12.1174.qualifier -Bundle-Vendor: RAYTHEON -Export-Package: com.raytheon.edex.monitors, - com.raytheon.edex.services -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: com.raytheon.edex.util, - org.apache.commons.logging, - org.apache.log4j -Require-Bundle: com.raytheon.uf.edex.core;bundle-version="1.12.1174", - com.raytheon.uf.edex.database;bundle-version="1.0.0", - com.raytheon.uf.common.util;bundle-version="1.12.1174" diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/build.properties b/edexOsgi/com.raytheon.edex.monitorsrv/build.properties deleted file mode 100644 index 5791d48d5f..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/com.raytheon.edex.monitorsrv.ecl b/edexOsgi/com.raytheon.edex.monitorsrv/com.raytheon.edex.monitorsrv.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/res/spring/jmx-log4j-manager-spring.xml b/edexOsgi/com.raytheon.edex.monitorsrv/res/spring/jmx-log4j-manager-spring.xml deleted file mode 100644 index 5884ccbe7e..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/res/spring/jmx-log4j-manager-spring.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/logging/Log4jLevels.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/logging/Log4jLevels.java deleted file mode 100644 index 36160b1b4d..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/logging/Log4jLevels.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.logging; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -/** - * Class to modify log4j levels at runtime - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 12/13/07     629        garmendariz Initial check-in
- * 
- * 
- * - * @author garmendariz - * @version 1.0 - */ -public class Log4jLevels { - - public String setLevel(String loggerName, String level) { - - if(!checkLevel(level)) - { - return "Can not set level. Valid levels are: debug, info, error, fatal, warn"; - } - - int nLevel = Level.toLevel(level.toLowerCase()).toInt(); - - switch (nLevel) { - case Level.DEBUG_INT: - Logger.getLogger(loggerName).setLevel(Level.DEBUG); - break; - case Level.INFO_INT: - Logger.getLogger(loggerName).setLevel(Level.INFO); - break; - case Level.ERROR_INT: - Logger.getLogger(loggerName).setLevel(Level.ERROR); - break; - case Level.FATAL_INT: - Logger.getLogger(loggerName).setLevel(Level.FATAL); - break; - case Level.WARN_INT: - Logger.getLogger(loggerName).setLevel(Level.WARN); - break; - } - - return loggerName + " has been set to " + level + ".\nModify log4j.properties in the Mule conf for permanent changes"; - } - - /** - * Check that the level is a valid one - * @param level - */ - private boolean checkLevel(String level) { - - if(level.equalsIgnoreCase("debug") || - level.equalsIgnoreCase("error") || - level.equalsIgnoreCase("debug") || - level.equalsIgnoreCase("fatal") || - level.equalsIgnoreCase("warn") || - level.equalsIgnoreCase("info")) - { - return true; - }else - { - return false; - } - } - -} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexDBMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexDBMonitor.java deleted file mode 100644 index e1803c5c18..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexDBMonitor.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -/** - * An abstract base class for EDEX Database Monitors. - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 12May2008    1113       MW Fegan    Initial creation.
- * 	
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public abstract class AEdexDBMonitor extends AEdexMonitor { - protected String query - = "select count(*) from pg_stat_activity where usename='awips' and datname='metadata'"; - - protected static final String REPORT_FORMAT = "Database: %s, connections = %s"; - /** - * Constructor. Creates a default object with the default query. - */ - public AEdexDBMonitor() { - // Intentionally empty. - } - /** - * Constructor. Creates an object for the specified query. - * @param query - */ - public AEdexDBMonitor(String query) { - this.query = query; - } - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#execute() - */ - @Override - abstract public void execute(); - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#setData(java.lang.String) - */ - @Override - public void setData(String data) { - this.query = data; - } - -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexDirMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexDirMonitor.java deleted file mode 100644 index 0f0dcaf4f1..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexDirMonitor.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import java.io.FilenameFilter; - -import com.raytheon.uf.common.util.file.FilenameFilters; - -/** - * An abstract base class for directory monitors. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08May2008    1113       MW Fegan    Initial creation.
- * Mar 14, 2013 1794       djohnson    Consolidate common FilenameFilter implementations.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public abstract class AEdexDirMonitor extends AEdexMonitor { - /** format string for invalid directory messages */ - protected static final String DIR_ERROR_FORMAT = "Specified path [%s] is not a directory"; - /** indicates if the directory search is recursive */ - protected boolean recursive = false; - - /** path to the directory to scan */ - protected String dirToCheck = "."; - - /* file filter that screens out "dot" files */ - protected FilenameFilter filter = FilenameFilters.NO_LINUX_HIDDEN_FILES; - - /** - * Constructor. Takes no action. - */ - public AEdexDirMonitor() { - // intentionally empty - } - /** - * Constructor. Sets the {@code dirToCheck} to the specified value. - */ - public AEdexDirMonitor(String directory) { - this.dirToCheck = directory; - } - /** - * Constructor. Sets the {@code dirToCheck} and {@code recursive} attributes - * to the specified values. - */ - public AEdexDirMonitor(String directory, String tree) { - this.dirToCheck = directory; - this.recursive = Boolean.valueOf(tree); - } - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#execute() - */ - @Override - abstract public void execute(); - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#setData(java.lang.String) - */ - @Override - abstract public void setData(String data); -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexMonitor.java deleted file mode 100644 index 768aa65887..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/AEdexMonitor.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * TODO Add Description - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- *  06May2008    1113       MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public abstract class AEdexMonitor implements IEdexMonitor { - protected transient Log logger = LogFactory.getLog(getClass()); - /** - * Constructor. Creates an empty object. - */ - public AEdexMonitor() { - /* intentionally empty */ - } - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.IEdexMonitor#execute() - */ - @Override - abstract public void execute(); - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.IEdexMonitor#setData(java.lang.String) - */ - @Override - abstract public void setData(String data);} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDBLocalMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDBLocalMonitor.java deleted file mode 100644 index c666a77b1c..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDBLocalMonitor.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import com.raytheon.edex.services.MonitorSrv; -import com.raytheon.uf.edex.database.dao.CoreDao; -import com.raytheon.uf.edex.database.dao.DaoConfig; - -/** - * Performs a database monitoring task on the database utilized by the Mule - * instance. The number of connections is reported to the system log. The format - * of the log message is - *

- * Database: {connection URL}, connections = {count} - *

- * This class is intended to be injected into an {@link MonitorSrv} instance by - * Mule. Because of that, all constructor arguments are of type String. - *

- * - *

- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- *  06May2008    1113       MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class EdexDBLocalMonitor extends AEdexDBMonitor { - - /** - * Constructor. Creates a Local Database Monitor using the default query - * string. - */ - public EdexDBLocalMonitor() { - // Intentionally Empty - } - - /** - * Constructor. Creates a Local Database Monitor using the specified query - * string. - * - * @param query - * the monitoring query string - */ - public EdexDBLocalMonitor(String query) { - super(query); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.edex.monitors.AEdexDBMonitor#execute() - */ - @Override - public void execute() { - CoreDao dao = new CoreDao(DaoConfig.DEFAULT); - - Object[] results = dao.executeSQLQuery(query); - if (results == null || results.length == 0) { - logger.info("No results returned from query [" + query + "]"); - return; - } - - logger.info(String.format(REPORT_FORMAT, "localhost/" - + DaoConfig.DEFAULT_DB_NAME, results[0].toString())); - - } -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDBRemoteMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDBRemoteMonitor.java deleted file mode 100644 index 266c7e32cc..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDBRemoteMonitor.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -//import com.raytheon.edex.db.dao.CoreDao; -//import com.raytheon.edex.db.dao.pool.DaoConfig; -//import com.raytheon.edex.db.dao.pool.DaoPool; -import com.raytheon.edex.services.MonitorSrv; -import com.raytheon.uf.edex.core.EdexException; - -/** - * Performs a database monitoring task on a remote database. This monitor - * is intended to allow an instance of EDEX to monitor database connections - * on another server. The number of connections is reported to the system - * log. The format of the log message is - *

- * Database: {connection URL}, connections = {count} - *

- * This class is intended to be injected into an {@link MonitorSrv} instance by - * Mule. Because of that, all constructor arguments are of type String. - *

- *

- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- *  12May2008    1113       MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class EdexDBRemoteMonitor extends AEdexDBMonitor { - private static final String DB_DRIVER = "org.postgresql.Driver"; - private String connectionURL = "jdbc:postgresql://localhost:5432/metadata"; - private String user = "awips:awips"; - - static { - try { - Class.forName(DB_DRIVER); - } catch (ClassNotFoundException e) { - System.out.println(new EdexException("Unable to load PostgresSQL driver",e)); - } - } - /** - * Constructor. Creates an empty object. - */ - public EdexDBRemoteMonitor() { - super(); - } - /** - * Constructor. Initialized the SQL query to the argument. - * - * @param data SQL string used to monitor the database. - */ - public EdexDBRemoteMonitor(String query) { - super(query); - } - /** - * - * @param url - * @param user - * @param query - */ - public EdexDBRemoteMonitor(String url, String user, String query) { - super(); - this.connectionURL = url; - this.user = user; - this.query = query; - } - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.IEdexMonitor#execute() - */ - @Override - public void execute() { - Connection conn = null; - try { - conn = getConnection(connectionURL, user); - if (conn == null) { - return; - } - List results = performQuery(conn, query); - printResult(results); - } finally { - closeConnection(conn); - } - } - private void printResult(List results) { - if (results.size() != 1) { - logger.warn("obtained invalid result from status query."); - } - logger.info(String.format(REPORT_FORMAT,connectionURL, results.get(0).toString())); - } - /** - * - * @param conn - * @param query - * @return - */ - private List performQuery(Connection conn, String query) { - List retVal = new ArrayList(); - Statement s = null; - ResultSet r = null; - try { - s = conn.createStatement(); - r = s.executeQuery(query); - while (r.next()) { - retVal.add(r.getObject(1)); - } - } catch (Exception e) { - logger.warn("Encountered problems executing status query",e); - } finally { - try { - if (r != null) { - r.close(); - } - if (s != null) { - s.close(); - } - } catch (SQLException e) { - logger.warn("Unable to close resultset/statement for status query", e); - } - } - return retVal; - } - /** - * - * @param url - * @param user - * @return - */ - private Connection getConnection(String url, String user) { - Connection conn = null; - try { - Pattern p = Pattern.compile("(.+)[:=@](.+)"); - Matcher m = p.matcher(user); - String name = ""; - String passwd = ""; - if (m.matches()) { - name = m.group(1); - passwd = m.group(2); - } - conn = DriverManager.getConnection(url, name, passwd); - } catch (SQLException e) { - logger.warn("Unable to create connection to database, url=" + url + ", user=" + user, e); - } - return conn; - } - /** - * - * @param conn - */ - private void closeConnection(Connection conn) { - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - // can't do much, just log and return - logger.warn("Unable to close DB Connection",e); - } - } - } -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDirCountMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDirCountMonitor.java deleted file mode 100644 index 68522a7ecd..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDirCountMonitor.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import java.io.File; - -import com.raytheon.edex.services.MonitorSrv; - -/** - * Performs a count of the files in a directory or directory tree. The total - * file count is reported by logging to the application log. The format - * of the log message is - *

- * {directory path}: Directory contains {count} files - *

- * File scan defaults to the current directory (not tree search). - *

- * This class is intended to be injected into an {@link MonitorSrv} instance by - * Mule. Because of that, all constructor arguments are of type String. - *

- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08May2008    1113       MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class EdexDirCountMonitor extends AEdexDirMonitor { - /* format string for reporting statistics */ - private static final String REPORT_FORMAT = "%s: Directory contains %d files"; - - /** - * Constructor. Creates a monitor using the defaults. - */ - public EdexDirCountMonitor() { - super(); - } - - /** - * Constructor. Creates a monitor for the specified directory. - * The scan is non-recursive. - * - * @param directory the directory to scan. - */ - public EdexDirCountMonitor(String directory) { - super(directory); - } - /** - * Constructor. Creates a monitor for the specified directory.The second - * argument controls scanning depth. Pass "true" to scan the tree, pass - * "false" to scan just the specified directory. - * - * @param path path to the directory to scan - * @param tree scan tree flag. Use "true" to scan entire tree. - */ - public EdexDirCountMonitor(String directory, String tree) { - super(directory,tree); - } - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.IEdexMonitor#execute() - */ - @Override - public void execute() { - File dir = new File(dirToCheck); - if (!dir.isDirectory()) { - logger.warn(String.format(DIR_ERROR_FORMAT, dirToCheck)); - return; - } - long count = getCounts(dir,this.recursive); - logger.info(String.format(REPORT_FORMAT, dirToCheck, count)); - } - /** - * - * @param dir - * @param recursive - * @return - */ - private long getCounts(File dir,boolean recursive) { - long retVal = 0; - for(File file : dir.listFiles(filter)){ - if (recursive && file.isDirectory()) { - retVal += getCounts(file,recursive); - } else { - retVal++; - } - } - return retVal; - } - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.IEdexMonitor#setData(java.lang.String) - */ - @Override - public void setData(String data) { - this.dirToCheck = data; - } - -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDirSizeMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDirSizeMonitor.java deleted file mode 100644 index 91d08c9c96..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexDirSizeMonitor.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import java.io.File; -import com.raytheon.edex.services.MonitorSrv; - -/** - * Performs a file size calculation on a directory or directory tree. The total - * file size is reported by logging to the application log. The format - * of the log message is - *

- * {directory path}: Total file size {size} bytes - *

- * File scan defaults to the current directory (not tree search). - *

- * This class is intended to be injected into an {@link MonitorSrv} instance by - * Mule. Because of that, all constructor arguments are of type String. - *

- * - *

- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08May2008    1113       MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class EdexDirSizeMonitor extends AEdexDirMonitor { - - private static final String REPORT_FORMAT = "%s: Total file size %d bytes"; - - /** - * Constructor. Creates a directory size monitor using the default settings. - */ - public EdexDirSizeMonitor() { - super(); - } - /** - * Constructor. Creates a directory size monitor for the specified directory. - * The scan is limited to the specified directory. - * - * @param directory path to the directory to scan - */ - public EdexDirSizeMonitor(String directory) { - super(directory); - } - /** - * Constructor. Creates a directory size monitor for the specified directory. - * The second argument controls scanning depth. Pass "true" to scan the tree, - * pass "false" to scan just the specified directory. - * - * @param directory path to the directory to scan - * @param tree scan tree flag. Use "true" to scan entire tree. - */ - public EdexDirSizeMonitor(String directory, String tree) { - super(directory,tree); - } - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#execute() - */ - @Override - public void execute() { - File dir = new File(dirToCheck); - if (!dir.isDirectory()) { - logger.warn(String.format(DIR_ERROR_FORMAT, dirToCheck)); - return; - } - long size = getSizes(dir,this.recursive); - logger.info(String.format(REPORT_FORMAT, dirToCheck,size)); - } - /** - * Finds the total size of the files in a directory. Recursively - * scans the directory and finds the total number of bytes in the - * files in the directory. Setting the recursive flag to false limits - * the search to a single directory. - * - * @param dir the directory to search - * @param recursive set true to search entire tree - * - * @return number of bytes used by files in the directory - */ - private long getSizes(File dir, boolean recursive) { - long retVal = 0; - for(File file : dir.listFiles(filter)){ - if (recursive && file.isDirectory()) { - retVal += getSizes(file,recursive); - } else { - retVal += file.length(); - } - } - return retVal; - } - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#setData(java.lang.String) - */ - @Override - public void setData(String data) { - dirToCheck = data; - } - -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexLatencyMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexLatencyMonitor.java deleted file mode 100644 index e676ee0681..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/EdexLatencyMonitor.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.Set; - -import javax.management.MBeanServerConnection; -import javax.management.ObjectName; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; - -import com.raytheon.edex.services.MonitorSrv; -import com.raytheon.uf.common.util.StringUtil; - -/** - * Uses JMX to obtain latency information for an end-point. Reports queue size, - * event backlog and average execution time for the end-point. The format of the - * log message is - *

- * {end-point name}: Queue Size = {count}, Event Backlog = {count}, Average Execution Time = {count} - *

- * The monitoring defaults to the current Mule instance on the local computer. - * There is no default for the end-point parameter. - *

- * This class is intended to be injected into an {@link MonitorSrv} instance by - * Mule. Because of that, all constructor arguments are of type String. - *

- * - *

- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 07May2008    1113       MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class EdexLatencyMonitor extends AEdexMonitor { - /* format string for creating the connection URL */ - private static final String URL_FORMAT = "service:jmx:rmi://%s/jndi/rmi://%s:%s/%s"; - /* format string for reporting statistics */ - private static final String REPORT_FORMAT = "%s: Queue Size = %d, Event Backlog = %d, Average Execution Time = %d"; - /** host name for connection string */ - private String server = "localhost"; - /** port for connection string */ - private String port = "1099"; - /** application for connection string */ - private String application = "Mule"; - /** complete connection URL */ - private String strurl = String.format(URL_FORMAT, server,server,port,application); - /** name of end-point to monitor */ - private String beanName = null; - - MBeanServerConnection connection = null; - /** - * Constructor. Creates a monitor using defaults. - */ - public EdexLatencyMonitor() { - // intentionally empty - } - /** - * Constructor. Creates a monitor for the specified end-point. The monitor uses - * the default connection URL. - * - * @param beanName name of end-point to monitor - */ - public EdexLatencyMonitor(String beanName) { - this.beanName = beanName; - } - /** - * Constructor. Creates a monitor for the specified Mule instance using the - * specified end-point. - * - * @param server the server hosting the mule instance - * @param port the port to which Mule is listening - * @param application the Mule application identifier (usually "Mule") - * @param beanName name of end-point to monitor - */ - public EdexLatencyMonitor(String server, String port, String application, String beanName) { - this.server = server; - this.port = port; - this.application = application; - this.strurl = String.format(URL_FORMAT, server,server,port,application); - this.beanName = beanName; - } - /** - * Constructor. Creates a monitor for the specified connection URL using the - * specified end-point. The format of the connection URL is - *

- * service:jmx:rmi://{server}/jndi/rmi://{server}:{port}/{application} - * - * @param strurl the connection URL - * @param beanName name of end-point to monitor - */ - public EdexLatencyMonitor(String strurl, String beanName) { - this.strurl = strurl; - this.beanName = beanName; - } - /** - * Initializes the JMX connection. - */ - private void init() { - if (this.connection != null) { - return; - } - JMXConnector connector = null; - try { - JMXServiceURL url = new JMXServiceURL(strurl); - connector = JMXConnectorFactory.connect(url); - } catch (MalformedURLException e) { - logger.warn(connection + "is invalid",e); - } catch (IOException e) { - logger.warn("Unable to connect to " + strurl,e); - } - if (connector != null) { - try { - this.connection = connector.getMBeanServerConnection(); - } catch (IOException e) { - logger.warn("Unable to create connection to " + strurl,e); - } - } - } - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#execute() - */ - @Override - public void execute() { - init(); - if (this.connection == null) { - logger.warn("connection to " + strurl + " is unavailable, unable to monitor"); - return; - } - try { - String[] domainNames = this.connection.getDomains(); - String domainName = ""; - for (String name : domainNames) { - if (name.startsWith("Mule")) { - domainName = name; - } - } - String objStr = domainName+":type=org.mule.Component,name=\""+beanName+"\""; - Set sets = null; - ObjectName obName = new ObjectName(objStr); - sets = this.connection.queryNames(obName, null); - if (sets.size() != 1) { - logger.warn("unable to get access to " + objStr); - return; - } - ObjectName theObject = (ObjectName)sets.toArray()[0]; - Integer queueSize = (Integer)connection.getAttribute(theObject, "QueueSize"); - Long queuedEvents = (Long)connection.getAttribute(theObject, "QueuedEvents"); - Long averageTime = (Long)connection.getAttribute(theObject, "AverageExecutionTime"); - logger.info(String.format(REPORT_FORMAT,StringUtil.printString(beanName), - queueSize,queuedEvents,averageTime)); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /* (non-Javadoc) - * @see com.raytheon.edex.monitors.AEdexMonitor#setData(java.lang.String) - */ - @Override - public void setData(String data) { - this.beanName = data; - } - -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/IEdexMonitor.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/IEdexMonitor.java deleted file mode 100644 index 113e4e0579..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/monitors/IEdexMonitor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.monitors; - -import com.raytheon.edex.services.MonitorSrv; - -/** - * Specifies the interface defining the capabilities of the EDEX monitor - * classes. These are used by the {@link MonitorSrv} to monitor and report - * various system conditions. - * - *

- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 02May2008    TBD        MW Fegan    Initial creation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public interface IEdexMonitor { - /** - * Sets the user data from the monitor. This should be called just - * prior to running the {@link #execute()} method. - * @param data the data to provide to the monitor - */ - public void setData(final String data); - /** - * Triggers a single monitoring event in the monitor. - */ - public void execute(); -} diff --git a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/services/MonitorSrv.java b/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/services/MonitorSrv.java deleted file mode 100644 index 50e19df711..0000000000 --- a/edexOsgi/com.raytheon.edex.monitorsrv/src/com/raytheon/edex/services/MonitorSrv.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.services; - -import com.raytheon.edex.monitors.IEdexMonitor; -import com.raytheon.uf.edex.core.EdexException; - -/** - * This is a service endpoint for EDEX monitoring. It receives an - * {@link IEdexMonitor} instance by injection and calls the - * {@link IEdexMonitor#execute()} method. All error handling is managed here as - * well. - *

- * - *

- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 02May2008    1113       MW Fegan    Initial implementation.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class MonitorSrv { - private IEdexMonitor edexMonitor = null; - - /** - * Constructor. Creates an empty end-point ready for use by Mule. - */ - public MonitorSrv() { - // Intentionally empty. - } - - public void process() throws EdexException { - if (edexMonitor == null) { - throw new EdexException("Monitor is null - unable to process"); - } - edexMonitor.execute(); - return; - } - - /** - * Returns the {@link IEdexMonitor} instance used by this end-point. - */ - public IEdexMonitor getEdexMonitor() { - return edexMonitor; - } - - /** - * Sets the {@link IEdexMonitor} instance for the monitor to use. - *

- * Note: This is provided to allow dependency injection by the container. - */ - public void setEdexMonitor(IEdexMonitor edexMonitor) { - this.edexMonitor = edexMonitor; - } - -}