com.isti.quakewatch.util
Class QWCorbaConnector

java.lang.Object
  extended by com.isti.quakewatch.util.QWAbstractConnector
      extended by com.isti.quakewatch.util.QWCorbaConnector

public class QWCorbaConnector
extends QWAbstractConnector

Class QWCorbaConnector manages the QuakeWatch host connection and the CORBA-event-channel used to receive XML text messages.


Nested Class Summary
protected  class QWCorbaConnector.EventChannelConnectThread
          Class EventChannelConnectThread defines a thread used to connect to the CORBA event channel.
protected  class QWCorbaConnector.EventChannelDisconnectThread
          Class EventChannelDisconnectThread defines a thread used to disconnect from the CORBA event channel.
 
Nested classes/interfaces inherited from class com.isti.quakewatch.util.QWAbstractConnector
QWAbstractConnector.ServerHostInfo, QWAbstractConnector.StatusCheckFailedException
 
Field Summary
protected  AddrPortListMgr altServersListMgr
           
protected  java.lang.String clientHostAddress
           
protected  int clientPortNum
           
protected  ConnectRejectCallBack connectRejectCallBackObj
           
protected static long CONNFAIL_WARN_TIMEMS
          Time elapsed before logging connect-fail msgs at warning level.
protected  java.lang.String errorMessage
           
protected  QWCorbaConnector.EventChannelConnectThread evtChConnectThreadObj
           
protected  java.lang.Object evtChConnThreadSyncObj
           
protected  QWCorbaConnector.EventChannelDisconnectThread evtChDisconnectThreadObj
           
protected  java.lang.Object evtChDisconnThreadSyncObj
           
protected  EvtChManager evtChManagerObj
           
protected  long lastConnectAttemptTime
           
protected  long lastConnectSessionTime
           
protected  long lastConnectSuccessTime
           
protected  MessageProcessor msgProcessorObj
           
protected  OrbManager orbManagerObj
           
protected  java.lang.String[] programArgs
           
static java.lang.String QWACCEPTOR_REFSTR
          Reference string for QWAcceptor object on server ("QWAcceptor").
protected  QWServices qwServicesObj
           
protected  java.lang.Object qwServicesSyncObj
           
protected  boolean reqServerMsgsAvailFlag
           
protected  boolean reqSourcedMsgsAvailFlag
           
 
Fields inherited from class com.isti.quakewatch.util.QWAbstractConnector
acceptorRejectIDString, acceptorRejectReasonStr, certificateFileDataArr, connAttemptFailedFlag, connAttemptRejectedFlag, connAttemptStartedFlag, connectDoneFlag, connectionInfoPropsString, connectionPasswordString, connectionUserNameString, connInvalidatedFlag, connStatusObj, disconnectClientServicesFlag, disconnectDoneFlag, encryptDecryptUtilObj, filterDomainTypeListStr, filterEventTypeArr, logObj, prevStatusMsgTypeNameStr, REQMSGS_NUM_RETRIES, serverHostInfoObj, serverIdNameString, serverRepHostAddrString, serverRevisionString, statusMsgTypeNameStr, statusReportDataAvailFlag
 
Constructor Summary
QWCorbaConnector(ConnectRejectCallBack connectRejectCallBackObj, java.lang.String[] programArgs, MessageProcessor msgProcessorObj, AddrPortListMgr altServersListMgr, ConnStatusInterface connStatusObj, LogFile logObj)
          Creates a manager for the CORBA-event-channel used to receive QuakeWatch XML text messages.
QWCorbaConnector(ConnectRejectCallBack connectRejectCallBackObj, java.lang.String[] programArgs, MessageProcessor msgProcessorObj, AddrPortListMgr altServersListMgr, ConnStatusInterface connStatusObj, LogFile logObj, java.lang.String clientHostAddress, int clientPortNum)
          Creates a manager for the CORBA-event-channel used to receive QuakeWatch XML text messages.
 
Method Summary
 void closeEventChannel()
          Close the CORBA event channel.
 boolean disconnectConsumerFromChannel()
          Disconnects the consumer implementation from the event channel (if connected).
protected  boolean doDisconnectClientServices()
          Performs the work of disconnecting this client from the server services.
 java.lang.String fetchClientUpgradeInfoFromServer()
          Returns information about available client-program upgrades via the QWServices 'getClientUpgradeInfo()' method.
 java.lang.String fetchRedirectedServerLoc()
          Returns the location of the server that the client is being redirected to.
 java.lang.String getClientHostAddress()
          Returns the client host address given to this manager.
 int getClientPortNum()
          Returns the client port number given to this manager.
 boolean getConnectedFlag()
          Returns the connection status of the event channel.
 java.lang.String getEnteredHostAddress()
          Returns the host address entered into the CORBA ORB.
 boolean getInitializedFlag()
          Returns the "initialized" status of the CORBA connection.
static java.lang.String getOpenOrbVersionStr()
          Returns the OpenORB version string.
 int getOrbPortNum()
          Returns the port number entered into the CORBA ORB.
 java.lang.String getServerIDNameStr()
          Returns the server ID name string (defined in the QWServer's configuration file).
 java.lang.String getServerRepHostAddrStr()
          Returns the host address reported by the server.
 java.lang.String getServerRevisionStr()
          Returns the server revision string.
 java.lang.String getStatusMsgTypeNameStr()
          Returns the type-name string used on status messages sent out by the server.
 java.lang.String getStatusReportData()
          Fetches the latest status-report data from the server.
 long getStatusReportTime()
          Fetches the timestamp value for the latest status report from the server.
 void invalidateConnection()
          Marks the connection as "invalidated", causing the 'getConnectedFlag()' method to return 'false'.
 boolean isReqServerMsgsAvailable()
          Returns an indicator of whether or not the 'requestMessages()' method is available via the 'QWServices' on the current server.
 boolean isStatusReportDataAvail()
          Determines if get-status-report methods are available on the server.
protected  void notifyConnectAttemptRejected(int connStatusVal, java.lang.String connStatusStr)
          Method called when a connect-to-server attempt was rejected.
 boolean performClientStatusCheck()
          Calls the QWServices 'clientStatusCheck()' method.
 void requestServerAliveMsg()
          Requests that the server send an 'Alive' message immediately.
 java.lang.String requestServerMessages(long timeVal, long msgNum, java.lang.String hostMsgNumListStr)
          Requests that messages newer or equal to the specified time value or later than the specified message number be returned from the server.
 void shutdownConnection(boolean showPopupFlag)
          Shuts down the CORBA connection and waits for the disconnect to complete or timeout.
 void startConnectViaHostInfo(java.lang.String serverHostAddrStr, int serverHostPortNum, boolean showPopupFlag)
          Starts a new thread that connects to the event channel via a connection to a QWServer.
 void startDisconnectThread()
          Starts a new thread that disconnects the CORBA connection.
 void terminateConnectChThread(int numWaitSecs)
          Terminates and disposes any event channel connect thread that is running.
 void terminateDisconnectChThread(int numWaitSecs)
          Terminates and disposes any event channel disconnect thread that is running.
 void updateConnectParams(java.lang.String clientHostAddress, int clientPortNum)
          Updates the connection parameters to be used on the next ORB initialization.
 
Methods inherited from class com.isti.quakewatch.util.QWAbstractConnector
autoClearConnStatusPopupDialog, clearConnAttemptFailedFlag, clearConnAttemptRejectedFlag, clearConnAttemptStartedFlag, disconnectClientServices, disconnectClientServices, enterConnectionInfo, getCertificateFileDataArr, getConnAttemptFailedFlag, getConnAttemptRejectedFlag, getConnAttemptStartedFlag, getConnPanelObj, getDecodedStatusReport, getDetailedServerIDString, getServerIDString, setAcceptorRejectIDStr, setConnPanelData, setConnPanelData, setConnPanelInitError, setConnPanelInitError, setConnStatusRefocusComponent, setFilterDomainTypeList, showConnPanelPopup, startConnectViaHostInfo, updateFilterDomainTypeList, userRequestShowConnStatusPopupDialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QWACCEPTOR_REFSTR

public static final java.lang.String QWACCEPTOR_REFSTR
Reference string for QWAcceptor object on server ("QWAcceptor").

See Also:
Constant Field Values

CONNFAIL_WARN_TIMEMS

protected static final long CONNFAIL_WARN_TIMEMS
Time elapsed before logging connect-fail msgs at warning level.

See Also:
Constant Field Values

programArgs

protected final java.lang.String[] programArgs

msgProcessorObj

protected final MessageProcessor msgProcessorObj

clientHostAddress

protected java.lang.String clientHostAddress

clientPortNum

protected int clientPortNum

altServersListMgr

protected final AddrPortListMgr altServersListMgr

errorMessage

protected java.lang.String errorMessage

orbManagerObj

protected OrbManager orbManagerObj

qwServicesObj

protected QWServices qwServicesObj

qwServicesSyncObj

protected final java.lang.Object qwServicesSyncObj

evtChManagerObj

protected EvtChManager evtChManagerObj

connectRejectCallBackObj

protected ConnectRejectCallBack connectRejectCallBackObj

reqSourcedMsgsAvailFlag

protected boolean reqSourcedMsgsAvailFlag

reqServerMsgsAvailFlag

protected boolean reqServerMsgsAvailFlag

evtChConnectThreadObj

protected QWCorbaConnector.EventChannelConnectThread evtChConnectThreadObj

evtChConnThreadSyncObj

protected final java.lang.Object evtChConnThreadSyncObj

evtChDisconnectThreadObj

protected QWCorbaConnector.EventChannelDisconnectThread evtChDisconnectThreadObj

evtChDisconnThreadSyncObj

protected final java.lang.Object evtChDisconnThreadSyncObj

lastConnectAttemptTime

protected long lastConnectAttemptTime

lastConnectSuccessTime

protected long lastConnectSuccessTime

lastConnectSessionTime

protected long lastConnectSessionTime
Constructor Detail

QWCorbaConnector

public QWCorbaConnector(ConnectRejectCallBack connectRejectCallBackObj,
                        java.lang.String[] programArgs,
                        MessageProcessor msgProcessorObj,
                        AddrPortListMgr altServersListMgr,
                        ConnStatusInterface connStatusObj,
                        LogFile logObj,
                        java.lang.String clientHostAddress,
                        int clientPortNum)
Creates a manager for the CORBA-event-channel used to receive QuakeWatch XML text messages.

Parameters:
connectRejectCallBackObj - call-back object whose method is invoked when a connect-attempt cannot be completed, or null for none.
programArgs - the array of command-line arguments to be passed on to the CORBA ORB.
msgProcessorObj - 'MessageProcessor' object to be used by the CORBA event-channel consumer, or null for none.
altServersListMgr - alternate servers list manager object, or null for none.
connStatusObj - connection-status panel object, or null for none.
logObj - log-file object to be used, or null for none.
clientHostAddress - an IP address to be associated with this client, or null to have the address auto-determined.
clientPortNum - a port address value to be associated with this client, or 0 to have the ORB choose the port address.

QWCorbaConnector

public QWCorbaConnector(ConnectRejectCallBack connectRejectCallBackObj,
                        java.lang.String[] programArgs,
                        MessageProcessor msgProcessorObj,
                        AddrPortListMgr altServersListMgr,
                        ConnStatusInterface connStatusObj,
                        LogFile logObj)
Creates a manager for the CORBA-event-channel used to receive QuakeWatch XML text messages.

Parameters:
connectRejectCallBackObj - call-back object whose method is invoked when a connect-attempt cannot be completed, or null for none.
programArgs - the array of command-line arguments to be passed on to the CORBA ORB.
msgProcessorObj - 'MessageProcessor' object to be used by the CORBA event-channel consumer, or null for none.
altServersListMgr - alternate servers list manager object, or null for none.
connStatusObj - connection-status panel object, or null for none.
logObj - log-file object to be used, or null for none.
Method Detail

updateConnectParams

public void updateConnectParams(java.lang.String clientHostAddress,
                                int clientPortNum)
Updates the connection parameters to be used on the next ORB initialization.

Specified by:
updateConnectParams in class QWAbstractConnector
Parameters:
clientHostAddress - an IP address to be associated with this client, or null to have the address auto-determined.
clientPortNum - a port address value to be associated with this client, or 0 to have the ORB choose the port address.

startConnectViaHostInfo

public void startConnectViaHostInfo(java.lang.String serverHostAddrStr,
                                    int serverHostPortNum,
                                    boolean showPopupFlag)
Starts a new thread that connects to the event channel via a connection to a QWServer.

Specified by:
startConnectViaHostInfo in class QWAbstractConnector
Parameters:
serverHostAddrStr - the host address used to locate the server.
serverHostPortNum - the port number used to locate the server.
showPopupFlag - true to force the connection status popup dialog to be shown.

terminateConnectChThread

public void terminateConnectChThread(int numWaitSecs)
Terminates and disposes any event channel connect thread that is running.

Parameters:
numWaitSecs - number of seconds to wait for thread to finish terminating.

shutdownConnection

public void shutdownConnection(boolean showPopupFlag)
Shuts down the CORBA connection and waits for the disconnect to complete or timeout.

Specified by:
shutdownConnection in class QWAbstractConnector
Parameters:
showPopupFlag - true to force the connection status popup dialog to be shown.

startDisconnectThread

public void startDisconnectThread()
Starts a new thread that disconnects the CORBA connection.


terminateDisconnectChThread

public void terminateDisconnectChThread(int numWaitSecs)
Terminates and disposes any event channel disconnect thread that is running.

Parameters:
numWaitSecs - number of seconds to wait for thread to finish terminating.

disconnectConsumerFromChannel

public boolean disconnectConsumerFromChannel()
Disconnects the consumer implementation from the event channel (if connected). A new thread is launched to perform the work to keep things from getting blocked if the channel disconnect gets "stuck".

Returns:
true if successful (or if consumer not setup), false if timeout occurred before disconnected was confirmed.

closeEventChannel

public void closeEventChannel()
Close the CORBA event channel.


doDisconnectClientServices

protected boolean doDisconnectClientServices()
Performs the work of disconnecting this client from the server services.

Specified by:
doDisconnectClientServices in class QWAbstractConnector
Returns:
true if successful; false if an error occurred.

getServerIDNameStr

public java.lang.String getServerIDNameStr()
Returns the server ID name string (defined in the QWServer's configuration file).

Specified by:
getServerIDNameStr in class QWAbstractConnector
Returns:
The server ID name string, or null if not available.

getServerRepHostAddrStr

public java.lang.String getServerRepHostAddrStr()
Returns the host address reported by the server.

Specified by:
getServerRepHostAddrStr in class QWAbstractConnector
Returns:
The host address reported by the server, or null if not available.

getServerRevisionStr

public java.lang.String getServerRevisionStr()
Returns the server revision string.

Specified by:
getServerRevisionStr in class QWAbstractConnector
Returns:
The server revision string, or null if not available.

getStatusMsgTypeNameStr

public java.lang.String getStatusMsgTypeNameStr()
Returns the type-name string used on status messages sent out by the server. When structured messages are enabled, status messages will be sent with the domain name "StatusMessage" and the type name set to this value. These names can be used on the client side to filter-in the status messages.

Returns:
The type-name string used on status messages sent out by the server (when structured messages are enabled), or null if not available.

requestServerAliveMsg

public void requestServerAliveMsg()
Requests that the server send an 'Alive' message immediately. This allows the connection to the event channel to be verified more quickly.

Specified by:
requestServerAliveMsg in class QWAbstractConnector

isReqServerMsgsAvailable

public boolean isReqServerMsgsAvailable()
Returns an indicator of whether or not the 'requestMessages()' method is available via the 'QWServices' on the current server.

Specified by:
isReqServerMsgsAvailable in class QWAbstractConnector
Returns:
true if the 'requestServerMessages()' method is available, false if not.

requestServerMessages

public java.lang.String requestServerMessages(long timeVal,
                                              long msgNum,
                                              java.lang.String hostMsgNumListStr)
Requests that messages newer or equal to the specified time value or later than the specified message number be returned from the server. If a 'hostMsgNumListStr' value is not given and a non-zero message number is given and the given time value matches then messages with message numbers greater than the given message number are returned; otherwise messages newer or equal to the specified time value are returned (within a tolerance value). If a 'hostMsgNumListStr' value is given then it is used with the QWServices "requestSourced...()" methods (and any given message number is ignored). An XML message containing the messages is returned, using the following format:
 [QWresend NumRequested="10"]
   [QWmessage ...] [/QWmessage]
   [QWmessage ...] [/QWmessage]
   ...
 [/QWresend]
 
(Substitute angle brackets for square brackets.) The number of messages that would be required to fill the request is returned in the "NumRequested" attribute. However, no more than the oldest 'maxResendNumMsgs' number of messages will be returned in any single call to this method (additional calls may be needed to fetch all of the desired messages).

Specified by:
requestServerMessages in class QWAbstractConnector
Parameters:
timeVal - the time-generated value for message associated with the given message number, or the requested time value to be used (milliseconds since 1/1/1970).
msgNum - the message number to use, or 0 or none.
hostMsgNumListStr - a list of feeder-data-source host-name/message-number entries, or null or empty string if the "requestSourced...()" methods should not be used.
Returns:
An XML-formatted string containing the messages, or an empty string if an error occurs.

performClientStatusCheck

public boolean performClientStatusCheck()
                                 throws java.lang.NoSuchMethodException,
                                        QWAbstractConnector.StatusCheckFailedException
Calls the QWServices 'clientStatusCheck()' method.

Specified by:
performClientStatusCheck in class QWAbstractConnector
Returns:
true if the an updated version of the client is available; false if not.
Throws:
java.lang.NoSuchMethodException - if the 'clientStatusCheck()' method is not implemented on the server.
StatusCheckFailedException - if the call to 'clientStatusCheck()' failed with an exception other than 'NoSuchMethodException'.
QWAbstractConnector.StatusCheckFailedException

fetchClientUpgradeInfoFromServer

public java.lang.String fetchClientUpgradeInfoFromServer()
Returns information about available client-program upgrades via the QWServices 'getClientUpgradeInfo()' method.

Specified by:
fetchClientUpgradeInfoFromServer in class QWAbstractConnector
Returns:
An XML-formatted string containing information about available client-program upgrades, or null if an error occurred.

fetchRedirectedServerLoc

public java.lang.String fetchRedirectedServerLoc()
Returns the location of the server that the client is being redirected to. The returned string may also be a comma-separated list of "hostAddr:portNum" entries.

Specified by:
fetchRedirectedServerLoc in class QWAbstractConnector
Returns:
The redirect-server location string in the form "hostAddr:portNum", an empty string if the client is not being redirected, or null if an error occurred.

isStatusReportDataAvail

public boolean isStatusReportDataAvail()
Determines if get-status-report methods are available on the server.

Specified by:
isStatusReportDataAvail in class QWAbstractConnector
Returns:
true if get-status-report methods are available on the server; false if not.

getStatusReportTime

public long getStatusReportTime()
Fetches the timestamp value for the latest status report from the server.

Specified by:
getStatusReportTime in class QWAbstractConnector
Returns:
The timestamp value for the latest status report from the server, or 0 if no report is available or if an error occurred.

getStatusReportData

public java.lang.String getStatusReportData()
Fetches the latest status-report data from the server.

Specified by:
getStatusReportData in class QWAbstractConnector
Returns:
A string containing the latest status-report data from the server, an empty string if no report is available, or null if an error occurred.

notifyConnectAttemptRejected

protected void notifyConnectAttemptRejected(int connStatusVal,
                                            java.lang.String connStatusStr)
Method called when a connect-to-server attempt was rejected. A worker thread and a slight delay are used to give the 'connect' thread a chance to terminate cleanly.

Parameters:
connStatusVal - a value indicating the status of the current connection to the server, one of the 'QWServices.CS_' values.
connStatusStr - a message-string describing the status of the current connection to the server.

getInitializedFlag

public boolean getInitializedFlag()
Returns the "initialized" status of the CORBA connection.

Specified by:
getInitializedFlag in class QWAbstractConnector
Returns:
true if the ORB is initialized.

getClientHostAddress

public java.lang.String getClientHostAddress()
Returns the client host address given to this manager.

Returns:
The client host address (possibly null).

getClientPortNum

public int getClientPortNum()
Returns the client port number given to this manager.

Returns:
The client port number (possibly 0).

getEnteredHostAddress

public java.lang.String getEnteredHostAddress()
Returns the host address entered into the CORBA ORB.

Returns:
The host address entered into the CORBA ORB, or null if none.

getOrbPortNum

public int getOrbPortNum()
Returns the port number entered into the CORBA ORB.

Returns:
The port number entered into the CORBA ORB, or 0 if none.

getConnectedFlag

public boolean getConnectedFlag()
Returns the connection status of the event channel. If 'invalidateConnection()' has been called then this method will return false until the connection is reinitialized.

Specified by:
getConnectedFlag in class QWAbstractConnector
Returns:
true if the connection to the event channel is active, false if not.

invalidateConnection

public void invalidateConnection()
Marks the connection as "invalidated", causing the 'getConnectedFlag()' method to return 'false'.

Specified by:
invalidateConnection in class QWAbstractConnector

getOpenOrbVersionStr

public static java.lang.String getOpenOrbVersionStr()
Returns the OpenORB version string.

Returns:
The OpenORB version string.