xmlBlaster 2.2.0 client API

org.xmlBlaster.util.qos
Class QosData

java.lang.Object
  extended by org.xmlBlaster.util.qos.QosData
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ConnectQosData, DisconnectQosData, MsgQosData, QueryQosData, StatusQosData

public abstract class QosData
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Base class for the various QoS implementations. Contains routing informations for cluster traversal

Author:
xmlBlaster@marcelruff.info
See Also:
MsgUnit, Serialized Form

Field Summary
static boolean DEFAULT_persistent
           
protected  Global glob
           
protected  Timestamp rcvTimestamp
          The receive timestamp (UTC time), when message arrived in requestBroker.publish() method.
In nanoseconds elapsed since midnight, January 1, 1970 UTC
protected  java.util.ArrayList<RouteInfo> routeNodeList
          ArrayList containing RouteInfo objects
protected  RouteInfo[] routeNodes
          Cache for RouteInfo in an array
protected  java.lang.String serialData
           
 
Constructor Summary
QosData(Global glob, java.lang.String serialData, MethodName methodName)
          Constructor, it does not parse the data, use a factory for this.
 
Method Summary
 void addClientProperty(ClientProperty clientProperty)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, boolean value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, byte value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, double value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, float value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, int value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, long value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, java.lang.Object value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, short value)
          Sets the client property to the given value
 void addClientProperty(java.lang.String key, java.lang.String type, java.lang.Object value)
          Sets the client property to the given value
 void addRouteInfo(RouteInfo routeInfo)
          Adds a new route hop to the QoS of this message.
 void clearRoutes()
           
 java.lang.Object clone()
          Returns a deep clone, you can change savely all mutable types.
 int count(NodeId nodeId)
          Check if the message has already been at the given node (circulating message).
 boolean dirtyRead(NodeId nodeId)
          Check if the message has already been at the given node (circulating message).
 java.util.Map<java.lang.String,ClientProperty> getClientProperties()
          Access all client properties.
 ClientProperty getClientProperty(java.lang.String name)
          Access the client property.
 boolean getClientProperty(java.lang.String name, boolean defaultValue)
          Access the boolean client property.
 byte getClientProperty(java.lang.String name, byte defaultValue)
          Access the byte client property.
 byte[] getClientProperty(java.lang.String name, byte[] defaultValue)
          Access the byte[] client property.
 double getClientProperty(java.lang.String name, double defaultValue)
          Access the double client property.
 float getClientProperty(java.lang.String name, float defaultValue)
          Access the float client property.
 int getClientProperty(java.lang.String name, int defaultValue)
          Access the integer client property.
 long getClientProperty(java.lang.String name, long defaultValue)
          Access the long client property.
 short getClientProperty(java.lang.String name, short defaultValue)
          Access the short client property.
 java.lang.String getClientProperty(java.lang.String name, java.lang.String defaultValue)
          Access the String client property.
 ClientProperty[] getClientPropertyArr()
           
 java.lang.String getContentCharset()
           
 java.lang.String getContentStr(byte[] msgContent)
          Convenience method to get the raw content as a string, the encoding is UTF-8 if not specified by clientProperty Constants.CLIENTPROPERTY_CONTENT_CHARSET
 java.lang.String getContentStrNoEx(byte[] msgContent)
           
 Global getGlobal()
           
 MethodName getMethod()
           
 int getNumRouteNodes()
          The number of hops
 PropBoolean getPersistentProp()
           
 java.lang.String getRcvTime()
          Deprecated. Use getXmlRcvTimestamp()
 Timestamp getRcvTimestamp()
          The approximate receive timestamp (UTC time), when message arrived in requestBroker.publish() method.
In milliseconds elapsed since midnight, January 1, 1970 UTC
 Timestamp getRcvTimestampNotNull()
           
 RouteInfo[] getRouteNodes()
           
 SessionName getSender()
          Access sender unified naming object.
 java.lang.String getState()
          Access state of message on update().
 java.lang.String getStateInfo()
          Access state of message on update().
 boolean hasStateInfo()
           
 boolean isAtMaster()
          Check if this message is at its master cluster location
 boolean isErase()
           
 boolean isErased()
          True if the message was erased by timer or by a client invoking erase().
 boolean isForwardError()
          True on cluster forward problems
 boolean isFromPersistenceRecovery()
          Flag if the message comes from persistent store after recovery.
 void isFromPersistenceRecovery(boolean fromPersistenceRecovery)
          Marker if the message comes from persistent store after recovery.
 boolean isGet()
           
 boolean isOk()
          True if the message is OK on update().
 boolean isPersistent()
           
 boolean isPublish()
           
 boolean isSubscribe()
           
 boolean isTimeout()
          True if a timeout on this message occurred.
 boolean isUnSubscribe()
           
 boolean isUpdate()
           
 boolean propertyExists(java.lang.String name)
          Check for client property.
 void setGlobal(Global glob)
          Sets the global object (used when deserializing the object)
 void setMethod(MethodName methodName)
           
 void setPersistent(boolean persistent)
           
 void setRcvTimestamp(Timestamp rcvTimestamp)
          The approximate receive timestamp (UTC time), when message arrived in requestBroker.publish() method.
In milliseconds elapsed since midnight, January 1, 1970 UTC
 void setSender(SessionName senderSessionName)
          Access sender name.
 void setState(java.lang.String state)
           
 void setStateInfo(java.lang.String stateInfo)
           
 int size()
          The data size for persistence
 void touchRcvTimestamp()
          Set timestamp to current time.
abstract  java.lang.String toXml()
          The literal XML string of the QoS
abstract  java.lang.String toXml(java.lang.String extraOffset, java.util.Properties props)
          Dump state of this object into a XML ASCII string.
 java.lang.String toXmlReadable()
           
 java.lang.String writePropertiesXml(java.lang.String offset)
           
 java.lang.String writePropertiesXml(java.lang.String offset, boolean forceReadable)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

glob

protected transient Global glob

serialData

protected final transient java.lang.String serialData

rcvTimestamp

protected Timestamp rcvTimestamp
The receive timestamp (UTC time), when message arrived in requestBroker.publish() method.
In nanoseconds elapsed since midnight, January 1, 1970 UTC


DEFAULT_persistent

public static final transient boolean DEFAULT_persistent
See Also:
Constant Field Values

routeNodeList

protected java.util.ArrayList<RouteInfo> routeNodeList
ArrayList containing RouteInfo objects


routeNodes

protected transient RouteInfo[] routeNodes
Cache for RouteInfo in an array

Constructor Detail

QosData

public QosData(Global glob,
               java.lang.String serialData,
               MethodName methodName)
Constructor, it does not parse the data, use a factory for this.

Method Detail

setGlobal

public void setGlobal(Global glob)
Sets the global object (used when deserializing the object)


setState

public void setState(java.lang.String state)
Parameters:
state - The state of an update message

getState

public java.lang.String getState()
Access state of message on update().

Returns:
Usually Constants.OK

setStateInfo

public void setStateInfo(java.lang.String stateInfo)
Parameters:
state - The human readable state text of an update message

getStateInfo

public java.lang.String getStateInfo()
Access state of message on update().

Returns:
The human readable info text

hasStateInfo

public boolean hasStateInfo()

isOk

public boolean isOk()
True if the message is OK on update().


isErased

public boolean isErased()
True if the message was erased by timer or by a client invoking erase().


isTimeout

public final boolean isTimeout()
True if a timeout on this message occurred.

Timeouts are spanned by the publisher and thrown by xmlBlaster on timeout to indicate for example STALE messages or any other user problem domain specific event.


isForwardError

public final boolean isForwardError()
True on cluster forward problems


isFromPersistenceRecovery

public void isFromPersistenceRecovery(boolean fromPersistenceRecovery)
Marker if the message comes from persistent store after recovery. NOTE: This information is not saved in to XML and is lost after a XML dump.


isFromPersistenceRecovery

public boolean isFromPersistenceRecovery()
Flag if the message comes from persistent store after recovery.


getSender

public SessionName getSender()
Access sender unified naming object. The sender (publisher) of this message (unique loginName), is set by server on arrival, and delivered with UpdateQos (with XML).

Returns:
sessionName of sender or null if not known

setSender

public void setSender(SessionName senderSessionName)
Access sender name.

Parameters:
loginName - of sender

setRcvTimestamp

public void setRcvTimestamp(Timestamp rcvTimestamp)
The approximate receive timestamp (UTC time), when message arrived in requestBroker.publish() method.
In milliseconds elapsed since midnight, January 1, 1970 UTC


getRcvTimestamp

public Timestamp getRcvTimestamp()
The approximate receive timestamp (UTC time), when message arrived in requestBroker.publish() method.
In milliseconds elapsed since midnight, January 1, 1970 UTC

This timestamp is unique for a message instance published and may be used to identify this message. For example a publisher and a receiver of a message can identify this message by its topic (key oid) and its receive timestamp.

To get a human readable view on the timestamp try:

 String time = qos.getRcvTimestamp().toString();

 -> "2002-02-10 10:52:40.879456789"
 

Returns:
can be null if not touchRcvTimestamp() was called

getRcvTimestampNotNull

public Timestamp getRcvTimestampNotNull()
Returns:
Never null
See Also:
getRcvTimestamp()

touchRcvTimestamp

public void touchRcvTimestamp()
Set timestamp to current time.


getRcvTime

public java.lang.String getRcvTime()
Deprecated. Use getXmlRcvTimestamp()

Human readable form of message receive time in xmlBlaster server, in SQL representation e.g.:
2001-12-07 23:31:45.862000004


setPersistent

public void setPersistent(boolean persistent)
Parameters:
persistent - mark a message as persistent

isPersistent

public boolean isPersistent()
Returns:
true/false

getPersistentProp

public PropBoolean getPersistentProp()

addRouteInfo

public final void addRouteInfo(RouteInfo routeInfo)
Adds a new route hop to the QoS of this message. The added routeInfo is assumed to be one stratum closer to the master So we will rearrange the stratum here. The given stratum in routeInfo is used to recalculate the other nodes as well.


getNumRouteNodes

public final int getNumRouteNodes()
The number of hops


getRouteNodes

public final RouteInfo[] getRouteNodes()
Returns:
never null, but may have length==0

clearRoutes

public final void clearRoutes()

count

public int count(NodeId nodeId)
Check if the message has already been at the given node (circulating message).

Returns:
How often the message has travelled the node already

isAtMaster

public final boolean isAtMaster()
Check if this message is at its master cluster location


dirtyRead

public boolean dirtyRead(NodeId nodeId)
Check if the message has already been at the given node (circulating message).

Returns:
How often the message has travelled the node already

size

public int size()
The data size for persistence

Returns:
The size in bytes of the data in XML form

toXml

public abstract java.lang.String toXml()
The literal XML string of the QoS


toXml

public abstract java.lang.String toXml(java.lang.String extraOffset,
                                       java.util.Properties props)
Dump state of this object into a XML ASCII string.

Parameters:
extraOffset - indenting of tags for nice output
forceReadable - hint to dump in human readable form (avoid Base64)
Returns:
internal state of the query as a XML ASCII string

toXmlReadable

public java.lang.String toXmlReadable()

getGlobal

public final Global getGlobal()

getMethod

public final MethodName getMethod()

setMethod

public final void setMethod(MethodName methodName)

isPublish

public final boolean isPublish()

isSubscribe

public final boolean isSubscribe()

isUnSubscribe

public final boolean isUnSubscribe()

isErase

public final boolean isErase()

isGet

public final boolean isGet()

isUpdate

public final boolean isUpdate()

clone

public java.lang.Object clone()
Returns a deep clone, you can change savely all mutable types. Immutable types are not cloned as they can't be changed.

Overrides:
clone in class java.lang.Object

addClientProperty

public final void addClientProperty(ClientProperty clientProperty)
Sets the client property to the given value


addClientProperty

public final void addClientProperty(java.lang.String key,
                                    java.lang.String type,
                                    java.lang.Object value)
Sets the client property to the given value

Parameters:
key -
type - For example Constants.TYPE_FLOAT
value - Of any type, it will be forced to the given type

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    java.lang.Object value)
Sets the client property to the given value

Parameters:
key -
value - for example a Float or Integer value

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    boolean value)
Sets the client property to the given value

Parameters:
key -
value -

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    int value)
Sets the client property to the given value

Parameters:
key -
value -

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    byte value)
Sets the client property to the given value

Parameters:
key -
value -

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    long value)
Sets the client property to the given value

Parameters:
key -
value -

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    short value)
Sets the client property to the given value

Parameters:
key -
value -

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    double value)
Sets the client property to the given value

Parameters:
key -
value -

addClientProperty

public final void addClientProperty(java.lang.String key,
                                    float value)
Sets the client property to the given value

Parameters:
key -
value -

getClientProperty

public final ClientProperty getClientProperty(java.lang.String name)
Access the client property.

Parameters:
name - The property key
Returns:
The ClientProperty instance or null if not found

propertyExists

public final boolean propertyExists(java.lang.String name)
Check for client property.

Parameters:
name - The property key
Returns:
true if the property exists

getClientProperty

public final java.lang.String getClientProperty(java.lang.String name,
                                                java.lang.String defaultValue)
Access the String client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final int getClientProperty(java.lang.String name,
                                   int defaultValue)
Access the integer client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final boolean getClientProperty(java.lang.String name,
                                       boolean defaultValue)
Access the boolean client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final double getClientProperty(java.lang.String name,
                                      double defaultValue)
Access the double client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final float getClientProperty(java.lang.String name,
                                     float defaultValue)
Access the float client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final byte getClientProperty(java.lang.String name,
                                    byte defaultValue)
Access the byte client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final byte[] getClientProperty(java.lang.String name,
                                      byte[] defaultValue)
Access the byte[] client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final long getClientProperty(java.lang.String name,
                                    long defaultValue)
Access the long client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperty

public final short getClientProperty(java.lang.String name,
                                     short defaultValue)
Access the short client property.

Parameters:
name - The property key
defaultValue - The value to return if the property is not known

getClientProperties

public final java.util.Map<java.lang.String,ClientProperty> getClientProperties()
Access all client properties.

Returns:
a map The return is unordered and the map values are of type ClientProperty.
See Also:
ClientProperty

getClientPropertyArr

public final ClientProperty[] getClientPropertyArr()
Returns:
never null

writePropertiesXml

public final java.lang.String writePropertiesXml(java.lang.String offset)

writePropertiesXml

public final java.lang.String writePropertiesXml(java.lang.String offset,
                                                 boolean forceReadable)

getContentCharset

public java.lang.String getContentCharset()

getContentStr

public java.lang.String getContentStr(byte[] msgContent)
                               throws XmlBlasterException
Convenience method to get the raw content as a string, the encoding is UTF-8 if not specified by clientProperty Constants.CLIENTPROPERTY_CONTENT_CHARSET

Returns:
never null
Throws:
XmlBlasterException

getContentStrNoEx

public java.lang.String getContentStrNoEx(byte[] msgContent)

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.