Class PersistenceBackendFactory

java.lang.Object
org.gcube.documentstore.persistence.PersistenceBackendFactory

public abstract class PersistenceBackendFactory extends Object
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • DEFAULT_CONTEXT

      public static final String DEFAULT_CONTEXT
      See Also:
    • HOME_SYSTEM_PROPERTY

      public static final String HOME_SYSTEM_PROPERTY
      See Also:
    • FALLBACK_FILENAME

      protected static final String 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

      public static void forceImmediateRediscovery(String context)
    • getForceImmediateRediscovery

      public static Boolean getForceImmediateRediscovery(String context)
    • addRecordPackage

      public static void addRecordPackage(Package packageObject)
    • setFallbackLocation

      public static void setFallbackLocation(String path)
    • getFallbackLocation

      protected static String getFallbackLocation()
    • sanitizeContext

      protected static String sanitizeContext(String context)
    • removeSlashFromContext

      protected static String removeSlashFromContext(String context)
    • getFallbackFile

      public static File getFallbackFile(String context)
    • createFallback

      protected static FallbackPersistenceBackend createFallback(String context)
    • discoverPersistenceBackend

      protected static PersistenceBackend discoverPersistenceBackend(String context, FallbackPersistenceBackend fallback)
    • getPersistenceBackend

      public static PersistenceBackend getPersistenceBackend(String context)
      Returns the persistence backend of the Context. The first call for a Context puts a FallbackPersistenceBackend in 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 compatibility
      Puts 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 use
      context - 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 use
      context - the Context
      Returns:
      the discovered backend, or actual if none is found
      Throws:
      Exception - if the library's credentials cannot be obtained
    • flush

      @Deprecated public static void flush(String context, long timeout, TimeUnit timeUnit)
      Deprecated.
      Use flush(String) instead
      Parameters:
      context -
      timeout -
      timeUnit -
    • flush

      public static void flush(String context)
    • flushAll

      @Deprecated public static void flushAll(long timeout, TimeUnit timeUnit)
      Deprecated.
      Use flushAll() 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. An elaboration of a fallback file in progress stops at the next record and writes the lines it has not sent yet back to the fallback file.