org.alfresco.bm.server
Class EventController

java.lang.Object
  extended by java.lang.Thread
      extended by org.alfresco.bm.server.EventController
All Implemented Interfaces:
Runnable, EventListener, ConfigConstants, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>

public class EventController
extends Thread
implements org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>, org.springframework.context.ApplicationContextAware, ConfigConstants

A master controlling thread that ensures that:

Application events are monitored to start, stop and otherwise control the threads.

Since:
1.0
Author:
Derek Hulley

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Nested classes/interfaces inherited from interface org.alfresco.bm.server.ConfigConstants
ConfigConstants.RunState
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface org.alfresco.bm.server.ConfigConstants
DEFAULT_RUNSTATE, DEFAULT_SERVER_ID, EXT_JAR, EXT_PROPERTIES, EXT_XML, PATH_CLASSES, PATH_CLUSTER_PROPERTIES, PATH_CLUSTERS, PATH_CONFIG, PATH_JARS, PATH_LOADED, PATH_RUN_PROPERTIES, PATH_RUNS, PATH_SERVER, PATH_SERVERS, PATH_TEST_CONTEXT, PATH_TEST_PROPERTIES, PATH_TESTS, PROP_CLUSTER, PROP_CONTROL_RUN_STATE, PROP_EVENT_PROCESSOR_THREADS, PROP_HTTP_CONNECTION_MAX, PROP_HTTP_CONNECTION_TIMEOUT_MS, PROP_HTTP_SOCKET_TIMEOUT_MS, PROP_MONGO_URI, PROP_SERVER_ID, PROP_TEST_NAME, PROP_TEST_RUN_FQN, PROP_TEST_RUN_NAME, SEPARATOR
 
Constructor Summary
EventController(String serverId, String testRunFqn, EventService eventService, EventProcessorRegistry eventProcessors, ExecutorService executor, ResultService resultService)
          Construct the controller
 
Method Summary
 void onApplicationEvent(org.springframework.context.event.ApplicationContextEvent event)
          The application context is started externally but may be stopped internally
 void run()
           
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
          Record the application context for shutdown once processing has finished
 void setQueuePollTimeMs(long queuePollTimeMs)
          The time between polls of the event provider.
 void setQueueRestAgeMs(long queueRestAgeMs)
          Set the time allowed before events can be requeued.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventController

public EventController(String serverId,
                       String testRunFqn,
                       EventService eventService,
                       EventProcessorRegistry eventProcessors,
                       ExecutorService executor,
                       ResultService resultService)
Construct the controller

Parameters:
serverId - the server controlling the events
testRunFqn - the fully qualified name of the test run
eventService - the source of events that will be pushed for execution
eventProcessors - the registry of processors for events
executor - the service that will provide the worker threads for processing
resultService - the service used to store and retrieve event results
Method Detail

setQueuePollTimeMs

public void setQueuePollTimeMs(long queuePollTimeMs)
The time between polls of the event provider. Default is DEFAULT_QUEUE_POLL_TIME_MS.

Parameters:
queuePollTimeMs - the time between checks for events

setQueueRestAgeMs

public void setQueueRestAgeMs(long queueRestAgeMs)
Set the time allowed before events can be requeued. Default is DEFAULT_QUEUE_REST_AGE_MS.


setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Record the application context for shutdown once processing has finished

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

onApplicationEvent

public void onApplicationEvent(org.springframework.context.event.ApplicationContextEvent event)
The application context is started externally but may be stopped internally

Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>

run

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


Copyright © 2012. All Rights Reserved.