xmlBlaster 2.2.0 API

org.xmlBlaster.engine
Class ServerScope

java.lang.Object
  extended by org.xmlBlaster.util.Global
      extended by org.xmlBlaster.engine.ServerScope
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, I_RunlevelListener

public final class ServerScope
extends Global
implements I_RunlevelListener

This holds global needed data of one xmlBlaster instance.

Author:
Marcel Ruff

Field Summary
private  I_Authenticate authenticate
          the authentication service (a layer around it for security reasons)
private  CbProtocolManager cbProtocolManager
           
private  ClusterManager clusterManager
           
private  CommandManager commandManager
           
private  int currRunlevel
           
private  boolean firstUseAdminManager
           
private  boolean firstUseCluster
           
private  java.lang.String instanceId
          Unique id, even for each restart of a node
private  SessionInfo internalSessionInfo
           
private static java.util.logging.Logger log
           
private  MomClientGateway momClientGateway
           
private  MsgDistributorPluginManager msgDistributorPluginManager
           
private  MsgFileDumper msgFileDumper
           
private  NodeId nodeId
           
private  PluginHolder pluginHolder
           
private  RequestBroker requestBroker
          the xmlBlaster core class
private  RunlevelManager runlevelManager
           
private  Timeout sessionTimer
           
private  SubjectEntryShuffler subjectEntryShuffler
           
private  Timeout telnetSessionTimer
           
private  TopicAccessor topicAccessor
           
private  StoragePluginManager topicStorePluginManager
           
private  Timeout topicTimer
           
private  boolean useAdminManager
           
private  boolean useCluster
           
 
Fields inherited from class org.xmlBlaster.util.Global
addressNormalized, bootstrapAddress, burstModeTimer, cbHostname, cbServerPluginManager, checkpointPlugin, clientSecurityLoader, connectQosFactory, contextNode, counter, disconnectQosFactory, dispatchPluginManager, dispatchWorkerPool, docBuilderFactory, entryFactory, errorText, heapMemoryUsage, id, ip_addr, isDoingShutdown, jdbcConnectionPoolTimer, logChannels, maxFileDescriptorCount, ME, messageTimer, msgKeyFactory, msgQosFactory, nativeCallbackDriverMap, objectMap, objectMapMonitor, pingTimer, property, protocolPluginManager, queryKeyFactory, queryQosFactory, queuePluginManager, saxFactory, scopeContextNode, sequenceNumber, statusQosFactory, totalPhysicalMemorySize, wipeOutDB, xmlBlasterAccess
 
Constructor Summary
ServerScope()
           
ServerScope(java.util.Properties p, boolean loadPropFile)
           
ServerScope(java.lang.String[] args)
          One instance of this represents one xmlBlaster server.
 
Method Summary
 DispatchConnectionsHandler createServerDispatchConnectionsHandler(ServerDispatchManager dispatchManager)
          Returns the callback layer implementation 'CbDispatchConnectionsHandler' on server side.
 void doStorageCleanup(JdbcQueue jdbcQueue)
           
 void finalize()
           
 I_Authenticate getAuthenticate()
           
 CbProtocolManager getCbProtocolManager()
          Initialize cb protocol manager.
 ClusterManager getClusterManager()
          Access instance which manages myself in a cluster environment.
 ClusterManager getClusterManager(SessionInfo sessionInfo)
          Initialize the instance which manages myself in a cluster environment.
 ClusterManager getClusterManagerNoEx()
           
 CommandManager getCommandManager()
          Access instance of remote command administration manager.
 CommandManager getCommandManager(SessionInfo sessionInfo)
          Initialize instance of remote command administration manager.
 ContextNode getContextNode()
          The unique name of this xmlBlaster server instance.
 java.lang.String getDump()
           
 void getDump(java.io.OutputStream out)
           
 I_EntryFactory getEntryFactory()
          The factory creating queue or msgUnitStore entries from persistent store.
 java.lang.String getId()
          Access the unique cluster node id (as a String).
 java.lang.String getInstanceId()
          Unique id of the xmlBlaster server, changes on each restart.
 SessionInfo getInternalSessionInfo()
           
 java.lang.String getLogPrefix()
          Returns for no cluster an empty string, in cluster environment if more than one node is known it returns the node id like "/node/heron".
 java.lang.String getLogPrefixDashed()
          Same as getLogPrefix() but if in cluster environment a "-" is prefixed like "-/node/heron/".
 java.lang.String getLogPrefixDashed(java.lang.String post)
          Returns for no cluster the given post string.
 MomClientGateway getMomClientGateway()
          Access handler to forward messages beginning with "__cmd:" (administrative messages)
 MsgDistributorPluginManager getMsgDistributorPluginManager()
           
 MsgFileDumper getMsgFileDumper()
          A helper to dump a message to a file.
 java.lang.String getName()
          A human readable name of the listener for logging.
 NodeId getNodeId()
          The unique name of this xmlBlaster server instance.
 PluginHolder getPluginHolder()
          gets the object holding all configuration information for the plugins (both for statically loaded plugins (by the run level manager) and dynamically loaded plugins (such plugins loaded on client request).
 RequestBroker getRequestBroker()
           
 int getRunlevel()
           
 RunlevelManager getRunlevelManager()
          Initialize runlevel manager used to start/stop xmlBlaster with different run levels.
 Timeout getSessionTimer()
          Access the handle of the user session timer thread.
 StoragePluginManager getStoragePluginManager()
           
 SubjectEntryShuffler getSubjectInfoShuffler()
           
 Timeout getTelnetSessionTimer()
          Access the handle of the TopicHandler timer thread.
 TopicAccessor getTopicAccessor()
          The singleton to handle all topics and its access.
 Timeout getTopicTimer()
          Access the handle of the TopicHandler timer thread.
 boolean hasTelnetSessionTimer()
           
 int init(java.lang.String[] args)
          Calls super.init and checks the environment for "cluster.node.id"

See private org.xmlBlaster.Main#createNodeId()

private  void initThis()
           
 boolean isAdministrationCommand(XmlKey xmlKey)
           
 boolean isClusterManagerReady()
          Since v1.1 the clusterManager is loaded via xmlBlasterPlugins.xml See useCluster() to check if clustering is switched on First checks if ClusterManager is loaded already and if its state is ready.
 boolean isEmbedded()
          If property -xmlBlaster.isEmbedded true is set we return true here

An embedded server should not do any exit()

 boolean isServerSide()
          Check where we are, on client or on server side? util.Global returns false
 java.lang.String[] peekMessages(I_Queue queue, int numOfEntries, java.lang.String label, boolean forceReadableTimestamp, boolean forceReadableBase64)
           
 java.lang.String[] peekQueueMessagesToFile(I_Queue queue, int numOfEntries, java.lang.String path, java.lang.String label)
          Dumps given amount of messages from queue to file.
 void registerMomClientGateway(MomClientGateway momClientGateway)
          Invoked by CommandManager to register message command handler
 void removeTelnetSessionTimer()
           
 void runlevelChange(int from, int to, boolean force)
          Invoked on run level change, see RunlevelManager.RUNLEVEL_HALTED and RunlevelManager.RUNLEVEL_RUNNING

Enforced by I_RunlevelListener

 void setAuthenticate(I_Authenticate auth)
          Sets the authentication in the engine.Global scope.
 void setClusterManager(ClusterManager clusterManager)
          Implicitely sets useCluster to true
 void setId(java.lang.String id)
          Currently set by enging.Global, used server side only.
 void setInternalSessionInfo(SessionInfo internalSessionInfo)
          Filled by RequestBroker.java
 void setRequestBroker(RequestBroker requestBroker)
           
 void setTopicAccessor(TopicAccessor topicAccessor)
           
 void setUseCluster(boolean useCluster)
           
 void shutdown()
           
 boolean supportAdministrative()
           
 java.lang.String usage()
          Command line usage.
 boolean useAdminManager()
           
 boolean useCluster()
          Is cluster support switched on?
 
Methods inherited from class org.xmlBlaster.util.Global
accessFromInternalHttpServer, addNativeCallbackDriver, addObjectEntry, byteString, changeLogLevel, clone, createClientDispatchConnectionsHandler, decode, encode, gc, get, get, get, get, get, getBootstrapAddress, getBuildJavaVendor, getBuildJavaVersion, getBuildTimestamp, getBurstModeTimer, getCbHostname, getCbHostname, getCbServerPluginManager, getCheckpointPlugin, getClassLoaderFactory, getClientSecurityPluginLoader, getClone, getConnectQosFactory, getCounter, getDatabaseNodeStr, getDisconnectQosFactory, getDispatchPluginManager, getDispatchWorkerPool, getDocumentBuilderFactory, getErrorText, getFromClasspath, getFromWeakRegistry, getHttpServer, getJavadocUrl, getJdbcConnectionPoolTimer, getJmxUsageLinkInfo, getJmxWrapper, getLocalIP, getLogLevel, getMemoryStatistic, getMessageTimer, getMsgKeyFactory, getMsgQosFactory, getNativeCallbackDriver, getNativeConnectArgs, getObjectEntry, getPersistentMap, getPingTimer, getPluginManager, getPluginRegistry, getProperty, getProtocolPluginManager, getQueryKeyFactory, getQueryQosFactory, getQueuePluginManager, getReleaseId, getRevisionNumber, getSAXParserFactory, getScopeContextNode, getStackTraceAsString, getStatusQosFactory, getStrippedId, getStrippedString, getVersion, getWipeOutDB, getXmlBlasterAccess, init, init, initId, instance, isJmxActivated, isRegisteredMBean, logUsage, main, putInWeakRegistry, registerMBean, removeFromWeakRegistry, removeNativeCallbackDriver, removeObjectEntry, resetInstanceId, sendNotification, setBootstrapAddress, setCheckpointPlugin, setContextNode, setScopeContextNode, setWipeOutDB, shallowCopy, shutdownHttpServer, supportJmx, unregisterMBean, validateJmxValue, waitOnKeyboardHit, wantsHelp
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

runlevelManager

private volatile RunlevelManager runlevelManager

currRunlevel

private int currRunlevel

authenticate

private I_Authenticate authenticate
the authentication service (a layer around it for security reasons)


requestBroker

private RequestBroker requestBroker
the xmlBlaster core class


nodeId

private NodeId nodeId

instanceId

private volatile java.lang.String instanceId
Unique id, even for each restart of a node


clusterManager

private volatile ClusterManager clusterManager

sessionTimer

private volatile Timeout sessionTimer

topicTimer

private volatile Timeout topicTimer

telnetSessionTimer

private volatile Timeout telnetSessionTimer

useCluster

private boolean useCluster

firstUseCluster

private boolean firstUseCluster

cbProtocolManager

private volatile CbProtocolManager cbProtocolManager

topicStorePluginManager

private volatile StoragePluginManager topicStorePluginManager

commandManager

private volatile CommandManager commandManager

useAdminManager

private boolean useAdminManager

firstUseAdminManager

private boolean firstUseAdminManager

momClientGateway

private MomClientGateway momClientGateway

msgFileDumper

private volatile MsgFileDumper msgFileDumper

pluginHolder

private PluginHolder pluginHolder

msgDistributorPluginManager

private volatile MsgDistributorPluginManager msgDistributorPluginManager

subjectEntryShuffler

private SubjectEntryShuffler subjectEntryShuffler

internalSessionInfo

private SessionInfo internalSessionInfo

topicAccessor

private TopicAccessor topicAccessor
Constructor Detail

ServerScope

public ServerScope()

ServerScope

public ServerScope(java.lang.String[] args)
One instance of this represents one xmlBlaster server.

Parameters:
args - Environment arguments (key/value pairs)

ServerScope

public ServerScope(java.util.Properties p,
                   boolean loadPropFile)
Method Detail

finalize

public void finalize()
Overrides:
finalize in class Global

shutdown

public void shutdown()
Overrides:
shutdown in class Global

init

public int init(java.lang.String[] args)
Calls super.init and checks the environment for "cluster.node.id"

See private org.xmlBlaster.Main#createNodeId()

Overrides:
init in class Global
Returns:
1 Show usage, 0 OK, -1 error

initThis

private void initThis()

isServerSide

public boolean isServerSide()
Check where we are, on client or on server side? util.Global returns false

Overrides:
isServerSide in class Global
Returns:
true As we are engine.Global and running server side

getContextNode

public final ContextNode getContextNode()
The unique name of this xmlBlaster server instance.

Overrides:
getContextNode in class Global
Returns:
Can be null during startup

getInstanceId

public java.lang.String getInstanceId()
Unique id of the xmlBlaster server, changes on each restart. If 'node/heron' is restarted, the instanceId changes.

Overrides:
getInstanceId in class Global
Returns:
nodeId + timestamp, '/node/heron/instanceId/33470080380'

getNodeId

public final NodeId getNodeId()
The unique name of this xmlBlaster server instance.

Overrides:
getNodeId in class Global
Returns:
Can be null during startup

getId

public final java.lang.String getId()
Access the unique cluster node id (as a String).

Overrides:
getId in class Global
Returns:
The name of this xmlBlaster instance, e.g. "heron.mycompany.com" or "http://mycomp:3412" Can be null during startup

setId

public final void setId(java.lang.String id)
Description copied from class: Global
Currently set by enging.Global, used server side only.

Overrides:
setId in class Global

getRunlevelManager

public final RunlevelManager getRunlevelManager()
Initialize runlevel manager used to start/stop xmlBlaster with different run levels.


getRunlevel

public int getRunlevel()
Overrides:
getRunlevel in class Global

setUseCluster

public void setUseCluster(boolean useCluster)

setClusterManager

public void setClusterManager(ClusterManager clusterManager)
Implicitely sets useCluster to true

Parameters:
clusterManager -

isClusterManagerReady

public final boolean isClusterManagerReady()
Since v1.1 the clusterManager is loaded via xmlBlasterPlugins.xml See useCluster() to check if clustering is switched on First checks if ClusterManager is loaded already and if its state is ready.

Returns:

getClusterManager

public final ClusterManager getClusterManager()
                                       throws XmlBlasterException
Access instance which manages myself in a cluster environment.

Returns:
null if cluster support is switched off
Throws:
XmlBlasterException

getClusterManagerNoEx

public final ClusterManager getClusterManagerNoEx()

useCluster

public final boolean useCluster()
Is cluster support switched on?


getLogPrefix

public final java.lang.String getLogPrefix()
Returns for no cluster an empty string, in cluster environment if more than one node is known it returns the node id like "/node/heron".

Used for logging

Overrides:
getLogPrefix in class Global

getLogPrefixDashed

public final java.lang.String getLogPrefixDashed(java.lang.String post)
Returns for no cluster the given post string. In cluster environment if more than one node is known it returns the node id like "/node/heron/client" if post="client".

Used for logging

Parameters:
post - the postfix string like "client"

getLogPrefixDashed

public final java.lang.String getLogPrefixDashed()
Same as getLogPrefix() but if in cluster environment a "-" is prefixed like "-/node/heron/".

Useful for logging information of classes like Authenticate.java

Overrides:
getLogPrefixDashed in class Global

getClusterManager

public final ClusterManager getClusterManager(SessionInfo sessionInfo)
                                       throws XmlBlasterException
Initialize the instance which manages myself in a cluster environment. Only the first call will set the sessionInfo

Parameters:
An - internal sessionInfo instance, see RequestBroker.
Returns:
null if cluster support is switched off
Throws:
XmlBlasterException

getCbProtocolManager

public final CbProtocolManager getCbProtocolManager()
                                             throws XmlBlasterException
Initialize cb protocol manager.

To administer CORBA/RMI etc. plugins

Throws:
XmlBlasterException

doStorageCleanup

public final void doStorageCleanup(JdbcQueue jdbcQueue)
Overrides:
doStorageCleanup in class Global

getStoragePluginManager

public final StoragePluginManager getStoragePluginManager()

getMsgFileDumper

public final MsgFileDumper getMsgFileDumper()
                                     throws XmlBlasterException
A helper to dump a message to a file.

Throws:
XmlBlasterException

getSessionTimer

public final Timeout getSessionTimer()
Access the handle of the user session timer thread.

Returns:
The Timeout instance

getTopicTimer

public final Timeout getTopicTimer()
Access the handle of the TopicHandler timer thread.

Returns:
The Timeout instance

getTelnetSessionTimer

public final Timeout getTelnetSessionTimer()
Access the handle of the TopicHandler timer thread.

Returns:
The Timeout instance

hasTelnetSessionTimer

public final boolean hasTelnetSessionTimer()

removeTelnetSessionTimer

public final void removeTelnetSessionTimer()

getEntryFactory

public I_EntryFactory getEntryFactory()
The factory creating queue or msgUnitStore entries from persistent store. Is derived from util.Global

Overrides:
getEntryFactory in class Global

getCommandManager

public final CommandManager getCommandManager()
                                       throws XmlBlasterException
Access instance of remote command administration manager.

Returns:
null if command administration support is switched off
Throws:
XmlBlasterException

useAdminManager

public final boolean useAdminManager()
Returns:
Is command administration support switched on?

getCommandManager

public final CommandManager getCommandManager(SessionInfo sessionInfo)
                                       throws XmlBlasterException
Initialize instance of remote command administration manager. Only the first call will set the sessionInfo

Parameters:
An - internal sessionInfo instance, see RequestBroker.
Returns:
null if command support is switched off
Throws:
XmlBlasterException

getMomClientGateway

public final MomClientGateway getMomClientGateway()
Access handler to forward messages beginning with "__cmd:" (administrative messages)

Returns:
null if no available. Is guaranteed to be not null if isAdministrationCommand(XmlKey) returned true.

supportAdministrative

public final boolean supportAdministrative()

registerMomClientGateway

public final void registerMomClientGateway(MomClientGateway momClientGateway)
Invoked by CommandManager to register message command handler


isAdministrationCommand

public final boolean isAdministrationCommand(XmlKey xmlKey)
                                      throws XmlBlasterException
Returns:
true if MomClientGateway is registered and key oid starts with "__cmd:" (case sensitiv)
Throws:
XmlBlasterException

createServerDispatchConnectionsHandler

public DispatchConnectionsHandler createServerDispatchConnectionsHandler(ServerDispatchManager dispatchManager)
                                                                  throws XmlBlasterException
Returns the callback layer implementation 'CbDispatchConnectionsHandler' on server side. In util.Global we return the client side implementation 'ClientDispatchConnectionsHandler'

Returns:
A new instance of CbDispatchConnectionsHandler
Throws:
XmlBlasterException

setAuthenticate

public void setAuthenticate(I_Authenticate auth)
Sets the authentication in the engine.Global scope.

Additionally the I_Authentication is registered in the util.Global.addObjectEntry under the name "/xmlBlaster/I_Authenticate" (see Constants.I_AUTHENTICATE_PROPERTY_KEY).
This allows lookup similar to a naming service if we are in the same JVM.


getAuthenticate

public I_Authenticate getAuthenticate()

getMsgDistributorPluginManager

public final MsgDistributorPluginManager getMsgDistributorPluginManager()

setRequestBroker

public void setRequestBroker(RequestBroker requestBroker)

getRequestBroker

public RequestBroker getRequestBroker()

getName

public java.lang.String getName()
A human readable name of the listener for logging.

Enforced by I_RunlevelListener

Specified by:
getName in interface I_RunlevelListener

runlevelChange

public void runlevelChange(int from,
                           int to,
                           boolean force)
                    throws XmlBlasterException
Invoked on run level change, see RunlevelManager.RUNLEVEL_HALTED and RunlevelManager.RUNLEVEL_RUNNING

Enforced by I_RunlevelListener

Specified by:
runlevelChange in interface I_RunlevelListener
Parameters:
from - The current runlevel
to - The runlevel we want to switch to
force - If true force the change even if messages are lost
Throws:
XmlBlasterException

isEmbedded

public boolean isEmbedded()
If property -xmlBlaster.isEmbedded true is set we return true here

An embedded server should not do any exit()


getDump

public java.lang.String getDump()
                         throws XmlBlasterException
Throws:
XmlBlasterException

getDump

public void getDump(java.io.OutputStream out)
             throws XmlBlasterException
Throws:
XmlBlasterException

getPluginHolder

public PluginHolder getPluginHolder()
                             throws XmlBlasterException
gets the object holding all configuration information for the plugins (both for statically loaded plugins (by the run level manager) and dynamically loaded plugins (such plugins loaded on client request).

Throws:
XmlBlasterException

getSubjectInfoShuffler

public SubjectEntryShuffler getSubjectInfoShuffler()

peekMessages

public java.lang.String[] peekMessages(I_Queue queue,
                                       int numOfEntries,
                                       java.lang.String label,
                                       boolean forceReadableTimestamp,
                                       boolean forceReadableBase64)
                                throws XmlBlasterException
Throws:
XmlBlasterException

peekQueueMessagesToFile

public java.lang.String[] peekQueueMessagesToFile(I_Queue queue,
                                                  int numOfEntries,
                                                  java.lang.String path,
                                                  java.lang.String label)
                                           throws XmlBlasterException
Dumps given amount of messages from queue to file.

Overrides:
peekQueueMessagesToFile in class Global
Parameters:
queue - The queue to observe
numOfEntries - Maximum number of messages to dump
path - The path to dump the messages to, it is automatically created if missing.
label - A nice queue name for logging/exceptions
Returns:
The file names dumped, including the path
Throws:
XmlBlasterException

usage

public java.lang.String usage()
Command line usage.

These variables may be set in your property file as well. Don't use the "-" prefix there.

Set the verbosity when loading properties (outputs with System.out).

0=nothing, 1=info, 2=trace, configure with

 java -Dproperty.verbose 2 ...

 java org.xmlBlaster.Main -property.verbose 2
 

Overrides:
usage in class Global

getInternalSessionInfo

public SessionInfo getInternalSessionInfo()

setInternalSessionInfo

public void setInternalSessionInfo(SessionInfo internalSessionInfo)
Filled by RequestBroker.java

Parameters:
internalSessionInfo -

getTopicAccessor

public TopicAccessor getTopicAccessor()
The singleton to handle all topics and its access.

Returns:
never null (is filled by RequestBroker after construction)

setTopicAccessor

public void setTopicAccessor(TopicAccessor topicAccessor)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.