public abstract class PersistenceBackend extends Object
| Modifier and Type | Field and Description |
|---|---|
protected AggregationScheduler |
aggregationScheduler |
protected boolean |
closed |
protected static Integer |
countFallback |
protected FallbackPersistenceBackend |
fallbackPersistence |
static Integer |
MAX_FALLBACK |
static long |
MAX_TIME_TO_FALLBACK |
protected PersistenceBackendMonitor |
persistenceBackendMonitor |
protected boolean |
timeoutFallback |
protected long |
timerToFallback |
| Modifier | Constructor and Description |
|---|---|
protected |
PersistenceBackend() |
protected |
PersistenceBackend(FallbackPersistenceBackend fallback) |
| Modifier and Type | Method and Description |
|---|---|
void |
account(Record record)
Persist the
#UsageRecord. |
protected void |
accountValidateAggregate(Record record,
boolean validate,
boolean aggregate) |
protected void |
accountWithFallback(Record... records) |
abstract void |
close()
This method is used to close
|
protected void |
closeAndClean()
This method is used to close db and clean the configuration.
|
protected abstract void |
closeConnection()
This method is used to open db connection
|
void |
flush(long timeout,
TimeUnit timeUnit) |
AggregationScheduler |
getAggregationScheduler() |
FallbackPersistenceBackend |
getFallbackPersistence() |
boolean |
isOpen() |
protected abstract void |
openConnection()
This method is used to open db connection
|
protected abstract void |
prepareConnection(PersistenceBackendConfiguration configuration)
Prepare the connection to persistence.
|
protected abstract void |
reallyAccount(Record record)
This method contains the code to save the
Record |
protected void |
setAggregationScheduler(AggregationScheduler aggregationScheduler) |
protected void |
setFallback(FallbackPersistenceBackend fallback) |
protected void |
setOpen() |
protected FallbackPersistenceBackend fallbackPersistence
protected AggregationScheduler aggregationScheduler
protected PersistenceBackendMonitor persistenceBackendMonitor
public static final Integer MAX_FALLBACK
protected static Integer countFallback
protected boolean timeoutFallback
protected long timerToFallback
public static final long MAX_TIME_TO_FALLBACK
protected boolean closed
protected PersistenceBackend()
protected PersistenceBackend(FallbackPersistenceBackend fallback)
public FallbackPersistenceBackend getFallbackPersistence()
protected void setFallback(FallbackPersistenceBackend fallback)
fallback - the fallback to setpublic AggregationScheduler getAggregationScheduler()
protected void setAggregationScheduler(AggregationScheduler aggregationScheduler)
aggregationScheduler - the aggregationScheduler to setprotected abstract void prepareConnection(PersistenceBackendConfiguration configuration) throws Exception
configuration - The configuration to create the connectionException - if failsprotected abstract void openConnection()
throws Exception
Exceptionprotected abstract void closeConnection()
throws Exception
Exceptionprotected void closeAndClean()
throws Exception
Exceptionprotected abstract void reallyAccount(Record record) throws Exception
RecordExceptionprotected void accountWithFallback(Record... records) throws Exception
records - Exceptionprotected void accountValidateAggregate(Record record, boolean validate, boolean aggregate)
record - validate - aggregate - public void account(Record record) throws InvalidValueException
#UsageRecord.
The Record is validated first, then accounted, in a separated thread.
So that the program can continue the execution.
If the persistence fails the class write that the record in a local file
so that the #UsageRecord can be recorder later.usageRecord - the #UsageRecord to persistInvalidValueException - if the Record Validation Failspublic boolean isOpen()
protected void setOpen()
Copyright © 2017. All Rights Reserved.