From 6f1a7f89a2bc9812c61f71d282ead3299556f876 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 02 Oct 2015 15:34:44 +0000
Subject: [PATCH] Ran UCDetector on the pluggable and PDB backend
---
/dev/null | 225 -------------------------------------
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/AccessMode.java | 2
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java | 8
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java | 11 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java | 25 ----
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java | 10 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/TreeName.java | 12 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java | 6 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Tree.java | 7 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java | 9 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractTree.java | 8 -
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java | 2
12 files changed, 10 insertions(+), 315 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractTree.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractTree.java
index 9e90eab..48f7940 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractTree.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractTree.java
@@ -38,7 +38,7 @@
abstract class AbstractTree implements Tree, Comparable<Tree>
{
/** The name of the tree within the entryContainer. */
- private TreeName name;
+ private final TreeName name;
AbstractTree(final TreeName name)
{
@@ -77,12 +77,6 @@
}
@Override
- public final void setName(TreeName name)
- {
- this.name = name;
- }
-
- @Override
public final String toString()
{
return name.toString();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
index 6924540..db9c584 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -684,16 +684,8 @@
return new SearchResultReference(URIList);
}
- ByteString toKey(DN dn)
+ private ByteString toKey(DN dn)
{
return DnKeyFormat.dnToDNKey(dn, prefixRDNComponents);
}
-
- ByteSequence toValue(DN dn, Entry entry)
- {
- // FIXME JNR This is not very efficient:
- // getReferralsURL() converts from bytestring into string
- // and the code down below then does the reverse
- return encode(dn, entry.getReferralURLs());
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
index a5e9991..b224b91 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
@@ -52,7 +52,6 @@
* is a byte array, and is constructed from some normalized form of an attribute value (or fragment
* of a value) appearing in the entry.
*/
-@SuppressWarnings("javadoc")
class DefaultIndex extends AbstractTree implements Index
{
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
@@ -129,21 +128,11 @@
return codec.decode(key, value);
}
- ByteString toValue(EntryID entryID)
- {
- return codec.encode(newDefinedSet(entryID.longValue()));
- }
-
ByteString toValue(EntryIDSet entryIDSet)
{
return codec.encode(entryIDSet);
}
- ByteString toValue(ImportIDSet importIDSet)
- {
- return importIDSet.valueToByteString(codec);
- }
-
@Override
public final void update(final WriteableTransaction txn, final ByteString key, final EntryIDSet deletedIDs,
final EntryIDSet addedIDs) throws StorageRuntimeException
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
index ce816d5..d4025c6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -1526,7 +1526,7 @@
}
}
- void addEntry0(final Entry entry, final DN parentDN, final EntryID entryID, final IndexBuffer indexBuffer,
+ private void addEntry0(final Entry entry, final DN parentDN, final EntryID entryID, final IndexBuffer indexBuffer,
final ByteString encodedEntry, WriteableTransaction txn) throws DirectoryException
{
// Check that the parent entry exists.
@@ -2763,29 +2763,6 @@
}
/**
- * Clear the contents for a tree from disk.
- *
- * @param txn a non null transaction
- * @param tree The tree to clear.
- * @throws StorageRuntimeException if a storage error occurs.
- */
- void clearTree(WriteableTransaction txn, Tree tree) throws StorageRuntimeException
- {
- try
- {
- tree.delete(txn);
- }
- finally
- {
- tree.open(txn, true);
- }
- if(logger.isTraceEnabled())
- {
- logger.trace("Cleared the tree %s", tree.getName());
- }
- }
-
- /**
* Finds an existing entry whose DN is the closest ancestor of a given baseDN.
*
* @param baseDN the DN for which we are searching a matched DN.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
index fc30dd3..1c591a2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
@@ -886,12 +886,6 @@
return concreteImpl.getRange();
}
- static long addWithoutOverflow(long a, long b) {
- // a and b must be > 0
- final long result = a + b;
- return result >= 0 ? result : Long.MAX_VALUE;
- }
-
private static long[] mergeOverlappingEntryIDSet(long set1[], long set2[])
{
final long[] a, b;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
index eb95f7b..7029c73 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
@@ -134,15 +134,6 @@
return getKeyFromEntryIDAndBucket(entryID, bucket);
}
- ByteSequence toKey(EntryID entryID)
- {
- if (entryID == null)
- {
- entryID = TOTAL_COUNT_ENTRY_ID;
- }
- return getShardedKey(entryID);
- }
-
ByteString toValue(final long count)
{
Reject.ifFalse(count != 0, "count must be != 0");
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java
deleted file mode 100644
index 3e3b2d2..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2009 Sun Microsystems, Inc.
- * Portions Copyright 2011-2015 ForgeRock AS
- */
-package org.opends.server.backends.pluggable;
-
-import static org.forgerock.util.Reject.*;
-import static org.opends.server.backends.pluggable.EntryIDSet.*;
-
-import java.util.Iterator;
-
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.util.Reject;
-import org.opends.server.backends.pluggable.EntryIDSet.EntryIDSetCodec;
-
-/**
- * This class manages the set of ID that are to be eventually added to an index
- * tree. It is responsible for determining if the number of IDs is above
- * the configured ID limit. If the limit it reached, the class stops tracking
- * individual IDs and marks the set as undefined. This class is not thread safe.
- */
-@SuppressWarnings("javadoc")
-final class ImportIDSet implements Iterable<EntryID> {
-
- /** The encapsulated entryIDSet where elements are stored until reaching the limit. */
- private EntryIDSet entryIDSet;
- /** Key related to an ID set. */
- private final ByteSequence key;
- /** The index entry limit size. */
- private final int indexEntryLimitSize;
-
- /**
- * Create an import ID set managing the entry limit of the provided EntryIDSet.
- *
- * @param key
- * The key associated to this ID set
- * @param entryIDSet
- * The entryIDSet that will be managed by this object
- * @param limit
- * The index entry limit or 0 if unlimited.
- * @throws NullPointerException
- * if key or entryIDSet is null
- * @throws IllegalArgumentException
- * if limit is < 0
- */
- public ImportIDSet(ByteSequence key, EntryIDSet entryIDSet, int limit)
- {
- checkNotNull(key, "key must not be null");
- checkNotNull(entryIDSet, "entryIDSet must not be null");
- ifFalse(limit >= 0, "limit must be >= 0");
-
- this.key = key;
- this.entryIDSet = entryIDSet;
- // FIXME: What to do if entryIDSet.size()> limit yet ?
- this.indexEntryLimitSize = limit == 0 ? Integer.MAX_VALUE : limit;
- }
-
- /**
- * @return <CODE>True</CODE> if an import ID set is defined.
- */
- boolean isDefined()
- {
- return entryIDSet.isDefined();
- }
-
- void setUndefined() {
- entryIDSet = newUndefinedSetWithKey(key);
- }
-
- /**
- * @param entryID The {@link EntryID} to add to an import ID set.
- */
- void addEntryID(long entryID)
- {
- Reject.ifTrue(entryID < 0, "entryID must be positive");
- if (!isDefined()) {
- return;
- }
- if (size() + 1 > indexEntryLimitSize) {
- entryIDSet = newUndefinedSetWithKey(key);
- } else {
- entryIDSet.add(new EntryID(entryID));
- }
- }
-
- /**
- * @param importIdSet The import ID set to delete.
- * @throws NullPointerException if importIdSet is null
- */
- void remove(ImportIDSet importIdSet)
- {
- checkNotNull(importIdSet, "importIdSet must not be null");
- if (!importIdSet.isDefined()) {
- setUndefined();
- } else if (isDefined()) {
- entryIDSet.removeAll(importIdSet.entryIDSet);
- }
- }
-
- /**
- * @param importIdSet The import ID set to merge the byte array with.
- * @return <CODE>true</CODE> if the import ID set reached the limit as a result of the merge.
- * @throws NullPointerException if importIdSet is null
- */
- boolean merge(ImportIDSet importIdSet)
- {
- checkNotNull(importIdSet, "importIdSet must not be null");
- return merge(importIdSet.entryIDSet);
- }
-
- boolean merge(EntryIDSet entryIDSet)
- {
- checkNotNull(entryIDSet, "entryID must not be null");
- boolean definedBeforeMerge = this.entryIDSet.isDefined();
- final long mergedSize = addWithoutOverflow(this.entryIDSet.size(), entryIDSet.size());
-
- if (!definedBeforeMerge || !entryIDSet.isDefined() || mergedSize > indexEntryLimitSize)
- {
- this.entryIDSet = newUndefinedSetWithKey(key);
- return definedBeforeMerge;
- }
- else if (this.entryIDSet.isDefined())
- {
- this.entryIDSet.addAll(entryIDSet);
- }
- return false;
- }
-
- /**
- * @return The current size of an import ID set.
- * @throws IllegalStateException if this set is undefined
- */
- int size()
- {
- if (!isDefined()) {
- throw new IllegalStateException("This ImportIDSet is undefined");
- }
- return (int) entryIDSet.size();
- }
-
- /**
- * @return The byte string containing the DB key related to this set.
- */
- ByteSequence getKey()
- {
- return key;
- }
-
- @Override
- public Iterator<EntryID> iterator() {
- return entryIDSet.iterator();
- }
-
- /**
- * @return Binary representation of this ID set
- */
- ByteString valueToByteString(EntryIDSetCodec codec) {
- checkNotNull(codec, "codec must not be null");
- return codec.encode(entryIDSet);
- }
-
- @Override
- public String toString()
- {
- return entryIDSet.toString();
- }
-}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
index cdfdf05..d764391 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
@@ -64,7 +64,7 @@
private final EntryID entryID;
private final EntryContainer entryContainer;
- EntryInformation(Entry entry, EntryID entryID, EntryContainer entryContainer)
+ private EntryInformation(Entry entry, EntryID entryID, EntryContainer entryContainer)
{
this.entry = entry;
this.entryID = entryID;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportRecord.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportRecord.java
deleted file mode 100644
index 300647f..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportRecord.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- * Copyright 2015 ForgeRock AS
- */
-package org.opends.server.backends.pluggable;
-
-import static org.opends.server.util.StaticUtils.*;
-
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteString;
-
-/** Record for import composed of a byte sequence key and an indexID. */
-final class ImportRecord implements Comparable<ImportRecord>
-{
- /**
- * The record overhead. In addition to entryID, key length and key bytes, the record overhead
- * includes the INS/DEL bit + indexID
- */
- static final int REC_OVERHEAD = 1 + INT_SIZE;
-
- static ImportRecord fromBufferAndPosition(byte[] buffer, int position)
- {
- return fromBufferAndOffset(buffer, readOffset(buffer, position));
- }
-
- static ImportRecord fromBufferAndOffset(byte[] buffer, int offSet)
- {
- int indexID = readIndexIDFromOffset(buffer, offSet);
- offSet += REC_OVERHEAD + LONG_SIZE;
- int keyLength = readInt(buffer, offSet);
- ByteString key = ByteString.wrap(buffer, INT_SIZE + offSet, keyLength);
- return new ImportRecord(key, indexID);
- }
-
- static ImportRecord from(ByteSequence key, int indexID)
- {
- return new ImportRecord(key, indexID);
- }
-
- private static int readOffset(byte[] buffer, int position)
- {
- return readInt(buffer, position * INT_SIZE);
- }
-
- private static int readIndexIDFromOffset(byte[] buffer, int offset)
- {
- return readInt(buffer, offset + 1);
- }
-
- private static int readInt(byte[] buffer, int index)
- {
- int answer = 0;
- for (int i = 0; i < INT_SIZE; i++)
- {
- byte b = buffer[index + i];
- answer <<= 8;
- answer |= b & 0xff;
- }
- return answer;
- }
-
- private final ByteSequence key;
- /**
- * The indexID, computed by calling {@link System#identityHashCode(Object)}
- * on the in-memory {@link Index} object.
- */
- private final int indexID;
-
- private ImportRecord(ByteSequence key, int indexID)
- {
- this.key = key;
- this.indexID = indexID;
- }
-
- public int getIndexID()
- {
- return indexID;
- }
-
- public ByteSequence getKey()
- {
- return key;
- }
-
- @Override
- public int compareTo(ImportRecord o)
- {
- if (o == null)
- {
- return -1;
- }
- int cmp = key.compareTo(o.getKey());
- if (cmp == 0)
- {
- return indexID - o.getIndexID();
- }
- return cmp;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o instanceof ImportRecord)
- {
- ImportRecord other = (ImportRecord) o;
- return indexID == other.getIndexID() && key.equals(other.getKey());
- }
- return false;
- }
-
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + indexID;
- result = prime * result + ((key == null) ? 0 : key.hashCode());
- return result;
- }
-
- @Override
- public String toString()
- {
- return "ImportRecord(key=" + key + ", indexID=" + indexID + ")";
- }
-}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportSuffixCommand.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportSuffixCommand.java
deleted file mode 100644
index 183c2bd..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportSuffixCommand.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2015 ForgeRock AS
- */
-package org.opends.server.backends.pluggable;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.opends.server.types.DN;
-import org.opends.server.types.DirectoryException;
-import org.opends.server.types.LDIFImportConfig;
-
-/**
- * Command that describes how a suffix should be imported. Gives the strategy to use and the data to
- * drive the import operation of a single suffix.
- */
-public class ImportSuffixCommand
-{
- /** Strategy for importing a suffix. */
- public static enum SuffixImportStrategy {
- /**
- * Create a {@link Suffix} specifying just the {@link EntryContainer} for the baseDN, no include or exclude
- * branches are needed, normally used for append or clear backend modes.
- */
- APPEND_OR_REPLACE,
- /** Do not create a {@link Suffix}. */
- SKIP_SUFFIX,
- /** Before creating a {@link Suffix}, clear the {@link EntryContainer} of the baseDN. */
- CLEAR_SUFFIX,
- /** Create a temporary {@link EntryContainer} to merge LDIF with original data. */
- MERGE_DB_WITH_LDIF,
- /**
- * Create a {@link Suffix} specifying include and exclude branches and optionally a source {@link EntryContainer}.
- */
- INCLUDE_EXCLUDE_BRANCHES
- }
-
- private List<DN> includeBranches;
- private List<DN> excludeBranches;
- private SuffixImportStrategy strategy = SuffixImportStrategy.APPEND_OR_REPLACE;
-
- List<DN> getIncludeBranches()
- {
- return includeBranches;
- }
-
- List<DN> getExcludeBranches()
- {
- return excludeBranches;
- }
-
- SuffixImportStrategy getSuffixImportStrategy()
- {
- return strategy;
- }
-
- ImportSuffixCommand(DN baseDN, LDIFImportConfig importCfg) throws DirectoryException
- {
- strategy = decideSuffixStrategy(baseDN, importCfg);
- }
-
- private SuffixImportStrategy decideSuffixStrategy(DN baseDN, LDIFImportConfig importCfg)
- throws DirectoryException
- {
- if (importCfg.appendToExistingData() || importCfg.clearBackend())
- {
- return SuffixImportStrategy.APPEND_OR_REPLACE;
- }
- if (importCfg.getExcludeBranches().contains(baseDN))
- {
- // This entire base DN was explicitly excluded. Skip.
- return SuffixImportStrategy.SKIP_SUFFIX;
- }
- excludeBranches = getDescendants(baseDN, importCfg.getExcludeBranches());
- if (!importCfg.getIncludeBranches().isEmpty())
- {
- includeBranches = getDescendants(baseDN, importCfg.getIncludeBranches());
- if (includeBranches.isEmpty())
- {
- // There are no branches in the explicitly defined include list under this base DN.
- // Skip this base DN altogether.
- return SuffixImportStrategy.SKIP_SUFFIX;
- }
-
- // Remove any overlapping include branches.
- Iterator<DN> includeBranchIterator = includeBranches.iterator();
- while (includeBranchIterator.hasNext())
- {
- DN includeDN = includeBranchIterator.next();
- if (!isAnyNotEqualAndAncestorOf(includeBranches, includeDN))
- {
- includeBranchIterator.remove();
- }
- }
-
- // Remove any exclude branches that are not are not under a include branch
- // since they will be migrated as part of the existing entries
- // outside of the include branches anyways.
- Iterator<DN> excludeBranchIterator = excludeBranches.iterator();
- while (excludeBranchIterator.hasNext())
- {
- DN excludeDN = excludeBranchIterator.next();
- if (!isAnyAncestorOf(includeBranches, excludeDN))
- {
- excludeBranchIterator.remove();
- }
- }
-
- if (excludeBranches.isEmpty() && includeBranches.size() == 1 && includeBranches.get(0).equals(baseDN))
- {
- // This entire base DN is explicitly included in the import with
- // no exclude branches that we need to migrate.
- // Just clear the entry container.
- return SuffixImportStrategy.CLEAR_SUFFIX;
- }
- return SuffixImportStrategy.MERGE_DB_WITH_LDIF;
- }
- return SuffixImportStrategy.INCLUDE_EXCLUDE_BRANCHES;
- }
-
- private List<DN> getDescendants(DN baseDN, Set<DN> dns)
- {
- final List<DN> results = new ArrayList<>();
- for (DN dn : dns)
- {
- if (baseDN.isAncestorOf(dn))
- {
- results.add(dn);
- }
- }
- return results;
- }
-
- private boolean isAnyAncestorOf(List<DN> dns, DN childDN)
- {
- for (DN dn : dns)
- {
- if (dn.isAncestorOf(childDN))
- {
- return true;
- }
- }
- return false;
- }
-
- private boolean isAnyNotEqualAndAncestorOf(List<DN> dns, DN childDN)
- {
- for (DN dn : dns)
- {
- if (!dn.equals(childDN) && dn.isAncestorOf(childDN))
- {
- return false;
- }
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
index 1a4ce66..83f4f5a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
@@ -698,7 +698,7 @@
this.importStrategy = importStrategy;
}
- public void doImport(final Source source) throws Exception
+ private void doImport(final Source source) throws Exception
{
final long phaseOneStartTime = System.currentTimeMillis();
final PhaseOneWriteableTransaction transaction = new PhaseOneWriteableTransaction(importStrategy);
@@ -1629,7 +1629,7 @@
private final long startOffset;
private long size;
private MappedByteBuffer mmapBuffer;
- private OutputStream mmapBufferOS = new OutputStream()
+ private final OutputStream mmapBufferOS = new OutputStream()
{
@Override
public void write(int arg0) throws IOException
@@ -2555,7 +2555,7 @@
}
}
- static boolean supportOffHeap()
+ private static boolean supportOffHeap()
{
return unsafe != null;
}
@@ -2575,7 +2575,7 @@
return bufferSize;
}
- public Buffer get()
+ private Buffer get()
{
try
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/SuccessiveAddsImportStrategy.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/SuccessiveAddsImportStrategy.java
deleted file mode 100644
index 8fe85bf..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/SuccessiveAddsImportStrategy.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- * Copyright 2015 ForgeRock AS
- */
-package org.opends.server.backends.pluggable;
-
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.messages.UtilityMessages.*;
-import static org.opends.server.util.StaticUtils.*;
-
-import java.io.IOException;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.admin.std.server.PluggableBackendCfg;
-import org.opends.server.backends.RebuildConfig;
-import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ServerContext;
-import org.opends.server.types.CanceledOperationException;
-import org.opends.server.types.DN;
-import org.opends.server.types.DirectoryException;
-import org.opends.server.types.Entry;
-import org.opends.server.types.LDIFImportConfig;
-import org.opends.server.types.LDIFImportResult;
-import org.opends.server.util.LDIFException;
-import org.opends.server.util.LDIFReader;
-
-/**
- * Imports LDIF entries one by one, by calling
- * {@link EntryContainer#addEntry(Entry, org.opends.server.core.AddOperation)}.
- */
-final class SuccessiveAddsImportStrategy implements ImportStrategy
-{
- /** Logs the progress of the import. */
- private static final class ImportProgress implements Runnable
- {
- private final LDIFReader reader;
- private long previousCount;
- private long previousTime;
-
- public ImportProgress(LDIFReader reader)
- {
- this.reader = reader;
- }
-
- @Override
- public void run()
- {
- long latestCount = reader.getEntriesRead() + 0;
- long deltaCount = latestCount - previousCount;
- long latestTime = System.currentTimeMillis();
- long deltaTime = latestTime - previousTime;
- if (deltaTime == 0)
- {
- return;
- }
- long entriesRead = reader.getEntriesRead();
- long entriesIgnored = reader.getEntriesIgnored();
- long entriesRejected = reader.getEntriesRejected();
- float rate = 1000f * deltaCount / deltaTime;
- logger.info(NOTE_IMPORT_PROGRESS_REPORT, entriesRead, entriesIgnored, entriesRejected, rate);
-
- previousCount = latestCount;
- previousTime = latestTime;
- }
- }
-
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- private static final int IMPORT_PROGRESS_INTERVAL = 10000;
-
- private final ServerContext serverContext;
-
- private final RootContainer rootContainer;
-
- private final PluggableBackendCfg backendCfg;
-
- SuccessiveAddsImportStrategy(ServerContext serverContext, RootContainer rootContainer, PluggableBackendCfg backendCfg)
- {
- this.serverContext = serverContext;
- this.rootContainer = rootContainer;
- this.backendCfg = backendCfg;
- }
-
- @Override
- public LDIFImportResult importLDIF(LDIFImportConfig importConfig) throws DirectoryException, IOException,
- CanceledOperationException, StorageRuntimeException, InterruptedException
- {
- ScheduledThreadPoolExecutor timerService = new ScheduledThreadPoolExecutor(1);
- try
- {
- final LDIFReader reader;
- try
- {
- reader = new LDIFReader(importConfig);
- }
- catch (Exception e)
- {
- LocalizableMessage m = ERR_LDIF_BACKEND_CANNOT_CREATE_LDIF_READER.get(stackTraceToSingleLineString(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), m, e);
- }
-
- long importCount = 0;
- final long startTime = System.currentTimeMillis();
- timerService.scheduleAtFixedRate(new ImportProgress(reader),
- IMPORT_PROGRESS_INTERVAL, IMPORT_PROGRESS_INTERVAL, TimeUnit.MILLISECONDS);
- while (true)
- {
- final Entry entry;
- try
- {
- entry = reader.readEntry();
- if (entry == null)
- {
- break;
- }
- }
- catch (LDIFException le)
- {
- if (!le.canContinueReading())
- {
- LocalizableMessage m = ERR_LDIF_BACKEND_ERROR_READING_LDIF.get(stackTraceToSingleLineString(le));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), m, le);
- }
- continue;
- }
-
- final DN dn = entry.getName();
- final EntryContainer ec = rootContainer.getEntryContainer(dn);
- if (ec == null)
- {
- final LocalizableMessage m = ERR_LDIF_SKIP.get(dn);
- logger.error(m);
- reader.rejectLastEntry(m);
- continue;
- }
-
- try
- {
- ec.addEntry(entry, null);
- importCount++;
- }
- catch (DirectoryException e)
- {
- switch (e.getResultCode().asEnum())
- {
- case ENTRY_ALREADY_EXISTS:
- if (importConfig.replaceExistingEntries())
- {
- final Entry oldEntry = ec.getEntry(entry.getName());
- ec.replaceEntry(oldEntry, entry, null);
- }
- else
- {
- reader.rejectLastEntry(WARN_IMPORT_ENTRY_EXISTS.get());
- }
- break;
- case NO_SUCH_OBJECT:
- reader.rejectLastEntry(ERR_IMPORT_PARENT_NOT_FOUND.get(dn.parent()));
- break;
- default:
- // Not sure why it failed.
- reader.rejectLastEntry(e.getMessageObject());
- break;
- }
- }
- }
- final long finishTime = System.currentTimeMillis();
-
- waitForShutdown(timerService);
-
- final long importTime = finishTime - startTime;
- float rate = 0;
- if (importTime > 0)
- {
- rate = 1000f * reader.getEntriesRead() / importTime;
- }
- logger.info(NOTE_IMPORT_FINAL_STATUS, reader.getEntriesRead(), importCount, reader.getEntriesIgnored(),
- reader.getEntriesRejected(), 0, importTime / 1000, rate);
- return new LDIFImportResult(reader.getEntriesRead(), reader.getEntriesRejected(), reader.getEntriesIgnored());
- }
- finally
- {
- rootContainer.close();
-
- // if not already stopped, then stop it
- waitForShutdown(timerService);
- }
- }
-
- @Override
- public void rebuildIndex(RebuildConfig rebuildConfig) throws Exception
- {
- new OnDiskMergeImporter.StrategyImpl(serverContext, rootContainer, backendCfg).rebuildIndex(rebuildConfig);
- }
-
- private void waitForShutdown(ScheduledThreadPoolExecutor timerService) throws InterruptedException
- {
- timerService.shutdown();
- timerService.awaitTermination(20, TimeUnit.SECONDS);
- }
-}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Tree.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Tree.java
index 8671489..cfce19e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Tree.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Tree.java
@@ -76,11 +76,4 @@
* @return name for this tree.
*/
TreeName getName();
-
- /**
- * Set the name to use for this tree.
- *
- * @param name The name to use for this tree.
- */
- void setName(TreeName name);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/AccessMode.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/AccessMode.java
index 77faf93..e2c7608 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/AccessMode.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/AccessMode.java
@@ -32,7 +32,7 @@
/** Constant used to open the Storage in read-write mode; implies trees will be created if not already present. */
READ_WRITE(true);
- private boolean readWrite;
+ private final boolean readWrite;
AccessMode(boolean update)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/TreeName.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/TreeName.java
index 23eee02..3d8e306 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/TreeName.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/spi/TreeName.java
@@ -84,17 +84,7 @@
return indexId;
}
- /**
- * Returns a new tree name object created by replacing the baseDN of the current object.
- *
- * @param newBaseDN
- * the new base DN that replaces the existing base DN
- * @return a new tree name object with the provided the base DN
- */
- public TreeName replaceBaseDN(String newBaseDN)
- {
- return new TreeName(newBaseDN, indexId);
- }
+
/** {@inheritDoc} */
@Override
--
Gitblit v1.10.0