Class ReindexResourceDAO
- java.lang.Object
-
- com.ibm.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
-
- com.ibm.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
-
- com.ibm.fhir.persistence.jdbc.dao.ReindexResourceDAO
-
- All Implemented Interfaces:
FHIRDbDAO
,ResourceDAO
- Direct Known Subclasses:
PostgresReindexResourceDAO
public class ReindexResourceDAO extends ResourceDAOImpl
DAO used to contain the logic required to reindex a given resource
-
-
Field Summary
-
Fields inherited from class com.ibm.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
DEFAULT_VALUE_REINDEX_TSTAMP, IDX_DATA, IDX_IS_DELETED, IDX_LAST_UPDATED, IDX_LOGICAL_ID, IDX_LOGICAL_RESOURCE_ID, IDX_RESOURCE_ID, IDX_VERSION_ID
-
-
Constructor Summary
Constructors Constructor Description ReindexResourceDAO(Connection connection, IDatabaseTranslator translator, ParameterDAO parameterDao, String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd)
Public constructorReindexResourceDAO(Connection connection, IDatabaseTranslator translator, ParameterDAO parameterDao, String schemaName, FHIRDbFlavor flavor, TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd, ParameterTransactionDataImpl ptdi)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
deleteFromParameterTable(Connection conn, String tableName, long logicalResourceId)
Delete all parameters for the given resourceId from the parameters tableprotected ResourceIndexRecord
getNextResource(SecureRandom random, Instant reindexTstamp, Integer resourceTypeId, String logicalId)
Pick the next resource to process resource and lock it.ResourceIndexRecord
getResourceToReindex(Instant reindexTstamp, Integer resourceTypeId, String logicalId)
Get the resource record we want to reindex.protected IDatabaseTranslator
getTranslator()
Getter for the translator currently held by this DAOvoid
updateParameters(String tablePrefix, List<ExtractedParameterValue> parameters, String logicalId, long logicalResourceId)
Reindex the resource by deleting existing parameters and replacing them with those passed in.-
Methods inherited from class com.ibm.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
addResourceTypeCacheCandidate, createDTO, getCache, getResourceReferenceDAO, getResourceTypeIdFromCaches, getSearchByIdsSql, getTransactionData, history, historyCount, insert, read, readAllResourceTypeNames, readResourceTypeId, search, search, searchByIds, searchCount, searchCount, searchForIds, searchStringValues, setPersistenceContext, versionRead
-
Methods inherited from class com.ibm.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
buildExceptionWithIssue, buildFHIRPersistenceDBConnectException, cleanup, cleanup, createDTOs, getConnection, getFlavor, getSchemaName, isDb2Database, runCountQuery, runQuery, runQuery_STR_VALUES, severe, severe
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.fhir.persistence.jdbc.dao.api.FHIRDbDAO
getConnection, getFlavor, isDb2Database
-
-
-
-
Constructor Detail
-
ReindexResourceDAO
public ReindexResourceDAO(Connection connection, IDatabaseTranslator translator, ParameterDAO parameterDao, String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd)
Public constructor- Parameters:
connection
-translator
-parameterDao
-schemaName
-flavor
-cache
-rrd
-
-
ReindexResourceDAO
public ReindexResourceDAO(Connection connection, IDatabaseTranslator translator, ParameterDAO parameterDao, String schemaName, FHIRDbFlavor flavor, TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd, ParameterTransactionDataImpl ptdi)
Public constructor- Parameters:
connection
-translator
-parameterDao
-schemaName
-flavor
-trxSynchRegistry
-cache
-rrd
-
-
-
Method Detail
-
getTranslator
protected IDatabaseTranslator getTranslator()
Getter for the translator currently held by this DAO- Returns:
-
getNextResource
protected ResourceIndexRecord getNextResource(SecureRandom random, Instant reindexTstamp, Integer resourceTypeId, String logicalId) throws Exception
Pick the next resource to process resource and lock it. Specializations for different databases may use different techniques to optimize locking/concurrency control- Parameters:
reindexTstamp
-- Returns:
- Throws:
Exception
-
getResourceToReindex
public ResourceIndexRecord getResourceToReindex(Instant reindexTstamp, Integer resourceTypeId, String logicalId) throws Exception
Get the resource record we want to reindex. This might take a few attempts, because there could be hundreds of threads all trying to do the same thing, and we may see collisions which will cause the FOR UPDATE to block, then return no rows.- Parameters:
reindexTstamp
-resourceCount
-- Returns:
- the resource record, or null when there is nothing left to do
- Throws:
Exception
-
updateParameters
public void updateParameters(String tablePrefix, List<ExtractedParameterValue> parameters, String logicalId, long logicalResourceId) throws Exception
Reindex the resource by deleting existing parameters and replacing them with those passed in.- Parameters:
tablePrefix
- the table prefixparameters
- the extracted parameterslogicalId
- the logical idlogicalResourceId
- the logical resource id- Throws:
Exception
-
deleteFromParameterTable
protected void deleteFromParameterTable(Connection conn, String tableName, long logicalResourceId) throws SQLException
Delete all parameters for the given resourceId from the parameters table- Parameters:
conn
-tableName
-logicalResourceId
-- Throws:
SQLException
-
-