Class DatasourceSessions
- java.lang.Object
-
- com.ibm.fhir.persistence.cassandra.cql.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 classstatic 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 timestatic 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 (seeFHIRRequestContext
).static boolean
isPayloadPersistenceConfigured()
Check if payload persistence is configured for the current tenant/datasourcevoid
serverReady()
Called after the server startup processing is done and all services are readystatic void
shutdown()
Close any sessions that are currently open to permit a clean exitvoid
startShutdown()
Called at the start of shutdown.
-
-
-
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 (seeFHIRRequestContext
).- 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 interfaceEventCallback
-
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 interfaceEventCallback
-
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 interfaceEventCallback
-
-