xmlBlaster 2.2.0 API

org.xmlBlaster.engine
Class RequestBroker

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.xmlBlaster.engine.RequestBroker
All Implemented Interfaces:
java.util.EventListener, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, I_ClientListener, I_AdminNode, RequestBrokerMBean, I_RunlevelListener, I_AdminUsage, I_LogListener

public final class RequestBroker
extends javax.management.NotificationBroadcasterSupport
implements I_ClientListener, RequestBrokerMBean, I_RunlevelListener, I_LogListener

This is the central message broker, all requests are routed through this singleton.

The interface I_ClientListener informs about Client login/logout

Most events are fired from the RequestBroker

See xmlBlaster.idl, the CORBA access interface on how clients can access xmlBlaster.

Author:
Marcel Ruff

Field Summary
private  AccessPluginManager accessPluginManager
           
private static int ALIVE
           
private  Authenticate authenticate
          the authentication service
private  BigXmlKeyDOM bigXmlKeyDOM
          This is a handle on the big DOM tree with all XmlKey keys (all message meta data)
private  ClientSubscriptions clientSubscriptions
          Helper to handle the subscriptions
private  DispatchStatistic dispatchStatistic
          Contains total count of published messages and get() invocations.
private  ServerScope glob
           
static java.lang.String internalLoginNamePrefix
           
private  java.lang.String lastError
           
private  java.lang.String lastWarning
           
private static java.util.logging.Logger log
           
private  JmxMBeanHandle mbeanHandle
          My JMX registration
private  java.lang.String ME
           
private  SessionName myselfLoginName
           
private  boolean publishLoginEvent
          The messageUnit for a login event
private  boolean publishLogoutEvent
          Initialize a messageUnit for a logout event
private  PublishPluginManager publishPluginManager
           
private  PublishQos publishQosForEvents
           
private  PublishQosServer publishQosLoginEvent
           
private  PublishQosServer publishQosLogoutEvent
           
private  boolean publishUserList
          Initialize a messageUnit for a userList event
private  java.util.Set remotePropertiesListeners
           
private  long startupTime
          Incarnation time of this object instance in millis
private  int state
           
private  boolean subscribeMultipleClusterForward
          Added 2011-06-16 Marcel, default behavior has changed For testing only, probably removed again in future (performance impact needs to be discussed if activated)
private  java.util.Map subscriptionListenerMap
          For listeners who want to be informed about subscribe/unsubscribe events.
private  I_Map topicStore
          Store configuration of all topics in xmlBlaster for recovery
private static int UNDEF
          State during construction
private  SessionInfo unsecureSessionInfo
          This client is only for internal use, it is un secure to pass it outside because there is no authentication.
The login name "__RequestBroker_internal__" is reserved!
TODO: security discussion
private  boolean useOldStylePersistence
          Flag for performance reasons only
private  MsgKeyData xmlKeyLoginEvent
           
private  MsgKeyData xmlKeyLogoutEvent
           
private  MsgKeyData xmlKeyUserListEvent
           
 
Constructor Summary
RequestBroker(Authenticate authenticate)
          One instance of this represents one xmlBlaster server.
 
Method Summary
 int addPersistentTopicHandler(TopicEntry topicEntry)
          Make the topicHandler persistent for crash recovery and shutdown/startup cycle.
 boolean addRemotePropertiesListener(I_RemotePropertiesListener remotePropertiesListener)
          Add listener if new remote properties arrive.
 void addSubscriptionListener(I_SubscriptionListener l)
          Adds the specified subscription listener to receive subscribe/unSubscribe events.
 int changePersistentTopicHandler(TopicEntry topicEntry)
          Remove the persistent TopicHandler entry.
 java.lang.String checkCallbackEntriesConsistency(boolean fixIt, java.lang.String reportFileName)
          Loop through all database entries of relating='callback' and check if there are entries from not existing sessions with pubSessionId=<0
 java.lang.String checkConsistency(java.lang.String fixIt, java.lang.String reportFileName)
          Do consistency check.
 java.lang.String checkConsistencyOld_XB_ENTRIES(I_Map map, boolean fixIt, java.lang.String reportFileName)
           
(package private)  void checkExistingSubscriptions(SessionInfo sessionInfo, TopicHandler topicHandler, PublishQosServer xmlQoS)
          This helper method checks for a published message which didn't exist before if there are any XPath subscriptions pending which match.
 void clearLastError()
          Clear the last exception text.
 void clearLastWarning()
          Clear the last warning text.
 java.lang.String[] deadMessage(MsgQueueEntry[] entries, I_Queue queue, java.lang.String reason)
          Publish dead letters, expired letters should be filtered away before.
 java.lang.String displayClassInfo(java.lang.String clazzName)
          Check if the given java class is known and wherefrom it was loaded.
 java.lang.String dump()
          Dump the complete internal state of xmlBlaster.
 java.lang.String dumpAllStacks()
           
 java.lang.String dumpAllStacksToFile(java.lang.String file)
           
 java.lang.String dumpToFile(java.lang.String reportFileName)
           
(package private)  java.lang.String[] erase(SessionInfo sessionInfo, QueryKeyData xmlKey, EraseQosServer eraseQos)
          Client wants to erase a message.
private  java.lang.String[] erase(SessionInfo sessionInfo, QueryKeyData xmlKey, EraseQosServer eraseQos, boolean isClusterUpdate)
          Client wants to erase a message.
 void exit()
          Shutdown xmlBlaster, exit value is '0'
(package private)  void fireSubscribeEvent(SubscriptionInfo subscriptionInfo)
           
private  void fireSubscriptionEvent(SubscriptionInfo subscriptionInfo, boolean subscribe)
          Is fired on subscribe(), unSubscribe() and several times on erase().
(package private)  void fireUnSubscribeEvent(SubscriptionInfo subscriptionInfo)
           
 PublishReturnQos forwardPtpPublish(SessionInfo sessionInfo, MsgUnit msgUnit, boolean isClusterUpdate, Destination destination)
          Rorward a message to another cluster node.
 MsgUnit[] get(SessionInfo sessionInfo, QueryKeyData xmlKey, GetQosServer getQos)
          Invoked by a client, to access one/many MsgUnit.
 AccessPluginManager getAccessPluginManager()
           
 java.lang.String[] getAliveCallbackClients()
          Shows the clients which have a alive callback connection.
(package private)  Authenticate getAuthenticate()
           
 Authenticate getAuthenticate(java.lang.String secretSessionId)
          This method returns the unprotected Authenticate object.
(package private)  BigXmlKeyDOM getBigXmlKeyDOM()
           
 java.lang.String getBuildJavaVendor()
          The java vendor of the compiler.
 java.lang.String getBuildJavaVersion()
          The compiler java version.
 java.lang.String getBuildTimestamp()
          Returns the date when xmlBlaster was compiled.
 java.lang.String getClientList()
          These are the login names returned, every client may be logged in multiple times which you can't see here
 java.lang.String[] getClients()
          Get the client names.
 ClientSubscriptions getClientSubscriptions()
          Holds all subscriptions.
 long getFreeMem()
          Memory in bytes
 java.lang.String getFreeMemStr()
          Nicer to read for humans.
 java.lang.String getGc()
           
 java.lang.String getHostname()
          Access the bootstrap host name.
 java.lang.String getInstanceId()
          Unique id of the xmlBlaster server, changes on each restart.
(package private)  SessionInfo getInternalSessionInfo()
           
 java.lang.String getLastError()
          Access the last logged error
 java.lang.String getLastWarning()
          Access the last logged error
 int getMaxClients()
          Get the maximum allowed number of clients.
 long getMaxFreeMem()
          Free memory in bytes
 java.lang.String getMaxFreeMemStr()
          Nicer to read for humans.
 long getMaxMem()
          Returns the total amount of memory including what the Java virtual machine could additionally allocate.
 java.lang.String getMaxMemStr()
          Nicer to read for humans.
 java.lang.String getName()
          A human readable name of the listener for logging.
 java.lang.String getNodeId()
          Get my cluster node name.
 java.lang.String getNodeList()
          Get the names of all known xmlBlaster cluster nodes.
 java.lang.String[] getNodes()
          Get the names of all known xmlBlaster cluster nodes.
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
          Declare available notification event types.
 int getNumClients()
          The number of different users, the sessions may be higher
 long getNumGet()
           
 int getNumNodes()
          Get the number of known cluster nodes.
 long getNumPublish()
           
 int getNumSubscriptions()
          Get the number of subscriptions.
 int getNumSysprop()
          Get the number of system properties.
 int getNumTopics()
          Get the number of topics.
 long getNumUpdate()
          The overall sent updates (callback to client)
 int getPort()
          The bootstrap bootstrap port
 PublishPluginManager getPublishPluginManager()
           
 I_RemotePropertiesListener[] getRemotePropertiesListenerArr()
          Access a current snapshot of all listeners.
 java.lang.String getRevisionNumber()
          Returns the xmlBlaster SVN version control revision number.
 java.lang.String getRunlevel()
          Access the current run level of xmlBlaster.
 ServerScope getServerScope()
          Access the ServerScope handle.
 java.lang.String getServerTimestamp()
          Access the current server time as a java.sql.Timestamp string.
 long getServerTimestampMillis()
          Returns the current server time in milliseconds.
 java.lang.String getStartupDate()
          Get date when xmlBlaster was started.
 java.lang.String getSubscriptionList()
          Get the subscriptions.
 I_SubscriptionListener getSubscriptionListener(java.lang.Integer prio)
          Returns the listener with the specified prio or null if none with that prio has been found.
 java.lang.String[] getSubscriptions()
          Get the subscriptions ids.
 java.lang.String getSyspropList()
          Deprecated. Is not supported anymore
 java.lang.String getTopicList()
          Get the topics.
 java.lang.String[] getTopics()
          Get the topics.
(package private)  I_Map getTopicStore()
           
 long getTotalMem()
          Returns the current amount of memory in the Java virtual machine.
 java.lang.String getTotalMemStr()
          Nicer to read for humans.
 long getUptime()
          How long is the server running (in seconds)
 java.lang.String getUsageUrl()
          JMX
 long getUsedMem()
           
 java.lang.String getUsedMemStr()
          Nicer to read for humans.
 java.lang.String getVersion()
          Get the xmlBlaster version number.
private  void initHelperQos()
          Put this code in a generic internal message producer class (future release)
 boolean isAcceptWrongSenderAddress()
          Configure server with '-xmlBlaster/acceptWrongSenderAddress true' or "-xmlBlaster/acceptWrongSenderAddress/joe true".
 void log(java.util.logging.LogRecord record)
          Redirect logging, configure in xmlBlaster.properties.
 java.lang.String pingTimerDumpToFile(java.lang.String fn)
           
 java.lang.String pingTimerInfo()
           
 java.lang.String publish(SessionInfo sessionInfo, MsgUnit msgUnit)
          Internal publishing helper.
private  java.lang.String publish(SessionInfo sessionInfo, MsgUnit msgUnit, boolean isClusterUpdate)
           
private  java.lang.String publish(SessionInfo sessionInfo, MsgUnit msgUnit, PublishQosServer publishQos)
          Write-Access method to publish a new message from a data source.
 java.lang.String publishDeadMessage(MsgUnit origMsgUnit, java.lang.String text, java.lang.String clientPropertyKey, SessionName receiver)
           
 java.lang.String publishDeadMessageRaw(SessionName sender, MsgUnitRaw origMsgUnit, java.lang.String text, SessionName receiver)
           
private  KeyData[] queryMatchingKeys(SessionInfo sessionInfo, QueryKeyData queryKeyData, QueryQosData qos)
          This method does the query (queryType = "XPATH" | "EXACT").
private  java.lang.String[] queryMatchingTopics(SessionInfo sessionInfo, QueryKeyData queryKeyData, QueryQosData qos)
          This method does the query (queryType = "XPATH" | "EXACT").
 int removePersistentTopicHandler(TopicEntry topicEntry)
          Remove the persistent TopicHandler entry.
 boolean removeRemotePropertiesListener(I_RemotePropertiesListener remotePropertiesListener)
          Remove the given listener
 void removeSubscriptionListener(I_SubscriptionListener l)
          Removes the specified listener.
 java.lang.String reportMemoryOverview()
           
private  java.lang.String reportMemoryOverview(java.lang.String reportFileName)
           
 java.lang.String reportMemoryOverviewToFile(java.lang.String reportFileName)
           
 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 sessionAdded(ClientEvent e)
          Event invoked on successful client login (interface I_ClientListener).
 void sessionPreRemoved(ClientEvent e)
          Invoked before a client does a logout
 void sessionRemoved(ClientEvent e)
          Event invoked when client does a logout (interface I_ClientListener).
 void sessionUpdated(ClientEvent e)
          Invoked on successful client re-login (interface I_ClientListener)
 void setAcceptWrongSenderAddress(boolean acceptWrongSenderAddress)
           
 void setDump(java.lang.String fn)
          Dump the internal xmlBlaster state to the given file.
 void setExit(java.lang.String exitValue)
           
 void setGc(java.lang.String dummy)
           
 void setRunlevel(java.lang.String levelStr)
          Change the run level of xmlBlaster.
 void setUsageUrl(java.lang.String url)
           
private  void startupTopicStore()
          This stores the topics configuration (the publish administrative message - the MsgUnit data struct)
 void subjectAdded(ClientEvent e)
          Event invoked on new created SubjectInfo.
 void subjectRemoved(ClientEvent e)
          Event invoked on deleted SubjectInfo.
 java.lang.String subscribe(SessionInfo sessionInfo, QueryKeyData xmlKey, SubscribeQosServer subscribeQos)
           
private  void subscribeToOid(SubscriptionInfo subs, boolean calleeIsXPathMatchCheck)
          Low level subscribe, is called when the to subscribe is exactly known.
 java.lang.String toXml()
          Dump state of this object into a XML ASCII string.
 java.lang.String toXml(java.lang.String extraOffset)
          Dump state of this object into a XML ASCII string.
 java.lang.String[] unSubscribe(SessionInfo sessionInfo, QueryKeyData xmlKey, UnSubscribeQosServer unSubscribeQos)
          Incoming unsubscribe request from a client.
 java.lang.String update(SessionInfo sessionInfo, UpdateKey updateKey, byte[] content, MsgQosData msgQosData)
          Used for cluster internal updates.
 void updateInternalUserList()
           
 java.lang.String usage()
          JMX
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
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

dispatchStatistic

private DispatchStatistic dispatchStatistic
Contains total count of published messages and get() invocations.


lastWarning

private java.lang.String lastWarning

lastError

private java.lang.String lastError

authenticate

private Authenticate authenticate
the authentication service


remotePropertiesListeners

private final java.util.Set remotePropertiesListeners

topicStore

private I_Map topicStore
Store configuration of all topics in xmlBlaster for recovery


unsecureSessionInfo

private final SessionInfo unsecureSessionInfo
This client is only for internal use, it is un secure to pass it outside because there is no authentication.
The login name "__RequestBroker_internal__" is reserved!
TODO: security discussion


myselfLoginName

private final SessionName myselfLoginName

internalLoginNamePrefix

public static final java.lang.String internalLoginNamePrefix
See Also:
Constant Field Values

clientSubscriptions

private final ClientSubscriptions clientSubscriptions
Helper to handle the subscriptions


subscriptionListenerMap

private final java.util.Map subscriptionListenerMap
For listeners who want to be informed about subscribe/unsubscribe events. The key is an Integer number where the lowest is the first invoked on subscribe and the last invoked on unsubscribe.


bigXmlKeyDOM

private BigXmlKeyDOM bigXmlKeyDOM
This is a handle on the big DOM tree with all XmlKey keys (all message meta data)


useOldStylePersistence

private boolean useOldStylePersistence
Flag for performance reasons only


publishLoginEvent

private boolean publishLoginEvent
The messageUnit for a login event


xmlKeyLoginEvent

private MsgKeyData xmlKeyLoginEvent

publishQosForEvents

private PublishQos publishQosForEvents

publishQosLoginEvent

private PublishQosServer publishQosLoginEvent

publishUserList

private boolean publishUserList
Initialize a messageUnit for a userList event


xmlKeyUserListEvent

private MsgKeyData xmlKeyUserListEvent

publishLogoutEvent

private boolean publishLogoutEvent
Initialize a messageUnit for a logout event


xmlKeyLogoutEvent

private MsgKeyData xmlKeyLogoutEvent

publishQosLogoutEvent

private PublishQosServer publishQosLogoutEvent

accessPluginManager

private AccessPluginManager accessPluginManager

publishPluginManager

private PublishPluginManager publishPluginManager

startupTime

private long startupTime
Incarnation time of this object instance in millis


UNDEF

private static final int UNDEF
State during construction

See Also:
Constant Field Values

ALIVE

private static final int ALIVE
See Also:
Constant Field Values

state

private int state

mbeanHandle

private JmxMBeanHandle mbeanHandle
My JMX registration


subscribeMultipleClusterForward

private boolean subscribeMultipleClusterForward
Added 2011-06-16 Marcel, default behavior has changed For testing only, probably removed again in future (performance impact needs to be discussed if activated)

Constructor Detail

RequestBroker

public RequestBroker(Authenticate authenticate)
              throws XmlBlasterException
One instance of this represents one xmlBlaster server.

Parameters:
authenticate - The authentication service
Throws:
XmlBlasterException
Method Detail

getAuthenticate

Authenticate getAuthenticate()

initHelperQos

private void initHelperQos()
                    throws XmlBlasterException
Put this code in a generic internal message producer class (future release)

Throws:
XmlBlasterException

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

getBigXmlKeyDOM

BigXmlKeyDOM getBigXmlKeyDOM()

getClientSubscriptions

public ClientSubscriptions getClientSubscriptions()
Holds all subscriptions.

Returns:
Is never null

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

getServerScope

public final ServerScope getServerScope()
Access the ServerScope handle.

Returns:
The ServerScope instance of this xmlBlaster server

getTopicStore

I_Map getTopicStore()
Returns:
The handle on the persistence storage for all topics

startupTopicStore

private void startupTopicStore()
                        throws XmlBlasterException
This stores the topics configuration (the publish administrative message - the MsgUnit data struct)

Throws:
XmlBlasterException

getAccessPluginManager

public final AccessPluginManager getAccessPluginManager()

getPublishPluginManager

public final PublishPluginManager getPublishPluginManager()

getInternalSessionInfo

final SessionInfo getInternalSessionInfo()

deadMessage

public java.lang.String[] deadMessage(MsgQueueEntry[] entries,
                                      I_Queue queue,
                                      java.lang.String reason)
Publish dead letters, expired letters should be filtered away before.

The key contains an attribute with the oid of the lost message:

   <key oid='__sys__deadMessage'>
      <oid>aMessage</oid>
   <key>
 

The usual sources to send dead letters are:

  1. A publish of a message fails, the message is lost but you can handle it if you subscribe to dead messages
  2. A subscribe fails because a mime plugin throws an exception
  3. A callback fails

Parameters:
entries - The message to send as dead letters
queue - The belonging queue or null
reason - A human readable text describing the problem
Returns:
State information returned from the publish call (is never null)

publishDeadMessage

public java.lang.String publishDeadMessage(MsgUnit origMsgUnit,
                                           java.lang.String text,
                                           java.lang.String clientPropertyKey,
                                           SessionName receiver)
                                    throws XmlBlasterException
Throws:
XmlBlasterException

publishDeadMessageRaw

public java.lang.String publishDeadMessageRaw(SessionName sender,
                                              MsgUnitRaw origMsgUnit,
                                              java.lang.String text,
                                              SessionName receiver)
                                       throws XmlBlasterException
Throws:
XmlBlasterException

subscribe

public java.lang.String subscribe(SessionInfo sessionInfo,
                                  QueryKeyData xmlKey,
                                  SubscribeQosServer subscribeQos)
                           throws XmlBlasterException
Throws:
XmlBlasterException

get

public MsgUnit[] get(SessionInfo sessionInfo,
                     QueryKeyData xmlKey,
                     GetQosServer getQos)
              throws XmlBlasterException
Invoked by a client, to access one/many MsgUnit.

Synchronous read-access method.

In the cluster environment all messages are accessed from the master cluster node, tuning with XmlBlasterAccess.synchronousCache is not yet implemented.

Parameters:
xmlKey - Key allowing XPath or exact selection
See XmlKey.dtd for a description
getQos - Quality of Service, flags to control subscription
See XmlQoS.dtd for a description, XmlQoS.xml for examples

Returns:
A sequence of 0 - n MsgUnit structs. 0 if no message matched. They are clones from the internal messageUnit, so native clients can manipulate them without danger
Throws:
XmlBlasterException - on internal errors
See Also:
GetQos, The interface.get requirement

updateInternalUserList

public void updateInternalUserList()
                            throws XmlBlasterException
Throws:
XmlBlasterException

queryMatchingKeys

private KeyData[] queryMatchingKeys(SessionInfo sessionInfo,
                                    QueryKeyData queryKeyData,
                                    QueryQosData qos)
                             throws XmlBlasterException
This method does the query (queryType = "XPATH" | "EXACT").

Parameters:
clientName - is only needed for nicer logging output
Returns:
Array of matching XmlKey objects (may contain null elements), the array is never null TODO: a query Handler, allowing drivers for REGEX, XPath, SQL, etc. queries
Throws:
XmlBlasterException

queryMatchingTopics

private java.lang.String[] queryMatchingTopics(SessionInfo sessionInfo,
                                               QueryKeyData queryKeyData,
                                               QueryQosData qos)
                                        throws XmlBlasterException
This method does the query (queryType = "XPATH" | "EXACT").

Parameters:
clientName - is only needed for nicer logging output
Returns:
Array of matching XmlKey objects (may contain null elements), the array is never null TODO: a query Handler, allowing drivers for REGEX, XPath, SQL, etc. queries
Throws:
XmlBlasterException

addPersistentTopicHandler

public final int addPersistentTopicHandler(TopicEntry topicEntry)
                                    throws XmlBlasterException
Make the topicHandler persistent for crash recovery and shutdown/startup cycle.

Returns:
Number of new entries added: 0 if entry existed, 1 if new entry added
Throws:
XmlBlasterException

removePersistentTopicHandler

public final int removePersistentTopicHandler(TopicEntry topicEntry)
                                       throws XmlBlasterException
Remove the persistent TopicHandler entry.

Returns:
the number of elements erased.
Throws:
XmlBlasterException

changePersistentTopicHandler

public final int changePersistentTopicHandler(TopicEntry topicEntry)
                                       throws XmlBlasterException
Remove the persistent TopicHandler entry.

Returns:
the number of elements erased.
Throws:
XmlBlasterException

subscribeToOid

private void subscribeToOid(SubscriptionInfo subs,
                            boolean calleeIsXPathMatchCheck)
                     throws XmlBlasterException
Low level subscribe, is called when the to subscribe is exactly known.

If the message is yet unknown, an empty is created to hold the subscription.

Parameters:
subs -
calleeIsXPathMatchCheck - true The calling thread is internally to check if a Query matches a new published topic false The callee is a subscribe() thread from a client
Throws:
XmlBlasterException

getAuthenticate

public Authenticate getAuthenticate(java.lang.String secretSessionId)
This method returns the unprotected Authenticate object.

Parameters:
secretSessionId - the secret Session Id of the invoker. TODO in future an authorization operation shall be performed here
Returns:

unSubscribe

public java.lang.String[] unSubscribe(SessionInfo sessionInfo,
                                      QueryKeyData xmlKey,
                                      UnSubscribeQosServer unSubscribeQos)
                               throws XmlBlasterException
Incoming unsubscribe request from a client.

If you have subscribed before, you can cancel your subscription with this method again

Parameters:
sessionInfo -
xmlKey - Key with the oid to unSubscribe
See XmlKey.dtd for a description
If you subscribed with XPath, you need to pass the id you got from your subscription
qos - Quality of Service, flags to control unsubscription
See XmlQoS.dtd for a description Example (note that the qos are not yet fully implemented):

    <qos>
       <notify>false     <!-- The subscribers shall not be notified when this message is destroyed -->
    </qos>
 
Returns:
An array of canceled subscriptions e.g.
   <qos>
      <subscribe id='__subId:2'/>
      <isUnSubscribe/>
   </qos>
 
Throws:
XmlBlasterException

update

public final java.lang.String update(SessionInfo sessionInfo,
                                     UpdateKey updateKey,
                                     byte[] content,
                                     MsgQosData msgQosData)
                              throws XmlBlasterException
Used for cluster internal updates.

Throws:
XmlBlasterException

publish

public final java.lang.String publish(SessionInfo sessionInfo,
                                      MsgUnit msgUnit)
                               throws XmlBlasterException
Internal publishing helper.

Throws:
XmlBlasterException

publish

private final java.lang.String publish(SessionInfo sessionInfo,
                                       MsgUnit msgUnit,
                                       boolean isClusterUpdate)
                                throws XmlBlasterException
Throws:
XmlBlasterException

publish

private final java.lang.String publish(SessionInfo sessionInfo,
                                       MsgUnit msgUnit,
                                       PublishQosServer publishQos)
                                throws XmlBlasterException
Write-Access method to publish a new message from a data source.

There are two MoM styles supported:

This triggers the method update() if observed by somebody

If the given key oid doesn't exist, it will be automatically added,
so this covers the SQL'ish INSERT and UPDATE.

If MsgUnit is created from subscribe or MsgUnit is new, the key meta data are added to the big DOM tree once (XmlKey takes care of that).

See xmlBlaster.idl, the CORBA access interface on how clients can access xmlBlaster.

TODO: Allow XML formatted returns which exactly match the update() return syntax (for clustering ClusterNode.java:update())

Parameters:
sessionInfo - The SessionInfo object, describing the publishing client
msgUnit - The MsgUnit struct
isClusterUpdate - true if it is a update() callback message from another cluster node
Returns:
String with the XML encoded key oid of the msgUnit
If you let the oid be generated, you need this information for further publishing to the same MsgUnit
Rejected Messages will contain a string with state id!=OK
Throws:
XmlBlasterException
See Also:
The interface.publish requirement

forwardPtpPublish

public PublishReturnQos forwardPtpPublish(SessionInfo sessionInfo,
                                          MsgUnit msgUnit,
                                          boolean isClusterUpdate,
                                          Destination destination)
                                   throws XmlBlasterException
Rorward a message to another cluster node. TODO: How to return multiple retVal from multiple destinations? !!!

Returns:
if not null the message was forwarded to another cluster
Throws:
XmlBlasterException

checkExistingSubscriptions

final void checkExistingSubscriptions(SessionInfo sessionInfo,
                                      TopicHandler topicHandler,
                                      PublishQosServer xmlQoS)
                               throws XmlBlasterException
This helper method checks for a published message which didn't exist before if there are any XPath subscriptions pending which match.

Throws:
XmlBlasterException

erase

java.lang.String[] erase(SessionInfo sessionInfo,
                         QueryKeyData xmlKey,
                         EraseQosServer eraseQos)
                   throws XmlBlasterException
Client wants to erase a message.

Parameters:
sessionInfo - The SessionInfo object, describing the invoking client
xmlKey - Key allowing XPath or exact selection
See XmlKey.dtd for a description
eraseQoS - Quality of Service, flags to control the erasing
Returns:
String array with the xml encoded key oid's which are deleted
Throws:
XmlBlasterException
See Also:
The interface.publish requirement

erase

private java.lang.String[] erase(SessionInfo sessionInfo,
                                 QueryKeyData xmlKey,
                                 EraseQosServer eraseQos,
                                 boolean isClusterUpdate)
                          throws XmlBlasterException
Client wants to erase a message.

Parameters:
sessionInfo - The SessionInfo object, describing the invoking client
xmlKey - Key allowing XPath or exact selection
See XmlKey.dtd for a description
eraseQoS - Quality of Service, flags to control the erasing
isClusterUpdate - true if it is a update() callback message from another cluster node
Returns:
String array with the xml encoded key oid's which are deleted
Throws:
XmlBlasterException
See Also:
The interface.publish requirement

sessionAdded

public void sessionAdded(ClientEvent e)
                  throws XmlBlasterException
Event invoked on successful client login (interface I_ClientListener).

Publishes a login event for this client with key oid="__sys_Login"

    <key oid='__sys__Login'>    <!-- Client name is delivered in the content -->
    </key>
 

Specified by:
sessionAdded in interface I_ClientListener
Throws:
XmlBlasterException

sessionUpdated

public void sessionUpdated(ClientEvent e)
                    throws XmlBlasterException
Invoked on successful client re-login (interface I_ClientListener)

Specified by:
sessionUpdated in interface I_ClientListener
Throws:
XmlBlasterException

sessionRemoved

public void sessionRemoved(ClientEvent e)
                    throws XmlBlasterException
Event invoked when client does a logout (interface I_ClientListener).

Publishes a logout event for this client with key oid="__sys_Logout"

    <key oid='__sys__Logout'>    <!-- Client name is delivered in the content -->
    </key>
 

Specified by:
sessionRemoved in interface I_ClientListener
Throws:
XmlBlasterException

sessionPreRemoved

public void sessionPreRemoved(ClientEvent e)
                       throws XmlBlasterException
Description copied from interface: I_ClientListener
Invoked before a client does a logout

Specified by:
sessionPreRemoved in interface I_ClientListener
Throws:
XmlBlasterException

subjectAdded

public void subjectAdded(ClientEvent e)
                  throws XmlBlasterException
Event invoked on new created SubjectInfo.

Specified by:
subjectAdded in interface I_ClientListener
Throws:
XmlBlasterException

subjectRemoved

public void subjectRemoved(ClientEvent e)
                    throws XmlBlasterException
Event invoked on deleted SubjectInfo.

Specified by:
subjectRemoved in interface I_ClientListener
Throws:
XmlBlasterException

addRemotePropertiesListener

public boolean addRemotePropertiesListener(I_RemotePropertiesListener remotePropertiesListener)
Add listener if new remote properties arrive. Clients which publish client side properties to their sessionInfo

Parameters:
RemotePropertiesListener -
Returns:

removeRemotePropertiesListener

public boolean removeRemotePropertiesListener(I_RemotePropertiesListener remotePropertiesListener)
Remove the given listener

Parameters:
RemotePropertiesListener -
Returns:
true if it was removed

getRemotePropertiesListenerArr

public I_RemotePropertiesListener[] getRemotePropertiesListenerArr()
Access a current snapshot of all listeners.

Returns:

addSubscriptionListener

public void addSubscriptionListener(I_SubscriptionListener l)
Adds the specified subscription listener to receive subscribe/unSubscribe events.


getSubscriptionListener

public I_SubscriptionListener getSubscriptionListener(java.lang.Integer prio)
Returns the listener with the specified prio or null if none with that prio has been found.

Parameters:
prio -
Returns:

removeSubscriptionListener

public void removeSubscriptionListener(I_SubscriptionListener l)
Removes the specified listener.


fireUnSubscribeEvent

final void fireUnSubscribeEvent(SubscriptionInfo subscriptionInfo)
                         throws XmlBlasterException
Throws:
XmlBlasterException

fireSubscribeEvent

final void fireSubscribeEvent(SubscriptionInfo subscriptionInfo)
                       throws XmlBlasterException
Throws:
XmlBlasterException

fireSubscriptionEvent

private final void fireSubscriptionEvent(SubscriptionInfo subscriptionInfo,
                                         boolean subscribe)
                                  throws XmlBlasterException
Is fired on subscribe(), unSubscribe() and several times on erase().

Parameters:
subscribe - true: on subscribe, false: on unSubscribe
Throws:
XmlBlasterException

toXml

public final java.lang.String toXml()
                             throws XmlBlasterException
Dump state of this object into a XML ASCII string.

Returns:
internal state of the RequestBroker as a XML ASCII string
Throws:
XmlBlasterException

toXml

public final java.lang.String toXml(java.lang.String extraOffset)
                             throws XmlBlasterException
Dump state of this object into a XML ASCII string.

Parameters:
extraOffset - indenting of tags for nice output
Returns:
internal state of the RequestBroker as a XML ASCII string
Throws:
XmlBlasterException

getNumNodes

public int getNumNodes()
Description copied from interface: I_AdminNode
Get the number of known cluster nodes.

Specified by:
getNumNodes in interface I_AdminNode
Returns:
The number of xmlBlaster cluster nodes

pingTimerInfo

public java.lang.String pingTimerInfo()
Specified by:
pingTimerInfo in interface RequestBrokerMBean

pingTimerDumpToFile

public java.lang.String pingTimerDumpToFile(java.lang.String fn)
Specified by:
pingTimerDumpToFile in interface RequestBrokerMBean

getNodeList

public java.lang.String getNodeList()
Description copied from interface: I_AdminNode
Get the names of all known xmlBlaster cluster nodes.

Specified by:
getNodeList in interface I_AdminNode
Returns:
A comma separated list of cluster node names

getNodes

public java.lang.String[] getNodes()
Description copied from interface: I_AdminNode
Get the names of all known xmlBlaster cluster nodes.

Specified by:
getNodes in interface I_AdminNode
Returns:
A comma separated list of cluster node names

getNodeId

public java.lang.String getNodeId()
Description copied from interface: I_AdminNode
Get my cluster node name.

Specified by:
getNodeId in interface I_AdminNode
Returns:
My cluster wide unique name

getInstanceId

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

Specified by:
getInstanceId in interface I_AdminNode
Returns:
nodeId + timestamp, '/node/heron/instanceId/33470080380'

getVersion

public java.lang.String getVersion()
Description copied from interface: I_AdminNode
Get the xmlBlaster version number.

Specified by:
getVersion in interface I_AdminNode
Returns:
For example "1.0.4"

getRevisionNumber

public java.lang.String getRevisionNumber()
Description copied from interface: I_AdminNode
Returns the xmlBlaster SVN version control revision number.

Specified by:
getRevisionNumber in interface I_AdminNode
Returns:
The subversion revision number of the monitored instance, for example "13593"

getServerTimestampMillis

public long getServerTimestampMillis()
Description copied from interface: I_AdminNode
Returns the current server time in milliseconds. For an accuracy discussion please consult System.currentTimeMillis

Specified by:
getServerTimestampMillis in interface I_AdminNode
Returns:
For example 1111400317333

getServerTimestamp

public java.lang.String getServerTimestamp()
Description copied from interface: I_AdminNode
Access the current server time as a java.sql.Timestamp string.

Specified by:
getServerTimestamp in interface I_AdminNode
Returns:
For example "2005-03-21 11:18:12.622"

getBuildTimestamp

public java.lang.String getBuildTimestamp()
Description copied from interface: I_AdminNode
Returns the date when xmlBlaster was compiled.

Specified by:
getBuildTimestamp in interface I_AdminNode
Returns:
For example "07/28/2005 03:47 PM"

getBuildJavaVendor

public java.lang.String getBuildJavaVendor()
Description copied from interface: I_AdminNode
The java vendor of the compiler.

Specified by:
getBuildJavaVendor in interface I_AdminNode
Returns:
For example "Sun Microsystems Inc."

getBuildJavaVersion

public java.lang.String getBuildJavaVersion()
Description copied from interface: I_AdminNode
The compiler java version.

Specified by:
getBuildJavaVersion in interface I_AdminNode
Returns:
For example "1.5.0"

dumpToFile

public java.lang.String dumpToFile(java.lang.String reportFileName)
Specified by:
dumpToFile in interface I_AdminNode
Parameters:
reportFileName - e.g. "/tmp/x.xml"
Returns:

dump

public java.lang.String dump()
                      throws XmlBlasterException
Description copied from interface: I_AdminNode
Dump the complete internal state of xmlBlaster. Is an operation to not do it automatically on JMX load

Specified by:
dump in interface I_AdminNode
Throws:
XmlBlasterException

setDump

public void setDump(java.lang.String fn)
             throws XmlBlasterException
Description copied from interface: I_AdminNode
Dump the internal xmlBlaster state to the given file.

deprecated, use #dumpToFile(String, String) which uses OutputStream

Specified by:
setDump in interface I_AdminNode
Parameters:
fn - The complete path and file name
Throws:
XmlBlasterException

getRunlevel

public java.lang.String getRunlevel()
Description copied from interface: I_AdminNode
Access the current run level of xmlBlaster.

Specified by:
getRunlevel in interface I_AdminNode
Returns:
0 is halted and 9 is fully operational

setRunlevel

public void setRunlevel(java.lang.String levelStr)
                 throws XmlBlasterException
Description copied from interface: I_AdminNode
Change the run level of xmlBlaster.

Specified by:
setRunlevel in interface I_AdminNode
Throws:
XmlBlasterException

getStartupDate

public java.lang.String getStartupDate()
Get date when xmlBlaster was started.

Specified by:
getStartupDate in interface I_AdminNode
Returns:
"2005-03-20 11:19:12.322"

getUptime

public long getUptime()
How long is the server running (in seconds)

Specified by:
getUptime in interface I_AdminNode

getLastWarning

public java.lang.String getLastWarning()
Access the last logged error

Specified by:
getLastWarning in interface I_AdminNode
Returns:
The complete information about the last warning logged, never null

clearLastWarning

public void clearLastWarning()
Description copied from interface: I_AdminNode
Clear the last warning text.

Specified by:
clearLastWarning in interface I_AdminNode

getLastError

public java.lang.String getLastError()
Access the last logged error

Specified by:
getLastError in interface I_AdminNode
Returns:
The complete information about the last error logged, never null

clearLastError

public void clearLastError()
Description copied from interface: I_AdminNode
Clear the last exception text.

Specified by:
clearLastError in interface I_AdminNode

getFreeMem

public long getFreeMem()
Memory in bytes

Specified by:
getFreeMem in interface I_AdminNode
Returns:
an approximation to the total amount of memory currently available for future allocated objects, measured in bytes. Note that the JVM may allocate more memory and the free memory will grow.

getFreeMemStr

public java.lang.String getFreeMemStr()
Description copied from interface: I_AdminNode
Nicer to read for humans.

Specified by:
getFreeMemStr in interface I_AdminNode
See Also:
I_AdminNode.getFreeMem()

getMaxFreeMem

public long getMaxFreeMem()
Free memory in bytes

Specified by:
getMaxFreeMem in interface I_AdminNode
Returns:
an approximation to the total amount of memory available for future allocated objects, measured in bytes.

getMaxFreeMemStr

public java.lang.String getMaxFreeMemStr()
Description copied from interface: I_AdminNode
Nicer to read for humans.

Specified by:
getMaxFreeMemStr in interface I_AdminNode
See Also:
I_AdminNode.getMaxFreeMem()

getTotalMem

public long getTotalMem()
Description copied from interface: I_AdminNode
Returns the current amount of memory in the Java virtual machine. The value returned by this method may vary over time, depending on the host environment.

Note that the amount of memory required to hold an object of any given type may be implementation-dependent.

Specified by:
getTotalMem in interface I_AdminNode
Returns:
the total amount of memory currently available for current and future objects, measured in bytes.

getTotalMemStr

public java.lang.String getTotalMemStr()
Description copied from interface: I_AdminNode
Nicer to read for humans.

Specified by:
getTotalMemStr in interface I_AdminNode
See Also:
I_AdminNode.getTotalMem()

getMaxMem

public long getMaxMem()
Description copied from interface: I_AdminNode
Returns the total amount of memory including what the Java virtual machine could additionally allocate. The value returned by this method does not change (see java -Xmx...).

Increase with for example java -Xmx512M on startup.

Specified by:
getMaxMem in interface I_AdminNode
Returns:
the total amount of memory currently available for current and future objects, measured in bytes.

getMaxMemStr

public java.lang.String getMaxMemStr()
Description copied from interface: I_AdminNode
Nicer to read for humans.

Specified by:
getMaxMemStr in interface I_AdminNode
See Also:
I_AdminNode.getMaxMem()

getUsedMem

public long getUsedMem()
Specified by:
getUsedMem in interface I_AdminNode
Returns:
getTotalMem() - getFreeMem()

getUsedMemStr

public java.lang.String getUsedMemStr()
Description copied from interface: I_AdminNode
Nicer to read for humans.

Specified by:
getUsedMemStr in interface I_AdminNode
See Also:
I_AdminNode.getUsedMem()

getGc

public java.lang.String getGc()
Specified by:
getGc in interface I_AdminNode

setGc

public void setGc(java.lang.String dummy)
Specified by:
setGc in interface I_AdminNode

exit

public void exit()
          throws XmlBlasterException
Description copied from interface: I_AdminNode
Shutdown xmlBlaster, exit value is '0'

Specified by:
exit in interface I_AdminNode
Throws:
XmlBlasterException

setExit

public void setExit(java.lang.String exitValue)
             throws XmlBlasterException
Specified by:
setExit in interface I_AdminNode
Throws:
XmlBlasterException

getHostname

public java.lang.String getHostname()
Description copied from interface: I_AdminNode
Access the bootstrap host name. This IP or DNS hostname is used for IOR download (CORBA) and for our internal tiny http server.

Specified by:
getHostname in interface I_AdminNode
Returns:
The hostname where xmlBlaster listens on

getPort

public int getPort()
The bootstrap bootstrap port

Specified by:
getPort in interface I_AdminNode
Returns:
The port number, for example 3412

getNumClients

public int getNumClients()
The number of different users, the sessions may be higher

Specified by:
getNumClients in interface I_AdminNode

getMaxClients

public int getMaxClients()
Description copied from interface: I_AdminNode
Get the maximum allowed number of clients.

Specified by:
getMaxClients in interface I_AdminNode

getAliveCallbackClients

public java.lang.String[] getAliveCallbackClients()
Description copied from interface: I_AdminNode
Shows the clients which have a alive callback connection.

Specified by:
getAliveCallbackClients in interface I_AdminNode
Returns:
The client session names

getClientList

public java.lang.String getClientList()
These are the login names returned, every client may be logged in multiple times which you can't see here

Specified by:
getClientList in interface I_AdminNode
Returns:
A comma separated list

getClients

public java.lang.String[] getClients()
Description copied from interface: I_AdminNode
Get the client names.

Specified by:
getClients in interface I_AdminNode
Returns:
An array with all client names

getNumSysprop

public int getNumSysprop()
Description copied from interface: I_AdminNode
Get the number of system properties.

Specified by:
getNumSysprop in interface I_AdminNode

getSyspropList

public java.lang.String getSyspropList()
Deprecated. Is not supported anymore

Description copied from interface: I_AdminNode
Get the system properties.

Specified by:
getSyspropList in interface I_AdminNode
Returns:
A comma separated list

getNumTopics

public int getNumTopics()
Description copied from interface: I_AdminNode
Get the number of topics.

Specified by:
getNumTopics in interface I_AdminNode

getTopicList

public java.lang.String getTopicList()
Description copied from interface: I_AdminNode
Get the topics.

Specified by:
getTopicList in interface I_AdminNode
Returns:
A comma separated list

getTopics

public java.lang.String[] getTopics()
Description copied from interface: I_AdminNode
Get the topics.

Specified by:
getTopics in interface I_AdminNode
Returns:
An array of all topic names

getNumSubscriptions

public int getNumSubscriptions()
Description copied from interface: I_AdminNode
Get the number of subscriptions.

Specified by:
getNumSubscriptions in interface I_AdminNode
Returns:
A comma separated list

getSubscriptionList

public java.lang.String getSubscriptionList()
Description copied from interface: I_AdminNode
Get the subscriptions.

Specified by:
getSubscriptionList in interface I_AdminNode
Returns:
A comma separated list

getSubscriptions

public java.lang.String[] getSubscriptions()
Description copied from interface: I_AdminNode
Get the subscriptions ids.

Specified by:
getSubscriptions in interface I_AdminNode
Returns:
An array of all subscription ids

displayClassInfo

public java.lang.String displayClassInfo(java.lang.String clazzName)
Description copied from interface: I_AdminNode
Check if the given java class is known and wherefrom it was loaded.

Specified by:
displayClassInfo in interface I_AdminNode
Returns:
The info

usage

public java.lang.String usage()
JMX

Specified by:
usage in interface I_AdminUsage
Returns:
a human readable usage help string

getUsageUrl

public java.lang.String getUsageUrl()
JMX

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

log

public void log(java.util.logging.LogRecord record)
Redirect logging, configure in xmlBlaster.properties. Enforced by interface LogableDevice

Specified by:
log in interface I_LogListener

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Declare available notification event types.

Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster
Overrides:
getNotificationInfo in class javax.management.NotificationBroadcasterSupport

getNumGet

public long getNumGet()
Specified by:
getNumGet in interface I_AdminNode
Returns:
Returns the number of get() invocations

getNumPublish

public long getNumPublish()
Specified by:
getNumPublish in interface I_AdminNode
Returns:
Returns the number if publish() invocations

getNumUpdate

public long getNumUpdate()
Description copied from interface: I_AdminNode
The overall sent updates (callback to client)

Specified by:
getNumUpdate in interface I_AdminNode

checkConsistency

public java.lang.String checkConsistency(java.lang.String fixIt,
                                         java.lang.String reportFileName)
Description copied from interface: I_AdminNode
Do consistency check.

Specified by:
checkConsistency in interface I_AdminNode
Parameters:
fixIt - If "true" (ignoring case) there will be attempts to fix problems, defaults to "false"
reportFileName - The file to dump the report
Returns:
A short status report

checkCallbackEntriesConsistency

public java.lang.String checkCallbackEntriesConsistency(boolean fixIt,
                                                        java.lang.String reportFileName)
Loop through all database entries of relating='callback' and check if there are entries from not existing sessions with pubSessionId=<0

Parameters:
fixIt - default to false which is readonly
reportFileName -
Returns:
A short report

reportMemoryOverviewToFile

public java.lang.String reportMemoryOverviewToFile(java.lang.String reportFileName)
Specified by:
reportMemoryOverviewToFile in interface I_AdminNode

reportMemoryOverview

public java.lang.String reportMemoryOverview()
Specified by:
reportMemoryOverview in interface I_AdminNode

reportMemoryOverview

private java.lang.String reportMemoryOverview(java.lang.String reportFileName)

checkConsistencyOld_XB_ENTRIES

public java.lang.String checkConsistencyOld_XB_ENTRIES(I_Map map,
                                                       boolean fixIt,
                                                       java.lang.String reportFileName)

dumpAllStacks

public java.lang.String dumpAllStacks()
Specified by:
dumpAllStacks in interface I_AdminNode

dumpAllStacksToFile

public java.lang.String dumpAllStacksToFile(java.lang.String file)
Specified by:
dumpAllStacksToFile in interface I_AdminNode

isAcceptWrongSenderAddress

public boolean isAcceptWrongSenderAddress()
Description copied from interface: I_AdminNode
Configure server with '-xmlBlaster/acceptWrongSenderAddress true' or "-xmlBlaster/acceptWrongSenderAddress/joe true".

Specified by:
isAcceptWrongSenderAddress in interface I_AdminNode
Returns:
true: We accept wrong sender address in PublishQos.getSender() (not myself)

setAcceptWrongSenderAddress

public void setAcceptWrongSenderAddress(boolean acceptWrongSenderAddress)
Specified by:
setAcceptWrongSenderAddress in interface I_AdminNode
Parameters:
acceptWrongSenderAddress - the acceptWrongSenderAddress to set

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.