org.alfresco.bm.server
Class BMServer

java.lang.Object
  extended by org.alfresco.bm.server.BMServer
All Implemented Interfaces:
EventListener, ConfigConstants, org.alfresco.config.ConfigChildListener, org.alfresco.config.ConfigDataListener, org.I0Itec.zkclient.IZkStateListener, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>

public class BMServer
extends Object
implements ConfigConstants, org.alfresco.config.ConfigDataListener, org.alfresco.config.ConfigChildListener, org.I0Itec.zkclient.IZkStateListener, org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>, org.springframework.context.ApplicationContextAware

Top level Benchmark Server driver class.

Since:
1.0
Author:
Derek Hulley

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.alfresco.bm.server.ConfigConstants
ConfigConstants.RunState
 
Field Summary
 
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
BMServer(org.alfresco.config.ConfigService configService, String cluster)
          Constructor as used by Spring context
 
Method Summary
 void checkTestRunsForRestart()
          Prompt the server to perform a check of the loaded test runs in case they have changed state.
 void childrenChanged(String path)
           
 void dataChanged(String path, boolean deleted)
          Triggers a restart whenever the cluster configuration change is made.
 org.springframework.context.support.AbstractApplicationContext getApplicationContext()
          Get the application context that the server is using
 String getCluster()
          Get the name of the cluster that the server will join
 ConfigConstants.RunState getDesiredRunState()
           
 ConfigConstants.RunState getRunState()
           
 String getServerId()
           
 void handleNewSession()
           
 void handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState state)
          Triggers a restart
static void main(String... args)
          Real main method
 void onApplicationEvent(org.springframework.context.event.ApplicationContextEvent event)
          Starts up application contexts as required.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
          Stores the application context for use by the tests.
 void setDesiredRunState(ConfigConstants.RunState runState)
          Sets the desired run state and notifies listeners (main thread).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BMServer

public BMServer(org.alfresco.config.ConfigService configService,
                String cluster)
Constructor as used by Spring context

Method Detail

main

public static void main(String... args)
Real main method

Parameters:
args - command line arguments

getCluster

public String getCluster()
Get the name of the cluster that the server will join

Returns:
Returns one of {zkPath}/clusters/*

getRunState

public ConfigConstants.RunState getRunState()
Returns:
the run state for the server as set at startup

getDesiredRunState

public ConfigConstants.RunState getDesiredRunState()
Returns:
get the desired run state for the server

setDesiredRunState

public void setDesiredRunState(ConfigConstants.RunState runState)
Sets the desired run state and notifies listeners (main thread).

Parameters:
runState - the desired server run state

getApplicationContext

public org.springframework.context.support.AbstractApplicationContext getApplicationContext()
Get the application context that the server is using

Returns:
the server's application context or null if it has not been set

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Stores the application context for use by the tests.

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Parameters:
applicationContext - the server's application context
Throws:
org.springframework.beans.BeansException

getServerId

public String getServerId()
Returns:
Returns the unique server identifier

handleStateChanged

public void handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState state)
                        throws Exception
Triggers a restart

Specified by:
handleStateChanged in interface org.I0Itec.zkclient.IZkStateListener
Throws:
Exception

handleNewSession

public void handleNewSession()
                      throws Exception
Specified by:
handleNewSession in interface org.I0Itec.zkclient.IZkStateListener
Throws:
Exception

checkTestRunsForRestart

public void checkTestRunsForRestart()
Prompt the server to perform a check of the loaded test runs in case they have changed state.

It is necessary to do this from an external source because ZooKeeper-prompted actions cannot shut down the ZooKeeper instance.


dataChanged

public void dataChanged(String path,
                        boolean deleted)
Triggers a restart whenever the cluster configuration change is made. The entire server configuration is invalid.

Specified by:
dataChanged in interface org.alfresco.config.ConfigDataListener

childrenChanged

public void childrenChanged(String path)
Specified by:
childrenChanged in interface org.alfresco.config.ConfigChildListener

onApplicationEvent

public void onApplicationEvent(org.springframework.context.event.ApplicationContextEvent event)
Starts up application contexts as required.

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


Copyright © 2012. All Rights Reserved.