Class ReindexResourceDAO

    • Method Detail

      • getResource

        protected ResourceIndexRecord getResource​(Instant reindexTstamp,
                                                  Long logicalResourceId)
                                           throws Exception
        Pick a specific resource to process by logicalResourceId (primary key). Since the logicalResourceId is specified, we avoid updating the record as the caller of $reindex operation is passing in an explicit list of resources, so no need to lock for the purpose of picking a random resource. This can improve performance (especially with PostgreSQL by avoiding the generation of tombstones).
        Parameters:
        reindexTstamp - only get resource with a reindex_tstamp less than this
        logicalResourceId - the logical resource ID (primary key) of a specific resource
        Returns:
        the resource record, or null when the resource is not found
        Throws:
        Exception
      • getNextResource

        protected ResourceIndexRecord getNextResource​(SecureRandom random,
                                                      Instant reindexTstamp,
                                                      Integer resourceTypeId,
                                                      String logicalId)
                                               throws Exception
        Pick the next resource to process, then also lock it. Specializations for different databases may use different techniques to optimize locking/concurrency control.
        Parameters:
        random - used to generate a random number
        reindexTstamp - only get resource with a reindex_tstamp less than this
        resourceTypeId - the resource type ID of a specific resource type, or null
        logicalId - the resource ID of a specific resource, or null
        Returns:
        the resource record, or null when there is nothing left to do
        Throws:
        Exception
      • getResourceToReindex

        public ResourceIndexRecord getResourceToReindex​(Instant reindexTstamp,
                                                        Long logicalResourceId,
                                                        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 - only get resource with an index_tstamp less than this
        logicalResourceId - logical resource ID (primary key) of resource to reindex, or null
        resourceTypeId - the resource type ID of a specific resource type, or null; this parameter is ignored if the logicalResourceId parameter value is non-null
        logicalId - the resource ID of a specific resource, or null; this parameter is ignored if the logicalResourceId parameter value is non-null
        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 parameterHashB64,
                                     String logicalId,
                                     long logicalResourceId)
                              throws Exception
        Reindex the resource by deleting existing parameters and replacing them with those passed in.
        Parameters:
        tablePrefix - the table prefix
        parameters - A collection of search parameters to be persisted along with the passed Resource
        parameterHashB64 - the Base64 encoded SHA-256 hash of parameters
        logicalId - the logical id
        logicalResourceId - the logical resource id
        Throws:
        Exception
      • updateParameterHash

        protected void updateParameterHash​(Connection conn,
                                           long logicalResourceId,
                                           String parameterHashB64)
                                    throws SQLException
        Updates the parameter hash in the LOGICAL_RESOURCES table.
        Parameters:
        conn - the connection
        logicalResourceId - the logical resource ID
        parameterHashB64 - the Base64 encoded SHA-256 hash of parameters
        Throws:
        SQLException