T
- The type of the Record
instances managed by the
Logger
.Flushable
, org.refcodes.component.Component
, org.refcodes.component.Decomposeable
, org.refcodes.component.Destroyable
, org.refcodes.component.Flushable
, org.refcodes.component.Initializable
, org.refcodes.logger.LogDecorator
, org.refcodes.logger.Logger<T>
SimpleDbQueryLogger
public class SimpleDbLogger<T> extends Object implements org.refcodes.logger.Logger<T>, org.refcodes.component.Component, org.refcodes.component.Initializable, org.refcodes.component.Decomposeable, org.refcodes.component.Flushable
SimpleDbLogger
is the Amazon SimpleDB implementation of the
Logger
interface. As Amazon SimpleDB stores only String
values (everything is a String
), type information may be lost as
inferencing from the String
content may not be possible. The
Record
instances Column.toStorageString(Object)
and
Column.fromStorageString(String)
methods are used to apply
conversion.
ATTENTION: Logging field values exceeding the size of 1024 characters will be
truncated and an error message is logged out. We assume not having fields
longer than 1024 bytes with this implementation of the Logger
.
org.refcodes.component.Decomposeable.DecomposeAutomaton
org.refcodes.component.Destroyable.DestroyAutomaton
org.refcodes.component.Flushable.FlushBuilder<B extends org.refcodes.component.Flushable.FlushBuilder<B>>
org.refcodes.component.Initializable.InitializeAutomaton, org.refcodes.component.Initializable.InitializeBuilder<B extends org.refcodes.component.Initializable.InitializeBuilder<B>>, org.refcodes.component.Initializable.UncheckedInitializable
Modifier and Type | Field | Description |
---|---|---|
protected static org.refcodes.logger.RuntimeLogger |
LOGGER |
Constructor | Description |
---|---|
SimpleDbLogger(String aDomainName,
String aAccessKey,
String aSecretKey,
String aEndPoint,
org.refcodes.tabular.ColumnFactory<T> aColumnFactory) |
Constructs the
SimpleDbLogger for a given SimpleDB domain. |
SimpleDbLogger(String aDomainName,
String aAccessKey,
String aSecretKey,
org.refcodes.tabular.ColumnFactory<T> aColumnFactory) |
Constructs the
SimpleDbLogger for a given SimpleDB domain. |
Modifier and Type | Method | Description |
---|---|---|
protected void |
addHeaderColumn(String eKey) |
Adds a key to the dynamically created
Header for reducing object
creation overhead when massively logging data as no Column
instances are created once the key was already added. |
protected static void |
clearDomain(com.amazonaws.services.simpledb.AmazonSimpleDB aAmazonSimpleDbClient,
String aDomainName) |
Clears all content from the given Amazon SimpleDB domain.
|
void |
decompose() |
|
void |
destroy() |
|
void |
flush() |
|
protected void |
flushBuffer() |
Flushes the buffer with
Records already encapsulated in Amazon
SimpleDB's items. |
protected com.amazonaws.services.simpledb.AmazonSimpleDB |
getAmazonSimpleDbClient() |
Retrieves the amazon SimpleDB client to be used.
|
protected static com.amazonaws.services.simpledb.AmazonSimpleDB |
getAmazonSimpleDbClient(File aConfigFile) |
Retrieves an
AmazonSimpleDBClient from a configuration file
containing the access- and the secret key. |
protected String |
getAmazonSimpleDbDomainName() |
Retrieves the domain name to be used.
|
protected static List<String> |
getDomainNames(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient) |
Retrieves a list of domain names retrievable from the given
AmazonSimpleDBClient . |
protected org.refcodes.tabular.Header<T> |
getHeader() |
Provides access to the
Header member variable required for
Record related operation. |
protected static boolean |
hasDomain(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient,
String aDomainName) |
Tests whether the given domain exists in Amazon SimpleDB.
|
void |
initialize() |
|
protected static boolean |
isRequestTimeoutException(Exception aException) |
Checks if is request timeout exception.
|
protected static boolean |
isServiceUnavailableException(Exception aException) |
Checks if is service unavailable exception.
|
void |
log(org.refcodes.tabular.Record<? extends T> aRecord) |
Log.
|
protected void |
setAmazonSimpleDbDomainName(String aAmazonSimpleDbDomainName) |
Sets the domain name to be used.
|
protected static String |
toMessage(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.
|
public SimpleDbLogger(String aDomainName, String aAccessKey, String aSecretKey, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
SimpleDbLogger
for a given SimpleDB domain.aDomainName
- The name for the Amazon SimpleDB domainaAccessKey
- The Amazon access key for Amazon SimpleDBaSecretKey
- The Amazon secret key for Amazon SimpleDBaColumnFactory
- The ColumnFactory
to create default
Column
instances for Record
instances to be
processedpublic SimpleDbLogger(String aDomainName, String aAccessKey, String aSecretKey, String aEndPoint, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
SimpleDbLogger
for a given SimpleDB domain.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 (see
AbstractSimpleDbClient
's constructor documentation for
possible values).aColumnFactory
- The ColumnFactory
to create default
Column
instances for Record
instances to be
processedpublic void log(org.refcodes.tabular.Record<? extends T> aRecord) throws org.refcodes.logger.IllegalRecordRuntimeException, org.refcodes.logger.UnexpectedLogRuntimeException
log
in interface org.refcodes.logger.Logger<T>
aRecord
- the recordorg.refcodes.logger.IllegalRecordRuntimeException
- the illegal record runtime
exceptionorg.refcodes.logger.UnexpectedLogRuntimeException
- the unexpected log runtime
exceptionpublic void initialize() throws org.refcodes.component.InitializeException
initialize
in interface org.refcodes.component.Initializable
org.refcodes.component.InitializeException
public void destroy()
destroy
in interface org.refcodes.component.Destroyable
public void decompose()
decompose
in interface org.refcodes.component.Decomposeable
public void flush() throws IOException
flush
in interface Flushable
flush
in interface org.refcodes.component.Flushable
IOException
protected org.refcodes.tabular.Header<T> getHeader()
Header
member variable required for
Record
related operation.Header
.protected void addHeaderColumn(String eKey)
Header
for reducing object
creation overhead when massively logging data as no Column
instances are created once the key was already added.eKey
- The key for which a Column
is to be added.protected void flushBuffer()
Records
already encapsulated in Amazon
SimpleDB's items.protected String getAmazonSimpleDbDomainName()
protected void setAmazonSimpleDbDomainName(String aAmazonSimpleDbDomainName)
aAmazonSimpleDbDomainName
- the new amazon simple db domain nameprotected com.amazonaws.services.simpledb.AmazonSimpleDB getAmazonSimpleDbClient()
protected static boolean isRequestTimeoutException(Exception aException)
aException
- the exceptionprotected static boolean isServiceUnavailableException(Exception aException)
aException
- the exceptionprotected static String toMessage(Throwable aThrowable)
aThrowable
- The throwable from which to generate the Amazon AWS
specific exception message.protected static void clearDomain(com.amazonaws.services.simpledb.AmazonSimpleDB aAmazonSimpleDbClient, String aDomainName)
aAmazonSimpleDbClient
- The AmazonSimpleDBClient
.aDomainName
- The domain name of the domain to be cleared.protected static com.amazonaws.services.simpledb.AmazonSimpleDB getAmazonSimpleDbClient(File aConfigFile) throws IOException
AmazonSimpleDBClient
from a configuration file
containing the access- and the secret key.aConfigFile
- The configuration file used to configure the
AmazonSimpleDBClient
.AmazonSimpleDBClient
.IOException
- In case there were problems reading the configuration
file.protected static List<String> getDomainNames(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient)
AmazonSimpleDBClient
.aAmazonSimpleDbClient
- The AmazonSimpleDBClient
.String
instances representing the
retrievable domain names.protected static boolean hasDomain(com.amazonaws.services.simpledb.AmazonSimpleDBClient aAmazonSimpleDbClient, String aDomainName)
aAmazonSimpleDbClient
- The AmazonSimpleDBClient
.aDomainName
- The domain name to be tested.Copyright © 2021. All rights reserved.