Class FallbackPersistenceBackend
- java.lang.Object
-
- org.gcube.documentstore.persistence.PersistenceBackend
-
- org.gcube.documentstore.persistence.FallbackPersistenceBackend
-
public class FallbackPersistenceBackend extends PersistenceBackend
- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
-
Fields inherited from class org.gcube.documentstore.persistence.PersistenceBackend
aggregationScheduler, fallbackPersistence, fallbackUseCounter, fallbackUseStartTime, forceFallbackUse, MAX_FALLBACK_RETRY, MAX_TIME_TO_FALLBACK, persistenceBackendMonitor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFallbackPersistenceBackend(File fallbackFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaccountWithFallback(Record... records)protected 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 voidcloseConnection()This method is used to close db connectionprotected FilegetFallbackFile()protected FilegetOldFallbackFile()Deprecated.booleanisConnectionActive()Check the Connection stateprotected FilemoveFallbackFile(String suffix)Move the fallbackFile to a new file with the same name by appending a suffixprotected voidopenConnection()This method is used to open db connectionvoidprepareConnection(PersistenceBackendConfiguration configuration)Prepare the connection to persistence.protected voidprintLine(String line)This method is synchronized on fallbackFile.protected voidreallyAccount(Record record)This method contains the code to save theRecord-
Methods inherited from class org.gcube.documentstore.persistence.PersistenceBackend
account, accountValidateAggregate, flush, flush, getAggregationScheduler, getFallbackPersistence, setAggregationScheduler, setFallback
-
-
-
-
Constructor Detail
-
FallbackPersistenceBackend
protected FallbackPersistenceBackend(File fallbackFile)
-
-
Method Detail
-
getFallbackFile
protected File getFallbackFile()
- Returns:
- the fallbackFile
-
getOldFallbackFile
@Deprecated protected File getOldFallbackFile()
Deprecated.
-
moveFallbackFile
protected File moveFallbackFile(String suffix)
Move the fallbackFile to a new file with the same name by appending a suffix- Parameters:
suffix-- Returns:
- the moved file if any, null otherwise
-
prepareConnection
public void prepareConnection(PersistenceBackendConfiguration configuration)
Prepare the connection to persistence. This method must be used by implementation class to prepare the connection with the persistence storage, DB, file etc.- Specified by:
prepareConnectionin classPersistenceBackend- Parameters:
configuration- The configuration to create the connection
-
openConnection
protected void openConnection() throws ExceptionDescription copied from class:PersistenceBackendThis method is used to open db connection- Specified by:
openConnectionin classPersistenceBackend- Throws:
Exception
-
close
public void close() throws ExceptionThis method is used to close- Overrides:
closein classPersistenceBackend- Throws:
Exception
-
accountWithFallback
protected void accountWithFallback(Record... records) throws Exception
- Overrides:
accountWithFallbackin classPersistenceBackend- Throws:
Exception
-
reallyAccount
protected void reallyAccount(Record record)
This method contains the code to save theRecord- Specified by:
reallyAccountin classPersistenceBackend
-
printLine
protected void printLine(String line) throws Exception
This method is synchronized on fallbackFile. Any actions which has to modify, rename or delete the file must be synchronized on this file. To retrieve it usegetFallbackFile()method. This is intended for internal library usage only so that is protected. It- Throws:
Exception
-
closeConnection
protected void closeConnection() throws ExceptionDescription copied from class:PersistenceBackendThis method is used to close db connection- Specified by:
closeConnectionin classPersistenceBackend- Throws:
Exception
-
isConnectionActive
public boolean isConnectionActive() throws ExceptionDescription copied from class:PersistenceBackendCheck the Connection state- Specified by:
isConnectionActivein classPersistenceBackend- Returns:
- true if the connection is active, false otherwise
- Throws:
Exception
-
clean
protected void clean() throws ExceptionDescription copied from class:PersistenceBackendThis 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.- Specified by:
cleanin classPersistenceBackend- Throws:
Exception
-
-