opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -30,9 +30,11 @@ import static org.opends.server.backends.pluggable.DnKeyFormat.*; import static org.opends.server.util.ServerConstants.*; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import org.forgerock.i18n.slf4j.LocalizedLogger; @@ -43,7 +45,6 @@ import org.forgerock.opendj.ldap.ConditionResult; import org.forgerock.opendj.ldap.ResultCode; 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.ReadableTransaction; import org.opends.server.backends.pluggable.spi.StorageRuntimeException; @@ -74,7 +75,6 @@ * as in dn2id so that all referrals in a subtree can be retrieved by cursoring * through a range of the records. */ @SuppressWarnings("javadoc") class DN2URI extends AbstractTree { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); @@ -135,31 +135,57 @@ } /** Decodes the value as a pair where the first element is the DN key and the second is the actual value. */ private Pair<DN, List<String>> decode(ByteSequence bs) throws StorageRuntimeException private Map.Entry<DN, List<String>> decode(ByteSequence bs) throws StorageRuntimeException { return decode0(bs, true); } private Collection<String> decodeUrisOnly(ByteSequence oldValue) { return decode0(oldValue, false).getValue(); } private Map.Entry<DN, List<String>> decode0(ByteSequence bs, boolean decodeDN) { if (!bs.isEmpty()) { ByteSequenceReader r = bs.asReader(); final int dnLength = r.getInt(); DN dn = null; DN dn = decodeDN(r, decodeDN); List<String> uris = decodeUris(r); return new SimpleImmutableEntry<>(dn, uris); } return new SimpleImmutableEntry<>(null, null); } private DN decodeDN(ByteSequenceReader r, boolean decodeDN) { final int dnLength = r.getInt(); if (decodeDN) { try { dn = DN.valueOf(r.getString(dnLength)); return DN.valueOf(r.getString(dnLength)); } catch (DirectoryException e) { throw new StorageRuntimeException("Unable to decode DN from binary value", e); } final int nbElems = r.getInt(); List<String> results = new ArrayList<>(nbElems); for (int i = 0; i < nbElems; i++) { final int stringLength = r.getInt(); results.add(r.getString(stringLength)); } return Pair.of(dn, results); } return Pair.empty(); r.skip(dnLength); return null; } private List<String> decodeUris(ByteSequenceReader r) { final int nbElems = r.getInt(); List<String> results = new ArrayList<>(nbElems); for (int i = 0; i < nbElems; i++) { final int stringLength = r.getInt(); results.add(r.getString(stringLength)); } return results; } /** @@ -181,8 +207,7 @@ { if (oldValue != null) { final Pair<DN, List<String>> dnAndUris = decode(oldValue); final Collection<String> newUris = dnAndUris.getSecond(); final Collection<String> newUris = decodeUrisOnly(oldValue); if (newUris.addAll(labeledURIs)) { return encode(dn, newUris); @@ -237,8 +262,7 @@ { if (oldValue != null) { final Pair<DN, List<String>> dnAndUris = decode(oldValue); final Collection<String> oldUris = dnAndUris.getSecond(); final Collection<String> oldUris = decodeUrisOnly(oldValue); if (oldUris.removeAll(labeledURIs)) { return encode(dn, oldUris); @@ -524,8 +548,7 @@ if (cursor.positionToKey(toKey(dn))) { // Construct a set of all the labeled URIs in the referral. final Pair<DN, List<String>> dnAndUris = decode(cursor.getValue()); Collection<String> labeledURIs = dnAndUris.getSecond(); Collection<String> labeledURIs = decodeUrisOnly(cursor.getValue()); throwReferralException(targetDN, dn, labeledURIs, searchScope); } } @@ -589,9 +612,9 @@ } // Construct a list of all the URIs in the referral. final Pair<DN, List<String>> dnAndUris = decode(cursor.getValue()); final DN dn = dnAndUris.getFirst(); final Collection<String> labeledURIs = dnAndUris.getSecond(); final Map.Entry<DN, List<String>> dnAndUris = decode(cursor.getValue()); final DN dn = dnAndUris.getKey(); final Collection<String> labeledURIs = dnAndUris.getValue(); SearchResultReference reference = toSearchResultReference(dn, labeledURIs, searchOp.getScope()); if (!searchOp.returnReference(dn, reference)) { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -189,7 +189,6 @@ ConfigurationAddListener<BackendIndexCfg>, ConfigurationDeleteListener<BackendIndexCfg> { /** {@inheritDoc} */ @Override public boolean isConfigurationAddAcceptable(final BackendIndexCfg cfg, List<LocalizableMessage> unacceptableReasons) { @@ -205,7 +204,6 @@ } } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationAdd(final BackendIndexCfg cfg) { @@ -236,7 +234,6 @@ return ccr; } /** {@inheritDoc} */ @Override public boolean isConfigurationDeleteAcceptable( BackendIndexCfg cfg, List<LocalizableMessage> unacceptableReasons) @@ -245,7 +242,6 @@ return true; } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationDelete(final BackendIndexCfg cfg) { @@ -285,7 +281,6 @@ ConfigurationAddListener<BackendVLVIndexCfg>, ConfigurationDeleteListener<BackendVLVIndexCfg> { /** {@inheritDoc} */ @Override public boolean isConfigurationAddAcceptable( BackendVLVIndexCfg cfg, List<LocalizableMessage> unacceptableReasons) @@ -341,7 +336,6 @@ return true; } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationAdd(final BackendVLVIndexCfg cfg) { @@ -372,7 +366,6 @@ return ccr; } /** {@inheritDoc} */ @Override public boolean isConfigurationDeleteAcceptable(BackendVLVIndexCfg cfg, List<LocalizableMessage> unacceptableReasons) { @@ -380,7 +373,6 @@ return true; } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationDelete(final BackendVLVIndexCfg cfg) { @@ -605,7 +597,7 @@ } /** * Look for an VLV index for the given index name. * Look for a VLV index for the given index name. * * @param vlvIndexName The vlv index name for which an vlv index is needed. * @return The VLV index or null if there is none with that name. @@ -2539,8 +2531,7 @@ @Override public Long run(ReadableTransaction txn) throws Exception { final int baseDnIfExists = dn2id.get(txn, baseDN) != null ? 1 : 0; return id2childrenCount.getTotalCount(txn) + baseDnIfExists; return getNumberOfEntriesInBaseDN0(txn); } }); } @@ -2550,6 +2541,12 @@ } } long getNumberOfEntriesInBaseDN0(ReadableTransaction txn) { final int baseDnIfExists = dn2id.get(txn, baseDN) != null ? 1 : 0; return id2childrenCount.getTotalCount(txn) + baseDnIfExists; } /** * Determine whether the provided operation has the ManageDsaIT request * control. @@ -2680,7 +2677,6 @@ } } /** {@inheritDoc} */ @Override public DN getBaseDN() { @@ -2702,7 +2698,6 @@ return dn.parent(); } /** {@inheritDoc} */ @Override public boolean isConfigurationChangeAcceptable( PluggableBackendCfg cfg, List<LocalizableMessage> unacceptableReasons) @@ -2712,7 +2707,6 @@ return true; } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationChange(final PluggableBackendCfg cfg) { @@ -3127,10 +3121,8 @@ exclusiveLock.unlock(); } /** {@inheritDoc} */ @Override public String toString() { return treePrefix; } } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
@@ -409,7 +409,7 @@ ec.sharedLock.lock(); try { entryCount += ec.getNumberOfEntriesInBaseDN(); entryCount += ec.getNumberOfEntriesInBaseDN0(txn); } finally { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java
@@ -28,6 +28,7 @@ import static org.opends.messages.BackendMessages.*; import static org.opends.server.backends.pluggable.DnKeyFormat.*; import static org.opends.server.backends.pluggable.SuffixContainer.*; import static org.opends.server.backends.pluggable.VLVIndex.*; import static org.opends.server.util.StaticUtils.*; @@ -192,11 +193,11 @@ for (String index : list) { String lowerName = index.toLowerCase(); if ("dn2id".equals(lowerName)) if (DN2ID_INDEX_NAME.equals(lowerName)) { verifyDN2ID = true; } else if ("id2childrencount".equals(lowerName)) else if (ID2CHILDREN_COUNT_NAME.equals(lowerName)) { verifyID2ChildrenCount = true; } @@ -207,10 +208,11 @@ throw new StorageRuntimeException(ERR_VLV_INDEX_NOT_CONFIGURED.get(lowerName).toString()); } VLVIndex vlvIndex = entryContainer.getVLVIndex(lowerName.substring(4)); String vlvIndexName = lowerName.substring(4); VLVIndex vlvIndex = entryContainer.getVLVIndex(vlvIndexName); if(vlvIndex == null) { throw new StorageRuntimeException(ERR_VLV_INDEX_NOT_CONFIGURED.get(lowerName.substring(4)).toString()); throw new StorageRuntimeException(ERR_VLV_INDEX_NOT_CONFIGURED.get(vlvIndexName).toString()); } vlvIndexList.add(vlvIndex);