Renamed ReadableStorage and WriteableStorage to ReadableTransaction and WriteableTransaction.
Code review: Matthew Swift
2 files renamed
24 files modified
| | |
| | | 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); |
| | | |
| | |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | 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.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.RuntimeInformation; |
| | |
| | | rootContainer.getStorage().write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | SortedSet<DN> newBaseDNs = newCfg.getBaseDN(); |
| | | DN[] newBaseDNsArray = newBaseDNs.toArray(new DN[newBaseDNs.size()]); |
| | |
| | | return ccr; |
| | | } |
| | | |
| | | private void removeDeletedBaseDNs(SortedSet<DN> newBaseDNs, WriteableStorage txn) throws DirectoryException |
| | | private void removeDeletedBaseDNs(SortedSet<DN> newBaseDNs, WriteableTransaction txn) throws DirectoryException |
| | | { |
| | | for (DN baseDN : cfg.getBaseDN()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean createNewBaseDNs(DN[] newBaseDNsArray, ConfigChangeResult ccr, WriteableStorage txn) |
| | | private boolean createNewBaseDNs(DN[] newBaseDNsArray, ConfigChangeResult ccr, WriteableTransaction txn) |
| | | { |
| | | for (DN baseDN : newBaseDNsArray) |
| | | { |
| | |
| | | import static org.opends.server.backends.pluggable.JebFormat.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | |
| | | * @throws StorageRuntimeException If an error occurred while attempting to insert |
| | | * the new record. |
| | | */ |
| | | void put(WriteableStorage txn, DN dn, EntryID id) throws StorageRuntimeException |
| | | void put(WriteableTransaction txn, DN dn, EntryID id) throws StorageRuntimeException |
| | | { |
| | | ByteString key = dnToDNKey(dn, prefixRDNComponents); |
| | | ByteString value = id.toByteString(); |
| | |
| | | * @throws StorageRuntimeException If an error occurred while attempting to remove |
| | | * the record. |
| | | */ |
| | | boolean remove(WriteableStorage txn, DN dn) throws StorageRuntimeException |
| | | boolean remove(WriteableTransaction txn, DN dn) throws StorageRuntimeException |
| | | { |
| | | ByteString key = dnToDNKey(dn, prefixRDNComponents); |
| | | |
| | |
| | | * @return The entry ID, or null if the given DN is not in the DN database. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | EntryID get(ReadableStorage txn, DN dn) throws StorageRuntimeException |
| | | EntryID get(ReadableTransaction txn, DN dn) throws StorageRuntimeException |
| | | { |
| | | ByteString key = dnToDNKey(dn, prefixRDNComponents); |
| | | ByteString value = txn.read(getName(), key); |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Pair; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.UpdateFunction; |
| | | 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.core.SearchOperation; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | * @param labeledURIs The labeled URI value of the ref attribute. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void put(final WriteableStorage txn, final DN dn, final Collection<String> labeledURIs) |
| | | private void put(final WriteableTransaction txn, final DN dn, final Collection<String> labeledURIs) |
| | | throws StorageRuntimeException |
| | | { |
| | | final ByteString key = toKey(dn); |
| | |
| | | * @return true if the values were deleted, false if not. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private boolean delete(WriteableStorage txn, DN dn) throws StorageRuntimeException |
| | | private boolean delete(WriteableTransaction txn, DN dn) throws StorageRuntimeException |
| | | { |
| | | ByteString key = toKey(dn); |
| | | |
| | |
| | | * @param labeledURIs The URI value to be deleted. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void delete(final WriteableStorage txn, final DN dn, final Collection<String> labeledURIs) |
| | | private void delete(final WriteableTransaction txn, final DN dn, final Collection<String> labeledURIs) |
| | | throws StorageRuntimeException |
| | | { |
| | | ByteString key = toKey(dn); |
| | |
| | | * contain at least one referral, or {@code false} if it is certain |
| | | * that it doesn't. |
| | | */ |
| | | private ConditionResult containsReferrals(ReadableStorage txn) |
| | | private ConditionResult containsReferrals(ReadableTransaction txn) |
| | | { |
| | | Cursor cursor = txn.openCursor(getName()); |
| | | try |
| | |
| | | * @param mods The sequence of modifications made to the entry. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | void modifyEntry(WriteableStorage txn, Entry before, Entry after, List<Modification> mods) |
| | | void modifyEntry(WriteableTransaction txn, Entry before, Entry after, List<Modification> mods) |
| | | throws StorageRuntimeException |
| | | { |
| | | DN entryDN = before.getName(); |
| | |
| | | * @throws StorageRuntimeException |
| | | * If an error occurs in the JE database. |
| | | */ |
| | | void replaceEntry(WriteableStorage txn, Entry before, Entry after) |
| | | void replaceEntry(WriteableTransaction txn, Entry before, Entry after) |
| | | throws StorageRuntimeException |
| | | { |
| | | deleteEntry(txn, before); |
| | |
| | | * @param entry The entry to be added. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | void addEntry(WriteableStorage txn, Entry entry) |
| | | void addEntry(WriteableTransaction txn, Entry entry) |
| | | throws StorageRuntimeException |
| | | { |
| | | Set<String> labeledURIs = entry.getReferralURLs(); |
| | |
| | | * @param entry The entry to be deleted. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | void deleteEntry(WriteableStorage txn, Entry entry) throws StorageRuntimeException |
| | | void deleteEntry(WriteableTransaction txn, Entry entry) throws StorageRuntimeException |
| | | { |
| | | Set<String> labeledURIs = entry.getReferralURLs(); |
| | | if (labeledURIs != null) |
| | |
| | | * DN. The referral URLs will be set appropriately for the references found |
| | | * in the referral entry. |
| | | */ |
| | | void targetEntryReferrals(ReadableStorage txn, DN targetDN, SearchScope searchScope) throws DirectoryException |
| | | void targetEntryReferrals(ReadableTransaction txn, DN targetDN, SearchScope searchScope) throws DirectoryException |
| | | { |
| | | if (containsReferrals == ConditionResult.UNDEFINED) |
| | | { |
| | |
| | | * has been reached or the search has been abandoned). |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | boolean returnSearchReferences(ReadableStorage txn, SearchOperation searchOp) throws DirectoryException |
| | | boolean returnSearchReferences(ReadableTransaction txn, SearchOperation searchOp) throws DirectoryException |
| | | { |
| | | if (containsReferrals == ConditionResult.UNDEFINED) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | |
| | | /** |
| | | * This class is a wrapper around the JE database object and provides basic |
| | |
| | | * @throws StorageRuntimeException |
| | | * if a JE database error occurs while opening the index. |
| | | */ |
| | | void open(WriteableStorage txn) throws StorageRuntimeException |
| | | void open(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | txn.openTree(name); |
| | | } |
| | |
| | | * @throws StorageRuntimeException |
| | | * if a database error occurs while deleting the index. |
| | | */ |
| | | void delete(WriteableStorage txn) throws StorageRuntimeException |
| | | void delete(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | txn.deleteTree(name); |
| | | } |
| | |
| | | * @throws StorageRuntimeException |
| | | * If an error occurs in the DB operation. |
| | | */ |
| | | long getRecordCount(ReadableStorage txn) throws StorageRuntimeException |
| | | long getRecordCount(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | return txn.getRecordCount(name); |
| | | } |
| | |
| | | import org.opends.server.api.plugin.PluginResult.SubordinateModifyDN; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadOperation; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | | 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.controls.PagedResultsControl; |
| | | import org.opends.server.controls.ServerSideSortRequestControl; |
| | | import org.opends.server.controls.ServerSideSortResponseControl; |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | //Try creating all the indexes before confirming they are valid ones. |
| | | new AttributeIndex(cfg, EntryContainer.this, txn); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | final AttributeIndex index = new AttributeIndex(cfg, EntryContainer.this, txn); |
| | | index.open(txn); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | AttributeIndex index = attrIndexMap.get(cfg.getAttribute()); |
| | | deleteAttributeIndex(txn, index); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | VLVIndex vlvIndex = new VLVIndex(cfg, state, storage, EntryContainer.this, txn); |
| | | vlvIndex.open(txn); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | VLVIndex vlvIndex = vlvIndexMap.get(cfg.getName().toLowerCase()); |
| | | deleteDatabase(txn, vlvIndex); |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | * @throws ConfigException if a configuration related error occurs. |
| | | */ |
| | | void open(WriteableStorage txn) throws StorageRuntimeException, ConfigException |
| | | void open(WriteableTransaction txn) throws StorageRuntimeException, ConfigException |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private NullIndex openNewNullIndex(WriteableStorage txn, String indexId, Indexer indexer) |
| | | private NullIndex openNewNullIndex(WriteableTransaction txn, String indexId, Indexer indexer) |
| | | { |
| | | return new NullIndex(getIndexName(indexId), indexer, state, txn, this); |
| | | } |
| | |
| | | * @return The highest entry ID. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | EntryID getHighestEntryID(ReadableStorage txn) throws StorageRuntimeException |
| | | EntryID getHighestEntryID(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | Cursor cursor = txn.openCursor(id2entry.getName()); |
| | | try |
| | |
| | | return storage.read(new ReadOperation<Long>() |
| | | { |
| | | @Override |
| | | public Long run(ReadableStorage txn) throws Exception |
| | | public Long run(ReadableTransaction txn) throws Exception |
| | | { |
| | | EntryID entryID = dn2id.get(txn, entryDN); |
| | | if (entryID != null) |
| | |
| | | storage.read(new ReadOperation<Void>() |
| | | { |
| | | @Override |
| | | public Void run(ReadableStorage txn) throws Exception |
| | | public Void run(ReadableTransaction txn) throws Exception |
| | | { |
| | | DN aBaseDN = searchOperation.getBaseDN(); |
| | | SearchScope searchScope = searchOperation.getScope(); |
| | |
| | | * @throws DirectoryException If an error prevented the search from being |
| | | * processed. |
| | | */ |
| | | private void searchNotIndexed(ReadableStorage txn, SearchOperation searchOperation, PagedResultsControl pageRequest) |
| | | throws DirectoryException, CanceledOperationException |
| | | private void searchNotIndexed(ReadableTransaction txn, SearchOperation searchOperation, |
| | | PagedResultsControl pageRequest) throws DirectoryException, CanceledOperationException |
| | | { |
| | | DN aBaseDN = searchOperation.getBaseDN(); |
| | | SearchScope searchScope = searchOperation.getScope(); |
| | |
| | | * @throws DirectoryException |
| | | * If an error occurs retrieving the entry |
| | | */ |
| | | Entry getEntry(ReadableStorage txn, EntryID entryID) throws DirectoryException |
| | | Entry getEntry(ReadableTransaction txn, EntryID entryID) throws DirectoryException |
| | | { |
| | | // Try the entry cache first. |
| | | final EntryCache<?> entryCache = getEntryCache(); |
| | |
| | | * @throws DirectoryException If an error prevented the search from being |
| | | * processed. |
| | | */ |
| | | private void searchIndexed(ReadableStorage txn, EntryIDSet entryIDSet, boolean candidatesAreInScope, |
| | | private void searchIndexed(ReadableTransaction txn, EntryIDSet entryIDSet, boolean candidatesAreInScope, |
| | | SearchOperation searchOperation, PagedResultsControl pageRequest) throws DirectoryException, |
| | | CanceledOperationException |
| | | { |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | DN parentDN = getParentWithinBase(entry.getName()); |
| | | |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | final IndexBuffer indexBuffer = new IndexBuffer(EntryContainer.this); |
| | | |
| | |
| | | return newBS; |
| | | } |
| | | |
| | | private void deleteEntry(WriteableStorage txn, |
| | | private void deleteEntry(WriteableTransaction txn, |
| | | IndexBuffer indexBuffer, |
| | | boolean manageDsaIT, |
| | | DN targetDN, |
| | |
| | | * @throws DirectoryException If a problem occurs while trying to make the |
| | | * determination. |
| | | */ |
| | | private boolean entryExists(ReadableStorage txn, final DN entryDN) throws DirectoryException |
| | | private boolean entryExists(ReadableTransaction txn, final DN entryDN) throws DirectoryException |
| | | { |
| | | // Try the entry cache first. |
| | | EntryCache<?> entryCache = DirectoryServer.getEntryCache(); |
| | |
| | | return storage.read(new ReadOperation<Entry>() |
| | | { |
| | | @Override |
| | | public Entry run(ReadableStorage txn) throws Exception |
| | | public Entry run(ReadableTransaction txn) throws Exception |
| | | { |
| | | return getEntry0(txn, entryDN); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private Entry getEntry0(ReadableStorage txn, final DN entryDN) throws StorageRuntimeException, DirectoryException |
| | | private Entry getEntry0(ReadableTransaction txn, final DN entryDN) throws StorageRuntimeException, DirectoryException |
| | | { |
| | | final EntryCache<?> entryCache = DirectoryServer.getEntryCache(); |
| | | |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | try |
| | | { |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | DN oldSuperiorDN = getParentWithinBase(currentDN); |
| | | DN newSuperiorDN = getParentWithinBase(entry.getName()); |
| | |
| | | } |
| | | } |
| | | |
| | | private void addRenamedEntry(WriteableStorage txn, IndexBuffer buffer, |
| | | private void addRenamedEntry(WriteableTransaction txn, IndexBuffer buffer, |
| | | EntryID newID, |
| | | Entry newEntry, |
| | | boolean isApexEntryMoved, |
| | |
| | | } |
| | | } |
| | | |
| | | private void removeApexEntry(WriteableStorage txn, IndexBuffer buffer, |
| | | private void removeApexEntry(WriteableTransaction txn, IndexBuffer buffer, |
| | | DN oldSuperiorDN, |
| | | EntryID oldID, EntryID newID, |
| | | Entry oldEntry, Entry newEntry, |
| | |
| | | } |
| | | } |
| | | |
| | | private void removeSubordinateEntry(WriteableStorage txn, IndexBuffer buffer, |
| | | private void removeSubordinateEntry(WriteableTransaction txn, IndexBuffer buffer, |
| | | DN oldSuperiorDN, |
| | | EntryID oldID, EntryID newID, |
| | | Entry oldEntry, DN newDN, |
| | |
| | | * @return The number of entries stored in this entry container. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | long getEntryCount(ReadableStorage txn) throws StorageRuntimeException |
| | | long getEntryCount(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | final EntryID entryID = dn2id.get(txn, baseDN); |
| | | if (entryID != null) |
| | |
| | | * @throws StorageRuntimeException If an error occurs while removing the entry |
| | | * container. |
| | | */ |
| | | void delete(WriteableStorage txn) throws StorageRuntimeException |
| | | void delete(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | List<DatabaseContainer> databases = new ArrayList<DatabaseContainer>(); |
| | | listDatabases(databases); |
| | |
| | | * @throws StorageRuntimeException If an error occurs while attempting to delete the |
| | | * database. |
| | | */ |
| | | void deleteDatabase(WriteableStorage txn, DatabaseContainer database) throws StorageRuntimeException |
| | | void deleteDatabase(WriteableTransaction txn, DatabaseContainer database) throws StorageRuntimeException |
| | | { |
| | | if(database == state) |
| | | { |
| | |
| | | * @throws StorageRuntimeException If an JE database error occurs while attempting |
| | | * to delete the index. |
| | | */ |
| | | private void deleteAttributeIndex(WriteableStorage txn, AttributeIndex attributeIndex) throws StorageRuntimeException |
| | | private void deleteAttributeIndex(WriteableTransaction txn, AttributeIndex attributeIndex) |
| | | throws StorageRuntimeException |
| | | { |
| | | attributeIndex.close(); |
| | | for (Index index : attributeIndex.getAllIndexes()) |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | for(DatabaseContainer db : databases) |
| | | { |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | // Open the containers backup. |
| | | for(DatabaseContainer db : databases) |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | if (config.isSubordinateIndexesEnabled() != cfg.isSubordinateIndexesEnabled()) |
| | | { |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | clear0(txn); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private void clear0(WriteableStorage txn) throws StorageRuntimeException |
| | | private void clear0(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | final List<DatabaseContainer> databases = new ArrayList<DatabaseContainer>(); |
| | | listDatabases(databases); |
| | |
| | | * @param database The database to clear. |
| | | * @throws StorageRuntimeException if a JE database error occurs. |
| | | */ |
| | | void clearDatabase(WriteableStorage txn, DatabaseContainer database) |
| | | void clearDatabase(WriteableTransaction txn, DatabaseContainer database) |
| | | throws StorageRuntimeException |
| | | { |
| | | try |
| | |
| | | * @throws DirectoryException If an error prevented the check of an |
| | | * existing entry from being performed. |
| | | */ |
| | | private DN getMatchedDN(ReadableStorage txn, DN baseDN) throws DirectoryException |
| | | private DN getMatchedDN(ReadableTransaction txn, DN baseDN) throws DirectoryException |
| | | { |
| | | DN parentDN = baseDN.getParentDNInSuffix(); |
| | | while (parentDN != null && parentDN.isDescendantOf(getBaseDN())) |
| | |
| | | } |
| | | |
| | | /** Opens the id2children and id2subtree indexes. */ |
| | | private void openSubordinateIndexes(WriteableStorage txn) |
| | | private void openSubordinateIndexes(WriteableTransaction txn) |
| | | { |
| | | id2children = newIndex(txn, ID2CHILDREN_DATABASE_NAME, new ID2CIndexer()); |
| | | id2subtree = newIndex(txn, ID2SUBTREE_DATABASE_NAME, new ID2SIndexer()); |
| | | } |
| | | |
| | | private Index newIndex(WriteableStorage txn, String name, Indexer indexer) |
| | | private Index newIndex(WriteableTransaction txn, String name, Indexer indexer) |
| | | { |
| | | final Index index = new Index(getIndexName(name), indexer, state, config.getIndexEntryLimit(), 0, true, txn, this); |
| | | index.open(txn); |
| | |
| | | * @param indexEntryLimit the index entry limit |
| | | * @return a new index |
| | | */ |
| | | Index newIndexForAttribute(WriteableStorage txn, TreeName indexName, Indexer indexer, int indexEntryLimit) |
| | | Index newIndexForAttribute(WriteableTransaction txn, TreeName indexName, Indexer indexer, int indexEntryLimit) |
| | | { |
| | | return new Index(indexName, indexer, state, indexEntryLimit, CURSOR_ENTRY_LIMIT, false, txn, this); |
| | | } |
| | |
| | | * @return the Entry matching the baseDN. |
| | | * @throws DirectoryException if the baseDN doesn't exist. |
| | | */ |
| | | private Entry fetchBaseEntry(ReadableStorage txn, DN baseDN, SearchScope searchScope) |
| | | private Entry fetchBaseEntry(ReadableTransaction txn, DN baseDN, SearchScope searchScope) |
| | | throws DirectoryException |
| | | { |
| | | Entry baseEntry = null; |
| | |
| | | return baseEntry; |
| | | } |
| | | |
| | | private EntryIDSet sort(ReadableStorage txn, EntryIDSet entryIDSet, SearchOperation searchOperation, |
| | | private EntryIDSet sort(ReadableTransaction txn, EntryIDSet entryIDSet, SearchOperation searchOperation, |
| | | SortOrder sortOrder, VLVRequestControl vlvRequest) throws DirectoryException |
| | | { |
| | | if (!entryIDSet.isDefined()) |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadOperation; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | rootContainer.getStorage().read(new ReadOperation<Void>() |
| | | { |
| | | @Override |
| | | public Void run(ReadableStorage txn) throws Exception |
| | | public Void run(ReadableTransaction txn) throws Exception |
| | | { |
| | | for (EntryContainer exportContainer : exportContainers) |
| | | { |
| | |
| | | * @throws LDIFException If an error occurs while trying to determine |
| | | * whether to write an entry. |
| | | */ |
| | | private void exportContainer(ReadableStorage txn, EntryContainer entryContainer) |
| | | private void exportContainer(ReadableTransaction txn, EntryContainer entryContainer) |
| | | throws StorageRuntimeException, IOException, LDIFException |
| | | { |
| | | Cursor cursor = txn.openCursor(entryContainer.getID2Entry().getName()); |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.CompressedSchema; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | 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.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * @throws DirectoryException If a problem occurs while attempting to encode |
| | | * the entry. |
| | | */ |
| | | public void put(WriteableStorage txn, EntryID id, Entry entry) |
| | | public void put(WriteableTransaction txn, EntryID id, Entry entry) |
| | | throws StorageRuntimeException, DirectoryException |
| | | { |
| | | ByteString key = id.toByteString(); |
| | |
| | | * @return true if the entry was removed, false if it was not. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | boolean remove(WriteableStorage txn, EntryID id) throws StorageRuntimeException |
| | | boolean remove(WriteableTransaction txn, EntryID id) throws StorageRuntimeException |
| | | { |
| | | return txn.delete(getName(), id.toByteString()); |
| | | } |
| | |
| | | * @throws DirectoryException If a problem occurs while getting the entry. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | public Entry get(ReadableStorage txn, EntryID id) |
| | | public Entry get(ReadableTransaction txn, EntryID id) |
| | | throws DirectoryException, StorageRuntimeException |
| | | { |
| | | return get0(id, txn.read(getName(), id.toByteString())); |
| | |
| | | import org.opends.server.backends.RebuildConfig.RebuildMode; |
| | | import org.opends.server.backends.persistit.PersistItStorage; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.UpdateFunction; |
| | | 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.extensions.DiskSpaceMonitor; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | * @param backendCfg |
| | | * the backend configuration object |
| | | * @return true if the backend must be cleared, false otherwise |
| | | * @see Importer#getSuffix(WriteableStorage, EntryContainer) for per-suffix cleanups. |
| | | * @see Importer#getSuffix(WriteableTransaction, EntryContainer) for per-suffix cleanups. |
| | | */ |
| | | static boolean mustClearBackend(LDIFImportConfig importCfg, PluggableBackendCfg backendCfg) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void initializeSuffixes(WriteableStorage txn) throws StorageRuntimeException, |
| | | private void initializeSuffixes(WriteableTransaction txn) throws StorageRuntimeException, |
| | | ConfigException |
| | | { |
| | | for (EntryContainer ec : rootContainer.getEntryContainers()) |
| | |
| | | return System.identityHashCode(index); |
| | | } |
| | | |
| | | private Suffix getSuffix(WriteableStorage txn, EntryContainer entryContainer) |
| | | private Suffix getSuffix(WriteableTransaction txn, EntryContainer entryContainer) |
| | | throws ConfigException |
| | | { |
| | | DN baseDN = entryContainer.getBaseDN(); |
| | |
| | | return new Suffix(entryContainer, sourceEntryContainer, includeBranches, excludeBranches); |
| | | } |
| | | |
| | | private EntryContainer createEntryContainer(WriteableStorage txn, DN baseDN) throws ConfigException |
| | | private EntryContainer createEntryContainer(WriteableTransaction txn, DN baseDN) throws ConfigException |
| | | { |
| | | try |
| | | { |
| | |
| | | rootContainer.getStorage().write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | final long startTime = System.currentTimeMillis(); |
| | | rebuildManager.initialize(); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | rebuildManager.initialize(); |
| | | rebuildManager.printStartMessage(txn); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | rebuildManager.postRebuildIndexes(txn); |
| | | } |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | initializeSuffixes(txn); |
| | | setIndexesTrusted(txn, false); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | setIndexesTrusted(txn, true); |
| | | switchEntryContainers(txn); |
| | |
| | | dir.delete(); |
| | | } |
| | | |
| | | private void switchEntryContainers(WriteableStorage txn) throws StorageRuntimeException, InitializationException |
| | | private void switchEntryContainers(WriteableTransaction txn) throws StorageRuntimeException, InitializationException |
| | | { |
| | | for (Suffix suffix : dnSuffixMap.values()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void setIndexesTrusted(WriteableStorage txn, boolean trusted) throws StorageRuntimeException |
| | | private void setIndexesTrusted(WriteableTransaction txn, boolean trusted) throws StorageRuntimeException |
| | | { |
| | | try |
| | | { |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | execService.submit(new MigrateExistingTask(txn)).get(); |
| | | } |
| | |
| | | { |
| | | for (int i = 0; i < threadCount; i++) |
| | | { |
| | | tasks.add(new AppendReplaceTask(storage.getWriteableStorage())); |
| | | tasks.add(new AppendReplaceTask(storage.getWriteableTransaction())); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < threadCount; i++) |
| | | { |
| | | tasks.add(new ImportTask(storage.getWriteableStorage())); |
| | | tasks.add(new ImportTask(storage.getWriteableTransaction())); |
| | | } |
| | | } |
| | | getAll(execService.invokeAll(tasks)); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | execService.submit(new MigrateExcludedTask(txn)).get(); |
| | | } |
| | |
| | | { |
| | | // avoid threading issues by allocating one writeable storage per thread |
| | | // DB transactions are generally tied to a single thread |
| | | WriteableStorage txn = this.rootContainer.getStorage().getWriteableStorage(); |
| | | WriteableTransaction txn = this.rootContainer.getStorage().getWriteableTransaction(); |
| | | futures.add(dbService.submit(new IndexDBWriteTask(indexMgr, txn, permits, buffers, readAheadSize))); |
| | | } |
| | | } |
| | |
| | | /** Task used to migrate excluded branch. */ |
| | | private final class MigrateExcludedTask extends ImportTask |
| | | { |
| | | private MigrateExcludedTask(final WriteableStorage txn) |
| | | private MigrateExcludedTask(final WriteableTransaction txn) |
| | | { |
| | | super(txn); |
| | | } |
| | |
| | | /** Task to migrate existing entries. */ |
| | | private final class MigrateExistingTask extends ImportTask |
| | | { |
| | | private MigrateExistingTask(final WriteableStorage txn) |
| | | private MigrateExistingTask(final WriteableTransaction txn) |
| | | { |
| | | super(txn); |
| | | } |
| | |
| | | */ |
| | | private class AppendReplaceTask extends ImportTask |
| | | { |
| | | public AppendReplaceTask(final WriteableStorage txn) |
| | | public AppendReplaceTask(final WriteableTransaction txn) |
| | | { |
| | | super(txn); |
| | | } |
| | |
| | | */ |
| | | private class ImportTask implements Callable<Void> |
| | | { |
| | | WriteableStorage txn; |
| | | WriteableTransaction txn; |
| | | private final Map<IndexKey, IndexOutputBuffer> indexBufferMap = new HashMap<IndexKey, IndexOutputBuffer>(); |
| | | private final Set<ByteString> insertKeySet = new HashSet<ByteString>(); |
| | | private final EntryInformation entryInfo = new EntryInformation(); |
| | | private final IndexKey dnIndexKey = new IndexKey(dnType, ImportIndexType.DN, 1); |
| | | |
| | | public ImportTask(final WriteableStorage txn) |
| | | public ImportTask(final WriteableTransaction txn) |
| | | { |
| | | this.txn = txn; |
| | | } |
| | |
| | | private int nextBufferID; |
| | | private int ownedPermits; |
| | | private volatile boolean isRunning; |
| | | private final WriteableStorage txn; |
| | | private final WriteableTransaction txn; |
| | | |
| | | /** |
| | | * Creates a new index DB writer. |
| | |
| | | * @param cacheSize |
| | | * The buffer cache size. |
| | | */ |
| | | public IndexDBWriteTask(IndexManager indexMgr, WriteableStorage txn, Semaphore permits, int maxPermits, |
| | | public IndexDBWriteTask(IndexManager indexMgr, WriteableTransaction txn, Semaphore permits, int maxPermits, |
| | | int cacheSize) |
| | | { |
| | | this.indexMgr = indexMgr; |
| | |
| | | } |
| | | |
| | | /** Why do we still need this if we are checking parents in the first phase? */ |
| | | private boolean checkParent(ReadableStorage txn, ImportIDSet idSet) throws StorageRuntimeException |
| | | private boolean checkParent(ReadableTransaction txn, ImportIDSet idSet) throws StorageRuntimeException |
| | | { |
| | | entryID = new EntryID(idSet.valueToByteString()); |
| | | parentDN = getParent(idSet.getKey()); |
| | |
| | | return idSet; |
| | | } |
| | | |
| | | private EntryID getParentID(ReadableStorage txn, ByteSequence dn) throws StorageRuntimeException |
| | | private EntryID getParentID(ReadableTransaction txn, ByteSequence dn) throws StorageRuntimeException |
| | | { |
| | | // Bypass the cache for append data, lookup the parent DN in the DN2ID db |
| | | if (importConfiguration == null || !importConfiguration.appendToExistingData()) |
| | |
| | | return value != null ? new EntryID(value) : null; |
| | | } |
| | | |
| | | private void id2SubTree(ReadableStorage txn, EntryID childID) throws DirectoryException |
| | | private void id2SubTree(ReadableTransaction txn, EntryID childID) throws DirectoryException |
| | | { |
| | | if (parentID == null) |
| | | { |
| | |
| | | /** |
| | | * Print start message. |
| | | */ |
| | | void printStartMessage(WriteableStorage txn) throws StorageRuntimeException |
| | | void printStartMessage(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | this.txn = txn; |
| | | totalEntries = suffix.getID2Entry().getRecordCount(txn); |
| | |
| | | } |
| | | } |
| | | |
| | | private void clearDegradedState(WriteableStorage txn) |
| | | private void clearDegradedState(WriteableTransaction txn) |
| | | { |
| | | setIndexesListsToBeRebuilt(txn); |
| | | logger.info(NOTE_JEB_REBUILD_CLEARDEGRADEDSTATE_FINAL_STATUS, rebuildConfig.getRebuildList()); |
| | |
| | | } |
| | | |
| | | |
| | | private void preRebuildIndexes(WriteableStorage txn) |
| | | private void preRebuildIndexes(WriteableTransaction txn) |
| | | { |
| | | setIndexesListsToBeRebuilt(txn); |
| | | setRebuildListIndexesTrusted(txn, false); |
| | |
| | | } |
| | | } |
| | | |
| | | private void postRebuildIndexes(WriteableStorage txn) |
| | | private void postRebuildIndexes(WriteableTransaction txn) |
| | | { |
| | | setRebuildListIndexesTrusted(txn, true); |
| | | } |
| | | |
| | | @SuppressWarnings("fallthrough") |
| | | private void setIndexesListsToBeRebuilt(WriteableStorage txn) throws StorageRuntimeException |
| | | private void setIndexesListsToBeRebuilt(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | // Depends on rebuild mode, (re)building indexes' lists. |
| | | final RebuildMode mode = rebuildConfig.getRebuildMode(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void rebuildIndexMap(WriteableStorage txn, boolean onlyDegraded) |
| | | private void rebuildIndexMap(WriteableTransaction txn, boolean onlyDegraded) |
| | | { |
| | | // rebuildList contains the user-selected index(in USER_DEFINED mode). |
| | | final List<String> rebuildList = rebuildConfig.getRebuildList(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void rebuildAttributeIndexes(WriteableStorage txn, AttributeIndex attrIndex, AttributeType attrType, |
| | | private void rebuildAttributeIndexes(WriteableTransaction txn, AttributeIndex attrIndex, AttributeType attrType, |
| | | boolean onlyDegraded) throws StorageRuntimeException |
| | | { |
| | | fillIndexMap(txn, attrType, attrIndex.getSubstringIndex(), ImportIndexType.SUBSTRING, onlyDegraded); |
| | |
| | | } |
| | | } |
| | | |
| | | private void fillIndexMap(WriteableStorage txn, AttributeType attrType, Collection<Index> indexes, |
| | | private void fillIndexMap(WriteableTransaction txn, AttributeType attrType, Collection<Index> indexes, |
| | | ImportIndexType importIndexType, boolean onlyDegraded) |
| | | { |
| | | if (indexes != null && !indexes.isEmpty()) |
| | |
| | | } |
| | | } |
| | | |
| | | private void fillIndexMap(WriteableStorage txn, AttributeType attrType, Index index, |
| | | private void fillIndexMap(WriteableTransaction txn, AttributeType attrType, Index index, |
| | | ImportIndexType importIndexType, boolean onlyDegraded) |
| | | { |
| | | if (index != null |
| | |
| | | } |
| | | } |
| | | |
| | | private void clearIndexes(WriteableStorage txn, boolean onlyDegraded) throws StorageRuntimeException |
| | | private void clearIndexes(WriteableTransaction txn, boolean onlyDegraded) throws StorageRuntimeException |
| | | { |
| | | // Clears all the entry's container databases which are containing the indexes |
| | | if (!onlyDegraded) |
| | |
| | | } |
| | | } |
| | | |
| | | private void setRebuildListIndexesTrusted(WriteableStorage txn, boolean trusted) throws StorageRuntimeException |
| | | private void setRebuildListIndexesTrusted(WriteableTransaction txn, boolean trusted) throws StorageRuntimeException |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void setTrusted(WriteableStorage txn, final Collection<Index> indexes, boolean trusted) |
| | | private void setTrusted(WriteableTransaction txn, final Collection<Index> indexes, boolean trusted) |
| | | { |
| | | if (indexes != null && !indexes.isEmpty()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** @see Importer#importPhaseOne(WriteableStorage) */ |
| | | /** @see Importer#importPhaseOne(WriteableTransaction) */ |
| | | private void rebuildIndexesPhaseOne() throws StorageRuntimeException, InterruptedException, |
| | | ExecutionException |
| | | { |
| | |
| | | private static final String DB_NAME = "dn_cache"; |
| | | private final TreeName dnCache = new TreeName("", DB_NAME); |
| | | private final Storage storage; |
| | | private final WriteableStorage txn; |
| | | private final WriteableTransaction txn; |
| | | |
| | | /** |
| | | * Create a temporary DB environment and database to be used as a cache of |
| | |
| | | storage = new PersistItStorage(newPersistitBackendCfgProxy(returnValues), |
| | | DirectoryServer.getInstance().getServerContext()); |
| | | storage.open(); |
| | | txn = storage.getWriteableStorage(); |
| | | txn = storage.getWriteableTransaction(); |
| | | txn.openTree(dnCache); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import org.forgerock.opendj.ldap.spi.IndexingOptions; |
| | | import org.opends.server.backends.pluggable.IndexBuffer.BufferedIndexValues; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.UpdateFunction; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | Index(TreeName name, Indexer indexer, State state, int indexEntryLimit, int cursorEntryLimit, boolean maintainCount, |
| | | WriteableStorage txn, EntryContainer entryContainer) throws StorageRuntimeException |
| | | WriteableTransaction txn, EntryContainer entryContainer) throws StorageRuntimeException |
| | | { |
| | | super(name); |
| | | this.indexer = indexer; |
| | |
| | | * @param importIdSet The import ID set to delete. |
| | | * @throws StorageRuntimeException If a database error occurs. |
| | | */ |
| | | final void delete(WriteableStorage txn, ImportIDSet importIdSet) throws StorageRuntimeException |
| | | final void delete(WriteableTransaction txn, ImportIDSet importIdSet) throws StorageRuntimeException |
| | | { |
| | | ByteSequence key = importIdSet.getKey(); |
| | | ByteString value = txn.read(getName(), key); |
| | |
| | | * @param importIdSet The set of import IDs. |
| | | * @throws StorageRuntimeException If a database error occurs. |
| | | */ |
| | | final void insert(WriteableStorage txn, ImportIDSet importIdSet) throws StorageRuntimeException |
| | | final void insert(WriteableTransaction txn, ImportIDSet importIdSet) throws StorageRuntimeException |
| | | { |
| | | ByteSequence key = importIdSet.getKey(); |
| | | ByteString value = txn.read(getName(), key); |
| | |
| | | txn.put(getName(), key, value); |
| | | } |
| | | |
| | | void updateKey(WriteableStorage txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs) |
| | | void updateKey(WriteableTransaction txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs) |
| | | throws StorageRuntimeException |
| | | { |
| | | /* |
| | |
| | | return entryIDSet != null && entryIDSet.size() > 0; |
| | | } |
| | | |
| | | private void updateKeyWithRMW(final WriteableStorage txn, final ByteString key, final EntryIDSet deletedIDs, |
| | | private void updateKeyWithRMW(final WriteableTransaction txn, final ByteString key, final EntryIDSet deletedIDs, |
| | | final EntryIDSet addedIDs) throws StorageRuntimeException |
| | | { |
| | | txn.update(getName(), key, new UpdateFunction() |
| | |
| | | getBufferedIndexValues(buffer, keyBytes).deleteEntryID(keyBytes, entryID); |
| | | } |
| | | |
| | | private void logIndexCorruptError(WriteableStorage txn, ByteString key) |
| | | private void logIndexCorruptError(WriteableTransaction txn, ByteString key) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | * @throws StorageRuntimeException |
| | | * If an error occurs in the JE database. |
| | | */ |
| | | ConditionResult containsID(ReadableStorage txn, ByteString key, EntryID entryID) |
| | | ConditionResult containsID(ReadableTransaction txn, ByteString key, EntryID entryID) |
| | | throws StorageRuntimeException |
| | | { |
| | | ByteString value = txn.read(getName(), key); |
| | |
| | | * @param key The key to read |
| | | * @return The non null set of entry IDs. |
| | | */ |
| | | EntryIDSet read(ReadableStorage txn, ByteSequence key) |
| | | EntryIDSet read(ReadableTransaction txn, ByteSequence key) |
| | | { |
| | | try |
| | | { |
| | |
| | | * specified. |
| | | * @return The non null set of entry IDs. |
| | | */ |
| | | EntryIDSet readRange(ReadableStorage txn, |
| | | EntryIDSet readRange(ReadableTransaction txn, |
| | | ByteSequence lower, ByteSequence upper, boolean lowerIncluded, boolean upperIncluded) |
| | | { |
| | | // If this index is not trusted, then just return an undefined id set. |
| | |
| | | return indexEntryLimit; |
| | | } |
| | | |
| | | synchronized void setTrusted(WriteableStorage txn, boolean trusted) throws StorageRuntimeException |
| | | synchronized void setTrusted(WriteableTransaction txn, boolean trusted) throws StorageRuntimeException |
| | | { |
| | | this.trusted = trusted; |
| | | state.putIndexTrustState(txn, this, trusted); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | void flush(WriteableStorage txn) throws StorageRuntimeException, DirectoryException |
| | | void flush(WriteableTransaction txn) throws StorageRuntimeException, DirectoryException |
| | | { |
| | | /* |
| | | * FIXME: this seems like a surprising way to update the indexes. Why not |
| | |
| | | } |
| | | } |
| | | |
| | | private void updateKeys(Index index, WriteableStorage txn, |
| | | private void updateKeys(Index index, WriteableTransaction txn, |
| | | Map<ByteString, BufferedIndexValues> bufferedValues) |
| | | { |
| | | if (bufferedValues != null) |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.backends.pluggable.AttributeIndex.IndexFilterType; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.FilterType; |
| | |
| | | |
| | | /** The entry container holding the attribute indexes. */ |
| | | private final EntryContainer entryContainer; |
| | | private final ReadableStorage txn; |
| | | private final ReadableTransaction txn; |
| | | |
| | | /** |
| | | * The search operation provides the search base, scope and filter. |
| | |
| | | * which will help determine how the indexes contributed |
| | | * to this search. |
| | | */ |
| | | IndexFilter(EntryContainer entryContainer, ReadableStorage txn, SearchOperation searchOp, |
| | | IndexFilter(EntryContainer entryContainer, ReadableTransaction txn, SearchOperation searchOp, |
| | | StringBuilder debugBuilder, DatabaseEnvironmentMonitor monitor) |
| | | { |
| | | this.entryContainer = entryContainer; |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.spi.IndexQueryFactory; |
| | | import org.forgerock.opendj.ldap.spi.IndexingOptions; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | |
| | | /** |
| | | * This class is an implementation of IndexQueryFactory which creates |
| | |
| | | |
| | | private static final String PRESENCE_INDEX_KEY = "presence"; |
| | | |
| | | private final ReadableStorage txn; |
| | | private final ReadableTransaction txn; |
| | | /** The Map containing the string type identifier and the corresponding index. */ |
| | | private final AttributeIndex attributeIndex; |
| | | |
| | |
| | | * @param attributeIndex |
| | | * The targeted attribute index |
| | | */ |
| | | IndexQueryFactoryImpl(ReadableStorage txn, AttributeIndex attributeIndex) |
| | | IndexQueryFactoryImpl(ReadableTransaction txn, AttributeIndex attributeIndex) |
| | | { |
| | | this.txn = txn; |
| | | this.attributeIndex = attributeIndex; |
| | |
| | | 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.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | * If an error occurs while loading and processing the compressed |
| | | * schema definitions. |
| | | */ |
| | | JECompressedSchema(final Storage storage, WriteableStorage txn) |
| | | JECompressedSchema(final Storage storage, WriteableTransaction txn) |
| | | throws StorageRuntimeException, InitializationException |
| | | { |
| | | this.storage = storage; |
| | |
| | | * @throws InitializationException |
| | | * If an error occurs while loading and processing the definitions. |
| | | */ |
| | | private void load(WriteableStorage txn) throws StorageRuntimeException, InitializationException |
| | | private void load(WriteableTransaction txn) throws StorageRuntimeException, InitializationException |
| | | { |
| | | txn.openTree(adTreeName); |
| | | txn.openTree(ocTreeName); |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | txn.put(treeName, keyEntry, value); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.spi.IndexingOptions; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | |
| | |
| | | final class NullIndex extends Index |
| | | { |
| | | |
| | | NullIndex(TreeName name, Indexer indexer, State state, WriteableStorage txn, |
| | | NullIndex(TreeName name, Indexer indexer, State state, WriteableTransaction txn, |
| | | EntryContainer entryContainer) throws StorageRuntimeException |
| | | { |
| | | super(name, indexer, state, 0, 0, false, txn, entryContainer); |
| | |
| | | } |
| | | |
| | | @Override |
| | | void updateKey(WriteableStorage txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs) |
| | | void updateKey(WriteableTransaction txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs) |
| | | throws StorageRuntimeException |
| | | { |
| | | // Do nothing. |
| | |
| | | } |
| | | |
| | | @Override |
| | | ConditionResult containsID(ReadableStorage txn, ByteString key, EntryID entryID) |
| | | ConditionResult containsID(ReadableTransaction txn, ByteString key, EntryID entryID) |
| | | throws StorageRuntimeException |
| | | { |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | @Override |
| | | EntryIDSet read(ReadableStorage txn, ByteSequence key) |
| | | EntryIDSet read(ReadableTransaction txn, ByteSequence key) |
| | | { |
| | | return newUndefinedSet(); |
| | | } |
| | | |
| | | @Override |
| | | EntryIDSet readRange(ReadableStorage txn, ByteSequence lower, ByteSequence upper, boolean lowerIncluded, |
| | | EntryIDSet readRange(ReadableTransaction txn, ByteSequence lower, ByteSequence upper, boolean lowerIncluded, |
| | | boolean upperIncluded) |
| | | { |
| | | return newUndefinedSet(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | void setTrusted(WriteableStorage txn, boolean trusted) throws StorageRuntimeException |
| | | void setTrusted(WriteableTransaction txn, boolean trusted) throws StorageRuntimeException |
| | | { |
| | | // Do nothing. |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | void open(WriteableStorage txn) throws StorageRuntimeException |
| | | void open(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | // Do nothing. |
| | | } |
| | | |
| | | @Override |
| | | long getRecordCount(ReadableStorage txn) throws StorageRuntimeException |
| | | long getRecordCount(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | void delete(WriteableStorage txn) throws StorageRuntimeException |
| | | void delete(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | // Do nothing. |
| | | } |
| | |
| | | import org.opends.server.admin.std.server.PluggableBackendCfg; |
| | | import org.opends.server.api.CompressedSchema; |
| | | import org.opends.server.backends.pluggable.spi.ReadOperation; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.StorageStatus; |
| | | 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.core.SearchOperation; |
| | | import org.opends.server.types.DN; |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | compressedSchema = new JECompressedSchema(storage, txn); |
| | | openAndRegisterEntryContainers(txn, config.getBaseDN()); |
| | |
| | | * @throws ConfigException |
| | | * If an configuration error occurs while opening the entry container. |
| | | */ |
| | | EntryContainer openEntryContainer(DN baseDN, WriteableStorage txn) |
| | | EntryContainer openEntryContainer(DN baseDN, WriteableTransaction txn) |
| | | throws StorageRuntimeException, ConfigException |
| | | { |
| | | EntryContainer ec = new EntryContainer(baseDN, backend, config, storage, this); |
| | |
| | | * If a configuration error occurs while opening the entry |
| | | * container. |
| | | */ |
| | | private void openAndRegisterEntryContainers(WriteableStorage txn, Set<DN> baseDNs) throws StorageRuntimeException, |
| | | private void openAndRegisterEntryContainers(WriteableTransaction txn, Set<DN> baseDNs) throws StorageRuntimeException, |
| | | InitializationException, ConfigException |
| | | { |
| | | EntryID highestID = null; |
| | |
| | | return storage.read(new ReadOperation<Long>() |
| | | { |
| | | @Override |
| | | public Long run(ReadableStorage txn) throws Exception |
| | | public Long run(ReadableTransaction txn) throws Exception |
| | | { |
| | | long entryCount = 0; |
| | | for (EntryContainer ec : entryContainers.values()) |
| | |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | /** |
| | |
| | | * @return true if the entry was removed, false if it was not. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | boolean removeIndexTrustState(WriteableStorage txn, DatabaseContainer index) throws StorageRuntimeException |
| | | boolean removeIndexTrustState(WriteableTransaction txn, DatabaseContainer index) throws StorageRuntimeException |
| | | { |
| | | ByteString key = keyForIndex(index); |
| | | return txn.delete(getName(), key); |
| | |
| | | * @return The trusted state of the index in the database. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | boolean getIndexTrustState(ReadableStorage txn, DatabaseContainer index) |
| | | boolean getIndexTrustState(ReadableTransaction txn, DatabaseContainer index) |
| | | throws StorageRuntimeException |
| | | { |
| | | ByteString key = keyForIndex(index); |
| | |
| | | * @param trusted The state value to put into the database. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | void putIndexTrustState(WriteableStorage txn, DatabaseContainer index, boolean trusted) |
| | | void putIndexTrustState(WriteableTransaction txn, DatabaseContainer index, boolean trusted) |
| | | throws StorageRuntimeException |
| | | { |
| | | ByteString key = keyForIndex(index); |
| | |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.backends.pluggable.Importer.DNCache; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | |
| | | * @throws InterruptedException If an error occurred processing the pending |
| | | * map. |
| | | */ |
| | | public boolean isParentProcessed(ReadableStorage txn, DN dn, DNCache dnCache, boolean clearedBackend) |
| | | public boolean isParentProcessed(ReadableTransaction txn, DN dn, DNCache dnCache, boolean clearedBackend) |
| | | throws StorageRuntimeException, InterruptedException { |
| | | synchronized(synchObject) { |
| | | if(parentSet.contains(dn)) |
| | |
| | | * @param trusted True if the indexes should be trusted or false otherwise. |
| | | * @throws StorageRuntimeException If an error occurred setting the indexes to trusted. |
| | | */ |
| | | public void setIndexesTrusted(WriteableStorage txn, boolean trusted) throws StorageRuntimeException |
| | | public void setIndexesTrusted(WriteableTransaction txn, boolean trusted) throws StorageRuntimeException |
| | | { |
| | | entryContainer.getID2Children().setTrusted(txn, trusted); |
| | | entryContainer.getID2Subtree().setTrusted(txn, trusted); |
| | |
| | | } |
| | | } |
| | | |
| | | private void setTrusted(WriteableStorage txn, Index index, boolean trusted) |
| | | private void setTrusted(WriteableTransaction txn, Index index, boolean trusted) |
| | | { |
| | | if (index != null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void setTrusted(WriteableStorage txn, Collection<Index> indexes, boolean trusted) |
| | | private void setTrusted(WriteableTransaction txn, Collection<Index> indexes, boolean trusted) |
| | | { |
| | | if (indexes != null) |
| | | { |
| | |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.Importer; |
| | | import org.opends.server.backends.pluggable.spi.ReadOperation; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.backends.pluggable.spi.StorageStatus; |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.UpdateFunction; |
| | | import org.opends.server.backends.pluggable.spi.WriteOperation; |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | |
| | | /** |
| | | * Decorates a {@link Storage} with additional trace logging. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Decorates an {@link ReadableStorage} with additional trace logging. |
| | | * Decorates an {@link ReadableTransaction} with additional trace logging. |
| | | */ |
| | | private final class TracedReadableStorage implements ReadableStorage |
| | | private final class TracedReadableStorage implements ReadableTransaction |
| | | { |
| | | private final ReadableStorage txn; |
| | | private final ReadableTransaction txn; |
| | | |
| | | private TracedReadableStorage(final ReadableStorage txn) |
| | | private TracedReadableStorage(final ReadableTransaction txn) |
| | | { |
| | | this.txn = txn; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Decorates an {@link WriteableStorage} with additional trace logging. |
| | | * Decorates an {@link WriteableTransaction} with additional trace logging. |
| | | */ |
| | | private final class TracedWriteableStorage implements WriteableStorage |
| | | private final class TracedWriteableStorage implements WriteableTransaction |
| | | { |
| | | private final WriteableStorage txn; |
| | | private final WriteableTransaction txn; |
| | | |
| | | private TracedWriteableStorage(final WriteableStorage txn) |
| | | private TracedWriteableStorage(final WriteableTransaction txn) |
| | | { |
| | | this.txn = txn; |
| | | } |
| | |
| | | op = new ReadOperation<T>() |
| | | { |
| | | @Override |
| | | public T run(final ReadableStorage txn) throws Exception |
| | | public T run(final ReadableTransaction txn) throws Exception |
| | | { |
| | | return readOperation.run(new TracedReadableStorage(txn)); |
| | | } |
| | |
| | | op = new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(final WriteableStorage txn) throws Exception |
| | | public void run(final WriteableTransaction txn) throws Exception |
| | | { |
| | | writeOperation.run(new TracedWriteableStorage(txn)); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public WriteableStorage getWriteableStorage() |
| | | public WriteableTransaction getWriteableTransaction() |
| | | { |
| | | final WriteableStorage writeableStorage = storage.getWriteableStorage(); |
| | | final WriteableTransaction writeableStorage = storage.getWriteableTransaction(); |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | return new TracedWriteableStorage(writeableStorage); |
| | |
| | | import org.opends.server.admin.std.meta.BackendVLVIndexCfgDefn.Scope; |
| | | import org.opends.server.admin.std.server.BackendVLVIndexCfg; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | | 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.controls.ServerSideSortRequestControl; |
| | | import org.opends.server.controls.VLVRequestControl; |
| | | import org.opends.server.controls.VLVResponseControl; |
| | |
| | | * @throws ConfigException if a error occurs while reading the VLV index |
| | | * configuration |
| | | */ |
| | | VLVIndex(BackendVLVIndexCfg config, State state, Storage storage, EntryContainer entryContainer, WriteableStorage txn) |
| | | throws StorageRuntimeException, ConfigException |
| | | VLVIndex(BackendVLVIndexCfg config, State state, Storage storage, EntryContainer entryContainer, |
| | | WriteableTransaction txn) throws StorageRuntimeException, ConfigException |
| | | { |
| | | super(new TreeName(entryContainer.getDatabasePrefix(), "vlv." + config.getName())); |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | void open(WriteableStorage txn) throws StorageRuntimeException |
| | | void open(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | super.open(txn); |
| | | |
| | |
| | | * JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | private SortValuesSet getSortValuesSet(ReadableStorage txn, long entryID, |
| | | private SortValuesSet getSortValuesSet(ReadableTransaction txn, long entryID, |
| | | ByteString[] values, AttributeType[] types) throws StorageRuntimeException, |
| | | DirectoryException |
| | | { |
| | |
| | | * JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | private boolean containsValues(ReadableStorage txn, long entryID, ByteString[] values, AttributeType[] types) |
| | | private boolean containsValues(ReadableTransaction txn, long entryID, ByteString[] values, AttributeType[] types) |
| | | throws StorageRuntimeException, DirectoryException |
| | | { |
| | | SortValuesSet valuesSet = getSortValuesSet(txn, entryID, values, types); |
| | |
| | | * @throws DirectoryException If a Directory Server |
| | | * error occurs. |
| | | */ |
| | | void updateIndex(WriteableStorage txn, TreeSet<SortValues> addedValues, TreeSet<SortValues> deletedValues) |
| | | void updateIndex(WriteableTransaction txn, TreeSet<SortValues> addedValues, TreeSet<SortValues> deletedValues) |
| | | throws DirectoryException, StorageRuntimeException |
| | | { |
| | | // Handle cases where nothing is changed early to avoid |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | EntryIDSet evaluate(ReadableStorage txn, |
| | | EntryIDSet evaluate(ReadableTransaction txn, |
| | | SearchOperation searchOperation, |
| | | ServerSideSortRequestControl sortControl, |
| | | VLVRequestControl vlvRequest, |
| | |
| | | * otherwise. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | synchronized void setTrusted(WriteableStorage txn, boolean trusted) |
| | | synchronized void setTrusted(WriteableTransaction txn, boolean trusted) |
| | | throws StorageRuntimeException |
| | | { |
| | | this.trusted = trusted; |
| | |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | applyConfigurationChange0(txn, cfg, ccr); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private synchronized void applyConfigurationChange0(WriteableStorage txn, BackendVLVIndexCfg cfg, |
| | | private synchronized void applyConfigurationChange0(WriteableTransaction txn, BackendVLVIndexCfg cfg, |
| | | ConfigChangeResult ccr) |
| | | { |
| | | // Update base DN only if changed.. |
| | |
| | | return sortOrder; |
| | | } |
| | | |
| | | boolean verifyEntry(ReadableStorage txn, EntryID entryID, Entry entry) throws DirectoryException |
| | | boolean verifyEntry(ReadableTransaction txn, EntryID entryID, Entry entry) throws DirectoryException |
| | | { |
| | | return shouldInclude(entry) && !containsValues(txn, entryID.longValue(), getSortValues(entry), getSortTypes()); |
| | | } |
| | |
| | | import org.opends.server.backends.VerifyConfig; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadOperation; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | return rootContainer.getStorage().read(new ReadOperation<Long>() |
| | | { |
| | | @Override |
| | | public Long run(ReadableStorage txn) throws Exception |
| | | public Long run(ReadableTransaction txn) throws Exception |
| | | { |
| | | return verifyBackend0(txn, rootContainer); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private long verifyBackend0(ReadableStorage txn, RootContainer rootContainer) |
| | | private long verifyBackend0(ReadableTransaction txn, RootContainer rootContainer) |
| | | throws StorageRuntimeException, DirectoryException |
| | | { |
| | | this.rootContainer = rootContainer; |
| | |
| | | * |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void iterateID2Entry(ReadableStorage txn) throws StorageRuntimeException |
| | | private void iterateID2Entry(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | Cursor cursor = txn.openCursor(id2entry.getName()); |
| | | try |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | * @throws DirectoryException If an error occurs reading values in the index. |
| | | */ |
| | | private void iterateIndex(ReadableStorage txn) throws StorageRuntimeException, DirectoryException |
| | | private void iterateIndex(ReadableTransaction txn) throws StorageRuntimeException, DirectoryException |
| | | { |
| | | if (verifyDN2ID) |
| | | { |
| | |
| | | * |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void iterateDN2ID(ReadableStorage txn) throws StorageRuntimeException |
| | | private void iterateDN2ID(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | Cursor cursor = txn.openCursor(dn2id.getName()); |
| | | try |
| | |
| | | * |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void iterateID2Children(ReadableStorage txn) throws StorageRuntimeException |
| | | private void iterateID2Children(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | Cursor cursor = txn.openCursor(id2c.getName()); |
| | | try |
| | |
| | | * |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void iterateID2Subtree(ReadableStorage txn) throws StorageRuntimeException |
| | | private void iterateID2Subtree(ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | Cursor cursor = txn.openCursor(id2s.getName()); |
| | | try |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | * @throws DirectoryException If an error occurs reading values in the index. |
| | | */ |
| | | private void iterateVLVIndex(ReadableStorage txn, VLVIndex vlvIndex, boolean verifyID) |
| | | private void iterateVLVIndex(ReadableTransaction txn, VLVIndex vlvIndex, boolean verifyID) |
| | | throws StorageRuntimeException, DirectoryException |
| | | { |
| | | if(vlvIndex == null) |
| | |
| | | * @param index The index database to be checked. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | private void iterateAttrIndex(ReadableStorage txn, Index index, IndexingOptions options) |
| | | private void iterateAttrIndex(ReadableTransaction txn, Index index, IndexingOptions options) |
| | | throws StorageRuntimeException |
| | | { |
| | | if (index == null) |
| | |
| | | * @param entryID The entry ID. |
| | | * @param entry The entry to be checked. |
| | | */ |
| | | private void verifyEntry(ReadableStorage txn, EntryID entryID, Entry entry) |
| | | private void verifyEntry(ReadableTransaction txn, EntryID entryID, Entry entry) |
| | | { |
| | | if (verifyDN2ID) |
| | | { |
| | |
| | | * @param entryID The entry ID. |
| | | * @param entry The entry to be checked. |
| | | */ |
| | | private void verifyDN2ID(ReadableStorage txn, EntryID entryID, Entry entry) |
| | | private void verifyDN2ID(ReadableTransaction txn, EntryID entryID, Entry entry) |
| | | { |
| | | DN dn = entry.getName(); |
| | | |
| | |
| | | * @param entryID The entry ID. |
| | | * @param entry The entry to be checked. |
| | | */ |
| | | private void verifyID2Children(ReadableStorage txn, EntryID entryID, Entry entry) |
| | | private void verifyID2Children(ReadableTransaction txn, EntryID entryID, Entry entry) |
| | | { |
| | | DN dn = entry.getName(); |
| | | |
| | |
| | | * @param entryID The entry ID. |
| | | * @param entry The entry to be checked. |
| | | */ |
| | | private void verifyID2Subtree(ReadableStorage txn, EntryID entryID, Entry entry) |
| | | private void verifyID2Subtree(ReadableTransaction txn, EntryID entryID, Entry entry) |
| | | { |
| | | for (DN dn = getParent(entry.getName()); dn != null; dn = getParent(dn)) |
| | | { |
| | |
| | | * @param entryID The entry ID. |
| | | * @param entry The entry to be checked. |
| | | */ |
| | | private void verifyIndex(ReadableStorage txn, EntryID entryID, Entry entry) |
| | | private void verifyIndex(ReadableTransaction txn, EntryID entryID, Entry entry) |
| | | { |
| | | for (AttributeIndex attrIndex : attrIndexList) |
| | | { |
| | |
| | | * @param attrList The attribute to be checked. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | private void verifyAttribute(ReadableStorage txn, AttributeIndex attrIndex, EntryID entryID, List<Attribute> attrList) |
| | | throws DirectoryException |
| | | private void verifyAttribute(ReadableTransaction txn, AttributeIndex attrIndex, EntryID entryID, |
| | | List<Attribute> attrList) throws DirectoryException |
| | | { |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void verifyAttributeInIndex(Index index, ReadableStorage txn, |
| | | private void verifyAttributeInIndex(Index index, ReadableTransaction txn, |
| | | ByteString key, EntryID entryID) |
| | | { |
| | | try |
| | |
| | | * @throws StorageRuntimeException An error occurred while accessing the JE |
| | | * database. |
| | | */ |
| | | private ProgressTask(boolean indexIterator, ReadableStorage txn) throws StorageRuntimeException |
| | | private ProgressTask(boolean indexIterator, ReadableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | previousTime = System.currentTimeMillis(); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private long getRecordCount(ReadableStorage txn, Index index) |
| | | private long getRecordCount(ReadableTransaction txn, Index index) |
| | | { |
| | | if (index != null) |
| | | { |
| | |
| | | * @throws Exception |
| | | * if a problem occurs with the underlying storage engine |
| | | */ |
| | | T run(ReadableStorage txn) throws Exception; |
| | | T run(ReadableTransaction txn) throws Exception; |
| | | } |
| File was renamed from opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/ReadableStorage.java |
| | |
| | | /** |
| | | * Represents a readable transaction on a storage engine. |
| | | */ |
| | | public interface ReadableStorage extends Closeable |
| | | public interface ReadableTransaction extends Closeable |
| | | { |
| | | /** |
| | | * Reads the record's value associated to the provided key, in the tree whose name is provided. |
| | |
| | | void write(WriteOperation writeOperation) throws Exception; |
| | | |
| | | /** |
| | | * Returns a new writeable storage. |
| | | * Returns a new writeable transaction. |
| | | * |
| | | * @return a new writeable storage |
| | | * @return a new writeable transaction |
| | | */ |
| | | WriteableStorage getWriteableStorage(); |
| | | WriteableTransaction getWriteableTransaction(); |
| | | |
| | | /** |
| | | * Remove all files for a backend of this storage. |
| | |
| | | * @throws Exception |
| | | * if a problem occurs with the underlying storage engine |
| | | */ |
| | | void run(WriteableStorage txn) throws Exception; |
| | | void run(WriteableTransaction txn) throws Exception; |
| | | } |
| File was renamed from opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/WriteableStorage.java |
| | |
| | | /** |
| | | * Represents a writeable transaction on a storage engine. |
| | | */ |
| | | public interface WriteableStorage extends ReadableStorage |
| | | public interface WriteableTransaction extends ReadableTransaction |
| | | { |
| | | /** |
| | | * Opens the tree identified by the provided name. The tree is created if it does not already exist. |