Class PersistenceBackend
java.lang.Object
org.gcube.documentstore.persistence.PersistenceBackend
- Direct Known Subclasses:
FallbackPersistenceBackend
- Author:
- Luca Frosini (ISTI - CNR), Alessandro Pieve (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AggregationSchedulerprotected FallbackPersistenceBackendprotected intprotected longprotected booleanstatic final intMax Times of Retry before forcing the usage of FallbackPersistenceBackendstatic final longMax Time Period Used during while the usage of FallbackPersistenceBackend is forcedprotected FallbackMonitor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedPersistenceBackend(FallbackPersistenceBackend fallback) -
Method Summary
Modifier and TypeMethodDescriptionvoidPersist the Record.protected voidaccountValidateAggregate(Record record, boolean validate, boolean aggregate) protected voidaccountWithFallback(Record... records) protected abstract voidclean()This method is used to allow PersistenceBackend implementations to clean a global status if any (or to renew it) when to much exceptions occurs trying to persist Records.voidclose()This method is used to closeprotected abstract voidThis method is used to close db connectionvoidflush()voidDeprecated.abstract booleanCheck the Connection stateprotected abstract voidThis method is used to open db connectionprotected abstract voidprepareConnection(PersistenceBackendConfiguration configuration) Prepare the connection to persistence.protected abstract voidreallyAccount(Record record) This method contains the code to save theRecordprotected voidsetAggregationScheduler(AggregationScheduler aggregationScheduler) protected voidsetFallback(FallbackPersistenceBackend fallback)
-
Field Details
-
MAX_TIME_TO_FALLBACK
public static final long MAX_TIME_TO_FALLBACKMax Time Period Used during while the usage of FallbackPersistenceBackend is forced- See Also:
-
MAX_FALLBACK_RETRY
public static final int MAX_FALLBACK_RETRYMax Times of Retry before forcing the usage of FallbackPersistenceBackend- See Also:
-
forceFallbackUse
protected boolean forceFallbackUse -
fallbackUseCounter
protected int fallbackUseCounter -
fallbackUseStartTime
protected long fallbackUseStartTime -
fallbackPersistence
-
aggregationScheduler
-
persistenceBackendMonitor
-
-
Constructor Details
-
PersistenceBackend
protected PersistenceBackend() -
PersistenceBackend
-
-
Method Details
-
getFallbackPersistence
- Returns:
- the fallbackPersistence
-
setFallback
- Parameters:
fallback- the fallback to set
-
getAggregationScheduler
- Returns:
- the aggregationScheduler
-
setAggregationScheduler
- Parameters:
aggregationScheduler- the aggregationScheduler to set
-
prepareConnection
protected abstract void prepareConnection(PersistenceBackendConfiguration configuration) throws Exception Prepare the connection to persistence. This method must be used by implementation class to prepare the connection with the persistence storage, DB, file etc.- Parameters:
configuration- The configuration to create the connection- Throws:
Exception- if fails
-
openConnection
This method is used to open db connection- Throws:
Exception
-
closeConnection
This method is used to close db connection- Throws:
Exception
-
close
This method is used to close- Throws:
Exception
-
clean
This method is used to allow PersistenceBackend implementations to clean a global status if any (or to renew it) when to much exceptions occurs trying to persist Records.- Throws:
Exception
-
isConnectionActive
Check the Connection state- Returns:
- true if the connection is active, false otherwise
- Throws:
Exception
-
reallyAccount
This method contains the code to save theRecord- Throws:
Exception
-
accountWithFallback
- Parameters:
records-- Throws:
Exception
-
accountValidateAggregate
- Parameters:
record-validate-aggregate-
-
account
Persist the Record. 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 Record can be recorder later.- Parameters:
record- the Record to persist- Throws:
InvalidValueException- if the Record Validation Fails
-
flush
Deprecated.Useflush()instead- Parameters:
timeout-timeUnit-- Throws:
Exception
-
flush
- Throws:
Exception
-