T
- The type of the Record
instances managed by the
Logger
.public class SimpleDbLoggerImpl<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
SimpleDbLoggerImpl
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.Destroyable.DestroyAutomaton
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 and Description |
---|---|
protected static org.refcodes.logger.RuntimeLogger |
LOGGER |
Constructor and Description |
---|
SimpleDbLoggerImpl(String aDomainName,
String aAccessKey,
String aSecretKey,
org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
Constructs the
SimpleDbLoggerImpl for a given SimpleDB domain. |
SimpleDbLoggerImpl(String aDomainName,
String aAccessKey,
String aSecretKey,
String aEndPoint,
org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
Constructs the
SimpleDbLoggerImpl for a given SimpleDB domain. |
Modifier and Type | Method and 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.AmazonSimpleDBClient aAmazonSimpleDbClient,
String aDomainName)
Clears all content from the given Amazon SimpleDB domain.
|
void |
decompose()
Tears down this component, also removes external resources.
-------------------------------------------------------------------------
ATTENTION: This method will also tear down the Amazon SimpleDB domain!
|
void |
destroy() |
void |
flush()
Flushes buffered log lines, when shutting down this component via the
destroy() method, the buffer then is flushed automatically! |
protected void |
flushBuffer()
Flushes the buffer with
Records already encapsulated in Amazon
SimpleDB's items. |
protected com.amazonaws.services.simpledb.AmazonSimpleDBClient |
getAmazonSimpleDbClient()
Retrieves the amazon SimpleDB client to be used.
|
protected static com.amazonaws.services.simpledb.AmazonSimpleDBClient |
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) |
protected static boolean |
isServiceUnavailableException(Exception aException) |
void |
log(org.refcodes.tabular.Record<? extends T> aRecord) |
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 SimpleDbLoggerImpl(String aDomainName, String aAccessKey, String aSecretKey, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
SimpleDbLoggerImpl
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
processedUnknownDomainAliasException
- in case the campaigning domain alias
cannot be resolved.public SimpleDbLoggerImpl(String aDomainName, String aAccessKey, String aSecretKey, String aEndPoint, org.refcodes.tabular.ColumnFactory<T> aColumnFactory)
SimpleDbLoggerImpl
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>
org.refcodes.logger.IllegalRecordRuntimeException
org.refcodes.logger.UnexpectedLogRuntimeException
public 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 org.refcodes.component.OpenException
destroy()
method, the buffer then is flushed automatically!
Especially useful when unit testing the SimpleDbLoggerImpl
, then
flushing can be forced by the test case.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)
The
- domain name to be used.protected com.amazonaws.services.simpledb.AmazonSimpleDBClient getAmazonSimpleDbClient()
protected static boolean isRequestTimeoutException(Exception aException)
protected static boolean isServiceUnavailableException(Exception aException)
protected 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.AmazonSimpleDBClient aAmazonSimpleDbClient, String aDomainName)
aAmazonSimpleDbClient
- The AmazonSimpleDBClient
.aDomainName
- The domain name of the domain to be cleared.protected static com.amazonaws.services.simpledb.AmazonSimpleDBClient 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 © 2016. All rights reserved.