Package org.refcodes.logger.alt.simpledb
Class SimpleDbQueryLogger<T>
- java.lang.Object
-
- org.refcodes.logger.alt.simpledb.SimpleDbLogger<T>
-
- org.refcodes.logger.alt.simpledb.SimpleDbQueryLogger<T>
-
- Type Parameters:
T
- The type of theRecord
instances managed by theLogger
.
- All Implemented Interfaces:
java.io.Flushable
,org.refcodes.component.Component
,org.refcodes.component.Decomposeable
,org.refcodes.component.Destroyable
,org.refcodes.component.Flushable
,org.refcodes.component.Initializable
,org.refcodes.logger.Logger<T>
,org.refcodes.logger.QueryLogger<T>
- Direct Known Subclasses:
SimpleDbTrimLogger
public class SimpleDbQueryLogger<T> extends SimpleDbLogger<T> implements org.refcodes.logger.QueryLogger<T>, org.refcodes.component.Component, org.refcodes.component.Initializable, org.refcodes.component.Decomposeable, org.refcodes.component.Flushable
TheSimpleDbQueryLogger
extends theSimpleDbLogger
implementation with theQueryLogger
functionality.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
SimpleDbQueryLogger.SimpleDbRecordsImpl
This iterator encapsulates an Amazon select request for the business logic to simply iterate through the results. ------------------------------------------------------------------------- TODO Make this unit testable and create unit test: --------------------------------------------------------------------------
Nested classes/interfaces inherited from interface org.refcodes.component.Decomposeable
org.refcodes.component.Decomposeable.DecomposeAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
org.refcodes.component.Destroyable.DestroyAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.Flushable
org.refcodes.component.Flushable.FlushBuilder<B extends org.refcodes.component.Flushable.FlushBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Initializable
org.refcodes.component.Initializable.InitializeAutomaton, org.refcodes.component.Initializable.InitializeBuilder<B extends org.refcodes.component.Initializable.InitializeBuilder<B>>, org.refcodes.component.Initializable.UncheckedInitializable
-
-
Field Summary
-
Fields inherited from class org.refcodes.logger.alt.simpledb.SimpleDbLogger
LOGGER
-
-
Constructor Summary
Constructors Constructor Description SimpleDbQueryLogger(java.lang.String aDomainName, java.lang.String aAccessKey, java.lang.String aSecretKey, java.lang.String aEndPoint, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
Constructs theSimpleDbQueryLogger
for a given SimpleDB domain.SimpleDbQueryLogger(java.lang.String aDomainName, java.lang.String aAccessKey, java.lang.String aSecretKey, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
Constructs theSimpleDbQueryLogger
for a given SimpleDB domain.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
clearDomain(com.amazonaws.services.simpledb.AmazonSimpleDB aAmazonSimpleDbClient, java.lang.String aDomainName)
Clears all content from the given Amazon SimpleDB domain.void
destroy()
org.refcodes.tabular.Records<T>
findLogs()
org.refcodes.tabular.Records<T>
findLogs(int aLimit)
org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria)
org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria, int aLimit)
org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader)
org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader, int aLimit)
org.refcodes.tabular.Records<T>
findLogs(org.refcodes.tabular.Header<T> aHeader, int aLimit)
protected com.amazonaws.services.simpledb.AmazonSimpleDB
getAmazonSimpleDbClient()
Retrieves the amazon SimpleDB client to be used.protected static com.amazonaws.services.simpledb.AmazonSimpleDB
getAmazonSimpleDbClient(java.io.File aConfigFile)
Retrieves anAmazonSimpleDBClient
from a configuration file containing the access- and the secret key.protected java.lang.String
getAmazonSimpleDbDomainName()
Retrieves the domain name to be used.protected static java.util.List<java.lang.String>
getDomainNames(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient)
Retrieves a list of domain names retrievable from the givenAmazonSimpleDBClient
.protected static boolean
hasDomain(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient, java.lang.String aDomainName)
Tests whether the given domain exists in Amazon SimpleDB.protected static boolean
isRequestTimeoutException(java.lang.Exception aException)
Checks if is request timeout exception.protected static boolean
isServiceUnavailableException(java.lang.Exception aException)
Checks if is service unavailable exception.protected void
setAmazonSimpleDbDomainName(java.lang.String aAmazonSimpleDbDomainName)
Sets the domain name to be used.protected static java.lang.String
toMessage(java.lang.Throwable aThrowable)
Creates an Amazon AWS specific exception message from the given throwable containing additional information such as the AWS error code, the AWS error type, the request ID, the service name and the status code.protected java.lang.String
toSqlQuery(org.refcodes.criteria.Criteria aCriteria, int aLimit)
Creates an SQL SELECT query from the givenCriteria
and the provided limit.-
Methods inherited from interface org.refcodes.component.Flushable
flush, flushUnchecked, isFlushable
-
Methods inherited from interface org.refcodes.component.Initializable
initialize, initializeUnchecked
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class org.refcodes.logger.alt.simpledb.SimpleDbLogger
addHeaderColumn, decompose, flush, flushBuffer, getHeader, initialize, log
-
-
-
-
Constructor Detail
-
SimpleDbQueryLogger
public SimpleDbQueryLogger(java.lang.String aDomainName, java.lang.String aAccessKey, java.lang.String aSecretKey, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
Constructs theSimpleDbQueryLogger
for a given SimpleDB domain.- Parameters:
aDomainName
- The name for the Amazon SimpleDB domainaAccessKey
- The Amazon access key for Amazon SimpleDBaSecretKey
- The Amazon secret key for Amazon SimpleDBaColumnFactory
- TheColumnFactory
to create defaultColumn
instances forRecord
instances to be processed
-
SimpleDbQueryLogger
public SimpleDbQueryLogger(java.lang.String aDomainName, java.lang.String aAccessKey, java.lang.String aSecretKey, java.lang.String aEndPoint, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
Constructs theSimpleDbQueryLogger
for a given SimpleDB domain.- Parameters:
aDomainName
- The name for the Amazon SimpleDB domainaAccessKey
- The Amazon access key for Amazon SimpleDBaSecretKey
- The Amazon secret key for Amazon SimpleDBaEndPoint
- The end-point (Amazon region) to use (seeAbstractSimpleDbClient
's constructor documentation for possible values).aColumnFactory
- TheColumnFactory
to create defaultColumn
instances forRecord
instances to be processed
-
-
Method Detail
-
findLogs
public org.refcodes.tabular.Records<T> findLogs()
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(int aLimit)
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria)
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, int aLimit)
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader)
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.tabular.Header<T> aHeader, int aLimit)
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader, int aLimit)
- Specified by:
findLogs
in interfaceorg.refcodes.logger.QueryLogger<T>
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceorg.refcodes.component.Destroyable
- Overrides:
destroy
in classSimpleDbLogger<T>
-
toSqlQuery
protected java.lang.String toSqlQuery(org.refcodes.criteria.Criteria aCriteria, int aLimit)
Creates an SQL SELECT query from the givenCriteria
and the provided limit.- Parameters:
aCriteria
- The Criteria from which to create the SQL query.aLimit
- The limit to be applied to the result set of the query.- Returns:
- A (No)SQL query for SimpleDB.
-
getAmazonSimpleDbDomainName
protected java.lang.String getAmazonSimpleDbDomainName()
Retrieves the domain name to be used.- Returns:
- The domain name.
-
setAmazonSimpleDbDomainName
protected void setAmazonSimpleDbDomainName(java.lang.String aAmazonSimpleDbDomainName)
Sets the domain name to be used.- Parameters:
aAmazonSimpleDbDomainName
- the new amazon simple db domain name
-
getAmazonSimpleDbClient
protected com.amazonaws.services.simpledb.AmazonSimpleDB getAmazonSimpleDbClient()
Retrieves the amazon SimpleDB client to be used.- Returns:
- The SimpleDB client to be used.
-
isRequestTimeoutException
protected static boolean isRequestTimeoutException(java.lang.Exception aException)
Checks if is request timeout exception.- Parameters:
aException
- the exception- Returns:
- true, if is request timeout exception
-
isServiceUnavailableException
protected static boolean isServiceUnavailableException(java.lang.Exception aException)
Checks if is service unavailable exception.- Parameters:
aException
- the exception- Returns:
- true, if is service unavailable exception
-
toMessage
protected static java.lang.String toMessage(java.lang.Throwable aThrowable)
Creates an Amazon AWS specific exception message from the given throwable containing additional information such as the AWS error code, the AWS error type, the request ID, the service name and the status code.- Parameters:
aThrowable
- The throwable from which to generate the Amazon AWS specific exception message.- Returns:
- The according exception message.
-
clearDomain
protected static void clearDomain(com.amazonaws.services.simpledb.AmazonSimpleDB aAmazonSimpleDbClient, java.lang.String aDomainName)
Clears all content from the given Amazon SimpleDB domain.- Parameters:
aAmazonSimpleDbClient
- TheAmazonSimpleDBClient
.aDomainName
- The domain name of the domain to be cleared.
-
getAmazonSimpleDbClient
protected static com.amazonaws.services.simpledb.AmazonSimpleDB getAmazonSimpleDbClient(java.io.File aConfigFile) throws java.io.IOException
Retrieves anAmazonSimpleDBClient
from a configuration file containing the access- and the secret key.- Parameters:
aConfigFile
- The configuration file used to configure theAmazonSimpleDBClient
.- Returns:
- An
AmazonSimpleDBClient
. - Throws:
java.io.IOException
- In case there were problems reading the configuration file.
-
getDomainNames
protected static java.util.List<java.lang.String> getDomainNames(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient)
Retrieves a list of domain names retrievable from the givenAmazonSimpleDBClient
.- Parameters:
aAmazonSimpleDbClient
- TheAmazonSimpleDBClient
.- Returns:
- A list containing
String
instances representing the retrievable domain names.
-
hasDomain
protected static boolean hasDomain(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient, java.lang.String aDomainName)
Tests whether the given domain exists in Amazon SimpleDB.- Parameters:
aAmazonSimpleDbClient
- TheAmazonSimpleDBClient
.aDomainName
- The domain name to be tested.- Returns:
- True in case the domain with the given name exists, else false.
-
-