| | |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.WriteOperation; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | * @param txn The database transaction |
| | | * @throws ConfigException if a configuration related error occurs. |
| | | */ |
| | | AttributeIndex(BackendIndexCfg indexConfig, EntryContainer entryContainer, WriteableStorage txn) |
| | | AttributeIndex(BackendIndexCfg indexConfig, EntryContainer entryContainer, WriteableTransaction txn) |
| | | throws ConfigException |
| | | { |
| | | this.entryContainer = entryContainer; |
| | |
| | | extensibleIndexesMapping = computeExtensibleIndexesMapping(); |
| | | } |
| | | |
| | | private void buildPresenceIndex(WriteableStorage txn) |
| | | private void buildPresenceIndex(WriteableTransaction txn) |
| | | { |
| | | final IndexType indexType = IndexType.PRESENCE; |
| | | if (indexConfig.getIndexType().contains(indexType)) |
| | |
| | | } |
| | | } |
| | | |
| | | private Index newPresenceIndex(WriteableStorage txn, BackendIndexCfg cfg) |
| | | private Index newPresenceIndex(WriteableTransaction txn, BackendIndexCfg cfg) |
| | | { |
| | | final AttributeType attrType = cfg.getAttribute(); |
| | | final TreeName indexName = getIndexName(attrType, IndexType.PRESENCE.toString()); |
| | |
| | | return entryContainer.newIndexForAttribute(txn, indexName, indexer, cfg.getIndexEntryLimit()); |
| | | } |
| | | |
| | | private void buildExtensibleIndexes(WriteableStorage txn) throws ConfigException |
| | | private void buildExtensibleIndexes(WriteableTransaction txn) throws ConfigException |
| | | { |
| | | final IndexType indexType = IndexType.EXTENSIBLE; |
| | | if (indexConfig.getIndexType().contains(indexType)) |
| | |
| | | } |
| | | } |
| | | |
| | | private void buildIndexes(WriteableStorage txn, IndexType indexType) throws ConfigException |
| | | private void buildIndexes(WriteableTransaction txn, IndexType indexType) throws ConfigException |
| | | { |
| | | if (indexConfig.getIndexType().contains(indexType)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private Index newAttributeIndex(WriteableStorage txn, BackendIndexCfg indexConfig, |
| | | private Index newAttributeIndex(WriteableTransaction txn, BackendIndexCfg indexConfig, |
| | | org.forgerock.opendj.ldap.spi.Indexer indexer) |
| | | { |
| | | final AttributeType attrType = indexConfig.getAttribute(); |
| | |
| | | * @throws StorageRuntimeException if a JE database error occurs while |
| | | * opening the index. |
| | | */ |
| | | void open(WriteableStorage txn) throws StorageRuntimeException |
| | | void open(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | for (Index index : nameToIndexes.values()) |
| | | { |
| | |
| | | entryContainer.getRootContainer().getStorage().write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | applyChangeToPresenceIndex(txn, cfg, ccr); |
| | | applyChangeToIndex(txn, IndexType.EQUALITY, cfg, ccr); |
| | |
| | | return ccr; |
| | | } |
| | | |
| | | private void applyChangeToExtensibleIndexes(WriteableStorage txn, BackendIndexCfg cfg, ConfigChangeResult ccr) |
| | | private void applyChangeToExtensibleIndexes(WriteableTransaction txn, BackendIndexCfg cfg, ConfigChangeResult ccr) |
| | | { |
| | | final AttributeType attrType = cfg.getAttribute(); |
| | | if (!cfg.getIndexType().contains(IndexType.EXTENSIBLE)) |
| | |
| | | } |
| | | |
| | | /** Remove indexes which do not correspond to valid rules. */ |
| | | private void removeIndexesForExtensibleMatchingRules(WriteableStorage txn, Set<MatchingRule> validRules, |
| | | private void removeIndexesForExtensibleMatchingRules(WriteableTransaction txn, Set<MatchingRule> validRules, |
| | | Set<String> validIndexIds) |
| | | { |
| | | final Set<MatchingRule> rulesToDelete = getCurrentExtensibleMatchingRules(); |
| | |
| | | return rules; |
| | | } |
| | | |
| | | private void applyChangeToIndex(final WriteableStorage txn, final IndexType indexType, final BackendIndexCfg cfg, |
| | | private void applyChangeToIndex(final WriteableTransaction txn, final IndexType indexType, final BackendIndexCfg cfg, |
| | | final ConfigChangeResult ccr) |
| | | { |
| | | String indexId = indexType.toString(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void applyChangeToPresenceIndex(WriteableStorage txn, BackendIndexCfg cfg, ConfigChangeResult ccr) |
| | | private void applyChangeToPresenceIndex(WriteableTransaction txn, BackendIndexCfg cfg, ConfigChangeResult ccr) |
| | | { |
| | | final IndexType indexType = IndexType.PRESENCE; |
| | | final String indexID = indexType.toString(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void removeIndex(WriteableStorage txn, Index index, IndexType indexType) |
| | | private void removeIndex(WriteableTransaction txn, Index index, IndexType indexType) |
| | | { |
| | | if (index != null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void openIndex(WriteableStorage txn, Index index, ConfigChangeResult ccr) |
| | | private void openIndex(WriteableTransaction txn, Index index, ConfigChangeResult ccr) |
| | | { |
| | | index.open(txn); |
| | | |