xmlBlaster 2.2.0 API

org.xmlBlaster.engine.runlevel
Class RunlevelManager

java.lang.Object
  extended by org.xmlBlaster.engine.runlevel.RunlevelManager
All Implemented Interfaces:
RunlevelManagerMBean, I_AdminUsage

public final class RunlevelManager
extends java.lang.Object
implements RunlevelManagerMBean

This starts/stops xmlBlaster with different run levels.

Author:
Marcel Ruff
See Also:
engine.runlevel requirement

Field Summary
private  boolean allowDynamicPlugins
           
private  ContextNode contextNode
           
private  int currRunlevel
           
private  I_RunlevelListener[] DUMMY_ARR
           
private  ServerScope glob
           
private static java.util.logging.Logger log
           
private  JmxMBeanHandle mbeanHandle
          My JMX registration
private  java.lang.String ME
           
static int RUNLEVEL_CLEANUP
           
static int RUNLEVEL_CLEANUP_POST
           
static int RUNLEVEL_CLEANUP_PRE
           
static int RUNLEVEL_HALTED
           
static int RUNLEVEL_HALTED_POST
           
static int RUNLEVEL_HALTED_PRE
           
static int RUNLEVEL_RUNNING
           
static int RUNLEVEL_RUNNING_POST
           
static int RUNLEVEL_RUNNING_PRE
           
static int RUNLEVEL_STANDBY
           
static int RUNLEVEL_STANDBY_POST
           
static int RUNLEVEL_STANDBY_PRE
           
private  java.util.Set runlevelListenerSet
          For listeners who want to be informed about runlevel changes.
 
Constructor Summary
RunlevelManager(ServerScope glob)
          One instance of this represents one xmlBlaster server.
 
Method Summary
private  void addPlugin(PluginConfig pluginConfig)
          Add a new plugin, if it exists remove the old first.
 void addRunlevelListener(I_RunlevelListener l)
          Adds the specified runlevel listener to receive runlevel change events.
 int changeRunlevel(int newRunlevel, boolean force)
          Change the run level to the given newRunlevel.
 int changeRunlevel(java.lang.String newRunlevel, boolean force)
          Allows to pass the newRunlevel as a String like "RUNLEVEL_STANDBY" or "6"
static boolean checkRunlevel(int level)
           
private  int fireRunlevelEvent(int from, int to, boolean force)
          The static plugins are loaded from (exclusive) to (inclusive) when startup and the same when shutting down.
 ContextNode getContextNode()
           
 int getCurrentRunlevel()
          See java for runlevels
 java.lang.String getUsageUrl()
           
 void initJmx()
           
 void initPluginManagers()
          Incarnate the different managers which handle run levels.
 boolean isCleanup()
           
 boolean isHalted()
           
 boolean isMajorLevel()
           
private static boolean isMajorLevel(int level)
           
 boolean isRunning()
           
 boolean isStandby()
           
 java.lang.String publish(SessionInfo sessionInfo, MsgUnit msgUnit, PublishQosServer publishQos)
          Called from RequestBroker when a new plugin XML is arriving.
 void removeRunlevelListener(I_RunlevelListener l)
          Removes the specified listener.
 void setId(java.lang.String id)
          Sets the cluster node ID as soon as it is known.
 java.lang.String setRunlevel(java.lang.String level)
          JMX: Change the run level of xmlBlaster.
 void setUsageUrl(java.lang.String url)
           
 void shutdown()
           
private  void shutdownPlugins(int from, int to)
           
private  void startupPlugins(int from, int to)
           
(package private)  void toggleCreate(PluginConfig pluginConfig, boolean create)
          Called by JMX, throws IllegalArgumentExcetion instead of XmlBlasterException.
static int toRunlevelInt(java.lang.String level)
          Parses given string to extract the priority of a message
static java.lang.String toRunlevelStr(int level)
          Parses given string to extract the priority of a message
 java.lang.String usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

glob

private final ServerScope glob

log

private static java.util.logging.Logger log

currRunlevel

private int currRunlevel

RUNLEVEL_HALTED_PRE

public static final int RUNLEVEL_HALTED_PRE
See Also:
Constant Field Values

RUNLEVEL_HALTED

public static final int RUNLEVEL_HALTED
See Also:
Constant Field Values

RUNLEVEL_HALTED_POST

public static final int RUNLEVEL_HALTED_POST
See Also:
Constant Field Values

RUNLEVEL_STANDBY_PRE

public static final int RUNLEVEL_STANDBY_PRE
See Also:
Constant Field Values

RUNLEVEL_STANDBY

public static final int RUNLEVEL_STANDBY
See Also:
Constant Field Values

RUNLEVEL_STANDBY_POST

public static final int RUNLEVEL_STANDBY_POST
See Also:
Constant Field Values

RUNLEVEL_CLEANUP_PRE

public static final int RUNLEVEL_CLEANUP_PRE
See Also:
Constant Field Values

RUNLEVEL_CLEANUP

public static final int RUNLEVEL_CLEANUP
See Also:
Constant Field Values

RUNLEVEL_CLEANUP_POST

public static final int RUNLEVEL_CLEANUP_POST
See Also:
Constant Field Values

RUNLEVEL_RUNNING_PRE

public static final int RUNLEVEL_RUNNING_PRE
See Also:
Constant Field Values

RUNLEVEL_RUNNING

public static final int RUNLEVEL_RUNNING
See Also:
Constant Field Values

RUNLEVEL_RUNNING_POST

public static final int RUNLEVEL_RUNNING_POST
See Also:
Constant Field Values

DUMMY_ARR

private final I_RunlevelListener[] DUMMY_ARR

mbeanHandle

private JmxMBeanHandle mbeanHandle
My JMX registration


contextNode

private ContextNode contextNode

allowDynamicPlugins

private boolean allowDynamicPlugins

runlevelListenerSet

private final java.util.Set runlevelListenerSet
For listeners who want to be informed about runlevel changes.

Constructor Detail

RunlevelManager

public RunlevelManager(ServerScope glob)
One instance of this represents one xmlBlaster server.

You need to call initPluginManagers() after creation.

Method Detail

initJmx

public void initJmx()

getContextNode

public ContextNode getContextNode()

setId

public void setId(java.lang.String id)
Sets the cluster node ID as soon as it is known.


initPluginManagers

public void initPluginManagers()
                        throws XmlBlasterException
Incarnate the different managers which handle run levels.

Throws:
XmlBlasterException

publish

public final java.lang.String publish(SessionInfo sessionInfo,
                                      MsgUnit msgUnit,
                                      PublishQosServer publishQos)
                               throws XmlBlasterException
Called from RequestBroker when a new plugin XML is arriving.
Allows to send dynamically new plugins
java javaclients.HelloWorldPublish -oid __sys__RunlevelManager -contentFile dynamic.jar -clientProperty[__plugin.jarName] dynamic.jar -clientProperty[__plugin.xml] ""

Parameters:
sessionInfo - The publisher
msgUnit - The content contains the jar file, and some client properties the configuration
publishQos -
Returns:
Throws:
XmlBlasterException

addRunlevelListener

public void addRunlevelListener(I_RunlevelListener l)
Adds the specified runlevel listener to receive runlevel change events. Multiple registrations fo the same listener will overwrite the old one.


removeRunlevelListener

public void removeRunlevelListener(I_RunlevelListener l)
Removes the specified listener.


changeRunlevel

public final int changeRunlevel(java.lang.String newRunlevel,
                                boolean force)
                         throws XmlBlasterException
Allows to pass the newRunlevel as a String like "RUNLEVEL_STANDBY" or "6"

Throws:
XmlBlasterException
See Also:
changeRunlevel(int, boolean)

setRunlevel

public java.lang.String setRunlevel(java.lang.String level)
                             throws java.lang.Exception
JMX: Change the run level of xmlBlaster.

Specified by:
setRunlevel in interface RunlevelManagerMBean
Parameters:
0 - is halted and 9 is fully operational
Throws:
java.lang.Exception

changeRunlevel

public final int changeRunlevel(int newRunlevel,
                                boolean force)
                         throws XmlBlasterException
Change the run level to the given newRunlevel.

See RUNLEVEL_HALTED etc.

Note that there are four main run levels:

and every RUNLEVEL sends a pre and a post run level event, to allow the listeners to prepare or log before or after successfully changing levels.
NOTE that the pre/post events are no run level states - they are just events.

Parameters:
newRunlevel - The new run level we want to switch to
force - Ignore exceptions during change, currently only force == true is supported
Returns:
numErrors
Throws:
XmlBlasterException - for invalid run level

startupPlugins

private void startupPlugins(int from,
                            int to)
                     throws XmlBlasterException
Throws:
XmlBlasterException

toggleCreate

void toggleCreate(PluginConfig pluginConfig,
                  boolean create)
Called by JMX, throws IllegalArgumentExcetion instead of XmlBlasterException.

Parameters:
pluginConfig -
create -

addPlugin

private void addPlugin(PluginConfig pluginConfig)
                throws XmlBlasterException
Add a new plugin, if it exists remove the old first.

Parameters:
pluginConfig -
Throws:
XmlBlasterException

shutdownPlugins

private void shutdownPlugins(int from,
                             int to)
                      throws XmlBlasterException
Throws:
XmlBlasterException

fireRunlevelEvent

private final int fireRunlevelEvent(int from,
                                    int to,
                                    boolean force)
                             throws XmlBlasterException
The static plugins are loaded from (exclusive) to (inclusive) when startup and the same when shutting down. For example if you define LOAD on r 3, and STOP on r 2, then LOAD is fired when from=2,to=3 and STOP when from=3,to=2

Throws:
XmlBlasterException

getCurrentRunlevel

public final int getCurrentRunlevel()
See java for runlevels

Specified by:
getCurrentRunlevel in interface RunlevelManagerMBean
Returns:
0 is halted and 9 is fully operational

isHalted

public boolean isHalted()

isStandby

public boolean isStandby()

isCleanup

public boolean isCleanup()

isRunning

public boolean isRunning()

isMajorLevel

public boolean isMajorLevel()
Returns:
true if one of the major run levels. false if pre or post event level

isMajorLevel

private static final boolean isMajorLevel(int level)

checkRunlevel

public static final boolean checkRunlevel(int level)
Returns:
true if one of the major levels

toRunlevelStr

public static final java.lang.String toRunlevelStr(int level)
Parses given string to extract the priority of a message

Parameters:
level - For example 7
Returns:
"RUNLEVEL_UNKNOWN" if no valid run level, else for example "STANDBY_POST"

toRunlevelInt

public static final int toRunlevelInt(java.lang.String level)
Parses given string to extract the priority of a message

Parameters:
level - For example "STANDBY" or 7
defaultPriority - Value to use if not parseable
Returns:
-10 if no valid run level

shutdown

public void shutdown()

usage

public java.lang.String usage()
Specified by:
usage in interface I_AdminUsage
Returns:
a human readable usage help string

getUsageUrl

public java.lang.String getUsageUrl()
Specified by:
getUsageUrl in interface I_AdminUsage
Returns:
A link on javadoc for JMX usage

setUsageUrl

public void setUsageUrl(java.lang.String url)
Specified by:
setUsageUrl in interface I_AdminUsage

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.