com.eurotech.framework.core.data.store
Class DbDataStore

java.lang.Object
  extended by com.eurotech.framework.core.data.store.DbDataStore
All Implemented Interfaces:
DataStore

public class DbDataStore
extends Object
implements DataStore

An implementation of the DataStore which stores messages into an embedded HSQLDB instance. FIXME: reset identity (see below, not working) on sequence limit exceed exception.


Constructor Summary
DbDataStore()
           
 
Method Summary
 List<DataMessage> allDroppedInFlightMessagesNoPayload()
          Finds the list of all published messages that will not be confirmed and returns them WITHOUT loading the payload.
 List<DataMessage> allInFlightMessagesNoPayload()
          Finds the list of all published but not yet confirmed messages and returns them WITHOUT loading the payload.
 List<DataMessage> allUnpublishedMessagesNoPayload()
          Finds the list of all unpublished messages and returns them WITHOUT loading the payload.
 void checkpoint()
          Performs a checkpoint of the store.
 void confirmed(int msgId)
          Acknowledges the delivery of the DataMessage published with the given protocol (e.g.
 void defrag()
          Defragments the store.
 void deleteStaleMessages(int purgeAge)
          Deletes stale messages.
 void dropAllInFlightMessages()
          Drops all in-flight messages.
 DataMessage get(int msgId)
          Returns a message from the DataStore by its message id.
 DataMessage getNextMessage()
          Gets the next unpublished message.
 void published(int msgId)
          Acknowledges the publication of the DataMessage with the given ID.
 void published(int msgId, int publishedMsgId, String sessionId)
          Acknowledges the publication of the DataMessage with the given ID associating it to the protocol (e.g.
 void start(DbService dbService, int houseKeeperInterval, int purgeAge, int capacity)
           
 void stop()
           
 DataMessage store(String topic, byte[] payload, int qos, boolean retain, int priority)
          Stores an MQTT message for deferred publication.
 void unpublishAllInFlighMessages()
          Marks all in-flight messages as unpublished.
 void update(int houseKeeperInterval, int purgeAge, int capacity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbDataStore

public DbDataStore()
Method Detail

start

public void start(DbService dbService,
                  int houseKeeperInterval,
                  int purgeAge,
                  int capacity)
           throws EsfStoreException
Specified by:
start in interface DataStore
Throws:
EsfStoreException

stop

public void stop()
Specified by:
stop in interface DataStore

update

public void update(int houseKeeperInterval,
                   int purgeAge,
                   int capacity)
Specified by:
update in interface DataStore

store

public DataMessage store(String topic,
                         byte[] payload,
                         int qos,
                         boolean retain,
                         int priority)
                  throws EsfStoreException
Description copied from interface: DataStore
Stores an MQTT message for deferred publication. An identifier is always generated and returned, even for messages published with QoS = 0. The store policy is FIFO within each priority level, 0 being the highest priority.

Specified by:
store in interface DataStore
Returns:
Throws:
EsfStoreException

get

public DataMessage get(int msgId)
                throws EsfStoreException
Description copied from interface: DataStore
Returns a message from the DataStore by its message id.

Specified by:
get in interface DataStore
Parameters:
msgId - ID of the message to be loaded
Returns:
Loaded message or null if not found.
Throws:
EsfStoreException

getNextMessage

public DataMessage getNextMessage()
                           throws EsfStoreException
Description copied from interface: DataStore
Gets the next unpublished message. Messages with higher priority (0 is the highest priority) are returned first. Within each priority level the oldest unpublished message is returned first.

Specified by:
getNextMessage in interface DataStore
Returns:
Throws:
EsfStoreException

published

public void published(int msgId,
                      int publishedMsgId,
                      String sessionId)
               throws EsfStoreException
Description copied from interface: DataStore
Acknowledges the publication of the DataMessage with the given ID associating it to the protocol (e.g. MQTT) message ID (QoS > 0).

Specified by:
published in interface DataStore
sessionId - TODO
Throws:
EsfStoreException

published

public void published(int msgId)
               throws EsfStoreException
Description copied from interface: DataStore
Acknowledges the publication of the DataMessage with the given ID. This is typically called for messages published with QoS = 0.

Specified by:
published in interface DataStore
Throws:
EsfStoreException

confirmed

public void confirmed(int msgId)
               throws EsfStoreException
Description copied from interface: DataStore
Acknowledges the delivery of the DataMessage published with the given protocol (e.g. MQTT) message ID. This method is only called for messages published with QoS > 0.

Specified by:
confirmed in interface DataStore
Throws:
EsfStoreException

allUnpublishedMessagesNoPayload

public List<DataMessage> allUnpublishedMessagesNoPayload()
                                                  throws EsfStoreException
Description copied from interface: DataStore
Finds the list of all unpublished messages and returns them WITHOUT loading the payload.

Specified by:
allUnpublishedMessagesNoPayload in interface DataStore
Returns:
Throws:
EsfStoreException

allInFlightMessagesNoPayload

public List<DataMessage> allInFlightMessagesNoPayload()
                                               throws EsfStoreException
Description copied from interface: DataStore
Finds the list of all published but not yet confirmed messages and returns them WITHOUT loading the payload. These are only messages published with QoS > 0. Messages published with QoS = 0 do not belong to the results list.

Specified by:
allInFlightMessagesNoPayload in interface DataStore
Returns:
Throws:
EsfStoreException

allDroppedInFlightMessagesNoPayload

public List<DataMessage> allDroppedInFlightMessagesNoPayload()
                                                      throws EsfStoreException
Description copied from interface: DataStore
Finds the list of all published messages that will not be confirmed and returns them WITHOUT loading the payload. These are only messages published with QoS > 0. Messages published with QoS = 0 do not belong to the results list.

Specified by:
allDroppedInFlightMessagesNoPayload in interface DataStore
Returns:
Throws:
EsfStoreException

unpublishAllInFlighMessages

public void unpublishAllInFlighMessages()
                                 throws EsfStoreException
Description copied from interface: DataStore
Marks all in-flight messages as unpublished.

Specified by:
unpublishAllInFlighMessages in interface DataStore
Throws:
EsfStoreException

dropAllInFlightMessages

public void dropAllInFlightMessages()
                             throws EsfStoreException
Description copied from interface: DataStore
Drops all in-flight messages.

Specified by:
dropAllInFlightMessages in interface DataStore
Throws:
EsfStoreException

deleteStaleMessages

public void deleteStaleMessages(int purgeAge)
                         throws EsfStoreException
Description copied from interface: DataStore
Deletes stale messages. These are either published messages with QoS = 0 or confirmed messages with QoS > 0, whose age exceeds the argument.

Specified by:
deleteStaleMessages in interface DataStore
Throws:
EsfStoreException

defrag

public void defrag()
            throws EsfStoreException
Description copied from interface: DataStore
Defragments the store.

Specified by:
defrag in interface DataStore
Throws:
EsfStoreException - TODO

checkpoint

public void checkpoint()
                throws EsfStoreException
Description copied from interface: DataStore
Performs a checkpoint of the store.

Specified by:
checkpoint in interface DataStore
Throws:
EsfStoreException


Copyright © 2013. All Rights Reserved.