xmlBlaster 1.5.1 API

org.xmlBlaster.util.recorder.file
Class FileRecorder

java.lang.Object
  extended byorg.xmlBlaster.util.recorder.file.FileRecorder
All Implemented Interfaces:
I_InvocationRecorder, I_Plugin, I_XmlBlaster

public class FileRecorder
extends java.lang.Object
implements I_Plugin, I_InvocationRecorder

Records requests of the client into a file, if the client is not able to connect to the xmlBlaster. By implementing the I_InvocationRecorder it can be plugged into the xmlBlaster. This implementation is very similar to the implementation of RamRecorder for the xmlBlaster ($XMLBLASTER_HOME/src/java/org/xmlBlaster/util/recorder/ram).

Configuration:

 RecorderPlugin[FileRecorder][1.0]=org.xmlBlaster.util.recorder.file.FileRecorder
 
See the util.recorder requirement.

Author:
astelzl@avitech.de, pavol.hrnciarik@pixelpark.com, xmlBlaster@marcelruff.info
See Also:
org.xmlBlaster.test.qos.TestFailSave, InvocationRecorderTest

Field Summary
private  boolean autoCommit
          Automatically write curr pos to file?
private  EraseReturnQos[] dummyEraseReturnQosArr
           
private  MsgUnit[] dummyMArr
           
private  PublishReturnQos dummyPubRet
           
private  PublishReturnQos[] dummyPubRetQosArr
           
private  SubscribeReturnQos dummySubRet
           
private  UnSubscribeReturnQos[] dummyUnSubRet
           
private  java.lang.String fileName
           
private  Global glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  FileIO rb
           
private  I_XmlBlaster serverCallback
           
 
Constructor Summary
FileRecorder()
           
 
Method Summary
private  void callback(RequestContainer cont)
           
private  java.lang.String createPathString(java.lang.String fn)
          Returns the name of the file to store tail back messages.
 void destroy()
          deletes the file
 EraseReturnQos[] erase(java.lang.String xmlKey, java.lang.String qos)
          storing erase request
 MsgUnit[] get(java.lang.String xmlKey, java.lang.String qos)
          storing get request
 java.lang.String getFullFileName()
          Returns the name of the database file or null if RAM based
 long getNumLost()
          How many messages are silently lost in 'discard' or 'discardOldest' mode?
 long getNumUnread()
          Number of requests buffered
 java.lang.String getType()
          Return plugin type for Plugin loader
 java.lang.String getVersion()
          Return plugin version for Plugin loader
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 void initialize(Global glob, java.lang.String fn, long maxEntries, I_XmlBlaster serverCallback)
          Setup the file name.
 boolean isFull()
          Dummy method.
 boolean ping()
           
 void playback(long startDate, long endDate, double motionFactor)
          Not implemented yet
 PublishReturnQos publish(MsgUnit msgUnit)
          storing publish request
 PublishReturnQos[] publishArr(MsgUnit[] msgUnitArr)
          storing publishArr request
 void publishOneway(MsgUnit[] msgUnitArr)
          storing publishOneway request
 void pullback(float msgPerSec)
          Playback the stored messages, the are removed from the recorder after the callback.
 void pullback(long startDate, long endDate, double motionFactor)
          This method reads out stored requests from the file where they were buffered.
 void setMode(java.lang.String mode)
           
 void shutdown()
          Cleans up the resource.
 SubscribeReturnQos subscribe(java.lang.String xmlKey, java.lang.String qos)
          storing subscribe request
 UnSubscribeReturnQos[] unSubscribe(java.lang.String xmlKey, java.lang.String qos)
          storing unSubscribe request
 java.lang.String[] update(java.lang.String cbSessionId, MsgUnit[] msgUnitArr)
          storing update request
 void updateOneway(java.lang.String cbSessionId, MsgUnit[] msgUnitArr)
          storing updateOneway request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private final java.lang.String ME
See Also:
Constant Field Values

glob

private Global glob

log

private static java.util.logging.Logger log

rb

private FileIO rb

fileName

private java.lang.String fileName

serverCallback

private I_XmlBlaster serverCallback

dummyMArr

private final MsgUnit[] dummyMArr

dummyPubRetQosArr

private final PublishReturnQos[] dummyPubRetQosArr

dummyPubRet

private PublishReturnQos dummyPubRet

dummySubRet

private SubscribeReturnQos dummySubRet

dummyUnSubRet

private UnSubscribeReturnQos[] dummyUnSubRet

dummyEraseReturnQosArr

private final EraseReturnQos[] dummyEraseReturnQosArr

autoCommit

private boolean autoCommit
Automatically write curr pos to file?

Constructor Detail

FileRecorder

public FileRecorder()
Method Detail

initialize

public void initialize(Global glob,
                       java.lang.String fn,
                       long maxEntries,
                       I_XmlBlaster serverCallback)
                throws XmlBlasterException
Setup the file name.

File name is:

   Persistence.Path=${user.home}${file.separator}tmp
   recorder.path=${Persistence.Path}${file.separator}fileRecorder

   The file name is
       tailback-[clientClusterNodeId]-[serverClusterNodeId].frc

   For example:
      /home/michelle/tmp/fileRecorder/tailback-heron-to-avalon.frc
 

Specified by:
initialize in interface I_InvocationRecorder
Parameters:
fn - The file name (without path information!) for persistence or null (will be generated or ignored if RAM based)
maxEntries - The maximum number of invocations to store
serverCallback - You need to implement I_XmlBlaster to receive the invocations on playback null if you are not interested in those
Throws:
XmlBlasterException
See Also:
util.recorder requirement

createPathString

private java.lang.String createPathString(java.lang.String fn)
Returns the name of the file to store tail back messages.

Example:

  For an ordinary client 'joe' with public session id 9

   /home/xmlblast/tmp/fileRecorder/tailback-joe9-to-frodo.frc

  In a cluster environment (which only logs in once (exactly one session):

   /home/xmlblast/tmp/fileRecorder/tailback-bilbo-to-heron.frc  (in cluster environment)
 
See the util.recorder requirement on how to configure.

Parameters:
fn - The file name, without any path information or null
Returns:
The complete path with filename

getFullFileName

public java.lang.String getFullFileName()
Returns the name of the database file or null if RAM based

Specified by:
getFullFileName in interface I_InvocationRecorder

init

public void init(Global glob,
                 PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin).

Specified by:
init in interface I_Plugin
See Also:
I_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)

getType

public java.lang.String getType()
Return plugin type for Plugin loader

Specified by:
getType in interface I_Plugin
Returns:
"FileRecorder"

getVersion

public java.lang.String getVersion()
Return plugin version for Plugin loader

Specified by:
getVersion in interface I_Plugin
Returns:
"1.0"

setMode

public void setMode(java.lang.String mode)
Specified by:
setMode in interface I_InvocationRecorder
Parameters:
mode - ONOVERFLOW_DEADMESSAGE = "deadMessage", ONOVERFLOW_DISCARD = "discard", ONOVERFLOW_DISCARDOLDEST = "discardOldest", ONOVERFLOW_EXCEPTION = "exception"

isFull

public final boolean isFull()
                     throws XmlBlasterException
Dummy method. Just provided as other recorders also provide it.

Specified by:
isFull in interface I_InvocationRecorder
Returns:
always false
Throws:
XmlBlasterException

getNumUnread

public final long getNumUnread()
Number of requests buffered

Specified by:
getNumUnread in interface I_InvocationRecorder
Returns:
The number of objects in this queue.

pullback

public void pullback(long startDate,
                     long endDate,
                     double motionFactor)
              throws XmlBlasterException
This method reads out stored requests from the file where they were buffered. Depending on the "request-method" the appropriate client operation will be invoked.

Specified by:
pullback in interface I_InvocationRecorder
Parameters:
startDate - Start date for playback, 0 means from the very start
endDate - End date to stop playback, pass 0 to go to the very end
motionFactor - for fast motion choose for example 4.0 so four reals seconds are elapsing in one second.
For slow motion choose for example 0.5 0. does everything instantly.
Throws:
XmlBlasterException

pullback

public void pullback(float msgPerSec)
              throws XmlBlasterException
Playback the stored messages, the are removed from the recorder after the callback.

The messages are retrieved with the given rate per second

This method is thread save, even for undo on exceptions.

Specified by:
pullback in interface I_InvocationRecorder
Parameters:
msgPerSec - 20. is 20 msg/sec, 0.1 is one message every 10 seconds
With -1.0 we deliver as fast as possible
Throws:
XmlBlasterException

getNumLost

public long getNumLost()
How many messages are silently lost in 'discard' or 'discardOldest' mode?

Specified by:
getNumLost in interface I_InvocationRecorder

playback

public void playback(long startDate,
                     long endDate,
                     double motionFactor)
              throws XmlBlasterException
Not implemented yet

Specified by:
playback in interface I_InvocationRecorder
Parameters:
startDate - Start date for playback, 0 means from the very start
endDate - End date to stop playback, pass 0 to go to the very end
motionFactor - for fast motion choose for example 4.0 so four reals seconds are elapsing in one second.
For slow motion choose for example 0.5
Throws:
XmlBlasterException

callback

private void callback(RequestContainer cont)
               throws XmlBlasterException
Throws:
XmlBlasterException

subscribe

public SubscribeReturnQos subscribe(java.lang.String xmlKey,
                                    java.lang.String qos)
                             throws XmlBlasterException
storing subscribe request

Specified by:
subscribe in interface I_XmlBlaster
Throws:
XmlBlasterException

unSubscribe

public UnSubscribeReturnQos[] unSubscribe(java.lang.String xmlKey,
                                          java.lang.String qos)
                                   throws XmlBlasterException
storing unSubscribe request

Specified by:
unSubscribe in interface I_XmlBlaster
Throws:
XmlBlasterException

publish

public PublishReturnQos publish(MsgUnit msgUnit)
                         throws XmlBlasterException
storing publish request

Specified by:
publish in interface I_XmlBlaster
Throws:
XmlBlasterException

publishOneway

public void publishOneway(MsgUnit[] msgUnitArr)
                   throws XmlBlasterException
storing publishOneway request

Specified by:
publishOneway in interface I_XmlBlaster
Throws:
XmlBlasterException

publishArr

public PublishReturnQos[] publishArr(MsgUnit[] msgUnitArr)
                              throws XmlBlasterException
storing publishArr request

Specified by:
publishArr in interface I_XmlBlaster
Throws:
XmlBlasterException

erase

public EraseReturnQos[] erase(java.lang.String xmlKey,
                              java.lang.String qos)
                       throws XmlBlasterException
storing erase request

Specified by:
erase in interface I_XmlBlaster
Throws:
XmlBlasterException

get

public MsgUnit[] get(java.lang.String xmlKey,
                     java.lang.String qos)
              throws XmlBlasterException
storing get request

Specified by:
get in interface I_XmlBlaster
Throws:
XmlBlasterException

ping

public boolean ping()

update

public java.lang.String[] update(java.lang.String cbSessionId,
                                 MsgUnit[] msgUnitArr)
                          throws XmlBlasterException
storing update request

Throws:
XmlBlasterException

updateOneway

public void updateOneway(java.lang.String cbSessionId,
                         MsgUnit[] msgUnitArr)
storing updateOneway request


destroy

public void destroy()
deletes the file

Specified by:
destroy in interface I_InvocationRecorder

shutdown

public void shutdown()
Description copied from interface: I_Plugin
Cleans up the resource.

Specified by:
shutdown in interface I_Plugin

xmlBlaster 1.5.1 API

Copyright © 1999-2007 The xmlBlaster.org contributers.