Class DatasourceSessions

  • All Implemented Interfaces:
    EventCallback

    public class DatasourceSessions
    extends java.lang.Object
    implements EventCallback
    Singleton to manage Cassandra CqlSession connections for each FHIR tenant/datasource. CqlSession holds the state of the cluster and is thread-safe. There should be a single value of CqlSession for a given tenant/datasource and this shouldn't be closed by the application until shutdown (handled by the EventCallback server lifecycle events).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void finalShutdown()
      Called after all startShutdown() calls have been processed.
      static DatasourceSessions getInstance()
      Get the singleton instance of this class
      static com.datastax.oss.driver.api.core.CqlSession getSessionForBootstrap​(java.lang.String tenantId, java.lang.String dsId)
      Create a special session without specifying the keyspace, which is needed to support schema creation where we create the keyspace for the first time
      static com.datastax.oss.driver.api.core.CqlSession getSessionForTenantDatasource()
      Get the (shared, thread-safe) session object representing the connection to Cassandra for the current tenant/datasource (see FHIRRequestContext).
      static boolean isPayloadPersistenceConfigured()
      Check if payload persistence is configured for the current tenant/datasource
      void serverReady()
      Called after the server startup processing is done and all services are ready
      static void shutdown()
      Close any sessions that are currently open to permit a clean exit
      void startShutdown()
      Called at the start of shutdown.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static DatasourceSessions getInstance()
        Get the singleton instance of this class
        Returns:
      • getSessionForTenantDatasource

        public static com.datastax.oss.driver.api.core.CqlSession getSessionForTenantDatasource()
        Get the (shared, thread-safe) session object representing the connection to Cassandra for the current tenant/datasource (see FHIRRequestContext).
        Returns:
      • isPayloadPersistenceConfigured

        public static boolean isPayloadPersistenceConfigured()
        Check if payload persistence is configured for the current tenant/datasource
        Returns:
      • getSessionForBootstrap

        public static com.datastax.oss.driver.api.core.CqlSession getSessionForBootstrap​(java.lang.String tenantId,
                                                                                         java.lang.String dsId)
        Create a special session without specifying the keyspace, which is needed to support schema creation where we create the keyspace for the first time
        Parameters:
        tenantId -
        dsId -
        Returns:
      • shutdown

        public static void shutdown()
        Close any sessions that are currently open to permit a clean exit
      • serverReady

        public void serverReady()
        Description copied from interface: EventCallback
        Called after the server startup processing is done and all services are ready
        Specified by:
        serverReady in interface EventCallback
      • startShutdown

        public void startShutdown()
        Description copied from interface: EventCallback
        Called at the start of shutdown. Must not block. This method is called for all registered EventCallback objects before finalShutdown() is called. Implementations may initiate, but not wait for, shutdown of the services they manage.
        Specified by:
        startShutdown in interface EventCallback
      • finalShutdown

        public void finalShutdown()
        Description copied from interface: EventCallback
        Called after all startShutdown() calls have been processed. Implementations should terminate internal services immediately at this point. Waiting for termination should be kept to a minimum, unless critical for stability.
        Specified by:
        finalShutdown in interface EventCallback