org.apache.sandesha.storage.dao
Class SandeshaQueueDAO

java.lang.Object
  extended byorg.apache.sandesha.storage.dao.SandeshaQueueDAO
All Implemented Interfaces:
ISandeshaDAO

public class SandeshaQueueDAO
extends java.lang.Object
implements ISandeshaDAO

Author:
Chamikara Jayalath, Jaliya Ekanayaka

Constructor Summary
SandeshaQueueDAO(byte endPoint)
           
 
Method Summary
 boolean addIncomingSequence(java.lang.String sequenceId)
          This adds a new entry in the storage to to hold messages of a perticular sequence that come in to the sandesha server/client
 void addLowPriorityMessage(RMMessageContext msg)
          Adds a low priority message to the storage (e.g.
 boolean addMessageToIncomingSequence(java.lang.String sequenceId, java.lang.Long msgNo, RMMessageContext rmMessageContext)
          This adds a incoming message to a area belonging to the given sequence in the queue.
 boolean addMessageToOutgoingSequence(java.lang.String sequenceId, RMMessageContext rmMessageContext)
          This adds the given message to the given sequence.
 void addOffer(java.lang.String msgID, java.lang.String offerID)
          Sets the offered incoming sequence, of a outgoing sequence.
 boolean addOutgoingSequence(java.lang.String sequenceId)
          This adds a entry in the storage for holding the messages of the given outgoing sequence.
 boolean addPriorityMessage(RMMessageContext msg)
          Adds a priority message (e.g.
 void addRequestedSequence(java.lang.String seqId)
          When a server or client sends a create sequence, it will be marked from this method.
 void addSendMsgNo(java.lang.String seqId, long msgNo)
          The message will be added to a sent list (the list holds the messages that were sent at least once)
 RMMessageContext checkForResponseMessage(java.lang.String requestId, java.lang.String seqId)
          When the messageId of therequest message (e.g.
 void clear()
          clears the storage.
 java.lang.String getAcksTo(java.lang.String seqId)
          gets the acksTo value
 java.util.Set getAllReceivedMsgNumsOfIncomingSeq(java.lang.String sequenceId)
          This reutns a set of message numbers with all the message numbers of incoming sequence.
 java.lang.String getKeyFromIncomingSequenceId(java.lang.String seqID)
          The client side will not be able to have sequenceId as a key for storing request messages.
 java.lang.String getKeyFromOutgoingSequenceId(java.lang.String seqID)
          This asks for the above key (the key used to hold messages) given the outgoing sequece id.
 long getLastIncomingMsgNo(java.lang.String seqId)
          Asks for the last message of the incoming sequence (if it has been received)
 RMMessageContext getNextLowPriorityMessageContextToSend()
          Asks the storage for the next low priority message (if there is any)
 RMMessageContext getNextMsgContextToProcess(java.lang.Object sequence)
          This tries to get the next message to be sent from the given outgoing sequence If these is no message to be sent in the given sequence, null will be returned.
 long getNextOutgoingMessageNumber(java.lang.String sequenceId)
          This gives the next message number, outgoing storage of the given sequence esxpects.
 RMMessageContext getNextOutgoingMsgContextToSend()
          Gets the next possible message to be sent from the queue.
 RMMessageContext getNextPriorityMessageContextToSend()
          This checks the priority messages to see weather there is any one to be sent (either for the first time or a retransmission)
 java.lang.String getOffer(java.lang.String msgID)
          Gets the offered incoming sequence, of outgoing sequence.
 java.lang.Object getRandomSeqToProcess()
           
 java.lang.String getSequenceOfOutSequence(java.lang.String outsequenceId)
          this gives the seqId which is used to hold the messages of which the outsequence entry has been set to the value outsequenceId.
 boolean hasLastIncomingMsgReceived(java.lang.String seqId)
          Can be used to ckeck weather the last message has been received in the incoming sequence.
 boolean isAllIncommingTerminateReceived()
          Use this to check weather the terminate message of all sequences (incoming) has been received.
 boolean isAllOutgoingTerminateSent()
          Checks weather the terminate message of all out going sequences have been sent.
 boolean isIncomingMessageExists(java.lang.String sequenceId, java.lang.Long msgNo)
          This checks in the given incoming sequence to see weather a message of the given message no exists
 boolean isIncomingSequenceExists(java.lang.String sequenceId)
          This checks weather there is a entry for the given incoming sequence in the queue.
 boolean isIncommingTerminateReceived(java.lang.String seqId)
           
 boolean isOutgoingSequenceExists(java.lang.String sequenceId)
          Checks weather a entry for the given outgoing sequence exists in the queue.
 boolean isOutgoingTerminateSent(java.lang.String seqId)
           
 boolean isRequestedSeqPresent(java.lang.String seqId)
          Check weather the given sequence id is one of the requested once (see 'addRequestedSequence')
 boolean isSentMsg(java.lang.String seqId, long msgNo)
          Asks from the storage weather the given message has been sent at least once
 void markOutgoingMessageToDelete(java.lang.String seqId, java.lang.Long msgNo)
          This outgoing message will be marked as deleted.
 void removeAllAcks(java.lang.String sequenceID)
           
 void removeCreateSequenceMsg(java.lang.String messageId)
          This checks the priority queue for a message if given messageid and moves it to the bin
 java.lang.String searchForSequenceId(java.lang.String messageId)
          Tries to give the sequence id of the outgoing message with the given message id
 void sendAck(java.lang.String sequenceId)
           
 void setAckReceived(java.lang.String seqId, long msgNo)
          Tells to the rtorage that the given message of given sequence was acked.
 void setAcksTo(java.lang.String seqId, java.lang.String acksTo)
          Set the acks to of the given sequence.
 void setOutSequence(java.lang.String seqId, java.lang.String outSeqId)
          This sets the outgoing sequence.
 void setOutSequenceApproved(java.lang.String seqId, boolean approved)
          This sets a flag in the queue to indicate that the outSequence of the perticular message set (stored with the id seqId) has been set correctly.
 void setTerminateReceived(java.lang.String seqId)
          Sets a incoming sequence of messages as terminate received.
 void setTerminateSend(java.lang.String seqId)
          Sets this after sending the terminate sequence message.
 void updateFinalMessageArrivedTime(java.lang.String sequenceID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SandeshaQueueDAO

public SandeshaQueueDAO(byte endPoint)
Method Detail

addIncomingSequence

public boolean addIncomingSequence(java.lang.String sequenceId)
Description copied from interface: ISandeshaDAO
This adds a new entry in the storage to to hold messages of a perticular sequence that come in to the sandesha server/client

Specified by:
addIncomingSequence in interface ISandeshaDAO

addPriorityMessage

public boolean addPriorityMessage(RMMessageContext msg)
Description copied from interface: ISandeshaDAO
Adds a priority message (e.g. create seq) to the queue. These will be sent before other messages like application requests.

Specified by:
addPriorityMessage in interface ISandeshaDAO

getNextPriorityMessageContextToSend

public RMMessageContext getNextPriorityMessageContextToSend()
Description copied from interface: ISandeshaDAO
This checks the priority messages to see weather there is any one to be sent (either for the first time or a retransmission)

Specified by:
getNextPriorityMessageContextToSend in interface ISandeshaDAO

addMessageToIncomingSequence

public boolean addMessageToIncomingSequence(java.lang.String sequenceId,
                                            java.lang.Long msgNo,
                                            RMMessageContext rmMessageContext)
Description copied from interface: ISandeshaDAO
This adds a incoming message to a area belonging to the given sequence in the queue.

Specified by:
addMessageToIncomingSequence in interface ISandeshaDAO

isIncomingSequenceExists

public boolean isIncomingSequenceExists(java.lang.String sequenceId)
Description copied from interface: ISandeshaDAO
This checks weather there is a entry for the given incoming sequence in the queue.

Specified by:
isIncomingSequenceExists in interface ISandeshaDAO

getNextMsgContextToProcess

public RMMessageContext getNextMsgContextToProcess(java.lang.Object sequence)
Description copied from interface: ISandeshaDAO
This tries to get the next message to be sent from the given outgoing sequence If these is no message to be sent in the given sequence, null will be returned.

Specified by:
getNextMsgContextToProcess in interface ISandeshaDAO

getRandomSeqToProcess

public java.lang.Object getRandomSeqToProcess()
Specified by:
getRandomSeqToProcess in interface ISandeshaDAO

getAllReceivedMsgNumsOfIncomingSeq

public java.util.Set getAllReceivedMsgNumsOfIncomingSeq(java.lang.String sequenceId)
Description copied from interface: ISandeshaDAO
This reutns a set of message numbers with all the message numbers of incoming sequence.

Specified by:
getAllReceivedMsgNumsOfIncomingSeq in interface ISandeshaDAO

isIncomingMessageExists

public boolean isIncomingMessageExists(java.lang.String sequenceId,
                                       java.lang.Long msgNo)
Description copied from interface: ISandeshaDAO
This checks in the given incoming sequence to see weather a message of the given message no exists

Specified by:
isIncomingMessageExists in interface ISandeshaDAO

addMessageToOutgoingSequence

public boolean addMessageToOutgoingSequence(java.lang.String sequenceId,
                                            RMMessageContext rmMessageContext)
Description copied from interface: ISandeshaDAO
This adds the given message to the given sequence.

Specified by:
addMessageToOutgoingSequence in interface ISandeshaDAO

addOutgoingSequence

public boolean addOutgoingSequence(java.lang.String sequenceId)
Description copied from interface: ISandeshaDAO
This adds a entry in the storage for holding the messages of the given outgoing sequence.

Specified by:
addOutgoingSequence in interface ISandeshaDAO

isOutgoingSequenceExists

public boolean isOutgoingSequenceExists(java.lang.String sequenceId)
Description copied from interface: ISandeshaDAO
Checks weather a entry for the given outgoing sequence exists in the queue.

Specified by:
isOutgoingSequenceExists in interface ISandeshaDAO

getNextOutgoingMsgContextToSend

public RMMessageContext getNextOutgoingMsgContextToSend()
Description copied from interface: ISandeshaDAO
Gets the next possible message to be sent from the queue.

Specified by:
getNextOutgoingMsgContextToSend in interface ISandeshaDAO

setOutSequence

public void setOutSequence(java.lang.String seqId,
                           java.lang.String outSeqId)
Description copied from interface: ISandeshaDAO
This sets the outgoing sequence. Here seqId is the entry in the queue that we hope to hold the messages of a perticular sequence. outseqid is the actual sequence id (i.e. uuid). That will be set within the wsrm:sequence field of this message. (remember that we may not have received this actual outgoing sequence id by the time we start to store outgoing messages).

Specified by:
setOutSequence in interface ISandeshaDAO

setOutSequenceApproved

public void setOutSequenceApproved(java.lang.String seqId,
                                   boolean approved)
Description copied from interface: ISandeshaDAO
This sets a flag in the queue to indicate that the outSequence of the perticular message set (stored with the id seqId) has been set correctly. The value in outSequence may be wrong before the sender gets the create seq. response. After getting this and after setting the out sequence correctly using the previous method, this flag will be set to true. Only then these messages thould be send to the sender.

Specified by:
setOutSequenceApproved in interface ISandeshaDAO

getSequenceOfOutSequence

public java.lang.String getSequenceOfOutSequence(java.lang.String outsequenceId)
Description copied from interface: ISandeshaDAO
this gives the seqId which is used to hold the messages of which the outsequence entry has been set to the value outsequenceId.

Specified by:
getSequenceOfOutSequence in interface ISandeshaDAO

removeCreateSequenceMsg

public void removeCreateSequenceMsg(java.lang.String messageId)
Description copied from interface: ISandeshaDAO
This checks the priority queue for a message if given messageid and moves it to the bin

Specified by:
removeCreateSequenceMsg in interface ISandeshaDAO

getNextOutgoingMessageNumber

public long getNextOutgoingMessageNumber(java.lang.String sequenceId)
Description copied from interface: ISandeshaDAO
This gives the next message number, outgoing storage of the given sequence esxpects. Actually this will be used by storage managers to obtain the message number that should be put to the next application message.

Specified by:
getNextOutgoingMessageNumber in interface ISandeshaDAO

checkForResponseMessage

public RMMessageContext checkForResponseMessage(java.lang.String requestId,
                                                java.lang.String seqId)
Description copied from interface: ISandeshaDAO
When the messageId of therequest message (e.g. from relates to) and the sequence id is given this will give the response message.

Specified by:
checkForResponseMessage in interface ISandeshaDAO

searchForSequenceId

public java.lang.String searchForSequenceId(java.lang.String messageId)
Description copied from interface: ISandeshaDAO
Tries to give the sequence id of the outgoing message with the given message id

Specified by:
searchForSequenceId in interface ISandeshaDAO

markOutgoingMessageToDelete

public void markOutgoingMessageToDelete(java.lang.String seqId,
                                        java.lang.Long msgNo)
Description copied from interface: ISandeshaDAO
This outgoing message will be marked as deleted. i.e. it will not be re-transmitted

Specified by:
markOutgoingMessageToDelete in interface ISandeshaDAO

addLowPriorityMessage

public void addLowPriorityMessage(RMMessageContext msg)
Description copied from interface: ISandeshaDAO
Adds a low priority message to the storage (e.g. terminate sequence). These messages are axpected to be sent after sending all the other messages of the given sequence (but it is not a must)

Specified by:
addLowPriorityMessage in interface ISandeshaDAO

getNextLowPriorityMessageContextToSend

public RMMessageContext getNextLowPriorityMessageContextToSend()
Description copied from interface: ISandeshaDAO
Asks the storage for the next low priority message (if there is any)

Specified by:
getNextLowPriorityMessageContextToSend in interface ISandeshaDAO

setAckReceived

public void setAckReceived(java.lang.String seqId,
                           long msgNo)
Description copied from interface: ISandeshaDAO
Tells to the rtorage that the given message of given sequence was acked.

Specified by:
setAckReceived in interface ISandeshaDAO

addSendMsgNo

public void addSendMsgNo(java.lang.String seqId,
                         long msgNo)
Description copied from interface: ISandeshaDAO
The message will be added to a sent list (the list holds the messages that were sent at least once)

Specified by:
addSendMsgNo in interface ISandeshaDAO

isSentMsg

public boolean isSentMsg(java.lang.String seqId,
                         long msgNo)
Description copied from interface: ISandeshaDAO
Asks from the storage weather the given message has been sent at least once

Specified by:
isSentMsg in interface ISandeshaDAO

hasLastIncomingMsgReceived

public boolean hasLastIncomingMsgReceived(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
Can be used to ckeck weather the last message has been received in the incoming sequence.

Specified by:
hasLastIncomingMsgReceived in interface ISandeshaDAO

getLastIncomingMsgNo

public long getLastIncomingMsgNo(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
Asks for the last message of the incoming sequence (if it has been received)

Specified by:
getLastIncomingMsgNo in interface ISandeshaDAO

addRequestedSequence

public void addRequestedSequence(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
When a server or client sends a create sequence, it will be marked from this method. But the actual resources will be allocated only when the first message arrives.

Specified by:
addRequestedSequence in interface ISandeshaDAO

isRequestedSeqPresent

public boolean isRequestedSeqPresent(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
Check weather the given sequence id is one of the requested once (see 'addRequestedSequence')

Specified by:
isRequestedSeqPresent in interface ISandeshaDAO

getKeyFromIncomingSequenceId

public java.lang.String getKeyFromIncomingSequenceId(java.lang.String seqID)
Description copied from interface: ISandeshaDAO
The client side will not be able to have sequenceId as a key for storing request messages. Since it may be not known when the user adds first message. This asks for that key, giving sequence id of incoming messages.

Specified by:
getKeyFromIncomingSequenceId in interface ISandeshaDAO

getKeyFromOutgoingSequenceId

public java.lang.String getKeyFromOutgoingSequenceId(java.lang.String seqID)
Description copied from interface: ISandeshaDAO
This asks for the above key (the key used to hold messages) given the outgoing sequece id.

Specified by:
getKeyFromOutgoingSequenceId in interface ISandeshaDAO

isAllOutgoingTerminateSent

public boolean isAllOutgoingTerminateSent()
Description copied from interface: ISandeshaDAO
Checks weather the terminate message of all out going sequences have been sent.

Specified by:
isAllOutgoingTerminateSent in interface ISandeshaDAO

isAllIncommingTerminateReceived

public boolean isAllIncommingTerminateReceived()
Description copied from interface: ISandeshaDAO
Use this to check weather the terminate message of all sequences (incoming) has been received.

Specified by:
isAllIncommingTerminateReceived in interface ISandeshaDAO

setTerminateSend

public void setTerminateSend(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
Sets this after sending the terminate sequence message.

Specified by:
setTerminateSend in interface ISandeshaDAO

setTerminateReceived

public void setTerminateReceived(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
Sets a incoming sequence of messages as terminate received.

Specified by:
setTerminateReceived in interface ISandeshaDAO

setAcksTo

public void setAcksTo(java.lang.String seqId,
                      java.lang.String acksTo)
Description copied from interface: ISandeshaDAO
Set the acks to of the given sequence.

Specified by:
setAcksTo in interface ISandeshaDAO

getAcksTo

public java.lang.String getAcksTo(java.lang.String seqId)
Description copied from interface: ISandeshaDAO
gets the acksTo value

Specified by:
getAcksTo in interface ISandeshaDAO

addOffer

public void addOffer(java.lang.String msgID,
                     java.lang.String offerID)
Description copied from interface: ISandeshaDAO
Sets the offered incoming sequence, of a outgoing sequence.

Specified by:
addOffer in interface ISandeshaDAO

getOffer

public java.lang.String getOffer(java.lang.String msgID)
Description copied from interface: ISandeshaDAO
Gets the offered incoming sequence, of outgoing sequence.

Specified by:
getOffer in interface ISandeshaDAO

clear

public void clear()
Description copied from interface: ISandeshaDAO
clears the storage.

Specified by:
clear in interface ISandeshaDAO

isOutgoingTerminateSent

public boolean isOutgoingTerminateSent(java.lang.String seqId)
Specified by:
isOutgoingTerminateSent in interface ISandeshaDAO

isIncommingTerminateReceived

public boolean isIncommingTerminateReceived(java.lang.String seqId)
Specified by:
isIncommingTerminateReceived in interface ISandeshaDAO

updateFinalMessageArrivedTime

public void updateFinalMessageArrivedTime(java.lang.String sequenceID)
Specified by:
updateFinalMessageArrivedTime in interface ISandeshaDAO

sendAck

public void sendAck(java.lang.String sequenceId)
Specified by:
sendAck in interface ISandeshaDAO

removeAllAcks

public void removeAllAcks(java.lang.String sequenceID)
Specified by:
removeAllAcks in interface ISandeshaDAO