WIDAR Classes

ca.nrc.widar.mccc.crm
Class Crm

java.lang.Object
  extended by ca.nrc.widar.mccc.crm.Crm
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class Crm
extends java.lang.Object
implements java.awt.event.ActionListener

WIDAR/EVLA - CRM: CorrelatorResourceMonitor Class

The Correlator Resource Monitor (CRM) main class.

The CRM is an application designed to self-test various subsystems of the correlator on a regular, or user-determined basis. The results of such tests are analyzed and stored within a database, leaving an indication of what correlator modules, or sub-modules are not in currently working order, or are not behaving as expected. This information will served be to various clients such as the CRM GUI, or the VciConfigMapper on request.

Copyright: National Research Council of Canada and Associated Universities Inc., 2010, 2011, 2012

Since:
1.0
Author:
Dave Del Rizzo (Dave.DelRizzo@nrc.gc.ca)
 

Nested Class Summary
static class Crm.CorrMode
          Correlator Mode Enumeration
static class Crm.CrmMode
          CRMDb Server Mode Enumeration
 
Field Summary
protected static CrmBlfFileAnalyzer cbfa
           
protected static CrmBlbHSXmlConfig cbxc
           
protected static CrmDb cd
           
protected static CrmLagFrameReceiver clfr
           
protected static CrmCorrelatorModel cm
           
protected static java.lang.String configFileString
           
protected static java.lang.String configUrlString
           
protected static CrmDiagnosticQueue2 cq
           
protected static java.net.InetAddress crmHost
           
protected static java.lang.String crmHostString
           
protected static javax.xml.bind.JAXBContext crmJaxbContext
           
protected static java.net.DatagramSocket lfrSocket
           
protected static java.lang.Integer lfrSocketPort
           
protected static java.lang.String releaseString
           
 
Constructor Summary
Crm()
          The main constructor for the Crm object.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Receives an ActionEvent, determines the source and performs instructions accordingly.
 void addActionListener(java.awt.event.ActionListener listener)
          Adds a listener to the action listener list within this class.
static void addGuiHost(java.lang.String hostName)
          Adds a hostname to the GUI hostname list
static void addXmlTraffic(ca.nrc.widar.jaxb.crm.XmlTraffic xmlTraffic)
          This method adds an XmlTraffic object to the xmlTrafficList buffer maintained by the CRM
static void clearXmlTraffic()
          Clears the current XmlTraffic buffer of all objects
protected  void fireActionEvent(java.awt.event.ActionEvent event)
          Generates an action event for each class listed in the listener list, and calls the actionPerformed method in that class.
static Crm.CorrMode getCorrMode()
          Return the correlator mode
static java.lang.String getCrmDescriptor()
          Return the current CRM mode string description
static Crm.CrmMode getCrmMode()
          Return the current CRM mode variable
static java.lang.String getDbInfoHtml()
          Returns an HTML string indicating the status of the CrmDb Server
static long getFreeMemory()
          Returns a long integer containing the amount of free memory available within the CRM Java Virtual Machine (JVM)
static java.util.ArrayList<java.lang.String> getGuiHostList()
          Returns the GUI hostname list
static java.lang.String getHostInfo()
           
static java.lang.String getLfrInfoHtml()
          Returns an HTML string indicating the status of the LFR
static java.lang.Integer getLfrPort()
          Returns the Lag Frame Receiver port identifier
static long getMaxMemory()
          Returns a long integer containing the maximum amount of memory currently available to the CRM JVM
static java.lang.String getModelInfoHtml()
          Returns an HTML string indicating the status of the Correlator Model within the CRM Server
static int getNumThreads()
          Returns the current number of conturrent threads within the JVM
static long getOpenFileDescriptorCount()
           
static java.lang.String getQueueInfoHtml()
          Returns an HTML string indicating the status of the CRM Queue
 java.lang.String getReleaseInfo()
          Obtains and returns the release info string for this instantiation of the CRM.
static java.lang.String getReleaseString()
           
static java.util.Date getStartTime()
          Returns to the caller the Date value indicating the instantiation time for this instance of the CRM Server
static long getTotalMemory()
          Returns a long integer containing the amount of total memory currently available to the CRM JVM
static java.lang.String getUpTime()
          Returns the instantiation time in String format
static int getXmlTrafficCount()
          Returns the number of XmlTraffic objects currently within the buffer
static java.util.ArrayList getXmlTrafficList()
          Returns a copy of the ArrayList containing the XmlTraffic buffer
static boolean isBlbHSXmlConfigAlive()
           
static boolean isDbAlive()
          Returns the basic operational state of the CRM Database server
static boolean isDbMode()
          Returns the DB Server mode flag
static boolean isDebugMode()
          Returns the Debug Mode flag
static boolean isDiagMode()
          Returns the Diagnostic mode flag
static boolean isDiagQueueAlive()
          Returns the basic operational status of the Diagnostic Queue
static boolean isGuiHost(java.lang.String hostName)
          Returns a boolean indicating whether or not the supplied GUI hostName is included in the CRM GUI Host list
static boolean isLfrAlive()
          Returns the basic operational status of the Lag Frame Receiver.
static boolean isLfrSocketOpen()
          Returns the basic operational status of the Lag Frame Receiver Socket
static boolean isXmlMonitorMode()
          Returns the xmlMonitorMode flag
protected static void killDb()
          Interrupts and kills the database connection thread.
protected static void killDiagQueue()
          Interrupts and kills the Diagnostic Queue.
protected static void killLfr()
          Interrupts and kills the current Lag Frame Receiver thread and closes the socket.
static void lfrRegisterDiagnostic(CrmDiagnostic d)
          Registers a Diagnostic object with the LFR.
static void main(java.lang.String[] args)
          The Main method
protected static ca.nrc.widar.jaxb.crm.XmlTraffic newXmlTraffic(ca.nrc.widar.jaxb.crm.XmlTraffic tXml, java.lang.String destIp, java.lang.String destContext, java.lang.String className, java.lang.String methodName, java.lang.Boolean safeMode, java.lang.String text)
          Creates and returns a new XmlTraffic JAXB object populated with the specified parameters
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes a listener from the action listener list within this class.
static void removeGuiHost(java.lang.String hostName)
          Removes a hostname from the GUI hostname list
static void setDebugMode(boolean mode)
          Sets the Debug Mode status to the provided value
static void setXmlMonitorMode(boolean mode)
          Sets the xmlMonitorMode status to the provided value
static void showMemoryUsage(java.lang.String className)
          Prints a memory usage summary (including thread count) to the console
static void showThreadSummary()
          Prints a Thread Summary to the console
protected  void startCorrelatorModel()
          Instantiates a Correlator Model to be used by the CRM Server
protected static void startDb(ca.nrc.widar.jaxb.crm.CrmDbInfo cdiXml)
          Instantiates the CRM Database server if it has not already happened.
protected static void startDiagQueue()
          Starts the CrmDiagnosticQueue
protected static void startHttpServer()
          Initializes the HTTP server to listen at the specified port number
protected static void startLfr(int port)
          Starts the Lag Frame Receiver thread.
protected static void startLfrSocket(int port)
          Starts the Lag Frame Receiver Socket at the specified port
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cd

protected static CrmDb cd

cbxc

protected static CrmBlbHSXmlConfig cbxc

cm

protected static CrmCorrelatorModel cm

cq

protected static CrmDiagnosticQueue2 cq

clfr

protected static CrmLagFrameReceiver clfr

cbfa

protected static CrmBlfFileAnalyzer cbfa

crmJaxbContext

protected static javax.xml.bind.JAXBContext crmJaxbContext

configFileString

protected static java.lang.String configFileString

configUrlString

protected static java.lang.String configUrlString

crmHostString

protected static java.lang.String crmHostString

releaseString

protected static java.lang.String releaseString

crmHost

protected static java.net.InetAddress crmHost

lfrSocket

protected static java.net.DatagramSocket lfrSocket

lfrSocketPort

protected static final java.lang.Integer lfrSocketPort
Constructor Detail

Crm

public Crm()
The main constructor for the Crm object. This method initializes all the pertinent CRM services and continues to run in the background until it is killed by an external signal (yet to be implemented)

Parameters:
config - A string indicating a configuration mode that the Crm should be initialized for. Currently, this can be either 'drao' or 'nrao' and is intended to allow the Crm to determine where it is being run. This may be deprecated in the near future.
Method Detail

startHttpServer

protected static void startHttpServer()
Initializes the HTTP server to listen at the specified port number

Parameters:
port - An integer port identifier

getLfrPort

public static java.lang.Integer getLfrPort()
Returns the Lag Frame Receiver port identifier

Returns:
An integer port ID

startLfr

protected static void startLfr(int port)
Starts the Lag Frame Receiver thread.

Parameters:
port - The integer port number for the LFR.

startLfrSocket

protected static void startLfrSocket(int port)
Starts the Lag Frame Receiver Socket at the specified port

Parameters:
port - The integer port number for the socket.

killLfr

protected static void killLfr()
Interrupts and kills the current Lag Frame Receiver thread and closes the socket.


startCorrelatorModel

protected void startCorrelatorModel()
Instantiates a Correlator Model to be used by the CRM Server

Parameters:
model - The (optional) String filename of a correlator model if thta model is to be obtained from a file, otherwise, null indicating that the model is to be obtained by probing the Correlator

startDiagQueue

protected static void startDiagQueue()
Starts the CrmDiagnosticQueue


killDiagQueue

protected static void killDiagQueue()
Interrupts and kills the Diagnostic Queue.


startDb

protected static void startDb(ca.nrc.widar.jaxb.crm.CrmDbInfo cdiXml)
Instantiates the CRM Database server if it has not already happened. This method is also called to restart the CrmDb server, or to login to a new database, requiring that a new set of login parameters are provided via the CrmDbInfo input parameter.

Parameters:
cdiXml - A CrmDbInfo object containing CrmDb parameters, or null if the default parameters are to be used.

killDb

protected static void killDb()
Interrupts and kills the database connection thread.


isBlbHSXmlConfigAlive

public static boolean isBlbHSXmlConfigAlive()

isLfrAlive

public static boolean isLfrAlive()
Returns the basic operational status of the Lag Frame Receiver.

Returns:
A boolean true if the LFR is alive, false otherwise.

isLfrSocketOpen

public static boolean isLfrSocketOpen()
Returns the basic operational status of the Lag Frame Receiver Socket

Returns:
A boolean true if the LFR socket is open and bound, false otherwise.

isDiagQueueAlive

public static boolean isDiagQueueAlive()
Returns the basic operational status of the Diagnostic Queue

Returns:
A boolean true if the Queue is running, false otherwise

isDbAlive

public static boolean isDbAlive()
Returns the basic operational state of the CRM Database server

Returns:
A boolean true if the DB server is connected and running, false otherwise

isDebugMode

public static boolean isDebugMode()
Returns the Debug Mode flag

Returns:
A boolean indicating the Debug Mode status

isXmlMonitorMode

public static boolean isXmlMonitorMode()
Returns the xmlMonitorMode flag

Returns:
A boolean indicating the XML Traffic Mode status

getCorrMode

public static Crm.CorrMode getCorrMode()
Return the correlator mode

Returns:
A CorrMode enumeration value indicating the current correlator mode of this instance of CRM

getCrmMode

public static Crm.CrmMode getCrmMode()
Return the current CRM mode variable

Returns:
A CrmMode enumeration value indicating the current mode of this instance of CRM

getCrmDescriptor

public static java.lang.String getCrmDescriptor()
Return the current CRM mode string description

Returns:
A String describing the current mode of this instance of CRM

isDbMode

public static boolean isDbMode()
Returns the DB Server mode flag

Returns:
A boolean true if CRM is in Database server mode, false otherwise.

isDiagMode

public static boolean isDiagMode()
Returns the Diagnostic mode flag

Returns:
A boolean true if CRM is in Diagnostic server mode, false otherwise.

setDebugMode

public static void setDebugMode(boolean mode)
Sets the Debug Mode status to the provided value

Parameters:
mode - The new debug state

setXmlMonitorMode

public static void setXmlMonitorMode(boolean mode)
Sets the xmlMonitorMode status to the provided value

Parameters:
mode - The new xmlMonitorMode state

getStartTime

public static java.util.Date getStartTime()
Returns to the caller the Date value indicating the instantiation time for this instance of the CRM Server

Returns:
A java.util.Date representing the time this instance of CRM Server was instantiated

getUpTime

public static java.lang.String getUpTime()
Returns the instantiation time in String format

Returns:
The String format of the CRM Server instantiation time

getReleaseInfo

public java.lang.String getReleaseInfo()
Obtains and returns the release info string for this instantiation of the CRM. Release information is obtained from the release.txt b file that is stored within the crm.jar. The string returned is simply a date format indicating the compile date and time for this instantiation of the CRM package.

Returns:
A String indicating the date and time of compile

getReleaseString

public static java.lang.String getReleaseString()
Returns:
The release info String for the CRM Server

getHostInfo

public static java.lang.String getHostInfo()
Returns:
The Host info String for the CRM Server

getModelInfoHtml

public static java.lang.String getModelInfoHtml()
Returns an HTML string indicating the status of the Correlator Model within the CRM Server

Returns:
An HTML formatted String

getQueueInfoHtml

public static java.lang.String getQueueInfoHtml()
Returns an HTML string indicating the status of the CRM Queue

Returns:
An HTML formatted string

getLfrInfoHtml

public static java.lang.String getLfrInfoHtml()
Returns an HTML string indicating the status of the LFR

Returns:
An HTML formatted string

getDbInfoHtml

public static java.lang.String getDbInfoHtml()
Returns an HTML string indicating the status of the CrmDb Server

Returns:
An HTML formatted string

lfrRegisterDiagnostic

public static void lfrRegisterDiagnostic(CrmDiagnostic d)
                                  throws java.lang.Exception
Registers a Diagnostic object with the LFR. This is done by calling the LFR's registerDiagnostic method, along with adding the LFR to the Diagnostic actionListenerList. This method is here due to its static nature.

Throws:
java.lang.Exception
Parameters:
d - A valid, initialized CrmDiagnostic object

addXmlTraffic

public static void addXmlTraffic(ca.nrc.widar.jaxb.crm.XmlTraffic xmlTraffic)
This method adds an XmlTraffic object to the xmlTrafficList buffer maintained by the CRM

Parameters:
xmlTraffic - An XmlTraffic object

getXmlTrafficList

public static java.util.ArrayList getXmlTrafficList()
Returns a copy of the ArrayList containing the XmlTraffic buffer

Returns:
An ArrayList containing all XmlTraffic objects currently within the buffer

getXmlTrafficCount

public static int getXmlTrafficCount()
Returns the number of XmlTraffic objects currently within the buffer

Returns:
An integer number of XmlTraffic objects

clearXmlTraffic

public static void clearXmlTraffic()
Clears the current XmlTraffic buffer of all objects


newXmlTraffic

protected static ca.nrc.widar.jaxb.crm.XmlTraffic newXmlTraffic(ca.nrc.widar.jaxb.crm.XmlTraffic tXml,
                                                                java.lang.String destIp,
                                                                java.lang.String destContext,
                                                                java.lang.String className,
                                                                java.lang.String methodName,
                                                                java.lang.Boolean safeMode,
                                                                java.lang.String text)
Creates and returns a new XmlTraffic JAXB object populated with the specified parameters

Parameters:
tXml - An empty XmlTraffic object
destIp - The destination IP string
destContext - A string describing the context of the destination application
className - A string representation of the classname (originating class)
methodName - A string representation of the method name (originating method)
text - The text of the xml traffic
Returns:
An XmlTraffic JAXB object

addGuiHost

public static void addGuiHost(java.lang.String hostName)
Adds a hostname to the GUI hostname list

Parameters:
hostName - A String including the hostName of a GUI that is currently connected to the CRM

removeGuiHost

public static void removeGuiHost(java.lang.String hostName)
Removes a hostname from the GUI hostname list

Parameters:
hostName - A String including the hostName of a GUI that is to be removed from the CRM GUI HostName list

isGuiHost

public static boolean isGuiHost(java.lang.String hostName)
Returns a boolean indicating whether or not the supplied GUI hostName is included in the CRM GUI Host list

Parameters:
hostName - A String including the hostName of the GUI that is to be checked against the current GUI host list
Returns:
A boolean indicating the state of the provided hostname against the GUI host name list

getGuiHostList

public static java.util.ArrayList<java.lang.String> getGuiHostList()
Returns the GUI hostname list

Returns:
An ArrayList, the contents of which is a list of hostNames for CRM GUI client hosts currently connected to the CRM

getOpenFileDescriptorCount

public static long getOpenFileDescriptorCount()

getFreeMemory

public static long getFreeMemory()
Returns a long integer containing the amount of free memory available within the CRM Java Virtual Machine (JVM)

Returns:
A long integer describing the amount of free memory in the JVM (bytes)

getTotalMemory

public static long getTotalMemory()
Returns a long integer containing the amount of total memory currently available to the CRM JVM

Returns:
A long integer describing the amount of total memory available to the JVM (bytes)

getMaxMemory

public static long getMaxMemory()
Returns a long integer containing the maximum amount of memory currently available to the CRM JVM

Returns:
A long integer describing the maximum amount of memory available to the JVM (bytes)

getNumThreads

public static int getNumThreads()
Returns the current number of conturrent threads within the JVM

Returns:
The number of current threads within the JVM

showThreadSummary

public static void showThreadSummary()
Prints a Thread Summary to the console


showMemoryUsage

public static void showMemoryUsage(java.lang.String className)
Prints a memory usage summary (including thread count) to the console


addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds a listener to the action listener list within this class.

Parameters:
listener - The class being added to the listener list.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes a listener from the action listener list within this class.

Parameters:
listener - The class being removed from the listener list.

fireActionEvent

protected void fireActionEvent(java.awt.event.ActionEvent event)
Generates an action event for each class listed in the listener list, and calls the actionPerformed method in that class.

Parameters:
event - The event being fired.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Receives an ActionEvent, determines the source and performs instructions accordingly. This is the action event handling method.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The incoming action event.

main

public static void main(java.lang.String[] args)
The Main method

Parameters:
args - The String array containing any arguments

NRAO/DRAO

National Radio Astronomy Observatory