Class PersistenceBackendFactory
java.lang.Object
org.gcube.documentstore.persistence.PersistenceBackendFactory
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddRecordPackage(Package packageObject) protected static FallbackPersistenceBackendcreateFallback(String context) protected static PersistenceBackenddiscoverPersistenceBackend(String context, FallbackPersistenceBackend fallback) static voidstatic voidDeprecated.static voidflushAll()static voidDeprecated.static voidforceImmediateRediscovery(String context) static FilegetFallbackFile(String context) protected static Stringstatic BooleangetForceImmediateRediscovery(String context) static PersistenceBackendgetPersistenceBackend(String context) Returns the persistence backend of the Context.protected static PersistenceBackendrediscoverPersistenceBackend(FallbackPersistenceBackend actual, String context) Discovers the real backend of the Context, with the library's credentials, and puts it in use.protected static StringremoveSlashFromContext(String context) protected static PersistenceBackendresetToFallbackPersistenceBackend(PersistenceBackend actual, String context) Deprecated.not used by the library; kept for compatibilityprotected static StringsanitizeContext(String context) static voidsetFallbackLocation(String path) static voidshutdown()Stops the library's threads, then writes the records still buffered to the fallback files, and closes the connections: a remote send at shutdown could be cut before completing, and its records lost.
-
Field Details
-
DEFAULT_CONTEXT
- See Also:
-
HOME_SYSTEM_PROPERTY
- See Also:
-
FALLBACK_FILENAME
- See Also:
-
INITIAL_DELAY
public static final long INITIAL_DELAY -
FALLBACK_RETRY_TIME
public static final long FALLBACK_RETRY_TIME
-
-
Constructor Details
-
PersistenceBackendFactory
public PersistenceBackendFactory()
-
-
Method Details
-
forceImmediateRediscovery
-
getForceImmediateRediscovery
-
addRecordPackage
-
setFallbackLocation
-
getFallbackLocation
-
sanitizeContext
-
removeSlashFromContext
-
getFallbackFile
-
createFallback
-
discoverPersistenceBackend
protected static PersistenceBackend discoverPersistenceBackend(String context, FallbackPersistenceBackend fallback) -
getPersistenceBackend
Returns the persistence backend of the Context. The first call for a Context puts aFallbackPersistenceBackendin use and discovers the real backend: immediately if forced (forceImmediateRediscovery(String)), otherwise, and whenever that fails, periodically in the background. The discovery runs outside the factory lock.- Parameters:
context- the Context- Returns:
- the persistence backend in use for the Context
-
resetToFallbackPersistenceBackend
@Deprecated protected static PersistenceBackend resetToFallbackPersistenceBackend(PersistenceBackend actual, String context) Deprecated.not used by the library; kept for compatibilityPuts the fallback of the given backend in use for the Context, and closes the given backend outside the factory lock.- Parameters:
actual- the backend in usecontext- the Context- Returns:
- the given backend
-
rediscoverPersistenceBackend
protected static PersistenceBackend rediscoverPersistenceBackend(FallbackPersistenceBackend actual, String context) throws Exception Discovers the real backend of the Context, with the library's credentials, and puts it in use.- Parameters:
actual- the fallback in usecontext- the Context- Returns:
- the discovered backend, or
actualif none is found - Throws:
Exception- if the library's credentials cannot be obtained
-
flush
Deprecated.Useflush(String)instead- Parameters:
context-timeout-timeUnit-
-
flush
-
flushAll
Deprecated.UseflushAll()instead- Parameters:
timeout-timeUnit-
-
flushAll
public static void flushAll() -
shutdown
public static void shutdown()Stops the library's threads, then writes the records still buffered to the fallback files, and closes the connections: a remote send at shutdown could be cut before completing, and its records lost.
-