|
xmlBlaster 2.2.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xmlBlaster.engine.MsgUnitWrapper
public final class MsgUnitWrapper
Wraps a publish() message into an entry for a persistence cache.
There are two options to make this object persistent (measure on a 2GHz Intel Linux laptop with Postgres):
1. QoS and Key are stored as XML ASCII strings, the content as byte[]
This variant takes about 50 microsec to serialize (toXml()) and 380 microsec to create the object again (SAX parse).
The size for an empty content is approx. 80 bytes for a medium sized key and QoS.
2. The whole object is java.io.Serialized
This variant takes about 160 microsec to serialize and 750 microsec to deserialize.
So we have chosen the XML variant as it is faster, has no versioning problems and has smaller size
ServerEntryFactory.main(String[]),
Serialized Form| Field Summary | |
|---|---|
private static int |
ALIVE
|
private static int |
DESTROYED
|
private Timeout |
destroyTimer
This topic is destroyed after given timeout The timer is activated on state change to UNREFERENCED and removed on change to ALIVE |
private java.lang.String |
embeddedType
|
private static int |
EXPIRED
|
private ServerScope |
glob
|
private int |
historyReferenceCounter
|
private long |
immutableSizeInBytes
|
private static java.util.logging.Logger |
log
|
private MsgUnit |
msgUnit
|
private I_Map |
ownerCache
|
private static int |
PRE_EXPIRED
|
private int |
referenceCounter
|
private java.lang.Object |
returnObj
|
private static long |
serialVersionUID
|
private Timestamp |
sortTimestamp
|
private int |
state
|
private StorageId |
storageId
|
private boolean |
stored
|
private boolean |
swapped
|
private Timestamp |
timerKey
|
private long |
uniqueId
|
private java.lang.String |
uniqueIdStr
|
private boolean |
wantReturnObj
used to tell to the MsgQueueEntry if a return value is desidered |
| Constructor Summary | |
|---|---|
MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
I_Map ownerCache,
int referenceCounter,
int historyReferenceCounter,
long sizeInBytes)
Used when message is created from TopicHandler.publish |
|
MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
I_Map ownerCache,
StorageId storageId,
int referenceCounter,
int historyReferenceCounter,
java.lang.String embeddedType,
long sizeInBytes)
Used when message comes from persistence, the owning I_Map is unknown |
|
MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
StorageId storageId)
Testsuite |
|
MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
StorageId storageId,
int referenceCounter,
int historyReferenceCounter,
long sizeInBytes)
Used when message comes from persistence, the owning I_Map is unknown |
|
| Method Summary | |
|---|---|
void |
added(StorageId storageId)
Notification if this entry is added to storage |
I_MapEntry |
changeEntry(I_MapEntry entry)
Callback invoked by I_Map.change inside the synchronization point. |
java.lang.Object |
clone()
Returns a shallow clone |
void |
embeddedObjectToXml(java.io.OutputStream out,
java.util.Properties props)
Dump content to xml representation |
void |
finalize()
Cleanup timer, it is a weak reference on us therefor it is a 'nice to have'. |
java.lang.String |
getContentMime()
|
java.lang.String |
getContentMimeExtended()
|
java.lang.String |
getDomain()
|
java.lang.Object |
getEmbeddedObject()
The embedded object. |
java.lang.String |
getEmbeddedType()
Gets the type of the object embedded in this entry, how the object is serialized. |
int |
getHistoryReferenceCounter()
|
java.lang.String |
getKeyOid()
|
java.lang.String |
getLogId()
Return a human readable identifier for logging output. |
XBMeat |
getMeat()
For the new queues |
MsgKeyData |
getMsgKeyData()
|
MsgQosData |
getMsgQosData()
|
MsgUnit |
getMsgUnit()
|
int |
getPriority()
Returns a dummy only as sorting is not important in this context. |
XBRef |
getRef()
For the new queues |
int |
getReferenceCounter()
|
java.lang.Object |
getReturnObj()
|
ServerScope |
getServerScope()
|
long |
getSizeInBytes()
returns the size in bytes of this entry. |
Timestamp |
getSortTimestamp()
Can be used by cache implementation to implement LRU |
java.lang.String |
getStateStr()
|
StorageId |
getStorageId()
Must be filled if retrieved from database. |
long |
getUniqueId()
The unique ID for this entry = getMsgQosData().getRcvTimestamp().getTimestamp() |
java.lang.String |
getUniqueIdStr()
|
boolean |
getWantReturnObj()
|
boolean |
hasRemainingLife()
The state may still be alive. |
void |
incrementReferenceCounter(int count,
StorageId storageId)
Invoked by ReferenceEntry.java and TopicHandler.java to support reference counting |
private boolean |
isAlive()
|
boolean |
isDestroyed()
|
boolean |
isExpired()
|
boolean |
isInternal()
|
boolean |
isPersistent()
Returns true if the entry is persistent (persistent on HD), false otherwise. |
boolean |
isStored()
|
boolean |
isSwapped()
The cache sets it to true when the entry is swapped away. |
void |
isSwapped(boolean swapped)
Used by the cache implementation to mark entries which will be swapped to the persistent store. |
void |
removed(StorageId storageId)
Notification if this entry is removed from storage |
void |
setMsgUnit(MsgUnit msg)
|
(package private) void |
setReferenceCounter(int count)
Internal use for TopicHandler |
void |
setReturnObj(java.lang.Object returnObj)
Set the object to be carried as return value. |
void |
setSortTimestamp(Timestamp timestamp)
Can be used by cache implementation to implement LRU |
void |
setStored(boolean stored)
Is invoked by the storage implementation with 'true' when the entry is put in a storage and with 'false' when the entry is removed from the storage. |
void |
setWantReturnObj(boolean wantReturnObj)
Sets this flag to true/false. |
void |
startExpiryTimer()
|
void |
timeout(java.lang.Object userData)
This timeout occurs after a configured expiration delay |
void |
toDestroyed()
Called by TopicHandler.java or ReferenceEntry.java |
private void |
toExpired()
|
java.lang.String |
toXml()
|
java.lang.String |
toXml(java.lang.String extraOffset,
boolean forceReadable)
Dumps the message. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private final transient ServerScope glob
private static java.util.logging.Logger log
private transient int historyReferenceCounter
private transient int referenceCounter
private final transient long uniqueId
private final transient java.lang.String uniqueIdStr
private transient I_Map ownerCache
private final transient java.lang.String embeddedType
private transient boolean wantReturnObj
private transient java.lang.Object returnObj
private transient Timeout destroyTimer
private transient Timestamp timerKey
private static final int ALIVE
private static final int PRE_EXPIRED
private static final int EXPIRED
private static final int DESTROYED
private transient int state
private MsgUnit msgUnit
private final long immutableSizeInBytes
private boolean stored
private transient boolean swapped
private transient Timestamp sortTimestamp
private transient StorageId storageId
| Constructor Detail |
|---|
public MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
StorageId storageId)
throws XmlBlasterException
XmlBlasterException
public MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
I_Map ownerCache,
int referenceCounter,
int historyReferenceCounter,
long sizeInBytes)
throws XmlBlasterException
XmlBlasterException
public MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
StorageId storageId,
int referenceCounter,
int historyReferenceCounter,
long sizeInBytes)
throws XmlBlasterException
XmlBlasterException
public MsgUnitWrapper(ServerScope glob,
MsgUnit msgUnit,
I_Map ownerCache,
StorageId storageId,
int referenceCounter,
int historyReferenceCounter,
java.lang.String embeddedType,
long sizeInBytes)
throws XmlBlasterException
embeddedType - Allows you to control how to make this object persistent:sizeInBytes - The estimated size of this entry in RAM, if -1 we estimate it for you
XmlBlasterException| Method Detail |
|---|
public final ServerScope getServerScope()
public void finalize()
finalize in class java.lang.Objectpublic boolean isSwapped()
isSwapped in interface I_MapEntryI_Map#isSwapped()public void isSwapped(boolean swapped)
isSwapped in interface I_MapEntry
public void incrementReferenceCounter(int count,
StorageId storageId)
throws XmlBlasterException
count - The number of ref-counts to add/subtractstorageId -
XmlBlasterExceptionvoid setReferenceCounter(int count)
public I_MapEntry changeEntry(I_MapEntry entry)
throws XmlBlasterException
changeEntry in interface I_ChangeCallbackentry - the entry to modify.
XmlBlasterException - if something has gone wrong and the change must be rolled back.public int getReferenceCounter()
public int getHistoryReferenceCounter()
public int getPriority()
getPriority in interface I_Entrypublic MsgQosData getMsgQosData()
public boolean isPersistent()
I_Entry
isPersistent in interface I_Entrypublic MsgKeyData getMsgKeyData()
public MsgUnit getMsgUnit()
public final java.lang.String getKeyOid()
public java.lang.String getContentMime()
public java.lang.String getContentMimeExtended()
public java.lang.String getDomain()
public void setMsgUnit(MsgUnit msg)
public long getSizeInBytes()
I_Entry
getSizeInBytes in interface I_Entrypublic long getUniqueId()
getUniqueId in interface I_Entrypublic java.lang.String getUniqueIdStr()
getUniqueIdStr in interface I_MapEntrypublic final java.lang.String getLogId()
I_EntrySee the derived class for a syntax description.
getLogId in interface I_Entrypublic final boolean isInternal()
public java.lang.String getEmbeddedType()
I_Entry
getEmbeddedType in interface I_Entrypublic java.lang.Object getEmbeddedObject()
IMPORTANT NOTE: If you change the data here you need to change MsgQueueUpdateEntry#getEmbeddedObject() as well! Check ServerEntryFactory as well.
getEmbeddedObject in interface I_Entrypublic java.lang.Object clone()
clone in class java.lang.Objectpublic final java.lang.String toXml()
public final void embeddedObjectToXml(java.io.OutputStream out,
java.util.Properties props)
throws java.io.IOException
I_Entry
embeddedObjectToXml in interface I_Entryout - The stream to dump toprops - Control porperties
java.io.IOException
public java.lang.String toXml(java.lang.String extraOffset,
boolean forceReadable)
public void added(StorageId storageId)
added in interface I_EntryI_Entry.added(StorageId)public void removed(StorageId storageId)
removed in interface I_EntrystorageId - The storage idI_Entry.removed(StorageId)private boolean isAlive()
public boolean hasRemainingLife()
public void startExpiryTimer()
public boolean isExpired()
private void toExpired()
throws XmlBlasterException
XmlBlasterExceptionpublic boolean isDestroyed()
public void toDestroyed()
public final void timeout(java.lang.Object userData)
timeout in interface I_TimeoutuserData - You get bounced back your userData which you passed
with Timeout.addTimeoutListener()public java.lang.String getStateStr()
public final void setStored(boolean stored)
I_EntryNote that this callback is guaranteed to be called from within the queue specific synchronized block
Todo: Remove this in favour of added()/removed() (isStored() is currently only used by CacheQueueInterceptorPlugin.java) I'm not sure if this usage relies on being inside syncThis method may never throw any exception
setStored in interface I_Entrystored - 'true' if the entry will be put into the storage, 'false' if it is removed.I_Entry.setStored(boolean)public final boolean isStored()
isStored in interface I_EntryI_Entry.isStored()public void setWantReturnObj(boolean wantReturnObj)
wantReturnObj - public boolean getWantReturnObj()
public java.lang.Object getReturnObj()
public void setReturnObj(java.lang.Object returnObj)
public final Timestamp getSortTimestamp()
getSortTimestamp in interface I_MapEntrypublic final void setSortTimestamp(Timestamp timestamp)
setSortTimestamp in interface I_MapEntrypublic XBMeat getMeat()
getMeat in interface I_Entrypublic XBRef getRef()
getRef in interface I_Entrypublic StorageId getStorageId()
I_MapEntry
getStorageId in interface I_MapEntry
|
xmlBlaster 2.2.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||