deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.portal.owswatch
Class ServiceWatcher

java.lang.Object
  extended by java.lang.Thread
      extended by org.deegree.portal.owswatch.ServiceWatcher
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class ServiceWatcher
extends java.lang.Thread
implements java.io.Serializable

Mail class of this framework. Its called upon starting tomcat to start watching services and test them regularly according to their test intervals and logs the result through its service invoker

Version:
$Revision: 20271 $, $Date: 2009-10-21 13:07:15 +0200 (Mi, 21 Okt 2009) $
Author:
Moataz Elmasry, last edited by: $Author: jmays $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServiceWatcher()
           
 
Method Summary
protected  void addActiveService(ServiceConfiguration service)
          Adds an active service to the list of active services.
 void addService(ServiceConfiguration service, ServiceLog servicelog)
          adds a new Service to the ServiceList
 void compileDownTimeReport(java.lang.String webinfPath, OwsWatchConfig conf)
          This function is called on starting tomcat.
 boolean containsService(int serviceId)
           
protected  java.lang.String createDownTimeReportBody(java.util.Hashtable<java.lang.Integer,java.lang.String> missedTests)
          Create the content of the down time time report
 void execute(int serviceId)
          executes the given service one time in the main thread
 ServiceConfiguration getService(int serviceId)
          returns the service identified by its Id in the serviceList
 java.util.List<ServiceConfiguration> getServiceList()
          returns list of services being watched
 java.util.Map<ServiceConfiguration,ServiceLog> getServiceLogs()
           
 java.util.Map<java.lang.Integer,ServiceConfiguration> getServices()
           
 boolean isThreadsuspended()
           
 void refreshAllServices()
          RefreshAllServices executes all the requests in the active monitors, and subtract the time from those who are waiting in line and restarts the time for those who had a turn This is the default to be called during the regular tests.
 ServiceConfiguration removeService(int serviceId)
          removes the service identify by -id- from the ServiceList
 void run()
           
 void setThreadsuspended(boolean threadsuspended)
           
 void startServiceConfiguration(int serviceId)
          This method will set the threadSuspended vaiable to false in order for the id-th service to restart sending requests
 void stopServiceConfiguration(int serviceId)
          This method will set the threadSuspended vaiable to true in order for the id-th service to stop sending GetCapabilities requests
protected  void writeAndSendTimeDownEmail(java.util.Hashtable<java.lang.Integer,java.lang.String> missedTests, OwsWatchConfig conf)
          Authors the down time report and sends it to the designated users
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceWatcher

public ServiceWatcher()
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

addService

public void addService(ServiceConfiguration service,
                       ServiceLog servicelog)
adds a new Service to the ServiceList

Parameters:
service -
servicelog -

addActiveService

protected void addActiveService(ServiceConfiguration service)
Adds an active service to the list of active services. It also sets when the first test should take place. This is useful to start tests at :00 :15 :30 minutes etc..

Parameters:
service -

getService

public ServiceConfiguration getService(int serviceId)
returns the service identified by its Id in the serviceList

Parameters:
serviceId -
Returns:
ServiceConfiguration

removeService

public ServiceConfiguration removeService(int serviceId)
removes the service identify by -id- from the ServiceList

Parameters:
serviceId -
Returns:
new ServiceConfiguration

stopServiceConfiguration

public void stopServiceConfiguration(int serviceId)
This method will set the threadSuspended vaiable to true in order for the id-th service to stop sending GetCapabilities requests

Parameters:
serviceId -

startServiceConfiguration

public void startServiceConfiguration(int serviceId)
This method will set the threadSuspended vaiable to false in order for the id-th service to restart sending requests

Parameters:
serviceId -

containsService

public boolean containsService(int serviceId)
Parameters:
serviceId -
Returns:
true if the currrent Service id at all exists in watcher, false otherwise

getServiceList

public java.util.List<ServiceConfiguration> getServiceList()
returns list of services being watched

Returns:
the serviceList

refreshAllServices

public void refreshAllServices()
RefreshAllServices executes all the requests in the active monitors, and subtract the time from those who are waiting in line and restarts the time for those who had a turn This is the default to be called during the regular tests. If you want to execute tests in the main thread and without affecting the regular tests executeTest(int) and executeall()


execute

public void execute(int serviceId)
executes the given service one time in the main thread

Parameters:
serviceId -

compileDownTimeReport

public void compileDownTimeReport(java.lang.String webinfPath,
                                  OwsWatchConfig conf)
This function is called on starting tomcat. It checks when was the last test performed before tomcat was shutdown. and sends an email to the user, notifying him with the situation and that a number of tests have been missed

Parameters:
webinfPath - WEB-INF folder path
conf - owsWatch configuration instance

writeAndSendTimeDownEmail

protected void writeAndSendTimeDownEmail(java.util.Hashtable<java.lang.Integer,java.lang.String> missedTests,
                                         OwsWatchConfig conf)
Authors the down time report and sends it to the designated users

Parameters:
missedTests - a hastable containing the missed tests
conf - owsWatchConfiguration

createDownTimeReportBody

protected java.lang.String createDownTimeReportBody(java.util.Hashtable<java.lang.Integer,java.lang.String> missedTests)
Create the content of the down time time report

Parameters:
missedTests -
Returns:
the down time report

getServices

public java.util.Map<java.lang.Integer,ServiceConfiguration> getServices()
Returns:
A map of all services

getServiceLogs

public java.util.Map<ServiceConfiguration,ServiceLog> getServiceLogs()
Returns:
Map key = ServiceConfiguration id

isThreadsuspended

public boolean isThreadsuspended()
Returns:
true if thread is suspended, false otherwise

setThreadsuspended

public void setThreadsuspended(boolean threadsuspended)
Parameters:
threadsuspended -

deegree 2.5 (2011/06/29 09:44 build-8-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org