com.mymed.controller.core.manager.storage
Class MyJamStorageManager

java.lang.Object
  extended by com.mymed.controller.core.manager.storage.StorageManager
      extended by com.mymed.controller.core.manager.storage.GeoLocStorageManager
All Implemented Interfaces:
IMyJamStorageManager, IStorageManager

public class MyJamStorageManager
extends StorageManager
implements IMyJamStorageManager

Storage manager created ad-hoc for myJam application.

Author:
iacopo

Field Summary
static int maxNumColumns
           
 
Fields inherited from interface com.mymed.controller.core.manager.storage.IStorageManager
consistencyOnRead, consistencyOnWrite
 
Constructor Summary
MyJamStorageManager()
          Default Constructor: will create a ServiceManger on top of a Cassandra Wrapper
MyJamStorageManager(WrapperConfiguration conf)
          /** will create a ServiceManger on top of the WrapperType And use the specific configuration file for the transport layer
 
Method Summary
 int countColumns(java.lang.String tableName, java.lang.String primaryKey, byte[] superColumn)
          Counts the number of colums of a given row or SuperColumn.
 java.util.Map<byte[],byte[]> getFrom(java.lang.String tableName, java.lang.String primaryKey, byte[] start)
          Gets the columns which have name following on the given CF row.
 java.util.Map<byte[],byte[]> getLastN(java.lang.String tableName, java.lang.String primaryKey, java.lang.Integer n)
          Gets the first n columns of the given CF row.
 void insertColumn(java.lang.String tableName, java.lang.String primaryKey, byte[] columnName, byte[] value)
          Is more general then the method insertColumn of IStorageManager, the name of the column can be something different from a String.
 void insertColumn(java.lang.String tableName, java.lang.String primaryKey, java.lang.String columnName, byte[] value)
          Update the value of a Simple Column
 void insertExpiringColumn(java.lang.String tableName, java.lang.String key, byte[] superColumn, byte[] columnName, byte[] value, long timestamp, int expiringTime)
          It allows to insert an expiring column.
 void insertExpiringColumn(java.lang.String tableName, java.lang.String primaryKey, byte[] columnName, byte[] value, long timestamp, int expiringTime)
           
 void insertSlice(java.lang.String tableName, java.lang.String primaryKey, java.util.Map<java.lang.String,byte[]> args)
          Insert a new entry in the database
 void insertSuperColumn(java.lang.String tableName, java.lang.String primaryKey, java.lang.String superColumn, java.lang.String columnName, byte[] value)
          Update the value of a Super Column
 void removeAll(java.lang.String tableName, java.lang.String key)
          Remove an entry in the columnFamily
 void removeColumn(java.lang.String tableName, java.lang.String primaryKey, byte[] superColumn, byte[] column)
          Remove a specific column defined by the columnName
 void removeColumn(java.lang.String tableName, java.lang.String key, java.lang.String columnName)
          Remove a specific column defined by the columnName
 java.util.Map<java.lang.String,java.util.Map<byte[],byte[]>> selectAll(java.lang.String tableName, java.util.List<java.lang.String> primaryKeys)
          Select all on a list of rows.
 java.util.Map<byte[],byte[]> selectAll(java.lang.String tableName, java.lang.String primaryKey)
          Get the value of a column family
 byte[] selectColumn(java.lang.String tableName, java.lang.String primaryKey, byte[] superColumn, byte[] column)
          Selects a column in a CF.
 ExpColumnBean selectExpiringColumn(java.lang.String tableName, java.lang.String primaryKey, byte[] superColumn, byte[] column)
          Returns the expiring column, with the timestamp and the TTL.
 java.util.Map<byte[],byte[]> selectRange(java.lang.String tableName, java.lang.String primaryKey, byte[] startColumn, byte[] stopColumn, int maxNum)
          Selects a range of columns, specifying the extremes.
 java.util.Map<byte[],byte[]> selectRange(java.lang.String tableName, java.lang.String primaryKey, java.util.List<java.lang.String> columnNames)
          Get the values of a range of columns
 java.util.Map<byte[],java.util.Map<byte[],byte[]>> selectSCRange(java.lang.String tableName, java.util.List<java.lang.String> primaryKeys, byte[] startColumn, byte[] stopColumn)
          Used in myJam to perform geographical range queries.
 
Methods inherited from class com.mymed.controller.core.manager.storage.StorageManager
countColumns, getWrapper, insertSuperSlice, removeSuperColumn, selectColumn, selectList
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.mymed.controller.core.manager.storage.IStorageManager
countColumns, insertSuperSlice, removeSuperColumn, selectColumn, selectList
 

Field Detail

maxNumColumns

public static final int maxNumColumns
See Also:
Constant Field Values
Constructor Detail

MyJamStorageManager

public MyJamStorageManager()
                    throws InternalBackEndException
Default Constructor: will create a ServiceManger on top of a Cassandra Wrapper

Throws:
IOBackEndException
InternalBackEndException

MyJamStorageManager

public MyJamStorageManager(WrapperConfiguration conf)
                    throws InternalBackEndException
/** will create a ServiceManger on top of the WrapperType And use the specific configuration file for the transport layer

Parameters:
type - Type of DHTClient used
conf - The configuration of the transport layer
Throws:
IOBackEndException
InternalBackEndException
Method Detail

insertSlice

public void insertSlice(java.lang.String tableName,
                        java.lang.String primaryKey,
                        java.util.Map<java.lang.String,byte[]> args)
                 throws InternalBackEndException
Description copied from class: StorageManager
Insert a new entry in the database

Specified by:
insertSlice in interface IStorageManager
Overrides:
insertSlice in class StorageManager
Parameters:
tableName - the name of the Table/ColumnFamily
primaryKey - the ID of the entry
args - All columnName and the their value
Throws:
InternalBackEndException

selectColumn

public byte[] selectColumn(java.lang.String tableName,
                           java.lang.String primaryKey,
                           byte[] superColumn,
                           byte[] column)
                    throws IOBackEndException,
                           InternalBackEndException
Selects a column in a CF.

Specified by:
selectColumn in interface IMyJamStorageManager
Parameters:
tableName -
primaryKey -
superColumn -
column -
Returns:
Throws:
ServiceManagerException
IOBackEndException
InternalBackEndException

selectExpiringColumn

public ExpColumnBean selectExpiringColumn(java.lang.String tableName,
                                          java.lang.String primaryKey,
                                          byte[] superColumn,
                                          byte[] column)
                                   throws IOBackEndException,
                                          InternalBackEndException
Returns the expiring column, with the timestamp and the TTL.

Specified by:
selectExpiringColumn in interface IMyJamStorageManager
Parameters:
tableName - Name of the CF.
primaryKey - The row key.
superColumn - The SuperColumn name, can be put safely to null if is a CF, but is compulsory if is a SuperCF.
column - The Column name.
Returns:
Throws:
ServiceManagerException
IOBackEndException - The column is not present.
InternalBackEndException

insertColumn

public void insertColumn(java.lang.String tableName,
                         java.lang.String primaryKey,
                         java.lang.String columnName,
                         byte[] value)
                  throws InternalBackEndException
Description copied from class: StorageManager
Update the value of a Simple Column

Specified by:
insertColumn in interface IStorageManager
Overrides:
insertColumn in class StorageManager
Parameters:
tableName - the name of the Table/ColumnFamily
primaryKey - the ID of the entry
columnName - the name of the column
value - the value updated
Throws:
InternalBackEndException

insertColumn

public void insertColumn(java.lang.String tableName,
                         java.lang.String primaryKey,
                         byte[] columnName,
                         byte[] value)
                  throws InternalBackEndException
Description copied from interface: IMyJamStorageManager
Is more general then the method insertColumn of IStorageManager, the name of the column can be something different from a String. (e.g. In my application I use long values as Column names, I cannot use string because I need that the columns was ordered.)

Specified by:
insertColumn in interface IMyJamStorageManager
Parameters:
tableName - Name of the CF.
primaryKey - Row key.
columnName - Column name.
value - Column value.
Throws:
InternalBackEndException

insertExpiringColumn

public void insertExpiringColumn(java.lang.String tableName,
                                 java.lang.String primaryKey,
                                 byte[] columnName,
                                 byte[] value,
                                 long timestamp,
                                 int expiringTime)
                          throws InternalBackEndException
Throws:
InternalBackEndException

insertSuperColumn

public void insertSuperColumn(java.lang.String tableName,
                              java.lang.String primaryKey,
                              java.lang.String superColumn,
                              java.lang.String columnName,
                              byte[] value)
                       throws InternalBackEndException
Description copied from class: StorageManager
Update the value of a Super Column

Specified by:
insertSuperColumn in interface IStorageManager
Overrides:
insertSuperColumn in class StorageManager
Parameters:
tableName - the name of the Table/ColumnFamily
primaryKey - the ID of the entry
superColumn - the ID of the superColumn
columnName - the name of the column
value - the value updated
Throws:
InternalBackEndException

insertExpiringColumn

public void insertExpiringColumn(java.lang.String tableName,
                                 java.lang.String key,
                                 byte[] superColumn,
                                 byte[] columnName,
                                 byte[] value,
                                 long timestamp,
                                 int expiringTime)
                          throws InternalBackEndException
Description copied from interface: IMyJamStorageManager
It allows to insert an expiring column. It permits to deal with both CF and SuperCF. Timestamp could be evaluated inside the method, but I need to insert a column in two different CF, that expire at the same time.

Specified by:
insertExpiringColumn in interface IMyJamStorageManager
Parameters:
tableName - Name of the CF.
superColumn - SuperColumn name, null if insertion is done on a CF.
columnName - Column name.
value - Column value.
timestamp - Timestamp in microseconds since 1 Jenuary 1970.
expiringTime - TTL in seconds.
Throws:
InternalBackEndException

selectAll

public java.util.Map<byte[],byte[]> selectAll(java.lang.String tableName,
                                              java.lang.String primaryKey)
                                       throws IOBackEndException,
                                              InternalBackEndException
Description copied from class: StorageManager
Get the value of a column family

Specified by:
selectAll in interface IStorageManager
Overrides:
selectAll in class StorageManager
Parameters:
tableName - the name of the Table/ColumnFamily
primaryKey - the ID of the entry
Returns:
the value of the column
Throws:
IOBackEndException
InternalBackEndException

selectAll

public java.util.Map<java.lang.String,java.util.Map<byte[],byte[]>> selectAll(java.lang.String tableName,
                                                                              java.util.List<java.lang.String> primaryKeys)
                                                                       throws IOBackEndException,
                                                                              InternalBackEndException
Description copied from interface: IMyJamStorageManager
Select all on a list of rows.

Specified by:
selectAll in interface IMyJamStorageManager
Parameters:
tableName - Name of the CF.
primaryKeys - List of row keys.
Returns:
Throws:
IOBackEndException
InternalBackEndException

selectRange

public java.util.Map<byte[],byte[]> selectRange(java.lang.String tableName,
                                                java.lang.String primaryKey,
                                                java.util.List<java.lang.String> columnNames)
                                         throws IOBackEndException,
                                                InternalBackEndException
Description copied from class: StorageManager
Get the values of a range of columns

Specified by:
selectRange in interface IStorageManager
Overrides:
selectRange in class StorageManager
Parameters:
tableName - the name of the Table/ColumnFamily
primaryKey - the ID of the entry
columnNames - the name of the columns to return the values
Returns:
the value of the columns
Throws:
IOBackEndException
InternalBackEndException

selectRange

public java.util.Map<byte[],byte[]> selectRange(java.lang.String tableName,
                                                java.lang.String primaryKey,
                                                byte[] startColumn,
                                                byte[] stopColumn,
                                                int maxNum)
                                         throws IOBackEndException,
                                                InternalBackEndException
Selects a range of columns, specifying the extremes.

Specified by:
selectRange in interface IMyJamStorageManager
Parameters:
tableName - Name of the CF.
primaryKey - Row key.
startColumn - Start column (columns are ordered).
stopColumn - Stop column.
maxNum - Maximum number of returned values,
Returns:
Throws:
IOBackEndException
InternalBackEndException

getLastN

public java.util.Map<byte[],byte[]> getLastN(java.lang.String tableName,
                                             java.lang.String primaryKey,
                                             java.lang.Integer n)
                                      throws IOBackEndException,
                                             InternalBackEndException
Gets the first n columns of the given CF row.

Specified by:
getLastN in interface IMyJamStorageManager
Parameters:
tableName - ColumnFamily.
primaryKey - Key of the row.
n - Number of returned columns (at most.)
Returns:
Throws:
IOBackEndException
InternalBackEndException

getFrom

public java.util.Map<byte[],byte[]> getFrom(java.lang.String tableName,
                                            java.lang.String primaryKey,
                                            byte[] start)
                                     throws IOBackEndException,
                                            InternalBackEndException
Gets the columns which have name following on the given CF row.

Specified by:
getFrom in interface IMyJamStorageManager
Parameters:
tableName - ColumnFamily.
primaryKey - Key of the row.
start - Starting value.
Returns:
Throws:
IOBackEndException
InternalBackEndException

selectSCRange

public java.util.Map<byte[],java.util.Map<byte[],byte[]>> selectSCRange(java.lang.String tableName,
                                                                        java.util.List<java.lang.String> primaryKeys,
                                                                        byte[] startColumn,
                                                                        byte[] stopColumn)
                                                                 throws IOBackEndException,
                                                                        InternalBackEndException
Used in myJam to perform geographical range queries.

Specified by:
selectSCRange in interface IMyJamStorageManager
Parameters:
tableName -
primaryKey -
startColumn -
stopColumn -
Returns:
Throws:
ServiceManagerException
IOBackEndException
InternalBackEndException

countColumns

public int countColumns(java.lang.String tableName,
                        java.lang.String primaryKey,
                        byte[] superColumn)
                 throws IOBackEndException,
                        InternalBackEndException
Description copied from interface: IMyJamStorageManager
Counts the number of colums of a given row or SuperColumn.

Specified by:
countColumns in interface IMyJamStorageManager
Parameters:
tableName - Name of the CF.
primaryKey - Row key.
superColumn - Number of columns ().
Returns:
Throws:
IOBackEndException
InternalBackEndException

removeColumn

public void removeColumn(java.lang.String tableName,
                         java.lang.String key,
                         java.lang.String columnName)
                  throws InternalBackEndException
Remove a specific column defined by the columnName

Specified by:
removeColumn in interface IStorageManager
Overrides:
removeColumn in class StorageManager
Parameters:
keyspace -
columnFamily -
key -
columnName -
Throws:
ServiceManagerException
InternalBackEndException
java.io.UnsupportedEncodingException

removeAll

public void removeAll(java.lang.String tableName,
                      java.lang.String key)
               throws InternalBackEndException
Description copied from class: StorageManager
Remove an entry in the columnFamily

Specified by:
removeAll in interface IStorageManager
Overrides:
removeAll in class StorageManager
Throws:
InternalBackEndException

removeColumn

public void removeColumn(java.lang.String tableName,
                         java.lang.String primaryKey,
                         byte[] superColumn,
                         byte[] column)
                  throws InternalBackEndException
Remove a specific column defined by the columnName

Specified by:
removeColumn in interface IMyJamStorageManager
Parameters:
keyspace -
columnFamily -
key -
columnName -
Throws:
ServiceManagerException
InternalBackEndException
java.io.UnsupportedEncodingException