indexed store rewrite in progress
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
index 180ceb0..dfdf9f2 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
@@ -38,7 +38,7 @@
private long lastBuild = 0L;
private Workspace workspace;
private final IJobManager jobManager = Platform.getJobManager();
- private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi");
+ private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$
AutoBuildJob(Workspace workspace) {
super(ICoreConstants.MSG_EVENTS_BUILDING_0);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java
index b8c222b..3687b1c 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java
@@ -10,12 +10,14 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.runtime.CoreException;
+
public abstract class AbstractObjectPolicy {
/**
* Creates a new instance of an object for this object store. Uses
* the contents of the field to decide what type of object to create.
*/
- public abstract StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws ObjectStoreException;
+ public abstract StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws CoreException;
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/BinarySmallObject.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/BinarySmallObject.java
index f7b2a02..cc08cc8 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/BinarySmallObject.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/BinarySmallObject.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.runtime.CoreException;
+
class BinarySmallObject extends IndexedStoreObject {
public static final int TYPE = 5;
public static final int VALUE_OFFSET = 2;
@@ -26,25 +28,14 @@
/**
* Constructs an object from bytes that came from the store.
*/
- public BinarySmallObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ public BinarySmallObject(Field f, ObjectStore store, ObjectAddress address) throws CoreException {
super(f, store, address);
}
/**
- * Places the contents of the fields into the buffer.
- * Subclasses should implement and call super.
- * The value field is maintained in the contents directly and does not need
- * to be copied there by this method.
- */
- protected void insertValues(Field f) {
- super.insertValues(f);
- f.subfield(VALUE_OFFSET).put(value);
- }
-
- /**
* Extracts the values from a field into the members of this object;
*/
- protected void extractValues(Field f) throws ObjectStoreException {
+ protected void extractValues(Field f) throws CoreException {
super.extractValues(f);
value = f.subfield(VALUE_OFFSET).get();
}
@@ -57,10 +48,6 @@
return 6000 + VALUE_OFFSET;
}
- protected int length() {
- return value.length + VALUE_OFFSET;
- }
-
/**
* Returns the minimum size of this object's instance -- including its type field.
* Subclasses should override.
@@ -84,6 +71,21 @@
return new Field(value).get();
}
+ /**
+ * Places the contents of the fields into the buffer.
+ * Subclasses should implement and call super.
+ * The value field is maintained in the contents directly and does not need
+ * to be copied there by this method.
+ */
+ protected void insertValues(Field f) {
+ super.insertValues(f);
+ f.subfield(VALUE_OFFSET).put(value);
+ }
+
+ protected int length() {
+ return value.length + VALUE_OFFSET;
+ }
+
/**
* Provides a printable representation of this object.
*/
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Buffer.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Buffer.java
index ce5a1a7..32772cf 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Buffer.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Buffer.java
@@ -46,10 +46,6 @@
this.contents = anObject.toByteArray();
}
- public void clear() {
- clear(contents, 0, contents.length);
- }
-
private static void clear(byte[] buffer, int offset, int length) {
int n = length;
int p = offset;
@@ -61,20 +57,10 @@
}
}
- private static void clear(byte[] buffer, int offset, int length, byte value) {
- for (int i = offset; i < offset + length; i++) {
- buffer[i] = value;
- }
- }
-
public void clear(int offset, int length) {
clear(contents, offset, length);
}
- public void clear(int offset, int length, byte value) {
- clear(contents, offset, length, value);
- }
-
private static int compare(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2) {
if (length1 < length2) {
return -compare(buffer2, offset2, length2, buffer1, offset1, length1);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Field.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Field.java
index 61dcaab..06822f3 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Field.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Field.java
@@ -83,11 +83,6 @@
return this;
}
- public Field clear(byte value) {
- buffer.clear(offset, length, value);
- return this;
- }
-
public int compareTo(Field that) {
return Buffer.compare(this.buffer, this.offset, this.length, that.buffer, that.offset, that.length);
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Index.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Index.java
index ac76c26..3f26a42 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Index.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Index.java
@@ -11,6 +11,8 @@
package org.eclipse.core.internal.indexing;
import java.util.Vector;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
/**
* This class provides the public interface to an index.
@@ -38,7 +40,7 @@
/**
* Returns the number of entries in the index.
*/
- public synchronized int getNumberOfEntries() throws IndexedStoreException {
+ public synchronized int getNumberOfEntries() throws CoreException {
IndexAnchor anchor = store.acquireAnchor(anchorAddress);
int n = anchor.getNumberOfEntries();
anchor.release();
@@ -48,7 +50,7 @@
/**
* Returns the number of nodes in the index.
*/
- public synchronized int getNumberOfNodes() throws IndexedStoreException {
+ public synchronized int getNumberOfNodes() throws CoreException {
IndexAnchor anchor = store.acquireAnchor(anchorAddress);
int n = anchor.getNumberOfNodes();
anchor.release();
@@ -60,7 +62,7 @@
* This assumes that the underlying index has values that can be converted
* to ObjectIDs.
*/
- public synchronized Vector getObjectIdentifiersMatching(byte[] key) throws IndexedStoreException {
+ public synchronized Vector getObjectIdentifiersMatching(byte[] key) throws CoreException {
IndexCursor cursor = open();
cursor.find(key);
Vector vector = new Vector(20);
@@ -77,7 +79,7 @@
* key given in the index. This assumes that the underlying
* index has values that can be converted to ObjectIDs.
*/
- public synchronized Vector getObjectIdentifiersMatching(String key) throws IndexedStoreException {
+ public synchronized Vector getObjectIdentifiersMatching(String key) throws CoreException {
return getObjectIdentifiersMatching(Convert.toUTF8(key));
}
@@ -86,7 +88,7 @@
* key given in the index. This assumes that the underlying
* index has values that can be converted to ObjectIDs.
*/
- public synchronized Vector getObjectIdentifiersMatching(Insertable key) throws IndexedStoreException {
+ public synchronized Vector getObjectIdentifiersMatching(Insertable key) throws CoreException {
return getObjectIdentifiersMatching(key.toByteArray());
}
@@ -96,45 +98,45 @@
* be greater than 2048 bytes in length. The other insert methods are
* convenience methods that use this for their implementation.
*/
- public synchronized void insert(byte[] key, byte[] value) throws IndexedStoreException {
+ public synchronized void insert(byte[] key, byte[] value) throws CoreException {
if (key.length > 1024)
- throw new IndexedStoreException(IndexedStoreException.EntryKeyLengthError);
+ throw Policy.exception("indexedStore.entryKeyLengthError"); //$NON-NLS-1$
if (value.length > 2048)
- throw new IndexedStoreException(IndexedStoreException.EntryValueLengthError);
+ throw Policy.exception("indexedStore.entryValueLengthError"); //$NON-NLS-1$
IndexAnchor anchor = store.acquireAnchor(anchorAddress);
anchor.insert(key, value);
anchor.release();
}
- public synchronized void insert(byte[] key, String value) throws IndexedStoreException {
+ public synchronized void insert(byte[] key, String value) throws CoreException {
insert(key, Convert.toUTF8(value));
}
- public synchronized void insert(byte[] key, Insertable value) throws IndexedStoreException {
+ public synchronized void insert(byte[] key, Insertable value) throws CoreException {
insert(key, value.toByteArray());
}
- public synchronized void insert(String key, byte[] value) throws IndexedStoreException {
+ public synchronized void insert(String key, byte[] value) throws CoreException {
insert(Convert.toUTF8(key), value);
}
- public synchronized void insert(String key, String value) throws IndexedStoreException {
+ public synchronized void insert(String key, String value) throws CoreException {
insert(Convert.toUTF8(key), Convert.toUTF8(value));
}
- public synchronized void insert(String key, Insertable value) throws IndexedStoreException {
+ public synchronized void insert(String key, Insertable value) throws CoreException {
insert(Convert.toUTF8(key), value.toByteArray());
}
- public synchronized void insert(Insertable key, byte[] value) throws IndexedStoreException {
+ public synchronized void insert(Insertable key, byte[] value) throws CoreException {
insert(key.toByteArray(), value);
}
- public synchronized void insert(Insertable key, String value) throws IndexedStoreException {
+ public synchronized void insert(Insertable key, String value) throws CoreException {
insert(key.toByteArray(), Convert.toUTF8(value));
}
- public synchronized void insert(Insertable key, Insertable value) throws IndexedStoreException {
+ public synchronized void insert(Insertable key, Insertable value) throws CoreException {
insert(key.toByteArray(), value.toByteArray());
}
@@ -142,7 +144,7 @@
* Returns a cursor for this index. The cursor is initially in the unset state
* and should be positioned using "find" before being used.
*/
- public synchronized IndexCursor open() throws IndexedStoreException {
+ public synchronized IndexCursor open() {
IndexCursor c = new IndexCursor(store, anchorAddress);
return c;
}
@@ -150,7 +152,7 @@
/**
* Removes all entries that have a key that is equal to the supplied key.
*/
- public synchronized void removeAllEqual(byte[] key) throws IndexedStoreException {
+ public synchronized void removeAllEqual(byte[] key) throws CoreException {
IndexCursor c = open();
c.find(key);
while (c.keyEquals(key)) {
@@ -162,7 +164,7 @@
/**
* Removes all entries that have a key that begins with the supplied prefix.
*/
- public synchronized void removeAllMatching(byte[] keyPrefix) throws IndexedStoreException {
+ public synchronized void removeAllMatching(byte[] keyPrefix) throws CoreException {
IndexCursor c = open();
c.find(keyPrefix);
while (c.keyMatches(keyPrefix)) {
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexAnchor.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexAnchor.java
index ecaf249..3143994 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexAnchor.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexAnchor.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
/**
* An IndexAnchor provides a place to hang index-wide information in a fixed spot, especially
* since the root node may change due to a root node split.
@@ -44,7 +47,7 @@
/**
* Constructs a new index anchor from a field read from the store. Used by the factory.
*/
- public IndexAnchor(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ public IndexAnchor(Field f, ObjectStore store, ObjectAddress address) throws CoreException {
super(f, store, address);
}
@@ -71,7 +74,7 @@
* Places the contents of the buffer into the fields.
* Subclasses should implement and call super.
*/
- protected void extractValues(Field f) throws ObjectStoreException {
+ protected void extractValues(Field f) throws CoreException {
super.extractValues(f);
setFields(f);
numberOfEntries = numberOfEntriesField.getInt();
@@ -138,7 +141,7 @@
/**
* This method requests the anchor to destroy its children.
*/
- void destroyChildren() throws IndexedStoreException {
+ void destroyChildren() throws CoreException {
IndexNode rootNode = acquireNode(rootNodeAddress);
rootNode.destroyChildren();
rootNode.release();
@@ -150,7 +153,7 @@
* is greater than or equal to the key provided. To set a cursor to the beginning
* of the index use a key of zero length.
*/
- void find(byte key[], IndexCursor cursor) throws IndexedStoreException {
+ void find(byte key[], IndexCursor cursor) throws CoreException {
if (rootNodeAddress.isNull()) {
cursor.reset();
} else {
@@ -163,7 +166,7 @@
/**
* This method returns a cursor set to the first entry in the index.
*/
- void findFirstEntry(IndexCursor cursor) throws IndexedStoreException {
+ void findFirstEntry(IndexCursor cursor) throws CoreException {
if (rootNodeAddress.isNull()) {
cursor.reset();
} else {
@@ -176,7 +179,7 @@
/**
* This method returns a cursor set to the last entry in the index.
*/
- void findLastEntry(IndexCursor cursor) throws IndexedStoreException {
+ void findLastEntry(IndexCursor cursor) throws CoreException {
if (rootNodeAddress.isNull()) {
cursor.reset();
} else {
@@ -189,13 +192,13 @@
/**
* Insert an entry into an index.
*/
- void insert(byte[] key, byte[] value) throws IndexedStoreException {
+ void insert(byte[] key, byte[] value) throws CoreException {
if (rootNodeAddress.isNull()) {
IndexNode rootNode = new IndexNode(this.address);
try {
store.insertObject(rootNode);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.IndexNodeNotCreated, e);
+ } catch (CoreException e) {
+ Policy.exception("indexedStore.indexNodeNotCreated", e); //$NON-NLS-1$
}
rootNodeAddress = rootNode.getAddress();
}
@@ -214,7 +217,7 @@
/**
* Returns the number of nodes in the index.
*/
- int getNumberOfNodes() throws IndexedStoreException {
+ int getNumberOfNodes() throws CoreException {
if (rootNodeAddress.isNull())
return 0;
IndexNode node = acquireNode(rootNodeAddress);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexCursor.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexCursor.java
index 8dcbea2..3b595de 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexCursor.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexCursor.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
public class IndexCursor {
private IndexedStore store;
@@ -41,7 +44,7 @@
* entry if it is pointing outside of the entries of a node.
* If there are no more entries then unset the cursor.
*/
- private void adjust() throws IndexedStoreException {
+ private void adjust() throws CoreException {
if (leafNode == null)
return;
if (entryNumber >= leafNode.getNumberOfEntries()) {
@@ -52,7 +55,6 @@
ObjectAddress previous = leafNode.getPreviousAddress();
int n = entryNumber;
set(previous, n);
- } else {
}
}
@@ -60,7 +62,7 @@
* Closes the cursor. This unsets the cursor and deregisters it from all the
* interested parties.
*/
- public void close() throws IndexedStoreException {
+ public void close() {
reset();
}
@@ -68,7 +70,7 @@
* Adjusts a cursor if there is a need after an entry is inserted.
* If not, it just returns.
*/
- void entryInserted(int i) throws IndexedStoreException {
+ void entryInserted(int i) throws CoreException {
if (entryNumber >= i)
entryNumber++;
adjust();
@@ -77,7 +79,7 @@
/**
* Adjusts a cursor if there is a need after an entry is removed.
*/
- void entryRemoved(int i) throws IndexedStoreException {
+ void entryRemoved(int i) throws CoreException {
entryRemoved = (entryNumber == i);
if (entryNumber > i)
entryNumber--;
@@ -89,7 +91,7 @@
* greater than or equal to that of the argument. Returns the cursor itself
* for convenience in chaining method invocations.
*/
- public synchronized IndexCursor find(byte[] b) throws IndexedStoreException {
+ public synchronized IndexCursor find(byte[] b) throws CoreException {
IndexAnchor anchor = store.acquireAnchor(anchorAddress);
anchor.find(b, this);
anchor.release();
@@ -102,7 +104,7 @@
* greater than or equal to that of the argument. Returns the cursor itself
* for convenience in chaining method invocations.
*/
- public synchronized IndexCursor find(String s) throws IndexedStoreException {
+ public synchronized IndexCursor find(String s) throws CoreException {
return find(Convert.toUTF8(s));
}
@@ -111,14 +113,14 @@
* greater than or equal to that of the argument. Returns the cursor itself
* for convenience in chaining method invocations.
*/
- public synchronized IndexCursor find(Insertable i) throws IndexedStoreException {
+ public synchronized IndexCursor find(Insertable i) throws CoreException {
return find(i.toByteArray());
}
/**
* Sets the cursor at the first entry of an index.
*/
- public synchronized IndexCursor findFirstEntry() throws IndexedStoreException {
+ public synchronized IndexCursor findFirstEntry() throws CoreException {
IndexAnchor anchor = store.acquireAnchor(anchorAddress);
anchor.findFirstEntry(this);
anchor.release();
@@ -129,7 +131,7 @@
/**
* Sets the cursor at the last entry of an index.
*/
- public synchronized IndexCursor findLastEntry() throws IndexedStoreException {
+ public synchronized IndexCursor findLastEntry() throws CoreException {
IndexAnchor anchor = store.acquireAnchor(anchorAddress);
anchor.findLastEntry(this);
anchor.release();
@@ -144,9 +146,9 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized byte[] getKey() throws IndexedStoreException {
+ public synchronized byte[] getKey() throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
if (leafNode == null)
return null;
byte[] key = leafNode.getKey(entryNumber);
@@ -157,7 +159,7 @@
* Returns the key at the cursor as a string.
* If the cursor is at the beginning or end of the index then return null.
*/
- public synchronized String getKeyAsString() throws IndexedStoreException {
+ public synchronized String getKeyAsString() throws CoreException {
byte[] key = getKey();
if (key == null)
return null;
@@ -175,9 +177,9 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized byte[] getValue() throws IndexedStoreException {
+ public synchronized byte[] getValue() throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
if (leafNode == null)
return null;
byte[] value = leafNode.getValue(entryNumber);
@@ -188,7 +190,7 @@
* Returns the value as an object address. May return null if the cursor is at the beginning
* or end of the index.
*/
- ObjectAddress getValueAsObjectAddress() throws IndexedStoreException {
+ ObjectAddress getValueAsObjectAddress() throws CoreException {
byte[] value = getValue();
if (value == null)
return null;
@@ -199,7 +201,7 @@
* Returns the ObjectID from the value for the current cursor location.
* If the cursor is at the beginning or end of the index then return null.
*/
- public synchronized ObjectID getValueAsObjectID() throws IndexedStoreException {
+ public synchronized ObjectID getValueAsObjectID() throws CoreException {
byte[] value = getValue();
if (value == null)
return null;
@@ -210,7 +212,7 @@
* Returns the String from the value for the current cursor location.
* If the cursor is at the beginning or end of the index then return null.
*/
- public synchronized String getValueAsString() throws IndexedStoreException {
+ public synchronized String getValueAsString() throws CoreException {
byte[] value = getValue();
if (value == null)
return null;
@@ -220,18 +222,18 @@
/**
* This method returns true if the current cursor location before the first entry in the index.
*/
- public synchronized boolean isAtBeginning() throws IndexedStoreException {
+ public synchronized boolean isAtBeginning() throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
return (leafNode == null);
}
/**
* This method returns true if the current cursor location after the last entry in the index.
*/
- public synchronized boolean isAtEnd() throws IndexedStoreException {
+ public synchronized boolean isAtEnd() throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
return (leafNode == null);
}
@@ -239,9 +241,9 @@
* Returns true if the cursor is set to an entry.
* Returns false otherwise.
*/
- public synchronized boolean isSet() throws IndexedStoreException {
+ public synchronized boolean isSet() throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
return !(leafNode == null);
}
@@ -252,9 +254,9 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized boolean keyEquals(byte[] b) throws IndexedStoreException {
+ public synchronized boolean keyEquals(byte[] b) throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
if (leafNode == null)
return false;
byte[] key = leafNode.getKey(entryNumber);
@@ -273,7 +275,7 @@
* Compares a String to the key in the cursor and
* returns true if the String is equal to the key at the entry in the cursor.
*/
- public synchronized boolean keyEquals(String s) throws IndexedStoreException {
+ public synchronized boolean keyEquals(String s) throws CoreException {
return keyEquals(Convert.toUTF8(s));
}
@@ -281,7 +283,7 @@
* Compares an Insertable to the key in the cursor and
* returns true if the String is equal to the key at the entry in the cursor.
*/
- public synchronized boolean keyEquals(Insertable anObject) throws IndexedStoreException {
+ public synchronized boolean keyEquals(Insertable anObject) throws CoreException {
return keyEquals(anObject.toByteArray());
}
@@ -293,9 +295,9 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized boolean keyMatches(byte[] b) throws IndexedStoreException {
+ public synchronized boolean keyMatches(byte[] b) throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
if (leafNode == null)
return false;
byte[] key = leafNode.getKey(entryNumber);
@@ -315,7 +317,7 @@
* returns true if the byte array is a prefix
* of the key at the entry in the cursor.
*/
- public synchronized boolean keyMatches(String s) throws IndexedStoreException {
+ public synchronized boolean keyMatches(String s) throws CoreException {
return keyMatches(Convert.toUTF8(s));
}
@@ -324,7 +326,7 @@
* returns true if the byte array is a prefix
* of the key at the entry in the cursor.
*/
- public synchronized boolean keyMatches(Insertable anObject) throws IndexedStoreException {
+ public synchronized boolean keyMatches(Insertable anObject) throws CoreException {
return keyMatches(anObject.toByteArray());
}
@@ -337,7 +339,7 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized IndexCursor next() throws IndexedStoreException {
+ public synchronized IndexCursor next() throws CoreException {
if (isAtBeginning()) {
findFirstEntry();
} else {
@@ -351,7 +353,7 @@
* Adjusts a cursor if there is a need after a node has been split.
* If not, it just returns.
*/
- void nodeSplit() throws IndexedStoreException {
+ void nodeSplit() throws CoreException {
adjust();
}
@@ -364,7 +366,7 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized IndexCursor previous() throws IndexedStoreException {
+ public synchronized IndexCursor previous() throws CoreException {
if (isAtEnd()) {
findLastEntry();
} else {
@@ -384,7 +386,7 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized void remove() throws IndexedStoreException {
+ public synchronized void remove() throws CoreException {
removeEntry();
}
@@ -398,9 +400,9 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- void removeEntry() throws IndexedStoreException {
+ void removeEntry() throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
if (leafNode == null)
return;
ObjectAddress address = leafNode.getAddress();
@@ -425,7 +427,7 @@
/**
* Places the cursor in the "unset" state.
*/
- public synchronized void reset() throws IndexedStoreException {
+ public synchronized void reset() {
unset();
entryRemoved = false;
}
@@ -433,7 +435,7 @@
/**
* Sets the cursor to a particular entry of an index node.
*/
- void set(ObjectAddress leafNodeAddress, int entryNumber) throws IndexedStoreException {
+ void set(ObjectAddress leafNodeAddress, int entryNumber) throws CoreException {
unset();
if (leafNodeAddress.isNull())
return;
@@ -449,7 +451,7 @@
/**
* Places the cursor in the "unset" state.
*/
- private void unset() throws IndexedStoreException {
+ private void unset() {
if (leafNode != null) {
leafNode.removeCursor(this);
leafNode.release();
@@ -464,11 +466,11 @@
* If the cursor is at the beginning or end of the index then do nothing.
* Returns true if the value is set, false otherwise.
*/
- void updateEntry(byte[] b) throws IndexedStoreException {
+ void updateEntry(byte[] b) throws CoreException {
if (entryRemoved)
- throw new IndexedStoreException(IndexedStoreException.EntryRemoved);
+ throw Policy.exception("indexedStore.entryRemoved"); //$NON-NLS-1$
if (b.length > 2048)
- throw new IndexedStoreException(IndexedStoreException.EntryValueLengthError);
+ throw Policy.exception("indexedStore.entryValueLengthError"); //$NON-NLS-1$
if (leafNode == null)
return;
leafNode.updateValueAt(entryNumber, b);
@@ -482,7 +484,7 @@
* Throws an EntryRemoved condition if the entry at which it has
* been pointing has been removed by another cursor.
*/
- public synchronized void updateValue(byte[] b) throws IndexedStoreException {
+ public synchronized void updateValue(byte[] b) throws CoreException {
updateEntry(b);
}
@@ -490,7 +492,7 @@
* Updates the value of the index entry at the cursor.
* If the cursor is at the beginning or end of the index then do nothing.
*/
- public synchronized void updateValue(String s) throws IndexedStoreException {
+ public synchronized void updateValue(String s) throws CoreException {
updateValue(Convert.toUTF8(s));
}
@@ -498,7 +500,7 @@
* Updates the value of the index entry at the cursor.
* If the cursor is at the beginning or end of the index then do nothing.
*/
- public synchronized void updateValue(Insertable anObject) throws IndexedStoreException {
+ public synchronized void updateValue(Insertable anObject) throws CoreException {
updateValue(anObject.toByteArray());
}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexNode.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexNode.java
index fce634f..aa3ca3d 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexNode.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexNode.java
@@ -11,6 +11,8 @@
package org.eclipse.core.internal.indexing;
import java.util.HashSet;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
class IndexNode extends IndexedStoreObject {
@@ -56,7 +58,7 @@
/**
* Reconstructs a node from a field.
*/
- IndexNode(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ IndexNode(Field f, ObjectStore store, ObjectAddress address) throws CoreException {
super(f, store, address);
}
@@ -105,7 +107,7 @@
/**
* Compares the key at a particular entry to a byte array.
*/
- private int compareEntryToKey(int entryNumber, byte[] key) throws IndexedStoreException {
+ private int compareEntryToKey(int entryNumber, byte[] key) {
Field keyField = new Field(key);
Field entryKeyField = getKeyField(entryNumber);
return entryKeyField.compareTo(keyField);
@@ -114,7 +116,7 @@
/**
* Compresses the space in the entries area of the node.
*/
- private void compress() throws IndexedStoreException {
+ private void compress() {
/* some preliminaries */
int entriesLength = entriesField.length();
@@ -139,7 +141,7 @@
* Compresses the space in the entries area of the node if the free space block
* is smaller than the given threshold.
*/
- private void compress(int threshold) throws IndexedStoreException {
+ private void compress(int threshold) {
int entriesLength = entriesField.length();
int descriptorBlockSize = numberOfEntries * DescriptorLength;
int freeBlockSize = entriesLength - (descriptorBlockSize + usedSpaceMax);
@@ -205,7 +207,7 @@
/**
* Causes the node to remove its children from the store.
*/
- void destroyChildren() throws IndexedStoreException {
+ void destroyChildren() throws CoreException {
if (!isLeaf()) {
for (int i = 0; i < numberOfEntries; i++) {
ObjectAddress childNodeAddress = new ObjectAddress(getValue(i));
@@ -220,7 +222,7 @@
/**
* Places a cursor and the first entry greater than or equal to a key.
*/
- void find(byte[] key, IndexCursor cursor) throws IndexedStoreException {
+ void find(byte[] key, IndexCursor cursor) throws CoreException {
int i;
i = findLastEntryLT(key);
if (isLeaf()) {
@@ -241,7 +243,7 @@
/**
* Places a cursor at the first entry of a node.
*/
- void findFirstEntry(IndexCursor cursor) throws IndexedStoreException {
+ void findFirstEntry(IndexCursor cursor) throws CoreException {
if (numberOfEntries == 0) {
cursor.reset();
} else if (!isLeaf()) {
@@ -256,7 +258,7 @@
/**
* Returns the index of the first entry greater than a key.
*/
- private int findFirstEntryGT(byte[] key) throws IndexedStoreException {
+ private int findFirstEntryGT(byte[] key) {
int lo = 0;
int hi = numberOfEntries - 1;
while (lo <= hi) {
@@ -274,7 +276,7 @@
/**
* Places a cursor at the last entry of a node.
*/
- void findLastEntry(IndexCursor cursor) throws IndexedStoreException {
+ void findLastEntry(IndexCursor cursor) throws CoreException {
if (numberOfEntries == 0) {
cursor.reset();
return;
@@ -292,7 +294,7 @@
/**
* Returns the index of the last entry less than a key.
*/
- private int findLastEntryLT(byte[] key) throws IndexedStoreException {
+ private int findLastEntryLT(byte[] key) {
int lo = 0;
int hi = numberOfEntries - 1;
Field keyField = new Field(key);
@@ -392,7 +394,7 @@
/**
* Returns the number of nodes in this subtree (this one plus all descendants).
*/
- int getNumberOfNodes() throws IndexedStoreException {
+ int getNumberOfNodes() throws CoreException {
if (isLeaf())
return 1;
int sum = 0;
@@ -452,7 +454,7 @@
* Implementation Note: Cannot use an iterator over the cursor set because
* notification of an insert may remove the cursor being notified from the cursor set.
*/
- void insertEntry(byte[] key, byte[] value) throws IndexedStoreException {
+ void insertEntry(byte[] key, byte[] value) throws CoreException {
int i = findFirstEntryGT(key);
if (isLeaf()) {
insertEntryBefore(i, key, value);
@@ -484,7 +486,7 @@
* non-leaf node then the value is the address of a child. That child's parent address
* will be updated if that (key, value) is to be inserted into a new node.
*/
- private void insertEntryBefore(int i, byte[] key, byte[] value) throws IndexedStoreException {
+ private void insertEntryBefore(int i, byte[] key, byte[] value) throws CoreException {
Field entries = entriesField;
int entriesLength = entries.length();
int keyValueLength = key.length + value.length;
@@ -541,7 +543,7 @@
/**
* Inserts a child address into a non-leaf node. This may result in this node splitting.
*/
- private void insertKeyForChild(ObjectAddress childAddress, byte[] key) throws IndexedStoreException {
+ private void insertKeyForChild(ObjectAddress childAddress, byte[] key) throws CoreException {
int i = findFirstEntryGT(key);
insertEntryBefore(i, key, childAddress.toByteArray());
if (i == 0 && !parentAddress.isNull()) {
@@ -567,7 +569,7 @@
* Places the contents of the buffer into the fields.
* Subclasses should implement and call super.
*/
- protected void extractValues(Field f) throws ObjectStoreException {
+ protected void extractValues(Field f) throws CoreException {
super.extractValues(f);
anchorAddress = new ObjectAddress(f.get(AnchorAddress));
parentAddress = new ObjectAddress(f.get(ParentAddress));
@@ -591,7 +593,7 @@
* Removes the descriptor and key/value pair at the entry number given. This may
* result in the node becoming empty. The caller will need to take steps to plan for this.
*/
- void removeEntry(int i) throws IndexedStoreException {
+ void removeEntry(int i) throws CoreException {
/* remove the (key,value) entry */
byte[] key = getKey(i);
@@ -629,7 +631,7 @@
/**
* Removes a child node address reference from a non-leaf node.
*/
- private void removeKeyForChild(ObjectAddress childAddress) throws IndexedStoreException {
+ private void removeKeyForChild(ObjectAddress childAddress) throws CoreException {
Field childAddressField = new Field(childAddress);
int i = 0;
while (i < numberOfEntries) {
@@ -681,12 +683,12 @@
* cause a parent node to split as well. Splits eventually propagate to the root node, cause it
* to split and a new root node to be created.
*/
- private ObjectAddress split() throws IndexedStoreException {
+ private ObjectAddress split() throws CoreException {
/* Nodes can only be split if there are at least 2 entries */
int n = numberOfEntries;
if (n < 2) {
- throw new IndexedStoreException(IndexedStoreException.IndexNodeNotSplit);
+ throw Policy.exception("indexedStore.indexNodeNotSplit"); //$NON-NLS-1$
}
/*
@@ -778,7 +780,7 @@
* Unlinks a node from its parent and siblings. This does not modify the current node, but
* does modify all the nodes and anchors pointing to it.
*/
- void unlink() throws IndexedStoreException {
+ void unlink() throws CoreException {
if (isRoot()) {
IndexAnchor anchor = acquireAnchor(anchorAddress);
anchor.setRootNodeAddress(ObjectAddress.Null);
@@ -805,7 +807,7 @@
* Update the key and value at this entry to a new key and value. This may result in a node split.
* The caller must be able to recognize that the node has split and compensate for that.
*/
- private void updateEntry(int i, byte[] key, byte[] value) throws IndexedStoreException {
+ private void updateEntry(int i, byte[] key, byte[] value) throws CoreException {
/*
If the node needs to be split, split it and then attempt the update again. Note that if
@@ -862,7 +864,7 @@
* Sets the key at this entry to a new key. This may result in a node split.
* The caller must be able to recognize that the node has split and compensate for that if necessary.
*/
- private void updateKeyAt(int i, byte[] key) throws IndexedStoreException {
+ private void updateKeyAt(int i, byte[] key) throws CoreException {
updateEntry(i, key, getValue(i));
}
@@ -870,7 +872,7 @@
* Updates the key of an (key,address) entry in a non-leaf node. The key must still be in order with respect
* to the other keys of the node.
*/
- private void updateKeyForChild(byte[] key, ObjectAddress childAddress, byte[] newKey) throws IndexedStoreException {
+ private void updateKeyForChild(byte[] key, ObjectAddress childAddress, byte[] newKey) throws CoreException {
Field childAddressField = new Field(childAddress.toByteArray());
int i = findLastEntryLT(key) + 1;
while (i < numberOfEntries) {
@@ -892,7 +894,7 @@
* Sets the value at this entry to a new value. This may result in a node split.
* The caller must be able to recognize that the node has split and compensate for that.
*/
- void updateValueAt(int i, byte[] value) throws IndexedStoreException {
+ void updateValueAt(int i, byte[] value) throws CoreException {
updateEntry(i, getKey(i), value);
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStore.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStore.java
index 793f6a6..af6af83 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStore.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStore.java
@@ -11,6 +11,8 @@
package org.eclipse.core.internal.indexing;
import java.util.*;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
public class IndexedStore {
@@ -41,7 +43,7 @@
/**
* Acquires an anchor.
*/
- IndexAnchor acquireAnchor(ObjectAddress address) throws IndexedStoreException {
+ IndexAnchor acquireAnchor(ObjectAddress address) throws CoreException {
return (IndexAnchor) acquireObject(address);
}
@@ -51,7 +53,7 @@
IndexedStoreContext acquireContext(ObjectAddress address) {
try {
return (IndexedStoreContext) acquireObject(address);
- } catch (IndexedStoreException e) {
+ } catch (CoreException e) {
//context couldn't be acquired - return null
return null;
}
@@ -60,19 +62,19 @@
/**
* Acquire an index node.
*/
- IndexNode acquireNode(ObjectAddress address) throws IndexedStoreException {
+ IndexNode acquireNode(ObjectAddress address) throws CoreException {
return (IndexNode) acquireObject(address);
}
/**
* Acquires an object.
*/
- private StoredObject acquireObject(ObjectAddress address) throws IndexedStoreException {
+ private StoredObject acquireObject(ObjectAddress address) throws CoreException {
StoredObject object;
try {
object = objectStore.acquireObject(address);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotAcquired, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.objectNotAcquired", e); //$NON-NLS-1$
}
return object;
}
@@ -80,7 +82,7 @@
/**
* Acquires a Binary Object.
*/
- BinarySmallObject acquireBinarySmallObject(ObjectAddress address) throws IndexedStoreException {
+ BinarySmallObject acquireBinarySmallObject(ObjectAddress address) throws CoreException {
return (BinarySmallObject) acquireObject(address);
}
@@ -88,7 +90,7 @@
* Checks to see if the metadata stored in the object store matches that expected by this
* code. If not, a conversion is necessary.
*/
- private void checkMetadata() throws IndexedStoreException {
+ private void checkMetadata() throws CoreException {
Buffer metadata = getMetadataArea(MetadataID);
Field versionField = metadata.getField(0, 4);
int version = versionField.getInt();
@@ -106,7 +108,7 @@
/**
* Closes the store. This is required to free the underlying file.
*/
- public synchronized void close() throws IndexedStoreException {
+ public synchronized void close() throws CoreException {
if (name == null)
return;//already closed
try {
@@ -115,19 +117,19 @@
objectDirectoryCursor.close();
if (indexDirectoryCursor != null)
indexDirectoryCursor.close();
- } catch (IndexedStoreException e) {
+ } catch (CoreException e) {
//make sure the file gets closed no matter what
try {
objectStore.close();
- } catch (ObjectStoreException e2) {
+ } catch (CoreException e2) {
//ignore this and rethrow the underlying exception
}
throw e;
}
try {
objectStore.close();
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.StoreNotClosed, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.storeNotClosed", e); //$NON-NLS-1$
}
registry.remove(name);
name = null;
@@ -139,11 +141,11 @@
indexDirectoryCursor = null;
}
- public synchronized void commit() throws IndexedStoreException {
+ public synchronized void commit() throws CoreException {
try {
objectStore.commit();
} catch (Exception e) {
- throw new IndexedStoreException(IndexedStoreException.StoreNotCommitted, e);
+ throw Policy.exception("indexedStore.storeNotCommitted", e); //$NON-NLS-1$
}
}
@@ -151,14 +153,14 @@
* Converts the store from a previous to the current version.
* No conversions are yet defined.
*/
- private void convert(int fromVersion) throws IndexedStoreException {
- throw new IndexedStoreException(IndexedStoreException.StoreNotConverted);
+ private void convert(int fromVersion) throws CoreException {
+ throw Policy.exception("indexedStore.storeNotConverted"); //$NON-NLS-1$
}
/**
* Creates and initializes an IndexedStore.
*/
- public static synchronized void create(String name) throws IndexedStoreException {
+ public static synchronized void create(String name) throws CoreException {
ObjectStore store = new ObjectStore(new IndexedStoreObjectPolicy());
try {
ObjectStore.create(name);
@@ -177,22 +179,22 @@
} catch (Exception e1) {
try {
store.close();
- } catch (ObjectStoreException e2) {
+ } catch (CoreException e2) {
//real exception thrown below
}
ObjectStore.delete(name);
- throw new IndexedStoreException(IndexedStoreException.StoreNotCreated, e1);
+ throw Policy.exception("indexedStore.storeNotCreated", e1); //$NON-NLS-1$
}
}
/**
* Creates an Index with the given name.
*/
- public synchronized Index createIndex(String indexName) throws IndexedStoreException {
+ public synchronized Index createIndex(String indexName) throws CoreException {
Index index = null;
indexDirectoryCursor.find(indexName);
if (indexDirectoryCursor.keyMatches(indexName)) {
- throw new IndexedStoreException(IndexedStoreException.IndexExists);
+ throw Policy.exception("indexedStore.indexExists"); //$NON-NLS-1$
}
ObjectAddress address = insertObject(new IndexAnchor());
indexDirectory.insert(indexName, address.toByteArray());
@@ -203,7 +205,7 @@
/**
* Places a byte array into the store, return a new object identifier.
*/
- public synchronized ObjectID createObject(byte[] b) throws IndexedStoreException {
+ public synchronized ObjectID createObject(byte[] b) throws CoreException {
ObjectAddress address = insertObject(new BinarySmallObject(b));
ObjectID id = getNextObjectID();
objectDirectory.insert(id.toByteArray(), address.toByteArray());
@@ -213,14 +215,14 @@
/**
* Places a String into the store.
*/
- public synchronized ObjectID createObject(String s) throws IndexedStoreException {
+ public synchronized ObjectID createObject(String s) throws CoreException {
return createObject(Convert.toUTF8(s));
}
/**
* Places an Insertable into the store.
*/
- public synchronized ObjectID createObject(Insertable anObject) throws IndexedStoreException {
+ public synchronized ObjectID createObject(Insertable anObject) throws CoreException {
return createObject(anObject.toByteArray());
}
@@ -262,33 +264,33 @@
/**
* @deprecated -- use commit()
*/
- public synchronized void flush() throws IndexedStoreException {
+ public synchronized void flush() throws CoreException {
try {
objectStore.commit();
} catch (Exception e) {
- throw new IndexedStoreException(IndexedStoreException.StoreNotFlushed, e);
+ throw Policy.exception("indexedStore.storeNotFlushed", e); //$NON-NLS-1$
}
}
/**
- * Returns an index given its name.
+ * Returns an index given its name, or null if no matching index was found
*/
- public synchronized Index getIndex(String indexName) throws IndexedStoreException {
+ public synchronized Index getIndex(String indexName) throws CoreException {
Index index;
byte[] key = Convert.toUTF8(indexName);
indexDirectoryCursor.find(key);
if (!indexDirectoryCursor.keyMatches(key))
- throw new IndexedStoreException(IndexedStoreException.IndexNotFound);
+ return null;
ObjectAddress address = indexDirectoryCursor.getValueAsObjectAddress();
index = new Index(this, address);
return index;
}
- private Buffer getMetadataArea(int i) throws IndexedStoreException {
+ private Buffer getMetadataArea(int i) throws CoreException {
try {
return objectStore.getMetadataArea(i);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.MetadataRequestError, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.metadataRequestError", e); //$NON-NLS-1$
}
}
@@ -302,10 +304,10 @@
/**
* Returns the next ObjectID
*/
- private ObjectID getNextObjectID() throws IndexedStoreException {
+ private ObjectID getNextObjectID() throws CoreException {
IndexedStoreContext context = acquireContext(contextAddress);
if (context == null)
- throw new IndexedStoreException(IndexedStoreException.ContextNotAvailable);
+ throw Policy.exception("indexedStore.contextNotAvailable"); //$NON-NLS-1$
long objectNumber = context.getNextObjectNumber();
context.release();
return new ObjectID(objectNumber);
@@ -314,7 +316,7 @@
/**
* Returns a byte array given its object identifier.
*/
- public synchronized byte[] getObject(ObjectID id) throws IndexedStoreException {
+ public synchronized byte[] getObject(ObjectID id) throws CoreException {
objectDirectoryCursor.find(id.toByteArray());
ObjectAddress address = objectDirectoryCursor.getValueAsObjectAddress();
BinarySmallObject object = acquireBinarySmallObject(address);
@@ -326,7 +328,7 @@
/**
* Returns an object as a string, truncated at the first null.
*/
- public synchronized String getObjectAsString(ObjectID id) throws IndexedStoreException {
+ public synchronized String getObjectAsString(ObjectID id) throws CoreException {
String s;
s = Convert.fromUTF8(getObject(id));
int i = s.indexOf(0);
@@ -345,69 +347,63 @@
/**
* Inserts a new object into my store.
*/
- ObjectAddress insertObject(StoredObject object) throws IndexedStoreException {
+ ObjectAddress insertObject(StoredObject object) throws CoreException {
try {
ObjectAddress address = objectStore.insertObject(object);
return address;
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotStored, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.objectNotStored", e); //$NON-NLS-1$
}
}
/**
* Opens the store.
*/
- public synchronized void open(String name) throws IndexedStoreException {
+ public synchronized void open(String name) throws CoreException {
if (registry.get(name) != null) {
- throw new IndexedStoreException(IndexedStoreException.StoreIsOpen);
+ throw Policy.exception("indexedStore.storeIsOpen"); //$NON-NLS-1$
}
if (!exists(name))
create(name);
- try {
- objectStore = new ObjectStore(new IndexedStoreObjectPolicy());
- objectStore.open(name);
- checkMetadata();
- contextAddress = ContextAddress10;
- IndexedStoreContext context = acquireContext(contextAddress);
- if (context == null) {
- contextAddress = ContextAddress11;
- context = acquireContext(contextAddress);
- }
- if (context == null) {
- throw new IndexedStoreException(IndexedStoreException.StoreFormatError);
- }
- indexDirectoryAddress = context.getIndexDirectoryAddress();
- objectDirectoryAddress = context.getObjectDirectoryAddress();
- context.release();
- indexDirectory = new Index(this, indexDirectoryAddress);
- indexDirectoryCursor = indexDirectory.open();
- objectDirectory = new Index(this, objectDirectoryAddress);
- objectDirectoryCursor = objectDirectory.open();
- this.name = name;
- registry.put(name, this);
- } catch (IndexedStoreException e) {
- throw e;
- } catch (Exception e) {
- throw new IndexedStoreException(IndexedStoreException.GenericError, e);
+ objectStore = new ObjectStore(new IndexedStoreObjectPolicy());
+ objectStore.open(name);
+ checkMetadata();
+ contextAddress = ContextAddress10;
+ IndexedStoreContext context = acquireContext(contextAddress);
+ if (context == null) {
+ contextAddress = ContextAddress11;
+ context = acquireContext(contextAddress);
}
+ if (context == null) {
+ throw Policy.exception("indexedStore.storeFormatError"); //$NON-NLS-1$
+ }
+ indexDirectoryAddress = context.getIndexDirectoryAddress();
+ objectDirectoryAddress = context.getObjectDirectoryAddress();
+ context.release();
+ indexDirectory = new Index(this, indexDirectoryAddress);
+ indexDirectoryCursor = indexDirectory.open();
+ objectDirectory = new Index(this, objectDirectoryAddress);
+ objectDirectoryCursor = objectDirectory.open();
+ this.name = name;
+ registry.put(name, this);
}
- private void putMetadataArea(int i, Buffer b) throws IndexedStoreException {
+ private void putMetadataArea(int i, Buffer b) throws CoreException {
try {
objectStore.putMetadataArea(i, b);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.MetadataRequestError, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.metadataRequestError", e); //$NON-NLS-1$
}
}
/**
* Destroys an Index given its name.
*/
- public synchronized void removeIndex(String indexName) throws IndexedStoreException {
+ public synchronized void removeIndex(String indexName) throws CoreException {
byte[] key = Convert.toUTF8(indexName);
indexDirectoryCursor.find(key);
if (!indexDirectoryCursor.keyMatches(key)) {
- throw new IndexedStoreException(IndexedStoreException.IndexNotFound);
+ throw Policy.exception("indexedStore.indexNotFound"); //$NON-NLS-1$
}
ObjectAddress address = indexDirectoryCursor.getValueAsObjectAddress();
IndexAnchor anchor = acquireAnchor(address);
@@ -420,44 +416,40 @@
/**
* Removes an object from my store.
*/
- void removeObject(ObjectAddress address) throws IndexedStoreException {
+ void removeObject(ObjectAddress address) throws CoreException {
try {
objectStore.removeObject(address);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotRemoved, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.objectNotRemoved", e); //$NON-NLS-1$
}
}
/**
* Removes the object identified by id from the store.
*/
- public synchronized void removeObject(ObjectID id) throws IndexedStoreException {
+ public synchronized void removeObject(ObjectID id) throws CoreException {
byte[] key = id.toByteArray();
objectDirectoryCursor.find(key);
if (!objectDirectoryCursor.keyMatches(key)) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotFound);
+ Policy.exception("indexedStore.objectNotFound"); //$NON-NLS-1$
}
ObjectAddress address = objectDirectoryCursor.getValueAsObjectAddress();
objectDirectoryCursor.remove();
removeObject(address);
}
- public synchronized void rollback() throws IndexedStoreException {
- try {
- objectStore.rollback();
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.StoreNotRolledBack, e);
- }
+ public synchronized void rollback() {
+ objectStore.rollback();
}
/**
* Replaces the contents of the object identified by "id" with the byte array "b".
*/
- public synchronized void updateObject(ObjectID id, byte[] b) throws IndexedStoreException {
+ public synchronized void updateObject(ObjectID id, byte[] b) throws CoreException {
byte[] key = id.toByteArray();
objectDirectoryCursor.find(key);
if (!objectDirectoryCursor.keyMatches(key)) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotFound);
+ Policy.exception("indexedStore.objectNotFound"); //$NON-NLS-1$
}
ObjectAddress oldAddress = objectDirectoryCursor.getValueAsObjectAddress();
ObjectAddress newAddress = insertObject(new BinarySmallObject(b));
@@ -468,14 +460,14 @@
/**
* Updates an object with a String.
*/
- public synchronized void updateObject(ObjectID id, String s) throws IndexedStoreException {
+ public synchronized void updateObject(ObjectID id, String s) throws CoreException {
updateObject(id, Convert.toUTF8(s));
}
/**
* Updates an object with an Insertable.
*/
- public synchronized void updateObject(ObjectID id, Insertable anObject) throws IndexedStoreException {
+ public synchronized void updateObject(ObjectID id, Insertable anObject) throws CoreException {
updateObject(id, anObject.toByteArray());
}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java
index 44d3017..3d3bfe5 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.runtime.CoreException;
+
class IndexedStoreContext extends IndexedStoreObject {
public static final int SIZE = 32;
@@ -53,7 +55,7 @@
/**
* Constructs a context from a field read from the store.
*/
- IndexedStoreContext(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ IndexedStoreContext(Field f, ObjectStore store, ObjectAddress address) throws CoreException {
super(f, store, address);
}
@@ -71,7 +73,7 @@
* Places the contents of the buffer into the fields.
* Subclasses should implement and call super.
*/
- protected void extractValues(Field contents) throws ObjectStoreException {
+ protected void extractValues(Field contents) throws CoreException {
super.extractValues(contents);
setFields(contents);
openNumber = openNumberField.getInt();
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreException.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreException.java
deleted file mode 100644
index fd6d65e..0000000
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreException.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.indexing;
-
-import org.eclipse.core.internal.utils.Policy;
-
-public class IndexedStoreException extends StoreException {
-
- public static final int GenericError = 0;
- public static final int EntryKeyLengthError = 1;
- public static final int EntryNotRemoved = 2;
- public static final int EntryValueLengthError = 3;
- public static final int EntryValueNotUpdated = 4;
- public static final int IndexNodeNotRetrieved = 5;
- public static final int IndexNodeNotStored = 6;
- public static final int IndexNodeNotSplit = 7;
- public static final int IndexNodeNotCreated = 8;
- public static final int IndexExists = 9;
- public static final int IndexNotCreated = 10;
- public static final int IndexNotFound = 11;
- public static final int IndexNotRemoved = 12;
- public static final int ObjectExists = 13;
- public static final int ObjectNotAcquired = 14;
- public static final int ObjectNotCreated = 15;
- public static final int ObjectNotFound = 16;
- public static final int ObjectNotReleased = 17;
- public static final int ObjectNotRemoved = 18;
- public static final int ObjectNotUpdated = 19;
- public static final int ObjectNotStored = 20;
- public static final int ObjectTypeError = 21;
- public static final int StoreEmpty = 22;
- public static final int StoreFormatError = 23;
- public static final int StoreNotCreated = 24;
- public static final int StoreNotOpen = 25;
- public static final int StoreNotClosed = 26;
- public static final int StoreNotFlushed = 27;
- public static final int StoreNotOpened = 28;
- public static final int StoreNotReadWrite = 29;
- public static final int ContextNotAvailable = 30;
- public static final int ObjectIDInvalid = 31;
- public static final int MetadataRequestError = 32;
- public static final int EntryRemoved = 33;
- public static final int StoreNotConverted = 34;
- public static final int StoreIsOpen = 35;
- public static final int StoreNotCommitted = 36;
- public static final int StoreNotRolledBack = 37;
-
- public static String[] messages = new String[40];
-
- static {
- initializeMessages();
- }
-
- public int id = GenericError;
-
- /**
- * IndexedStoreException constructor comment.
- */
- public IndexedStoreException(int id) {
- super(messages[id]);
- this.id = id;
- }
-
- /**
- * IndexedStoreException constructor comment.
- */
- public IndexedStoreException(int id, Throwable e) {
- super(messages[id], e);
- this.id = id;
- }
-
- /**
- * IndexedStoreException constructor comment.
- */
- public IndexedStoreException(String s) {
- super(s);
- id = GenericError;
- }
-
- /**
- * Initializes the messages at class load time.
- */
- private static void initializeMessages() {
- messages[GenericError] = bind("indexedStore.genericError"); //$NON-NLS-1$
- messages[EntryKeyLengthError] = bind("indexedStore.entryKeyLengthError"); //$NON-NLS-1$
- messages[EntryNotRemoved] = bind("indexedStore.entryNotRemoved"); //$NON-NLS-1$
- messages[EntryValueLengthError] = bind("indexedStore.entryValueLengthError"); //$NON-NLS-1$
- messages[EntryValueNotUpdated] = bind("indexedStore.entryValueNotUpdated"); //$NON-NLS-1$
- messages[IndexNodeNotRetrieved] = bind("indexedStore.indexNodeNotRetrieved"); //$NON-NLS-1$
- messages[IndexNodeNotStored] = bind("indexedStore.indexNodeNotStored"); //$NON-NLS-1$
- messages[IndexNodeNotSplit] = bind("indexedStore.indexNodeNotSplit"); //$NON-NLS-1$
- messages[IndexNodeNotCreated] = bind("indexedStore.indexNodeNotCreated"); //$NON-NLS-1$
- messages[IndexExists] = bind("indexedStore.indexExists"); //$NON-NLS-1$
- messages[IndexNotCreated] = bind("indexedStore.indexNotCreated"); //$NON-NLS-1$
- messages[IndexNotFound] = bind("indexedStore.indexNotFound"); //$NON-NLS-1$
- messages[IndexNotRemoved] = bind("indexedStore.indexNotRemoved"); //$NON-NLS-1$
- messages[ObjectExists] = bind("indexedStore.objectExists"); //$NON-NLS-1$
- messages[ObjectNotAcquired] = bind("indexedStore.objectNotAcquired"); //$NON-NLS-1$
- messages[ObjectNotCreated] = bind("indexedStore.objectNotCreated"); //$NON-NLS-1$
- messages[ObjectNotFound] = bind("indexedStore.objectNotFound"); //$NON-NLS-1$
- messages[ObjectNotReleased] = bind("indexedStore.objectNotReleased"); //$NON-NLS-1$
- messages[ObjectNotRemoved] = bind("indexedStore.objectNotRemoved"); //$NON-NLS-1$
- messages[ObjectNotUpdated] = bind("indexedStore.objectNotUpdated"); //$NON-NLS-1$
- messages[ObjectNotStored] = bind("indexedStore.objectNotStored"); //$NON-NLS-1$
- messages[ObjectTypeError] = bind("indexedStore.objectTypeError"); //$NON-NLS-1$
- messages[StoreEmpty] = bind("indexedStore.storeEmpty"); //$NON-NLS-1$
- messages[StoreFormatError] = bind("indexedStore.storeFormatError"); //$NON-NLS-1$
- messages[StoreNotCreated] = bind("indexedStore.storeNotCreated"); //$NON-NLS-1$
- messages[StoreNotOpen] = bind("indexedStore.storeNotOpen"); //$NON-NLS-1$
- messages[StoreNotClosed] = bind("indexedStore.storeNotClosed"); //$NON-NLS-1$
- messages[StoreNotFlushed] = bind("indexedStore.storeNotFlushed"); //$NON-NLS-1$
- messages[StoreNotOpened] = bind("indexedStore.storeNotOpened"); //$NON-NLS-1$
- messages[StoreNotReadWrite] = bind("indexedStore.storeNotReadWrite"); //$NON-NLS-1$
- messages[ContextNotAvailable] = bind("indexedStore.contextNotAvailable"); //$NON-NLS-1$
- messages[ObjectIDInvalid] = bind("indexedStore.objectIDInvalid"); //$NON-NLS-1$
- messages[MetadataRequestError] = bind("indexedStore.metadataRequestError"); //$NON-NLS-1$
- messages[EntryRemoved] = bind("indexedStore.entryRemoved"); //$NON-NLS-1$
- messages[StoreNotConverted] = bind("indexedStore.storeNotConverted"); //$NON-NLS-1$
- messages[StoreIsOpen] = bind("indexedStore.storeIsOpen"); //$NON-NLS-1$
- messages[StoreNotCommitted] = bind("indexedStore.storeNotCommitted"); //$NON-NLS-1$
- messages[StoreNotRolledBack] = bind("indexedStore.storeNotRolledBack"); //$NON-NLS-1$
- }
-
- private static String bind(String name) {
- return Policy.bind(name);
- }
-
- /**
- * Creates a printable representation of this exception.
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer(50);
- buffer.append("IndexedStoreException:"); //$NON-NLS-1$
- buffer.append(getMessage());
- if (wrappedException != null) {
- buffer.append("\n"); //$NON-NLS-1$
- buffer.append(wrappedException.toString());
- }
- return buffer.toString();
- }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java
index 3ea6313..950866f 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
abstract class IndexedStoreObject extends StoredObject {
public IndexedStoreObject() {
@@ -20,33 +23,33 @@
* Constructs an object from bytes that came from the store.
* These bytes include the 2 byte type field.
*/
- public IndexedStoreObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ public IndexedStoreObject(Field f, ObjectStore store, ObjectAddress address) throws CoreException {
super(f, store, address);
}
/**
* Acquires an anchor.
*/
- protected final IndexAnchor acquireAnchor(ObjectAddress address) throws IndexedStoreException {
+ protected final IndexAnchor acquireAnchor(ObjectAddress address) throws CoreException {
return (IndexAnchor) acquireObject(address);
}
/**
* Acquires a node.
*/
- protected final IndexNode acquireNode(ObjectAddress address) throws IndexedStoreException {
+ protected final IndexNode acquireNode(ObjectAddress address) throws CoreException {
return (IndexNode) acquireObject(address);
}
/**
* Acquires an object.
*/
- protected final StoredObject acquireObject(ObjectAddress address) throws IndexedStoreException {
+ protected final StoredObject acquireObject(ObjectAddress address) throws CoreException {
StoredObject object;
try {
object = store.acquireObject(address);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotAcquired, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.objectNotAcquired", e); //$NON-NLS-1$
}
return object;
}
@@ -54,34 +57,30 @@
/**
* Inserts a new object into my store. Subclasses must not override.
*/
- protected final ObjectAddress insertObject(StoredObject object) throws IndexedStoreException {
+ protected final ObjectAddress insertObject(StoredObject object) throws CoreException {
try {
ObjectAddress address = store.insertObject(object);
return address;
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotStored, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.objectNotStored", e); //$NON-NLS-1$
}
}
/**
* Releases this object. Subclasses must not override.
*/
- protected final void release() throws IndexedStoreException {
- try {
- store.releaseObject(this);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotReleased, e);
- }
+ protected final void release() {
+ store.releaseObject(this);
}
/**
* Removes an object from my store. Subclasses must not override.
*/
- protected final void removeObject(ObjectAddress address) throws IndexedStoreException {
+ protected final void removeObject(ObjectAddress address) throws CoreException {
try {
store.removeObject(address);
- } catch (ObjectStoreException e) {
- throw new IndexedStoreException(IndexedStoreException.ObjectNotRemoved, e);
+ } catch (CoreException e) {
+ throw Policy.exception("indexedStore.objectNotRemoved", e); //$NON-NLS-1$
}
}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java
index af1451e..bd13b31 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
public class IndexedStoreObjectPolicy extends AbstractObjectPolicy {
/**
@@ -24,7 +27,7 @@
* used to create the internal structure of the object. The field begins with a
* two byte type code that is used to determine the type of object to create.
*/
- public StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ public StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws CoreException {
int offset = StoredObject.TYPE_OFFSET;
int length = StoredObject.TYPE_LENGTH;
int type = field.subfield(offset, length).getInt();
@@ -43,7 +46,7 @@
object = new BinarySmallObject(field, store, address);
break;
default :
- throw new ObjectStoreException(ObjectStoreException.ObjectTypeFailure);
+ throw Policy.exception("objectStore.objectTypeFailure"); //$NON-NLS-1$
}
return object;
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Log.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Log.java
index 0e149b7..1a2cb72 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Log.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/Log.java
@@ -11,6 +11,9 @@
package org.eclipse.core.internal.indexing;
import java.io.*;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
class Log {
@@ -19,11 +22,11 @@
* argument is the name of the page store for which this log will
* be created.
*/
- static void create(String storeName) throws PageStoreException {
+ static void create(String storeName) throws CoreException {
try {
new RandomAccessFile(name(storeName), "rw").close(); //$NON-NLS-1$
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.LogCreateFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.logCreateFailure"), e));//$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogReader.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogReader.java
index 53d9374..796488e 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogReader.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogReader.java
@@ -14,18 +14,21 @@
import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
class LogReader {
+ protected byte[] b4;
protected FileInputStream in;
- protected PageStore store;
- protected byte[] b4;
protected byte[] pageBuffer;
+ protected PageStore store;
/**
* Returns the Hashmap of the modified pages.
*/
- public static Map getModifiedPages(PageStore store) throws PageStoreException {
+ public static Map getModifiedPages(PageStore store) throws CoreException {
LogReader reader = new LogReader(store);
Map modifiedPages = null;
try {
@@ -43,17 +46,11 @@
this.b4 = new byte[4];
}
- /**
- * Open a log for reading.
- */
- protected void open(PageStore pageStore) throws PageStoreException {
- String name = pageStore.getName();
- if (!Log.exists(name))
- return;
+ protected int bytesAvailable() throws CoreException {
try {
- in = new FileInputStream(Log.name(name));
+ return in.available();
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.LogOpenFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.logReadFailure"), e));//$NON-NLS-1$
}
}
@@ -73,7 +70,7 @@
/**
* Returns the Hashmap of modified pages read from the log.
*/
- protected Map getModifiedPages() throws PageStoreException {
+ protected Map getModifiedPages() throws CoreException {
Map modifiedPages = new TreeMap();
if (in == null)
return modifiedPages;
@@ -94,19 +91,25 @@
return modifiedPages;
}
- public void readBuffer(byte[] buffer) throws PageStoreException {
+ /**
+ * Open a log for reading.
+ */
+ protected void open(PageStore pageStore) throws CoreException {
+ String name = pageStore.getName();
+ if (!Log.exists(name))
+ return;
try {
- in.read(buffer);
+ in = new FileInputStream(Log.name(name));
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.LogReadFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.logOpenFailure"), e));//$NON-NLS-1$
}
}
- protected int bytesAvailable() throws PageStoreException {
+ public void readBuffer(byte[] buffer) throws CoreException {
try {
- return in.available();
+ in.read(buffer);
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.LogReadFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.logReadFailure"), e));//$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogWriter.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogWriter.java
index 0ebf85c..383be08 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogWriter.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/LogWriter.java
@@ -14,6 +14,9 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
class LogWriter {
@@ -23,7 +26,7 @@
/**
* Puts the modified pages to the log file.
*/
- public static void putModifiedPages(PageStore pageStore, Map modifiedPages) throws PageStoreException {
+ public static void putModifiedPages(PageStore pageStore, Map modifiedPages) throws CoreException {
LogWriter writer = new LogWriter();
try {
writer.open(pageStore);
@@ -36,12 +39,12 @@
/**
* Opens the log.
*/
- protected void open(PageStore store) throws PageStoreException {
+ protected void open(PageStore store) throws CoreException {
this.pageStore = store;
try {
out = new FileOutputStream(Log.name(store.getName()));
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.LogOpenFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.logOpenFailure"), e));//$NON-NLS-1$
}
}
@@ -61,7 +64,7 @@
/**
* Puts the modified pages into the log.
*/
- protected void putModifiedPages(Map modifiedPages) throws PageStoreException {
+ protected void putModifiedPages(Map modifiedPages) throws CoreException {
Buffer b4 = new Buffer(4);
byte[] pageBuffer = new byte[Page.SIZE];
int numberOfPages = modifiedPages.size();
@@ -78,7 +81,7 @@
write(pageBuffer);
}
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.LogWriteFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.logWriteFailure"), e));//$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectHeader.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectHeader.java
index 9e1d427..dc6a00a 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectHeader.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectHeader.java
@@ -10,41 +10,43 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
class ObjectHeader implements Insertable {
+ private static final int HeaderTagOffset = 0;
+ private static final int HeaderTagValue = 0xFFFF;
+ private static final int ObjectLengthOffset = 2;
public static final int SIZE = 4;
- private static final int HeaderTagValue = 0xFFFF;
- private static final int HeaderTagOffset = 0;
- private static final int ObjectLengthOffset = 2;
private int objectLength;
/**
* ObjectHeader constructor comment.
*/
- public ObjectHeader(byte[] buffer) throws ObjectStoreException {
+ public ObjectHeader(byte[] buffer) throws CoreException {
if (buffer.length != SIZE)
throw new IllegalArgumentException();
Buffer buf = new Buffer(buffer);
- if (buf.getUInt(HeaderTagOffset, 2) != HeaderTagValue) {
- throw new ObjectStoreException(ObjectStoreException.ObjectHeaderFailure);
- }
+ if (buf.getUInt(HeaderTagOffset, 2) != HeaderTagValue)
+ throw Policy.exception("objectStore.objectHeaderFailure"); //$NON-NLS-1$
this.objectLength = buf.getUInt(ObjectLengthOffset, 2);
}
/**
* ObjectHeader constructor comment.
*/
+ public ObjectHeader(Field f) throws CoreException {
+ this(f.get());
+ }
+
+ /**
+ * ObjectHeader constructor comment.
+ */
public ObjectHeader(int objectLength) {
this.objectLength = objectLength;
}
- /**
- * ObjectHeader constructor comment.
- */
- public ObjectHeader(Field f) throws ObjectStoreException {
- this(f.get());
- }
-
public int getObjectLength() {
return objectLength;
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectID.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectID.java
index b614e2e..9563eda 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectID.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectID.java
@@ -10,15 +10,18 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
public class ObjectID implements Insertable {
private static final int Size = 8;
private static final int ObjectNumberOffset = 0;
private long objectNumber;
- public ObjectID(byte[] b) throws IndexedStoreException {
+ public ObjectID(byte[] b) throws CoreException {
if (b.length != Size) {
- throw new IndexedStoreException(IndexedStoreException.ObjectIDInvalid);
+ throw Policy.exception("indexedStore.objectIDInvalid"); //$NON-NLS-1$
}
Buffer buf = new Buffer(b);
objectNumber = buf.getLong(ObjectNumberOffset, 8);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectPage.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectPage.java
index f2f64bb..977c1e8 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectPage.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectPage.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.core.internal.indexing;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
+
/**
An ObjectPage is a page in a page file that contains objects. Objects are byte arrays.
An object page contains metainformation about the objects located on that page as well
@@ -90,7 +93,7 @@
/**
* This method returns the Field mapped over the object for a given object number.
*/
- public Field getObjectField(int objectNumber) throws ObjectStoreException {
+ public Field getObjectField(int objectNumber) throws CoreException {
int entryOffset = ObjectDirectoryOffset + 2 * objectNumber;
int blockOffset = pageBuffer.getUInt(entryOffset, 2);
if (blockOffset == 0)
@@ -103,12 +106,12 @@
/**
* Places an object into a page. The object must have a reservation.
*/
- public void insertObject(StoredObject object) throws ObjectStoreException {
+ public void insertObject(StoredObject object) throws CoreException {
// ensure that there is space for this object
int blockLength = object.length() + ObjectHeader.SIZE;
if (getFreeSpace() < blockLength) {
- throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure);
+ throw Policy.exception("objectStore.objectSizeFailure"); //$NON-NLS-1$
}
// make sure the slot is still empty
@@ -116,7 +119,7 @@
int entryOffset = ObjectDirectoryOffset + (objectNumber * 2);
int blockOffset = pageBuffer.getUInt(entryOffset, 2);
if (blockOffset != 0) {
- throw new ObjectStoreException(ObjectStoreException.PageVacancyFailure);
+ throw Policy.exception("objectStore.pageVacancyFailure"); //$NON-NLS-1$
}
// place the object into the object space portion of the page
@@ -139,12 +142,12 @@
* Reserves space for an object on the page. Records the reservation in the
* reservation table.
*/
- public int reserveObject(StoredObject object, ReservationTable reservations) throws ObjectStoreException {
+ public int reserveObject(StoredObject object, ReservationTable reservations) throws CoreException {
// ensure that there is space for this object, there should be since we check beforehand
int blockLength = object.length() + ObjectHeader.SIZE;
if (getFreeSpace() < blockLength) {
- throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure);
+ throw Policy.exception("objectStore.objectSizeFailure"); //$NON-NLS-1$
}
// get the reservation for this page from the table, create a new one if necessary
@@ -168,7 +171,7 @@
objectNumber = (objectNumber + 1) % MaxEntries;
}
if (blockOffset != 0) {
- throw new ObjectStoreException(ObjectStoreException.PageVacancyFailure);
+ throw Policy.exception("objectStore.pageVacancyFailure"); //$NON-NLS-1$
}
// begin the next search just after where we left off
@@ -179,13 +182,13 @@
return objectNumber;
}
- public void removeObject(int objectNumber) throws ObjectStoreException {
+ public void removeObject(int objectNumber) throws CoreException {
/* check for existence of the object to be removed */
int entryOffset = ObjectDirectoryOffset + 2 * objectNumber;
int blockOffset = pageBuffer.getUInt(entryOffset, 2);
if (blockOffset == 0)
- throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure);
+ throw Policy.exception("objectStore.objectExistenceFailure"); //$NON-NLS-1$
/* remove the object */
pageBuffer.put(entryOffset, 2, 0); // remove its offset from the object table
@@ -202,7 +205,7 @@
/**
* Updates an object value on the page. An object may not change its size.
*/
- public void updateObject(StoredObject object) throws ObjectStoreException {
+ public void updateObject(StoredObject object) throws CoreException {
int objectNumber = object.getAddress().getObjectNumber();
@@ -210,13 +213,13 @@
int entryOffset = ObjectDirectoryOffset + 2 * objectNumber;
int blockOffset = pageBuffer.getUInt(entryOffset, 2);
if (blockOffset == 0) {
- throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure);
+ throw Policy.exception("objectStore.objectExistenceFailure"); //$NON-NLS-1$
}
/* retrieve the header and check the size */
ObjectHeader header = new ObjectHeader(pageBuffer.get(blockOffset, ObjectHeader.SIZE));
if (header.getObjectLength() != object.length()) {
- throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure);
+ throw Policy.exception("objectStore.objectSizeFailure"); //$NON-NLS-1$
}
/* update in place */
@@ -232,7 +235,7 @@
* of the other parameters of the page remain the same. Resets the number of
* used entries to fix an old bug.
*/
- private void compress() throws ObjectStoreException {
+ private void compress() throws CoreException {
Buffer temp = new Buffer(SIZE);
int newBlockOffset = ObjectSpaceOffset;
int entryOffset = ObjectDirectoryOffset;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStore.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStore.java
index 777a4b6..b1e571c 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStore.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStore.java
@@ -11,6 +11,8 @@
package org.eclipse.core.internal.indexing;
import java.util.*;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.runtime.CoreException;
public class ObjectStore implements Observer {
@@ -32,11 +34,11 @@
/**
* Creates a repository for the pathname.
*/
- public static void create(String path) throws ObjectStoreException {
+ public static void create(String path) throws CoreException {
try {
PageStore.create(path);
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.StoreCreateFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.storeCreateFailure", e); //$NON-NLS-1$
}
}
@@ -65,12 +67,12 @@
/**
* Opens an object store.
*/
- public void open(String name) throws ObjectStoreException {
+ public void open(String name) throws CoreException {
try {
pageStore = new PageStore(pagePolicy);
pageStore.open(name);
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.StoreOpenFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.storeOpenFailure", e); //$NON-NLS-1$
}
checkMetadata();
acquiredObjects = new HashMap();
@@ -83,10 +85,10 @@
/**
* Closes the object store.
*/
- public void close() throws ObjectStoreException {
+ public void close() throws CoreException {
try {
commit();
- } catch (ObjectStoreException e) {
+ } catch (CoreException e) {
//make sure the page store file gets closed no matter what
pageStore.close(false);
throw e;
@@ -103,19 +105,19 @@
reservations = null;
}
- public Buffer getMetadataArea(int i) throws ObjectStoreException {
+ public Buffer getMetadataArea(int i) throws CoreException {
try {
return new Buffer(pageStore.readMetadataArea(i));
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.MetadataRequestFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.metadataRequestFailure", e); //$NON-NLS-1$
}
}
- public void putMetadataArea(int i, Buffer buffer) throws ObjectStoreException {
+ public void putMetadataArea(int i, Buffer buffer) throws CoreException {
try {
pageStore.writeMetadataArea(i, buffer.getByteArray());
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.MetadataRequestFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.metadataRequestFailure", e); //$NON-NLS-1$
}
}
@@ -123,7 +125,7 @@
* Checks to see if the metadata stored in the object store matches that expected by this
* code. If not, a conversion is necessary.
*/
- protected void checkMetadata() throws ObjectStoreException {
+ protected void checkMetadata() throws CoreException {
Buffer metadata = getMetadataArea(ObjectStoreMetadataAreaID);
Field versionField = metadata.getField(0, 4);
int objectStoreVersion = versionField.getInt();
@@ -142,14 +144,14 @@
* Converts the object store from a previous to the current version.
* No conversions are yet defined.
*/
- protected void convert(int fromVersion) throws ObjectStoreException {
- throw new ObjectStoreException(ObjectStoreException.StoreConversionFailure);
+ protected void convert(int fromVersion) throws CoreException {
+ throw Policy.exception("objectStore.storeConversionFailure"); //$NON-NLS-1$
}
/**
* Commits the modified object collection to the underlying page store.
*/
- public void commit() throws ObjectStoreException {
+ public void commit() throws CoreException {
for (Iterator z = acquiredObjects.values().iterator(); z.hasNext();) {
StoredObject object = (StoredObject) z.next();
object.notifyObservers();
@@ -181,15 +183,15 @@
reservations.clear();
try {
pageStore.commit();
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.PageWriteFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.pageWriteFailure", e); //$NON-NLS-1$
}
}
/**
* Rollback the modified objects collection.
*/
- public void rollback() throws ObjectStoreException {
+ public void rollback() {
modifiedObjects.clear();
reservations.clear();
phantoms.clear();
@@ -213,9 +215,9 @@
* Returns the StoredObject at a given address. This registers the store as an
* observer of changes to this object.
*/
- public StoredObject acquireObject(ObjectAddress address) throws ObjectStoreException {
+ public StoredObject acquireObject(ObjectAddress address) throws CoreException {
if (phantoms.contains(address)) {
- throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure);
+ throw Policy.exception("objectStore.objectExistenceFailure"); //$NON-NLS-1$
}
StoredObject object = (StoredObject) acquiredObjects.get(address);
if (object == null) {
@@ -228,9 +230,9 @@
try {
Field f = page.getObjectField(address.getObjectNumber());
if (f == null)
- throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure);
+ throw Policy.exception("objectStore.objectExistenceFailure"); //$NON-NLS-1$
object = objectPolicy.createObject(f, this, address);
- } catch (ObjectStoreException e) {
+ } catch (CoreException e) {
page.release();
throw e;
}
@@ -250,7 +252,7 @@
* the standard cache. Objects in the standard cache always maintain a
* reference count of 0.
*/
- public void releaseObject(StoredObject object) throws ObjectStoreException {
+ public void releaseObject(StoredObject object) {
object.removeReference();
if (object.hasReferences())
return;
@@ -310,7 +312,7 @@
* Places an object into the store. This assigns it an address. The address
* is returned. The object is not observed until it is acquired.
*/
- // public ObjectAddress insertObject(StoredObject object) throws ObjectStoreException {
+ // public ObjectAddress insertObject(StoredObject object) throws CoreException {
// int bytesNeeded = object.length() + ObjectHeader.SIZE;
// ObjectPage page = acquireObjectPageForSize(bytesNeeded);
// int objectNumber = page.insertObject(object);
@@ -328,7 +330,7 @@
* records the address and the amount of space used. The object is not
* actually added to the underlying store until a commit operation is executed.
*/
- public ObjectAddress insertObject(StoredObject object) throws ObjectStoreException {
+ public ObjectAddress insertObject(StoredObject object) throws CoreException {
int bytesNeeded = object.length() + ObjectHeader.SIZE;
ObjectPage page = acquireObjectPageForSize(bytesNeeded);
int pageNumber = page.getPageNumber();
@@ -344,12 +346,12 @@
/**
* Removes an object from the object store. In doing so, it must remove it from the cache as well.
*/
- public void removeObject(ObjectAddress address) throws ObjectStoreException {
+ public void removeObject(ObjectAddress address) throws CoreException {
if (phantoms.contains(address)) {
- throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure);
+ throw Policy.exception("objectStore.objectExistenceFailure"); //$NON-NLS-1$
}
if (acquiredObjects.containsKey(address)) {
- throw new ObjectStoreException(ObjectStoreException.ObjectIsLocked);
+ throw Policy.exception("objectStore.objectIsLocked"); //$NON-NLS-1$
}
StoredObject object = (StoredObject) modifiedObjects.get(address);
boolean inStore = !reservations.contains(address);
@@ -378,7 +380,7 @@
// }
// }
- protected void updateSpaceMapPage(int objectPageNumber, int freeSpace) throws ObjectStoreException {
+ protected void updateSpaceMapPage(int objectPageNumber, int freeSpace) throws CoreException {
SpaceMapPage p = acquireSpaceMapPage(objectPageNumber);
p.setFreeSpace(objectPageNumber, freeSpace);
p.release();
@@ -387,12 +389,12 @@
/**
* Acquires an object page. This is a convenience method to translate exceptions.
*/
- protected ObjectPage acquireObjectPage(int pageNumber) throws ObjectStoreException {
+ protected ObjectPage acquireObjectPage(int pageNumber) throws CoreException {
ObjectPage page;
try {
page = (ObjectPage) pageStore.acquire(pageNumber);
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.pageReadFailure", e); //$NON-NLS-1$
}
return page;
}
@@ -407,7 +409,7 @@
* Since databases are expected to be quite small (<200Mb) we might be able to live with
* this simple algorithm.
*/
- protected ObjectPage acquireObjectPageForSize(int bytesNeeded) throws ObjectStoreException {
+ protected ObjectPage acquireObjectPageForSize(int bytesNeeded) throws CoreException {
int oPageNumber = 0;
int numberOfSpans = ((pageStore.numberOfPages() - 1) / ObjectStorePage.SIZE) + 1;
for (int i = 0; i <= numberOfSpans; i++) {
@@ -424,33 +426,33 @@
}
}
sPage.release();
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.pageReadFailure", e); //$NON-NLS-1$
}
if (oPageNumber != 0)
break;
}
if (oPageNumber == 0) {
- throw new ObjectStoreException(ObjectStoreException.PageReadFailure);
+ throw Policy.exception("objectStore.pageReadFailure"); //$NON-NLS-1$
}
try {
ObjectPage oPage = (ObjectPage) pageStore.acquire(oPageNumber);
return oPage;
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.pageReadFailure", e); //$NON-NLS-1$
}
}
/**
* Acquires a space map page. This is a convenience method to translate exceptions.
*/
- protected SpaceMapPage acquireSpaceMapPage(int objectPageNumber) throws ObjectStoreException {
+ protected SpaceMapPage acquireSpaceMapPage(int objectPageNumber) throws CoreException {
int pageNumber = objectPageNumber & 0xFFFFE000;
SpaceMapPage p = null;
try {
p = (SpaceMapPage) pageStore.acquire(pageNumber);
- } catch (PageStoreException e) {
- throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e);
+ } catch (CoreException e) {
+ throw Policy.exception("objectStore.pageReadFailure", e); //$NON-NLS-1$
}
return p;
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStoreException.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStoreException.java
deleted file mode 100644
index f65543e..0000000
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStoreException.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.indexing;
-
-import org.eclipse.core.internal.utils.Policy;
-
-public class ObjectStoreException extends StoreException {
-
- public final static int GenericFailure = 0;
- public final static int InternalFailure = 1;
- public final static int StoreCreateFailure = 10;
- public final static int StoreConversionFailure = 11;
- public final static int StoreOpenFailure = 12;
- public final static int StoreCloseFailure = 13;
- public final static int PageReadFailure = 20;
- public final static int PageWriteFailure = 21;
- public final static int PageVacancyFailure = 22;
- public final static int ObjectTypeFailure = 23;
- public final static int ObjectSizeFailure = 24;
- public final static int ObjectExistenceFailure = 25;
- public final static int ObjectHeaderFailure = 26;
- public final static int ObjectInsertFailure = 27;
- public final static int ObjectRemoveFailure = 28;
- public final static int ObjectUpdateFailure = 29;
- public final static int ObjectIsLocked = 30;
- public final static int MetadataRequestFailure = 40;
-
- public final static String[] message = new String[50];
- static {
- initializeMessages();
- }
-
- public int id = 0; // exception id
-
- public ObjectStoreException(int id) {
- this(id, null);
- }
-
- public ObjectStoreException(int id, Throwable exception) {
- super(message[id], exception);
- this.id = id;
- }
-
- public ObjectStoreException(String s) {
- this(s, null);
- }
-
- public ObjectStoreException(String s, Throwable exception) {
- super(s, exception);
- this.id = GenericFailure;
- }
-
- /**
- * Initializes the messages at class load time.
- */
- private static void initializeMessages() {
- message[GenericFailure] = bind("objectStore.genericFailure"); //$NON-NLS-1$
- message[InternalFailure] = bind("objectStore.internalFailure"); //$NON-NLS-1$
- message[StoreCreateFailure] = bind("objectStore.storeCreateFailure"); //$NON-NLS-1$
- message[StoreConversionFailure] = bind("objectStore.storeConversionFailure"); //$NON-NLS-1$
- message[StoreOpenFailure] = bind("objectStore.storeOpenFailure"); //$NON-NLS-1$
- message[StoreCloseFailure] = bind("objectStore.storeCloseFailure"); //$NON-NLS-1$
- message[PageReadFailure] = bind("objectStore.pageReadFailure"); //$NON-NLS-1$
- message[PageWriteFailure] = bind("objectStore.pageWriteFailure"); //$NON-NLS-1$
- message[PageVacancyFailure] = bind("objectStore.pageVacancyFailure"); //$NON-NLS-1$
- message[ObjectTypeFailure] = bind("objectStore.objectTypeFailure"); //$NON-NLS-1$
- message[ObjectSizeFailure] = bind("objectStore.objectSizeFailure"); //$NON-NLS-1$
- message[ObjectExistenceFailure] = bind("objectStore.objectExistenceFailure"); //$NON-NLS-1$
- message[ObjectHeaderFailure] = bind("objectStore.objectHeaderFailure"); //$NON-NLS-1$
- message[ObjectInsertFailure] = bind("objectStore.objectInsertFailure"); //$NON-NLS-1$
- message[ObjectRemoveFailure] = bind("objectStore.objectRemoveFailure"); //$NON-NLS-1$
- message[ObjectUpdateFailure] = bind("objectStore.objectUpdateFailure"); //$NON-NLS-1$
- message[ObjectIsLocked] = bind("objectStore.objectIsLocked"); //$NON-NLS-1$
- message[MetadataRequestFailure] = bind("objectStore.metadataRequestFailure"); //$NON-NLS-1$
- }
-
- private static String bind(String name) {
- return Policy.bind(name);
- }
-
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java
index 4afc767..eb490f7 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java
@@ -16,11 +16,8 @@
* @see AbstractPagePolicy#createPage(int, byte[], PageStore)
*/
public final Page createPage(int pageNumber, byte[] buffer, PageStore pageStore) {
- if (pageNumber % Page.SIZE == 0) {
+ if (pageNumber % Page.SIZE == 0)
return new SpaceMapPage(pageNumber, buffer, pageStore);
- } else {
- return new ObjectPage(pageNumber, buffer, pageStore);
- }
+ return new ObjectPage(pageNumber, buffer, pageStore);
}
-
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStore.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStore.java
index e1631f2..411328f 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStore.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStore.java
@@ -12,38 +12,40 @@
import java.io.*;
import java.util.*;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
public class PageStore implements Observer {
+ private static final int CurrentPageStoreVersion = 1; // version 1
private static final int NumberOfMetadataAreas = 16; // NEVER change this
private static final int SizeOfMetadataArea = 64; // NEVER change this
- private static final int CurrentPageStoreVersion = 1; // version 1
private static final byte[] ZEROES = new byte[1024];
+ private Map acquiredPages;
+ private RandomAccessFile file;
+ private byte[] metadataBuffer;
+ private Map modifiedPages;
private String name;
- private RandomAccessFile file;
- private int numberOfPages;
+ private int numberOfCacheHits;
private int numberOfFileReads;
private int numberOfFileWrites;
+ private int numberOfPages;
private int numberOfReads;
private int numberOfWrites;
- private int numberOfCacheHits;
- private Map modifiedPages;
- private Map acquiredPages;
- private int storeOffset;
- private AbstractPagePolicy policy;
private byte[] pageBuffer;
- private byte[] metadataBuffer;
+ private AbstractPagePolicy policy;
+ private int storeOffset;
/**
* Creates the page file on the file system. Creates a file of zero length.
*/
- public static void create(String fileName) throws PageStoreException {
+ public static void create(String fileName) throws CoreException {
try {
- FileOutputStream out = new FileOutputStream(fileName);
- out.close();
+ new java.io.File(fileName).createNewFile();
} catch (IOException e) {
- throw new PageStoreException(PageStoreException.CreateFailure, e);
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("pageStore.createFailure"), e));//$NON-NLS-1$
}
}
@@ -69,168 +71,6 @@
this.storeOffset = NumberOfMetadataAreas * SizeOfMetadataArea;
}
- /**
- * Acquires a new empty page.
- */
- //public Page acquire(IPageFactory pageFactory) throws PageStoreException {
- // return acquire(pageFactory, numberOfPages);
- //}
- /**
- * Returns the page that has the given page number from the page file.
- */
- //public Page acquire(IPageFactory pageFactory, int pageNumber) throws PageStoreException {
- // Page p = null;
- // numberOfReads++;
- // Integer key = new Integer(pageNumber);
- // p = (Page)acquiredPages.get(key);
- // if (p != null) {
- // numberOfCacheHits++;
- // addReference(p);
- // return p;
- // }
- // p = (Page)modifiedPages.get(key);
- // if (p != null) {
- // numberOfCacheHits++;
- // addReference(p);
- // return p;
- // }
- // p = readCache.get(pageNumber);
- // if (p != null) {
- // numberOfCacheHits++;
- // addReference(p);
- // return p;
- // }
- // numberOfPages = Math.max(pageNumber + 1, numberOfPages);
- // p = pageFactory.create(this, pageNumber);
- // getPageFromFile(pageNumber, p);
- // addReference(p);
- // return p;
- //}
- /**
- * Adds a reference to a page.
- */
- //private void addReference(Page page) {
- // Integer key = new Integer(page.getPageNumber());
- // if (!page.hasReferences()) acquiredPages.put(key, page);
- // page.addReference();
- //}
- /**
- * Opens the PageStore. The file is created if necessary.
- * This will raise an exception if the
- * media on which the file is located is read-only
- * or not authorized to the user.
- */
- public void open(String name) throws PageStoreException {
- this.name = name;
- pageBuffer = new byte[Page.SIZE];
- metadataBuffer = new byte[SizeOfMetadataArea];
- if (!exists(name))
- create(name);
- try {
- this.file = new RandomAccessFile(name, "rw"); //$NON-NLS-1$
- } catch (IOException e) {
- throw new PageStoreException(PageStoreException.OpenFailure, e);
- }
- checkMetadata();
- numberOfPages = numberOfPagesInFile();
- numberOfFileReads = 0;
- numberOfFileWrites = 0;
- numberOfReads = 0;
- numberOfWrites = 0;
- numberOfCacheHits = 0;
- /* apply any outstanding transaction by reading the log file and applying it */
- modifiedPages = LogReader.getModifiedPages(this);
- flush();
- Log.delete(name);
- /* prepare for normal operation */
- acquiredPages = new HashMap();
- }
-
- /**
- * Checks to see if the metadata stored in the page store matches that expected by this
- * code. If not, a conversion is necessary.
- */
- private void checkMetadata() throws PageStoreException {
- byte[] md = readMetadataArea(0);
- Buffer metadata = new Buffer(md);
- Field versionField = metadata.getField(0, 4);
- int pageStoreVersion = versionField.getInt();
- if (pageStoreVersion == 0) {
- versionField.put(CurrentPageStoreVersion);
- writeMetadataArea(0, md);
- return;
- }
- if (pageStoreVersion == CurrentPageStoreVersion)
- return;
- convertPageStore(pageStoreVersion);
- }
-
- /**
- * Converts the page store file from a previous to the current version.
- * No conversions are yet defined.
- */
- private void convertPageStore(int fromVersion) throws PageStoreException {
- throw new PageStoreException(PageStoreException.ConversionFailure);
- }
-
- /**
- * Commits all changes and closes the page store.
- */
- public void close() {
- close(true);
- }
-
- /**
- * Closes the page store.
- */
- public void close(boolean commit) {
- if (commit) {
- try {
- commit();
- } catch (PageStoreException e) {
- // ignore
- }
- }
- try {
- file.close();
- } catch (IOException e) {
- // ignore
- }
- file = null;
- }
-
- /**
- * Commits all modified pages to the file.
- */
- public void commit() throws PageStoreException {
- if (modifiedPages.size() == 0)
- return;
- LogWriter.putModifiedPages(this, modifiedPages);
- flush();
- Log.delete(name);
- }
-
- /**
- * Throws out the modified pages.
- */
- public void rollback() {
- modifiedPages.clear();
- }
-
- /**
- * Writes the modified pages to the page file.
- */
- private void flush() throws PageStoreException {
- if (modifiedPages.size() == 0)
- return;
- Iterator pageStream = modifiedPages.values().iterator();
- while (pageStream.hasNext()) {
- Page page = (Page) pageStream.next();
- writePage(page);
- }
- modifiedPages.clear();
- }
-
//public void readFrom(RandomAccessFile file, long offset) throws IOException {
// long n = file.length() - offset;
// if (n <= 0) {
@@ -267,7 +107,7 @@
/**
* Opens the PageStore with a cache size of 40.
*/
- //public void open(String name) throws PageStoreException {
+ //public void open(String name) throws CoreException {
// open(name, 40);
//}
/**
@@ -276,12 +116,12 @@
* media on which the file is located is read-only
* or not authorized to the user.
*/
- //public void open(String name, int cacheSize) throws PageStoreException {
+ //public void open(String name, int cacheSize) throws CoreException {
// if (!exists(name)) create(name);
// try {
// this.file = new RandomAccessFile(name, "rw");
// } catch (IOException e) {
- // throw new PageStoreException(PageStoreException.OpenFailure);
+ // throw new CoreException(CoreException.OpenFailure);
// }
// this.name = name;
// checkMetadata();
@@ -303,7 +143,7 @@
/**
* Acquires the page that has the given page number from the page store.
*/
- public Page acquire(int pageNumber) throws PageStoreException {
+ public Page acquire(int pageNumber) throws CoreException {
numberOfReads++;
Integer key = new Integer(pageNumber);
Page page = (Page) acquiredPages.get(key);
@@ -325,111 +165,21 @@
}
/**
- * Releases a page and decrements its reference count.
+ * Checks to see if the metadata stored in the page store matches that expected by this
+ * code. If not, a conversion is necessary.
*/
- public void release(Page page) {
- Integer key = new Integer(page.getPageNumber());
- page.removeReference();
- if (page.hasReferences())
+ private void checkMetadata() throws CoreException {
+ byte[] md = readMetadataArea(0);
+ Buffer metadata = new Buffer(md);
+ Field versionField = metadata.getField(0, 4);
+ int pageStoreVersion = versionField.getInt();
+ if (pageStoreVersion == 0) {
+ versionField.put(CurrentPageStoreVersion);
+ writeMetadataArea(0, md);
return;
- page.deleteObserver(this);
- acquiredPages.remove(key);
- }
-
- /**
- * Processes a page update.
- */
- public void update(Observable object, Object arg) {
- Page page = (Page) object;
- Integer key = new Integer(page.getPageNumber());
- modifiedPages.put(key, page);
- }
-
- /**
- * Returns the file seek offset for a given page number.
- */
- protected long offsetOfPage(int pageNumber) {
- return (long) (pageNumber * Page.SIZE) + storeOffset;
- }
-
- protected Page readPage(int pageNumber) throws PageStoreException {
- if (!readBuffer(offsetOfPage(pageNumber), pageBuffer)) {
- throw new PageStoreException(PageStoreException.ReadFailure);
}
- numberOfFileReads++;
- Page p = policy.createPage(pageNumber, pageBuffer, this);
- p.addObserver(this);
- return p;
- }
-
- protected void writePage(Page page) throws PageStoreException {
- page.toBuffer(pageBuffer);
- long fileOffset = offsetOfPage(page.getPageNumber());
- if (!writeBuffer(fileOffset, pageBuffer, 0, pageBuffer.length)) {
- throw new PageStoreException(PageStoreException.WriteFailure);
- }
- numberOfFileWrites++;
- }
-
- /**
- * Returns the file seek offset for a given metadata area
- */
- protected long offsetOfMetadataArea(int i) {
- return (long) i * SizeOfMetadataArea;
- }
-
- public byte[] readMetadataArea(int i) throws PageStoreException {
- if (!readBuffer(offsetOfMetadataArea(i), metadataBuffer)) {
- throw new PageStoreException(PageStoreException.MetadataRequestFailure);
- }
- return new Buffer(metadataBuffer).get(0, metadataBuffer.length);
- }
-
- public void writeMetadataArea(int i, byte[] buffer) throws PageStoreException {
- if (i < 0 || i >= NumberOfMetadataAreas)
- throw new PageStoreException(PageStoreException.MetadataRequestFailure);
- if (buffer.length != SizeOfMetadataArea)
- throw new PageStoreException(PageStoreException.MetadataRequestFailure);
- if (!writeBuffer(offsetOfMetadataArea(i), buffer, 0, buffer.length)) {
- throw new PageStoreException(PageStoreException.MetadataRequestFailure);
- }
- return;
- }
-
- protected boolean readBuffer(long fileOffset, byte[] buffer) {
- new Buffer(buffer).clear();
- long fileLength = getFileLength();
- if (fileOffset >= fileLength)
- return true;
- int bytesToRead = (int) Math.min(buffer.length, (fileLength - fileOffset));
- try {
- file.seek(fileOffset);
- file.readFully(buffer, 0, bytesToRead);
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- protected boolean writeBuffer(long fileOffset, byte[] buffer, int offset, int length) {
- clearFileToOffset(fileOffset);
- try {
- file.seek(fileOffset);
- file.write(buffer, offset, length);
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- protected long getFileLength() {
- long n = 0;
- try {
- n = file.length();
- } catch (IOException e) {
- return 0;
- }
- return n;
+ if (pageStoreVersion != CurrentPageStoreVersion)
+ throw Policy.exception("pageStore.conversionFailure");//$NON-NLS-1$
}
protected void clearFileToOffset(long fileOffset) {
@@ -442,10 +192,64 @@
}
/**
- * Returns the number of pages actually in the underlying file.
+ * Commits all changes and closes the page store.
*/
- protected int numberOfPagesInFile() {
- return (int) ((getFileLength() - offsetOfPage(0)) / Page.SIZE);
+ public void close() {
+ close(true);
+ }
+
+ /**
+ * Closes the page store.
+ */
+ public void close(boolean commit) {
+ if (commit) {
+ try {
+ commit();
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
+ try {
+ file.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ file = null;
+ }
+
+ /**
+ * Commits all modified pages to the file.
+ */
+ public void commit() throws CoreException {
+ if (modifiedPages.size() == 0)
+ return;
+ LogWriter.putModifiedPages(this, modifiedPages);
+ flush();
+ Log.delete(name);
+ }
+
+ /**
+ * Writes the modified pages to the page file.
+ */
+ private void flush() throws CoreException {
+ if (modifiedPages.size() == 0)
+ return;
+ Iterator pageStream = modifiedPages.values().iterator();
+ while (pageStream.hasNext()) {
+ Page page = (Page) pageStream.next();
+ writePage(page);
+ }
+ modifiedPages.clear();
+ }
+
+ protected long getFileLength() {
+ long n = 0;
+ try {
+ n = file.length();
+ } catch (IOException e) {
+ return 0;
+ }
+ return n;
}
/**
@@ -489,6 +293,13 @@
return numberOfPages;
}
+ /**
+ * Returns the number of pages actually in the underlying file.
+ */
+ protected int numberOfPagesInFile() {
+ return (int) ((getFileLength() - offsetOfPage(0)) / Page.SIZE);
+ }
+
/**
* Returns the number of read operations that have been done.
*/
@@ -504,31 +315,122 @@
}
/**
+ * Returns the file seek offset for a given metadata area
+ */
+ protected long offsetOfMetadataArea(int i) {
+ return (long) i * SizeOfMetadataArea;
+ }
+
+ /**
+ * Returns the file seek offset for a given page number.
+ */
+ protected long offsetOfPage(int pageNumber) {
+ return (long) (pageNumber * Page.SIZE) + storeOffset;
+ }
+
+ /**
+ * Opens the PageStore. The file is created if necessary.
+ * This will raise an exception if the
+ * media on which the file is located is read-only
+ * or not authorized to the user.
+ */
+ public void open(String name) throws CoreException {
+ this.name = name;
+ pageBuffer = new byte[Page.SIZE];
+ metadataBuffer = new byte[SizeOfMetadataArea];
+ if (!exists(name))
+ create(name);
+ try {
+ this.file = new RandomAccessFile(name, "rw"); //$NON-NLS-1$
+ } catch (IOException e) {
+ throw Policy.exception("pageStore.openFailure", e);//$NON-NLS-1$
+ }
+ checkMetadata();
+ numberOfPages = numberOfPagesInFile();
+ numberOfFileReads = 0;
+ numberOfFileWrites = 0;
+ numberOfReads = 0;
+ numberOfWrites = 0;
+ numberOfCacheHits = 0;
+ /* apply any outstanding transaction by reading the log file and applying it */
+ modifiedPages = LogReader.getModifiedPages(this);
+ flush();
+ Log.delete(name);
+ /* prepare for normal operation */
+ acquiredPages = new HashMap();
+ }
+
+ protected boolean readBuffer(long fileOffset, byte[] buffer) {
+ new Buffer(buffer);
+ long fileLength = getFileLength();
+ if (fileOffset >= fileLength)
+ return true;
+ int bytesToRead = (int) Math.min(buffer.length, (fileLength - fileOffset));
+ try {
+ file.seek(fileOffset);
+ file.readFully(buffer, 0, bytesToRead);
+ } catch (IOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public byte[] readMetadataArea(int i) throws CoreException {
+ if (!readBuffer(offsetOfMetadataArea(i), metadataBuffer))
+ throw Policy.exception("pageStore.metadataRequestFailure");//$NON-NLS-1$
+ return new Buffer(metadataBuffer).get(0, metadataBuffer.length);
+ }
+
+ protected Page readPage(int pageNumber) throws CoreException {
+ if (!readBuffer(offsetOfPage(pageNumber), pageBuffer))
+ throw Policy.exception("pageStore.readFailure");//$NON-NLS-1$
+ numberOfFileReads++;
+ Page p = policy.createPage(pageNumber, pageBuffer, this);
+ p.addObserver(this);
+ return p;
+ }
+
+ /**
+ * Releases a page and decrements its reference count.
+ */
+ public void release(Page page) {
+ Integer key = new Integer(page.getPageNumber());
+ page.removeReference();
+ if (page.hasReferences())
+ return;
+ page.deleteObserver(this);
+ acquiredPages.remove(key);
+ }
+
+ /**
+ * Throws out the modified pages.
+ */
+ public void rollback() {
+ modifiedPages.clear();
+ }
+
+ /**
* Internal test for page log consistency. Throws an exception if
* a problem is detected.
*/
- public void testLogging1() throws PageStoreException {
+ public void testLogging1() throws CoreException {
LogWriter.putModifiedPages(this, modifiedPages);
Map testPages = LogReader.getModifiedPages(this);
int m = testPages.size();
int n = modifiedPages.size();
- if (m != n) {
- throw new PageStoreException("Page set sizes do not match" //$NON-NLS-1$
- + m + " " + n); //$NON-NLS-1$
- }
+ if (m != n)
+ throw Policy.exception(Integer.toString(m) + ' ' + n);//Page set sizes do not match
Iterator testPagesStream = testPages.values().iterator();
Iterator modifiedPagesStream = modifiedPages.values().iterator();
while (testPagesStream.hasNext()) {
Page testPage = (Page) testPagesStream.next();
Page modifiedPage = (Page) modifiedPagesStream.next();
- if (testPage.getPageNumber() != modifiedPage.getPageNumber()) {
- throw new PageStoreException("Page number mismatch at " //$NON-NLS-1$
- + testPage.getPageNumber() + " " + modifiedPage.getPageNumber()); //$NON-NLS-1$
- }
- if (Buffer.compare(testPage.pageBuffer, modifiedPage.pageBuffer) != 0) {
- throw new PageStoreException("Page buffer mismatch at " //$NON-NLS-1$
- + testPage.getPageNumber());
- }
+ // Page number mismatch
+ if (testPage.getPageNumber() != modifiedPage.getPageNumber())
+ throw Policy.exception(Integer.toString(testPage.getPageNumber()) + ' ' + modifiedPage.getPageNumber());
+ // Page buffer mismatch
+ if (Buffer.compare(testPage.pageBuffer, modifiedPage.pageBuffer) != 0)
+ throw Policy.exception(Integer.toString(testPage.getPageNumber()));
}
Log.delete(name);
}
@@ -537,7 +439,7 @@
* Internal test for applying a page log to the file. Does the
* equivalent of a flush.
*/
- public void testLogging2() throws PageStoreException {
+ public void testLogging2() throws CoreException {
LogWriter.putModifiedPages(this, modifiedPages);
modifiedPages = LogReader.getModifiedPages(this);
flush();
@@ -550,9 +452,44 @@
* This should look like it does a flush, since the modified pages are written to the
* file.
*/
- public void testLogging3() throws PageStoreException {
+ public void testLogging3() throws CoreException {
LogWriter.putModifiedPages(this, modifiedPages);
close(false);
open(name);
}
+
+ /**
+ * Processes a page update.
+ */
+ public void update(Observable object, Object arg) {
+ Page page = (Page) object;
+ Integer key = new Integer(page.getPageNumber());
+ modifiedPages.put(key, page);
+ }
+
+ protected boolean writeBuffer(long fileOffset, byte[] buffer, int offset, int length) {
+ clearFileToOffset(fileOffset);
+ try {
+ file.seek(fileOffset);
+ file.write(buffer, offset, length);
+ } catch (IOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public void writeMetadataArea(int i, byte[] buffer) throws CoreException {
+ if (i < 0 || i >= NumberOfMetadataAreas || buffer.length != SizeOfMetadataArea)
+ throw Policy.exception("pageStore.metadataRequestFailure");//$NON-NLS-1$
+ if (!writeBuffer(offsetOfMetadataArea(i), buffer, 0, buffer.length))
+ throw Policy.exception("pageStore.metadataRequestFailure");//$NON-NLS-1$
+ }
+
+ protected void writePage(Page page) throws CoreException {
+ page.toBuffer(pageBuffer);
+ long fileOffset = offsetOfPage(page.getPageNumber());
+ if (!writeBuffer(fileOffset, pageBuffer, 0, pageBuffer.length))
+ throw Policy.exception("pageStore.writeFailure");//$NON-NLS-1$
+ numberOfFileWrites++;
+ }
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStoreException.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStoreException.java
deleted file mode 100644
index f2f8baf..0000000
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/PageStoreException.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.indexing;
-
-import org.eclipse.core.internal.utils.Policy;
-
-public class PageStoreException extends StoreException {
- public final static int GenericFailure = 0;
- public final static int CreateFailure = 1;
- public final static int OpenFailure = 2;
- public final static int LengthFailure = 3;
- public final static int WriteFailure = 4;
- public final static int ReadFailure = 5;
- public final static int CommitFailure = 6;
- public final static int IntegrityFailure = 7;
- public final static int MetadataRequestFailure = 8;
- public final static int ConversionFailure = 9;
-
- public final static int LogCreateFailure = 20;
- public final static int LogOpenFailure = 21;
- public final static int LogReadFailure = 23;
- public final static int LogWriteFailure = 24;
-
- public final static String[] message = new String[30];
- static {
- initializeMessages();
- }
-
- public int id = 0; // exception id
-
- public PageStoreException(int id) {
- this(id, null);
- }
-
- public PageStoreException(int id, Throwable exception) {
- super(message[id], exception);
- this.id = id;
- }
-
- public PageStoreException(String s) {
- this(s, null);
- }
-
- public PageStoreException(String s, Throwable exception) {
- super(s, exception);
- this.id = GenericFailure;
- }
-
- /**
- * Initialize the messages at class load time.
- */
- private static void initializeMessages() {
- message[GenericFailure] = bind("pageStore.genericFailure"); //$NON-NLS-1$
- message[CreateFailure] = bind("pageStore.createFailure"); //$NON-NLS-1$
- message[OpenFailure] = bind("pageStore.openFailure"); //$NON-NLS-1$
- message[LengthFailure] = bind("pageStore.lengthFailure"); //$NON-NLS-1$
- message[WriteFailure] = bind("pageStore.writeFailure"); //$NON-NLS-1$
- message[ReadFailure] = bind("pageStore.readFailure"); //$NON-NLS-1$
- message[CommitFailure] = bind("pageStore.commitFailure"); //$NON-NLS-1$
- message[IntegrityFailure] = bind("pageStore.integrityFailure"); //$NON-NLS-1$
- message[MetadataRequestFailure] = bind("pageStore.metadataRequestFailure"); //$NON-NLS-1$
- message[ConversionFailure] = bind("pageStore.conversionFailure"); //$NON-NLS-1$
- message[LogCreateFailure] = bind("pageStore.logCreateFailure"); //$NON-NLS-1$
- message[LogOpenFailure] = bind("pageStore.logOpenFailure"); //$NON-NLS-1$
- message[LogReadFailure] = bind("pageStore.logReadFailure"); //$NON-NLS-1$
- message[LogWriteFailure] = bind("pageStore.logWriteFailure"); //$NON-NLS-1$
- }
-
- private static String bind(String name) {
- return Policy.bind(name);
- }
-
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ReservationTable.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ReservationTable.java
index 3763361..cb4cbb6 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ReservationTable.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/ReservationTable.java
@@ -36,6 +36,7 @@
public boolean contains(ObjectAddress address) {
int pageNumber = address.getPageNumber();
int objectNumber = address.getObjectNumber();
+ //todo can be optimized
if (contains(pageNumber)) {
if (get(pageNumber).contains(objectNumber))
return true;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/SpaceMapPage.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/SpaceMapPage.java
index bdd53fb..9e8d835 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/SpaceMapPage.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/SpaceMapPage.java
@@ -104,6 +104,7 @@
}
protected void materialize() {
+ //nothing to do
}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoreException.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoreException.java
deleted file mode 100644
index 7e84ffe..0000000
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoreException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.indexing;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-public abstract class StoreException extends Exception {
- protected Throwable wrappedException;
-
- public StoreException(String message) {
- super(message);
- }
-
- public StoreException(String message, Throwable wrappedException) {
- super(message);
- this.wrappedException = wrappedException;
- }
-
- /**
- * Prints a stack trace out for the exception.
- */
- public void printStackTrace() {
- printStackTrace(System.err);
- }
-
- /**
- * Prints a stack trace out for the exception.
- */
- public void printStackTrace(PrintStream output) {
- synchronized (output) {
- super.printStackTrace(output);
- if (wrappedException != null)
- wrappedException.printStackTrace(output);
- }
- }
-
- /**
- * Prints a stack trace out for the exception.
- */
- public void printStackTrace(PrintWriter output) {
- synchronized (output) {
- super.printStackTrace(output);
- if (wrappedException != null)
- wrappedException.printStackTrace(output);
- }
- }
-
-}
-
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoredObject.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoredObject.java
index d666065..1f2f681 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoredObject.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/indexing/StoredObject.java
@@ -11,16 +11,19 @@
package org.eclipse.core.internal.indexing;
import java.util.Observable;
+import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
public abstract class StoredObject extends Observable implements Referable, Insertable {
public static final int MAXIMUM_OBJECT_SIZE = ObjectStore.MAXIMUM_OBJECT_SIZE;
- public static final int TYPE_OFFSET = 0;
public static final int TYPE_LENGTH = 2;
-
- protected ObjectStore store;
+ public static final int TYPE_OFFSET = 0;
protected ObjectAddress address;
protected int referenceCount;
+
+ protected ObjectStore store;
protected int type;
/**
@@ -33,38 +36,14 @@
/**
* Constructs a new instance from a field.
*/
- protected StoredObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
- if (f.length() < getMinimumSize()) {
- throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure);
- }
- if (f.length() > getMaximumSize()) {
- throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure);
- }
+ protected StoredObject(Field f, ObjectStore store, ObjectAddress address) throws CoreException {
+ if (f.length() < getMinimumSize() || f.length() > getMaximumSize())
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("objectStore.objectSizeFailure"), null));//$NON-NLS-1$
extractValues(f);
setStore(store);
setAddress(address);
}
- /**
- * Provides a printable representation of this object. Subclasses must implement.
- */
- public abstract String toString();
-
- /**
- * Returns the required type of this class of object.
- * Subclasses must override.
- */
- protected abstract int getRequiredType();
-
- /**
- * Returns a byte array value of the object.
- */
- public final byte[] toByteArray() {
- Field f = new Field(length());
- insertValues(f);
- return f.get();
- }
-
/**
* Adds a reference.
*/
@@ -74,27 +53,13 @@
}
/**
- * Removes a reference.
+ * Places the contents of the buffer into the members.
+ * Subclasses should implement and call super.
*/
- public final int removeReference() {
- if (referenceCount > 0)
- referenceCount--;
- return referenceCount;
- }
-
- /**
- * Tests for existing references.
- */
- public final boolean hasReferences() {
- return referenceCount > 0;
- }
-
- /**
- * Returns the store of the object.
- * Subclasses must not override.
- */
- public final ObjectStore getStore() {
- return store;
+ protected void extractValues(Field f) throws CoreException {
+ type = f.subfield(TYPE_OFFSET, TYPE_LENGTH).getInt();
+ if (type != getRequiredType())
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind("objectStore.objectTypeFailure"), null));//$NON-NLS-1$
}
/**
@@ -105,32 +70,6 @@
return address;
}
- public final void setStore(ObjectStore store) {
- this.store = store;
- }
-
- public final void setAddress(ObjectAddress address) {
- this.address = address;
- }
-
- /**
- * Places the contents of the buffer into the members.
- * Subclasses should implement and call super.
- */
- protected void extractValues(Field f) throws ObjectStoreException {
- type = f.subfield(TYPE_OFFSET, TYPE_LENGTH).getInt();
- if (type != getRequiredType())
- throw new ObjectStoreException(ObjectStoreException.ObjectTypeFailure);
- }
-
- /**
- * Places the contents of the fields into the buffer.
- * Subclasses should implement and call super.
- */
- protected void insertValues(Field f) {
- f.subfield(TYPE_OFFSET, TYPE_LENGTH).put(type);
- }
-
/**
* Returns the maximum size of this object's instance -- including its type field.
* Subclasses can override. The default is to have the this be equal to the minimum
@@ -149,10 +88,70 @@
}
/**
+ * Returns the required type of this class of object.
+ * Subclasses must override.
+ */
+ protected abstract int getRequiredType();
+
+ /**
+ * Returns the store of the object.
+ * Subclasses must not override.
+ */
+ public final ObjectStore getStore() {
+ return store;
+ }
+
+ /**
+ * Tests for existing references.
+ */
+ public final boolean hasReferences() {
+ return referenceCount > 0;
+ }
+
+ /**
+ * Places the contents of the fields into the buffer.
+ * Subclasses should implement and call super.
+ */
+ protected void insertValues(Field f) {
+ f.subfield(TYPE_OFFSET, TYPE_LENGTH).put(type);
+ }
+
+ /**
* Returns the actual size of this object's instance -- including its type field.
* Subclasses should override.
*/
protected int length() {
return getMinimumSize();
}
+
+ /**
+ * Removes a reference.
+ */
+ public final int removeReference() {
+ if (referenceCount > 0)
+ referenceCount--;
+ return referenceCount;
+ }
+
+ public final void setAddress(ObjectAddress address) {
+ this.address = address;
+ }
+
+ public final void setStore(ObjectStore store) {
+ this.store = store;
+ }
+
+ /**
+ * Returns a byte array value of the object.
+ */
+ public final byte[] toByteArray() {
+ Field f = new Field(length());
+ insertValues(f);
+ return f.get();
+ }
+
+ /**
+ * Provides a printable representation of this object. Subclasses must implement.
+ */
+ public abstract String toString();
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore.java
index dbbd6e9..768906f 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore.java
@@ -381,10 +381,6 @@
cursor.close();
removeOldestEntries(removeEntries, maxFileStates);
}
- } catch (IndexedStoreException e) {
- String message = Policy.bind("history.problemsPurging", source.toString(), destination.toString()); //$NON-NLS-1$
- ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_METADATA, source, message, e);
- ResourcesPlugin.getPlugin().getLog().log(status);
} catch (CoreException e) {
String message = Policy.bind("history.problemsPurging", source.toString(), destination.toString()); //$NON-NLS-1$
ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_METADATA, source, message, e);
@@ -465,7 +461,7 @@
return result;
}
- protected void remove(HistoryStoreEntry entry) throws IndexedStoreException {
+ protected void remove(HistoryStoreEntry entry) throws CoreException {
try {
Vector objectIds = store.getIndex().getObjectIdentifiersMatching(entry.getKey());
if (objectIds.size() == 1) {
@@ -555,7 +551,7 @@
}
}
- protected void removeOldestEntries(List entries, int maxEntries) throws IndexedStoreException {
+ protected void removeOldestEntries(List entries, int maxEntries) throws CoreException {
// do we have more states than necessary?
if (entries.size() <= maxEntries)
return;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java
index b143055..5456230 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java
@@ -74,7 +74,7 @@
* @param store Indexed history store from which data is to be read.
* @param cursor Position from which data is to be read.
*/
- public static HistoryStoreEntry create(IndexedStoreWrapper store, IndexCursor cursor) throws CoreException, IndexedStoreException {
+ public static HistoryStoreEntry create(IndexedStoreWrapper store, IndexCursor cursor) throws CoreException {
byte[] key = cursor.getKey();
ObjectID valueID = cursor.getValueAsObjectID();
byte[] value = store.getObject(valueID);
@@ -151,7 +151,7 @@
/**
* Removes this entry from the store.
*/
- public void remove() throws IndexedStoreException {
+ public void remove() throws CoreException {
if (cursor == null)
return;
reposition();
@@ -160,7 +160,7 @@
cursor.remove();
}
- protected void reposition() throws IndexedStoreException {
+ protected void reposition() throws CoreException {
if (cursor.isSet())
if (compare(cursor.getKey(), key))
return;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java
index 3afafbe..41761a0 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java
@@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.core.internal.localstore;
-import org.eclipse.core.internal.indexing.IndexedStoreException;
+import org.eclipse.core.runtime.CoreException;
+
public interface IHistoryStoreVisitor {
/**
@@ -18,5 +19,5 @@
*
* @param state State to be visited in IndexedStore.
*/
- public boolean visit(HistoryStoreEntry state) throws IndexedStoreException;
+ public boolean visit(HistoryStoreEntry state) throws CoreException;
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java
index 4a13337..f747646 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java
@@ -116,26 +116,16 @@
}
public synchronized Index getIndex() throws CoreException {
- Exception problem = null;
try {
- return getStore().getIndex(INDEX_NAME);
- } catch (IndexedStoreException e) {
- if (e.id == IndexedStoreException.IndexNotFound)
- return createIndex();
- problem = e;
- return null;
+ Index result = getStore().getIndex(INDEX_NAME);
+ return result == null ? createIndex() : result;
} catch (CoreException e) {
//just rethrow
throw e;
} catch (Exception e) {
- problem = e;
- return null;
- } finally {
- if (problem != null) {
- String message = Policy.bind("indexed.couldNotGetIndex", location.toOSString()); //$NON-NLS-1$
- ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_READ_LOCAL, location, message, problem);
- throw new ResourceException(status);
- }
+ String message = Policy.bind("indexed.couldNotGetIndex", location.toOSString()); //$NON-NLS-1$
+ ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_READ_LOCAL, location, message, e);
+ throw new ResourceException(status);
}
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java
index d43dac1..ab54a5c 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java
@@ -16,64 +16,64 @@
import org.eclipse.core.runtime.*;
public class Policy {
- public static final long MAX_BUILD_DELAY = 1000;
- public static final long MIN_BUILD_DELAY = 100;
+ private static final int autoBuildBuildWork = 1;
+
+ private static final int autoBuildOpWork = 99;
+
+ public static final boolean buildOnCancel = false;
+ public static int buildWork;
private static String bundleName = "org.eclipse.core.internal.utils.messages";//$NON-NLS-1$
private static ResourceBundle bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
- private static final int autoBuildOpWork = 99;
- private static final int autoBuildBuildWork = 1;
- private static final int manualBuildOpWork = 99;
- private static final int manualBuildBuildWork = 1;
-
- public static final boolean buildOnCancel = false;
- public static int opWork;
- public static int buildWork;
- public static int totalWork;
-
- // default workspace description values
- public static final boolean defaultAutoBuild = true;
- public static final boolean defaultSnapshots = true;
- public static final int defaultOperationsPerSnapshot = 100;
- public static final long defaultSnapshotInterval = 5 * 60 * 1000l;//5 minutes
- public static final long defaultDeltaExpiration = 30 * 24 * 3600 * 1000l; // 30 days
- public static final long defaultFileStateLongevity = 7 * 24 * 3600 * 1000l; // 7 days
- public static final long defaultMaxFileStateSize = 1024 * 1024l; // 1 Mb
- public static final int defaultMaxFileStates = 50;
- public static final int defaultMaxBuildIterations = 10;
- public static final long defaultMaxNotifyDelay = 10000;// 10 seconds
+ public static boolean DEBUG_AUTO_REFRESH = false;
+ public static boolean DEBUG_BUILD_DELTA = false;
//debug constants
public static boolean DEBUG_BUILD_FAILURE = false;
- public static boolean DEBUG_NEEDS_BUILD = false;
public static boolean DEBUG_BUILD_INVOKING = false;
- public static boolean DEBUG_BUILD_DELTA = false;
- public static boolean DEBUG_NATURES = false;
public static boolean DEBUG_HISTORY = false;
+ public static boolean DEBUG_NATURES = false;
+ public static boolean DEBUG_NEEDS_BUILD = false;
public static boolean DEBUG_PREFERENCES = false;
- public static boolean MONITOR_BUILDERS = false;
- public static boolean MONITOR_LISTENERS = false;
-
// Get timing information for restoring data
public static boolean DEBUG_RESTORE = false;
public static boolean DEBUG_RESTORE_MARKERS = false;
- public static boolean DEBUG_RESTORE_SYNCINFO = false;
- public static boolean DEBUG_RESTORE_TREE = false;
+ public static boolean DEBUG_RESTORE_MASTERTABLE = false;
public static boolean DEBUG_RESTORE_METAINFO = false;
public static boolean DEBUG_RESTORE_SNAPSHOTS = false;
- public static boolean DEBUG_RESTORE_MASTERTABLE = false;
+ public static boolean DEBUG_RESTORE_SYNCINFO = false;
+ public static boolean DEBUG_RESTORE_TREE = false;
// Get timing information for saving and snapshoting data
public static boolean DEBUG_SAVE = false;
public static boolean DEBUG_SAVE_MARKERS = false;
- public static boolean DEBUG_SAVE_SYNCINFO = false;
- public static boolean DEBUG_SAVE_TREE = false;
+ public static boolean DEBUG_SAVE_MASTERTABLE = false;
public static boolean DEBUG_SAVE_METAINFO = false;
public static boolean DEBUG_SAVE_SNAPSHOTS = false;
- public static boolean DEBUG_SAVE_MASTERTABLE = false;
+ public static boolean DEBUG_SAVE_SYNCINFO = false;
+ public static boolean DEBUG_SAVE_TREE = false;
- public static boolean DEBUG_AUTO_REFRESH = false;
+ // default workspace description values
+ public static final boolean defaultAutoBuild = true;
+ public static final long defaultDeltaExpiration = 30 * 24 * 3600 * 1000l; // 30 days
+ public static final long defaultFileStateLongevity = 7 * 24 * 3600 * 1000l; // 7 days
+ public static final int defaultMaxBuildIterations = 10;
+ public static final int defaultMaxFileStates = 50;
+ public static final long defaultMaxFileStateSize = 1024 * 1024l; // 1 Mb
+ public static final long defaultMaxNotifyDelay = 10000;// 10 seconds
+ public static final int defaultOperationsPerSnapshot = 100;
+ public static final long defaultSnapshotInterval = 5 * 60 * 1000l;//5 minutes
+ public static final boolean defaultSnapshots = true;
+ private static final int manualBuildBuildWork = 1;
+ private static final int manualBuildOpWork = 99;
+ public static final long MAX_BUILD_DELAY = 1000;
+ public static final long MIN_BUILD_DELAY = 100;
+
+ public static boolean MONITOR_BUILDERS = false;
+ public static boolean MONITOR_LISTENERS = false;
+ public static int opWork;
+ public static int totalWork;
static {
setupAutoBuildProgress(defaultAutoBuild);
@@ -160,6 +160,36 @@
throw new OperationCanceledException();
}
+ /**
+ * Print a debug message to the console.
+ * Pre-pend the message with the current date and the name of the current thread.
+ */
+ public static void debug(String message) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(new Date(System.currentTimeMillis()));
+ buffer.append(" - ["); //$NON-NLS-1$
+ buffer.append(Thread.currentThread().getName());
+ buffer.append("] "); //$NON-NLS-1$
+ buffer.append(message);
+ System.out.println(buffer.toString());
+ }
+
+ /**
+ * Returns a new CoreException with a translation of the provided message key,
+ * and optionally the provided nested exception
+ */
+ public static CoreException exception(String key, Exception e) {
+ return new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, Policy.bind(key), e));//$NON-NLS-1$
+ }
+
+ /**
+ * Returns a new CoreException with a translation of the provided message key,
+ * and optionally the provided nested exception
+ */
+ public static CoreException exception(String key) {
+ return exception(key, null);
+ }
+
public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
if (monitor == null)
return new NullProgressMonitor();
@@ -187,18 +217,4 @@
return monitor;
return new SubProgressMonitor(monitor, ticks, style);
}
-
- /**
- * Print a debug message to the console.
- * Pre-pend the message with the current date and the name of the current thread.
- */
- public static void debug(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
- }
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/messages.properties b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/messages.properties
index 43665a5..802f56a 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/messages.properties
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/messages.properties
@@ -277,31 +277,17 @@
### indexing
indexedStore.contextNotAvailable = Error occurred accessing the indexed store context.
indexedStore.entryKeyLengthError = Key length > 1024.
-indexedStore.entryNotRemoved = Cannot remove an index entry referenced by other cursors.
indexedStore.entryRemoved = Element at this cursor has been removed.
indexedStore.entryValueLengthError = Value length > 2048.
-indexedStore.entryValueNotUpdated = Error occurred updating value in leaf node.
-indexedStore.genericError = An error occurred during an indexed store operation.
indexedStore.indexExists = Index already exists.
indexedStore.indexNodeNotCreated = Index node not created.
-indexedStore.indexNodeNotRetrieved = Error occurred getting index node.
indexedStore.indexNodeNotSplit = Error occurred splitting an index node.
-indexedStore.indexNodeNotStored = Error occurred storing index node.
-indexedStore.indexNotCreated = Index was not created.
-indexedStore.indexNotFound = Index not found.
-indexedStore.indexNotRemoved = Error occurred removing index from the store.
indexedStore.metadataRequestError = Error occurred during metadata request processing.
-indexedStore.objectExists = Object already exists.
indexedStore.objectIDInvalid = ObjectID format is invalid.
indexedStore.objectNotAcquired = Object has not been acquired for the intent needed for this operation.
-indexedStore.objectNotCreated = Error occurred creating a new object.
indexedStore.objectNotFound = Object not found.
-indexedStore.objectNotReleased = Cannot release an object that has not been acquired.
indexedStore.objectNotRemoved = Error occurred removing an object from the store.
indexedStore.objectNotStored = Object was not stored.
-indexedStore.objectNotUpdated = Error occurred updating an object.
-indexedStore.objectTypeError = Unexpected object type found.
-indexedStore.storeEmpty = Could not find root context because store is empty.
indexedStore.storeFormatError = Could not find root context because store has invalid format.
indexedStore.storeIsOpen = The indexed store is already open.
indexedStore.storeNotClosed = Error closing indexed store.
@@ -309,36 +295,23 @@
indexedStore.storeNotConverted = The indexed store opened is not the current version and no conversion routine exists.
indexedStore.storeNotCreated = Store does not exist and cannot be created.
indexedStore.storeNotFlushed = Error flushing indexed store.
-indexedStore.storeNotOpen = Store has not been opened.
-indexedStore.storeNotOpened = Error occurred opening indexed store.
-indexedStore.storeNotReadWrite = Attempted to set a Modify intent for an object in a read-only store.
-indexedStore.storeNotRolledBack = Error occurred rolling back the indexed store.
-objectStore.genericFailure = Error occurred in object store operation.
-objectStore.internalFailure = Internal error occurred in object store operation.
objectStore.metadataRequestFailure = Error getting or putting metadata.
objectStore.objectExistenceFailure = Object was not found.
objectStore.objectHeaderFailure = Object header format is invalid.
-objectStore.objectInsertFailure = Error occurred writing object into page.
objectStore.objectIsLocked = Operation cannot be performed because the object is being used.
-objectStore.objectRemoveFailure = Error occurred removing object from page.
objectStore.objectSizeFailure = Object is too large for page.
objectStore.objectTypeFailure = Type check failed.
-objectStore.objectUpdateFailure = Error updating object.
objectStore.pageReadFailure = Error reading page from object store.
objectStore.pageVacancyFailure = Object table on page is full.
objectStore.pageWriteFailure = Cannot store page in page store.
-objectStore.storeCloseFailure = Error occurred during close of object store.
objectStore.storeConversionFailure = Error converting object store.
objectStore.storeCreateFailure = Error creating object store.
objectStore.storeOpenFailure = Error opening object store.
-pageStore.commitFailure = Error occurred during commit processing.
pageStore.conversionFailure = Error occurred during conversion of the page store file.
pageStore.createFailure = Error occurred creating page store file.
pageStore.genericFailure = Error occurred during a page store file operation.
-pageStore.integrityFailure = Error occurred that compromises the integrity of the page store file.
-pageStore.lengthFailure = Error occurred determining page store file length.
pageStore.logCreateFailure = Error occurred creating transaction log file.
pageStore.logOpenFailure = Error occurred opening transaction log file.
pageStore.logReadFailure = Error occurred reading transaction log file.
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AbstractIndexedStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AbstractIndexedStoreTest.java
new file mode 100644
index 0000000..dc1a0a8
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AbstractIndexedStoreTest.java
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Common Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.core.tests.internal.indexing;
+
+import junit.framework.TestCase;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+/**
+ *
+ */
+public abstract class AbstractIndexedStoreTest extends TestCase {
+ public AbstractIndexedStoreTest() {
+ super();
+ }
+ public AbstractIndexedStoreTest(String name) {
+ super(name);
+ }
+ protected String getFileName() {
+ return ResourcesPlugin.getWorkspace().getRoot().getLocation().append("test.dat").toOSString();
+ }
+ protected void println(String string) {
+ //don't log anything during tests
+ }
+ protected void printHeading(String string) {
+ //don't log anything during tests
+ }
+
+}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AllTests.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AllTests.java
index afc8fd2..2a507d1 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AllTests.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/AllTests.java
@@ -13,22 +13,18 @@
import junit.framework.*;
public class AllTests extends TestCase {
-
public AllTests() {
super(null);
}
-
public AllTests(String name) {
super(name);
}
-
public static Test suite() {
TestSuite suite = new TestSuite();
- suite.addTest(IntegratedFieldTest.suite());
- suite.addTest(IntegratedIndexedStoreTest.suite());
- suite.addTest(IntegratedObjectStoreTest.suite());
- suite.addTest(IntegratedPageStoreTest.suite());
+ suite.addTest(BasicFieldTest.suite());
+ suite.addTest(BasicIndexedStoreTest.suite());
+ suite.addTest(BasicObjectStoreTest.suite());
+ suite.addTest(BasicPageStoreTest.suite());
return suite;
}
-
}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicFieldTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicFieldTest.java
index 0605754..9f24dd1 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicFieldTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicFieldTest.java
@@ -16,14 +16,11 @@
public class BasicFieldTest extends TestCase {
- protected TestEnvironment env;
-
- public BasicFieldTest(String name, TestEnvironment env) {
+ public BasicFieldTest(String name) {
super(name);
- this.env = env;
}
- public static Test suite(TestEnvironment env) {
+ public static Test suite() {
List names = new Vector(10);
names.add("testBuffer");
names.add("testPointer");
@@ -31,7 +28,7 @@
names.add("testFieldArray");
TestSuite suite = new TestSuite();
for (Iterator z = names.iterator(); z.hasNext();) {
- suite.addTest(new BasicFieldTest((String) z.next(), env));
+ suite.addTest(new BasicFieldTest((String) z.next()));
}
return suite;
}
@@ -40,7 +37,6 @@
byte[] b = new byte[256];
Buffer buf = new Buffer(b);
int n = buf.length();
- buf.clear();
b[0] = -128;
b[1] = -0;
b[2] = -0;
@@ -90,15 +86,6 @@
assertEquals("t26", 1, Buffer.compare(buf2, buf1));
}
- public void testField() throws Exception {
- }
-
- public void testFieldArray() throws Exception {
- }
-
- public void testPointer() throws Exception {
- }
-
public void testFieldDef() throws Exception {
byte[] b = new byte[256];
Field f = new Field(b);
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicIndexedStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicIndexedStoreTest.java
index 8bef131..7eaff62 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicIndexedStoreTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicIndexedStoreTest.java
@@ -14,43 +14,23 @@
import java.util.*;
import junit.framework.*;
import org.eclipse.core.internal.indexing.*;
+import org.eclipse.core.runtime.CoreException;
-public class BasicIndexedStoreTest extends TestCase {
+public class BasicIndexedStoreTest extends AbstractIndexedStoreTest {
- TestEnvironment env;
-
- public BasicIndexedStoreTest(String name, TestEnvironment env) {
- super(name);
- this.env = env;
- }
-
- public static Test suite(TestEnvironment env) {
+ public static Test suite() {
+ // return new TestSuite(BasicIndexedStoreTest.class);
TestSuite suite = new TestSuite();
- suite.addTest(new BasicIndexedStoreTest("testSanity", env));
- suite.addTest(new BasicIndexedStoreTest("testRecovery", env));
- suite.addTest(new BasicIndexedStoreTest("testTransactions", env));
- suite.addTest(new BasicIndexedStoreTest("testIndexInsert", env));
- suite.addTest(new BasicIndexedStoreTest("testIndexCursorOperations", env));
- suite.addTest(new BasicIndexedStoreTest("testIndexRemove", env));
- suite.addTest(new BasicIndexedStoreTest("testIndexOrdering", env));
- suite.addTest(new BasicIndexedStoreTest("testIndexReplace", env));
- suite.addTest(new BasicIndexedStoreTest("testObjectUpdate", env));
- suite.addTest(new BasicIndexedStoreTest("testObjectPerformance", env));
- suite.addTest(new BasicIndexedStoreTest("testMultiCursorSearch", env));
- suite.addTest(new BasicIndexedStoreTest("testMultiCursorUpdate", env));
- suite.addTest(new BasicIndexedStoreTest("testMultiCursorRemove1", env));
- suite.addTest(new BasicIndexedStoreTest("testMultiCursorRemove2", env));
- suite.addTest(new BasicIndexedStoreTest("testIndexSplit", env));
- suite.addTest(new BasicIndexedStoreTest("test1GCE9JD", env));
- suite.addTest(new BasicIndexedStoreTest("testObjectLife", env));
+ suite.addTest(new BasicIndexedStoreTest("testIndexInsert"));
return suite;
}
- private int random(int lo, int hi) {
- double t0 = Math.random();
- double t1 = (hi + 1 - lo) * t0 + lo;
- double t2 = Math.floor(t1);
- return (int) t2;
+ public BasicIndexedStoreTest() {
+ this("");
+ }
+
+ public BasicIndexedStoreTest(String name) {
+ super(name);
}
/**
@@ -65,6 +45,7 @@
return a.toString();
}
+
/**
* Insert entries with the specified key length into the index. Compare the ordering after insertion.
* Key values are 0 to numberOfEntries-1.
@@ -72,9 +53,9 @@
* That is, all values equivalent to 0 are inserted first, then all values equivalent to 1, ...
*/
private void insertAndCompare(int keySize, int numberOfEntries, int skipValue) throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
store.createIndex("Index");
Index index = store.getIndex("Index");
String key;
@@ -91,7 +72,7 @@
}
store.close();
- store.open(env.getFileName());
+ store.open(getFileName());
index = store.getIndex("Index");
IndexCursor c = index.open();
c.findFirstEntry();
@@ -104,14 +85,21 @@
store.close();
}
+ private int random(int lo, int hi) {
+ double t0 = Math.random();
+ double t1 = (hi + 1 - lo) * t0 + lo;
+ double t2 = Math.floor(t1);
+ return (int) t2;
+ }
+
/**
* Test for index store mess up recorded in PR 1GCE9JD
*/
public void test1GCE9JD() throws Exception {
IndexedStore store = null;
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
String a = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>.<classpath>. <classpathentry kind=\"src\" path=\"\"/>. <classpathentry kind=\"output\" path=\"\"/>.</classpath>";
store.createIndex("index");
@@ -127,9 +115,9 @@
* This tests basic cursor insertion, location, and removal operations.
*/
public void testIndexCursorOperations() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
/* Create an index */
@@ -265,9 +253,9 @@
* Also tests many small insertions.
*/
public void testIndexOrdering() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
store.createIndex("Index");
Index index = store.getIndex("Index");
@@ -286,7 +274,7 @@
}
/* run the index, testing the key order */
- store.open(env.getFileName());
+ store.open(getFileName());
try {
Index index = store.getIndex("Index");
IndexCursor c = index.open();
@@ -313,9 +301,9 @@
int limit = 200;
int keySize = 500;
int valueSize = 100;
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
store.createIndex("Index");
Index index = store.getIndex("Index");
@@ -347,11 +335,11 @@
* Tests the replacement of values of items in an index.
*/
public void testIndexReplace() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
int n = 5000;
int i;
- store.open(env.getFileName());
+ store.open(getFileName());
try {
Index index = store.createIndex("Index");
String key;
@@ -401,17 +389,17 @@
int i;
Vector key = new Vector(n);
- env.println("Generating...");
+ println("Generating...");
for (i = 0; i < n; i++) {
key.addElement(generateString(l, i));
}
- env.println("...Done");
+ println("...Done");
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- env.println("Inserting...");
- store.open(env.getFileName());
+ println("Inserting...");
+ store.open(getFileName());
try {
Index index = store.createIndex("Index");
for (i = 0; i < n; i++) {
@@ -423,10 +411,10 @@
} finally {
store.close();
}
- env.println("...Done");
+ println("...Done");
- env.println("Retrieving by cursor...");
- store.open(env.getFileName());
+ println("Retrieving by cursor...");
+ store.open(getFileName());
try {
Index index = store.getIndex("Index");
IndexCursor c = index.open();
@@ -442,10 +430,10 @@
} finally {
store.close();
}
- env.println("...Done");
+ println("...Done");
- env.println("Retrieving by key...");
- store.open(env.getFileName());
+ println("Retrieving by key...");
+ store.open(getFileName());
try {
Index index = store.getIndex("Index");
IndexCursor c = index.open();
@@ -460,7 +448,7 @@
} finally {
store.close();
}
- env.println("...Done");
+ println("...Done");
}
/**
@@ -470,12 +458,12 @@
* Make sure that all the cursors are adjusted correctly.
*/
public void testMultiCursorRemove1() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
int keySize = 10;
String key;
int n = 10; /* number of entries & cursors */
- store.open(env.getFileName());
+ store.open(getFileName());
try {
Index index = store.createIndex("Index");
@@ -520,13 +508,13 @@
* invalid until repositioned.
*/
public void testMultiCursorRemove2() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
int keySize = 10;
String key;
int n = 10; // number of entries
- store.open(env.getFileName());
+ store.open(getFileName());
try {
/* create and populate an index */
@@ -544,103 +532,89 @@
/* Remove the entry at the first cursor and test the second cursor for results */
c1.remove();
- int id = 0;
try {
c2.remove();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("remove test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("remove test", IndexedStoreException.EntryRemoved, id);
-
- id = 0;
try {
c2.getKey();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("get key test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("get key test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.getValue();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("get value test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("get value test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.updateValue("123");
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("update value test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("update value test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.isAtEnd();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("isAtEnd test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("isAtEnd test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.isAtBeginning();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("isAtBeginning test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("isAtBeginning test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.isSet();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("isSet test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("isSet test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.next();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("move next test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("move next test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.previous();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("move previous test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("move previous test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.keyEquals("");
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("key equals test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("key equals test", IndexedStoreException.EntryRemoved, id);
- id = 0;
try {
c2.keyMatches("");
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("key matches test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("key matches test", IndexedStoreException.EntryRemoved, id);
c2.reset();
- id = 0;
try {
c2.next();
- } catch (IndexedStoreException e) {
- id = e.id;
+ fail("reset test");
+ } catch (CoreException e) {
+ //should fail
}
- assertEquals("reset test", 0, id);
-
assertEquals("positioning test", c1.getValueAsString(), c2.getValueAsString());
} finally {
@@ -656,9 +630,9 @@
int keySize = 5;
int n = 10; /* number of cursors */
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
@@ -736,7 +710,7 @@
* This tests adjustments due to node splitting.
*/
public void testMultiCursorUpdate() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
int keySize = 1000;
int valueSize1 = 0;
@@ -745,7 +719,7 @@
int n = 10; /* number of cursors */
/* create and populate an index, all keys and values are unique */
- store.open(env.getFileName());
+ store.open(getFileName());
try {
Index index = store.createIndex("Index");
for (int i = 0; i < n; i++) {
@@ -786,15 +760,73 @@
}
}
+ /**
+ * Tests the creating, updating, and deleting of objects in the store.
+ * This test generates object names and objects, stores the names in an
+ * index and the objects as blobs. Deletions and updates are done as well.
+ */
+ public void testObjectLife() throws Exception {
+ int n = 50000;
+ IndexedStore.delete(getFileName());
+ IndexedStore store = new IndexedStore();
+ store.open(getFileName());
+ try {
+ Index index = store.createIndex("index");
+ IndexCursor cursor = index.open();
+ ObjectID id = null;
+ String name = null;
+ String value = null;
+ Random r = new Random(100); // same seed should generate the same test on the same VM
+ for (int i = 0; i < n; i++) {
+ int k = Math.abs(r.nextInt());
+ int k1 = k % 100; // used to gen name
+ int k2 = k % 2; // used to gen operation
+ name = "Object" + generateString(20, k1);
+ value = "Value" + k1;
+ cursor.find(name);
+ if (cursor.keyEquals(name)) {
+ id = cursor.getValueAsObjectID();
+ String foundValue = store.getObjectAsString(id);
+ assertEquals(value, foundValue);
+ switch (k2) {
+ case 0 :
+ // delete object named x if it exists
+ println(" Deleting " + name);
+ store.removeObject(id);
+ cursor.remove();
+ break;
+ case 1 :
+ println(" Updating " + name);
+ store.updateObject(id, value);
+ break;
+ default :
+ // no operation
+ println(" Nothing");
+ }
+ } else {
+ println(" Inserting " + name);
+ id = store.createObject(value);
+ index.insert(name, id);
+ }
+ if (i % 20 == 19) {
+ println(" Commit");
+ store.commit();
+ }
+ }
+ } finally {
+ store.close();
+ }
+ }
+
/**
* Timed test for creation and retrieval of 100000 simple objects.
*/
public void testObjectPerformance() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
HashSet ids = new HashSet();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
int n = 100000;
byte[] a = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".getBytes();
@@ -805,12 +837,12 @@
store.commit();
}
long t1 = System.currentTimeMillis();
- env.println("Time to create = " + ((t1 - t0) / 1000));
+ println("Time to create = " + ((t1 - t0) / 1000));
} finally {
store.close();
}
- store.open(env.getFileName());
+ store.open(getFileName());
try {
Iterator idStream = ids.iterator();
long t0 = System.currentTimeMillis();
@@ -818,7 +850,7 @@
store.getObject((ObjectID) idStream.next());
}
long t1 = System.currentTimeMillis();
- env.println("Time to retrieve = " + ((t1 - t0) / 1000));
+ println("Time to retrieve = " + ((t1 - t0) / 1000));
} finally {
store.close();
}
@@ -831,9 +863,9 @@
*/
public void testObjectUpdate() throws Exception {
int n = 1000;
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
String s = "";
ObjectID id = store.createObject(s);
@@ -852,80 +884,21 @@
}
/**
- * Tests the creating, updating, and deleting of objects in the store.
- * This test generates object names and objects, stores the names in an
- * index and the objects as blobs. Deletions and updates are done as well.
- */
- public void testObjectLife() throws Exception {
- int n = 50000;
- IndexedStore.delete(env.getFileName());
- IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
- try {
- Index index = store.createIndex("index");
- IndexCursor cursor = index.open();
- ObjectID id = null;
- String name = null;
- String value = null;
- Random r = new Random(100); // same seed should generate the same test on the same VM
- for (int i = 0; i < n; i++) {
- env.print(i, 8);
- int k = Math.abs(r.nextInt());
- int k1 = k % 100; // used to gen name
- int k2 = k % 2; // used to gen operation
- name = "Object" + generateString(20, k1);
- value = "Value" + k1;
- cursor.find(name);
- if (cursor.keyEquals(name)) {
- id = cursor.getValueAsObjectID();
- String foundValue = store.getObjectAsString(id);
- assertEquals(value, foundValue);
- switch (k2) {
- case 0 :
- // delete object named x if it exists
- env.println(" Deleting " + name);
- store.removeObject(id);
- cursor.remove();
- break;
- case 1 :
- env.println(" Updating " + name);
- store.updateObject(id, value);
- break;
- default :
- // no operation
- env.println(" Nothing");
- }
- } else {
- env.println(" Inserting " + name);
- id = store.createObject(value);
- index.insert(name, id);
- }
- if (i % 20 == 19) {
- env.println(" Commit");
- store.commit();
- }
- }
- } finally {
- store.close();
- }
- }
-
- /**
* Tests simple recovery APIs.
*/
public void testRecovery() throws Exception {
IndexedStore store = null;
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
try {
- store.open(env.getFileName());
- } catch (IndexedStoreException e) {
- if (e.id != IndexedStoreException.StoreIsOpen)
- fail("expected exception did not occur");
+ store.open(getFileName());
+ fail("expected exception did not occur");
+ } catch (CoreException e) {
+ //should fail
}
- IndexedStore store2 = IndexedStore.find(env.getFileName());
+ IndexedStore store2 = IndexedStore.find(getFileName());
if (store2 == null)
fail("store looks like its not open");
assertSame(store, store2);
@@ -938,9 +911,9 @@
* Tests simple creation and deletion of an IndexedStore.
*/
public void testSanity() throws Exception {
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
IndexedStore store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
store.close();
}
@@ -949,18 +922,18 @@
*/
public void testTransactions() throws Exception {
IndexedStore store = null;
- IndexedStore.delete(env.getFileName());
+ IndexedStore.delete(getFileName());
store = new IndexedStore();
- store.open(env.getFileName());
+ store.open(getFileName());
try {
store.createIndex("Index");
store.getIndex("Index");
store.rollback();
try {
- store.getIndex("Index");
- } catch (IndexedStoreException e) {
- if (e.id != IndexedStoreException.IndexNotFound)
+ if (store.getIndex("Index") != null)
fail("expected exception was not thrown");
+ } catch (CoreException e) {
+ fail("expected exception was not thrown");
}
store.createIndex("Index");
store.getIndex("Index");
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicObjectStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicObjectStoreTest.java
index b2c8b72..58ec46c 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicObjectStoreTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicObjectStoreTest.java
@@ -16,26 +16,16 @@
import org.eclipse.core.internal.indexing.ObjectAddress;
import org.eclipse.core.internal.indexing.ObjectStore;
-public class BasicObjectStoreTest extends TestCase {
+public class BasicObjectStoreTest extends AbstractIndexedStoreTest {
protected Vector addresses;
- protected TestEnvironment env;
- public BasicObjectStoreTest(String name, TestEnvironment env) {
- super(name);
- this.env = env;
+ public static Test suite() {
+ return new TestSuite(BasicObjectStoreTest.class);
}
- public static Test suite(TestEnvironment env) {
- TestSuite suite = new TestSuite();
- suite.addTest(new BasicObjectStoreTest("testSanity", env));
- suite.addTest(new BasicObjectStoreTest("testInsertRemove", env));
- suite.addTest(new BasicObjectStoreTest("testPopulate", env));
- suite.addTest(new BasicObjectStoreTest("testUpdate", env));
- suite.addTest(new BasicObjectStoreTest("testIdentity", env));
- suite.addTest(new BasicObjectStoreTest("testRemove", env));
- suite.addTest(new BasicObjectStoreTest("testLarge", env));
- return suite;
+ public BasicObjectStoreTest(String name) {
+ super(name);
}
/**
@@ -53,7 +43,7 @@
// populate an object store with 256 copies of a particular string
public void populate(String string) throws Exception {
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
try {
addresses = new Vector();
for (int i = 0; i < 255; i++) {
@@ -70,11 +60,11 @@
// test object identity
public void testIdentity() throws Exception {
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
String s = "000011112222";
populate(s);
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
try {
s = "aaaabbbbcccc";
int n = addresses.size();
@@ -101,9 +91,9 @@
*/
public void testInsertRemove() throws Exception {
String string = "---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*";
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
try {
for (int i = 0; i < 1000; i++) {
TestObject object = new TestObject(string.getBytes());
@@ -119,14 +109,14 @@
// put some big objects in
public void testLarge() throws Exception {
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
StringBuffer buf = new StringBuffer(3500);
while (buf.length() < 3500)
buf.append("---*---*---*---*");
String s = buf.toString();
byte[] b1 = s.getBytes();
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
try {
addresses = new Vector();
for (int i = 0; i < (16 * 1024); i++) {
@@ -151,14 +141,14 @@
// populate and check the contents of the database
public void testPopulate() throws Exception {
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
ObjectStore store = new ObjectStore(new TestObjectPolicy());
StringBuffer buffer = new StringBuffer(4096);
String fragment = "---*---*---*---*";
for (int j = 0; j < 64; j++) {
String s = buffer.toString();
populate(s);
- store.open(env.getFileName());
+ store.open(getFileName());
try {
int n = addresses.size();
for (int i = 0; i < n; i++) {
@@ -177,11 +167,11 @@
// remove all the objects
public void testRemove() throws Exception {
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
String s = "000011112222";
populate(s);
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
try {
int n = addresses.size();
for (int i = 0; i < n; i++) {
@@ -196,20 +186,20 @@
// open and close
public void testSanity() throws Exception {
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
store.close();
return;
}
// update the objects and check the contents again, object size does not change
public void testUpdate() throws Exception {
- ObjectStore.delete(env.getFileName());
+ ObjectStore.delete(getFileName());
String s = "000011112222";
populate(s);
ObjectStore store = new ObjectStore(new TestObjectPolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
try {
s = "aaaabbbbcccc";
int n = addresses.size();
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicPageStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicPageStoreTest.java
index 28226ef..3607cc9 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicPageStoreTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/BasicPageStoreTest.java
@@ -14,31 +14,14 @@
import junit.framework.*;
import org.eclipse.core.internal.indexing.PageStore;
-public class BasicPageStoreTest extends TestCase {
+public class BasicPageStoreTest extends AbstractIndexedStoreTest{
- protected TestEnvironment env;
-
- public BasicPageStoreTest(String name, TestEnvironment env) {
+ public BasicPageStoreTest(String name) {
super(name);
- this.env = env;
}
- public static Test suite(TestEnvironment env) {
- TestSuite suite = new TestSuite();
- suite.addTest(new BasicPageStoreTest("testCreate", env));
- suite.addTest(new BasicPageStoreTest("testDelete", env));
- suite.addTest(new BasicPageStoreTest("testWrite", env));
- suite.addTest(new BasicPageStoreTest("testLogging1", env));
- suite.addTest(new BasicPageStoreTest("testLogging2", env));
- suite.addTest(new BasicPageStoreTest("testLogging3", env));
- suite.addTest(new BasicPageStoreTest("testWriteLarge", env));
- suite.addTest(new BasicPageStoreTest("testWriteHuge", env));
- suite.addTest(new BasicPageStoreTest("testReadOnly", env));
- suite.addTest(new BasicPageStoreTest("testCacheHitsSequential", env));
- suite.addTest(new BasicPageStoreTest("testCacheHitsCircular", env));
- suite.addTest(new BasicPageStoreTest("testCacheHitsRandom", env));
- suite.addTest(new BasicPageStoreTest("testRandomReadWrite", env));
- return suite;
+ public static Test suite() {
+ return new TestSuite(BasicPageStoreTest.class);
}
// check a byte array against a value
@@ -60,9 +43,9 @@
* Creates an initialized 128 page store.
*/
public int initializeStore() throws Exception {
- PageStore.delete(env.getFileName());
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
int n = 128;
for (int i = 0; i < n; i++) {
TestPage p = (TestPage) store.acquire(i);
@@ -74,23 +57,23 @@
}
void printStats(PageStore store) throws Exception {
- env.println("Number of pages = " + store.numberOfPages());
- env.println("Number of writes = " + store.numberOfFileWrites());
- env.println("Number of file reads = " + store.numberOfFileReads());
- env.println("Number of cache reads = " + store.numberOfCacheHits());
- env.println("Number of reads = " + store.numberOfReads());
- env.println("Cache hit ratio = " + (float) store.numberOfCacheHits() / (float) store.numberOfReads());
+ println("Number of pages = " + store.numberOfPages());
+ println("Number of writes = " + store.numberOfFileWrites());
+ println("Number of file reads = " + store.numberOfFileReads());
+ println("Number of cache reads = " + store.numberOfCacheHits());
+ println("Number of reads = " + store.numberOfReads());
+ println("Cache hit ratio = " + (float) store.numberOfCacheHits() / (float) store.numberOfReads());
}
/**
* Test cache performance using a circular reference pattern.
*/
public void testCacheHitsCircular() throws Exception {
- env.printHeading("testCacheHitsCircular");
+ printHeading("testCacheHitsCircular");
initializeStore();
PageStore store = new PageStore(new TestPagePolicy());
- env.println("Testing 41 of 40");
- store.open(env.getFileName());
+ println("Testing 41 of 40");
+ store.open(getFileName());
for (int j = 0; j < 100; j++) {
for (int i = 0; i < 41; i++) {
TestPage p = (TestPage) store.acquire(i);
@@ -100,8 +83,8 @@
}
printStats(store);
store.close();
- env.println("Testing 40 of 40");
- store.open(env.getFileName());
+ println("Testing 40 of 40");
+ store.open(getFileName());
for (int j = 0; j < 100; j++) {
for (int i = 0; i < 40; i++) {
TestPage p = (TestPage) store.acquire(i);
@@ -117,12 +100,12 @@
* Test the effect of increasing cache sizes
*/
public void testCacheHitsRandom() throws Exception {
- env.printHeading("testCacheHitsRandom");
- PageStore.delete(env.getFileName());
+ printHeading("testCacheHitsRandom");
+ PageStore.delete(getFileName());
int n = initializeStore();
for (int m = 0; m <= n; m += 16) {
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
Random r = new Random(100);
for (int i = 0; i < 1000; i++) {
TestPage p = (TestPage) store.acquire(Math.abs(r.nextInt() % n));
@@ -137,10 +120,10 @@
* Checks the performance of sequential access.
*/
public void testCacheHitsSequential() throws Exception {
- env.printHeading("testCacheHitsSequential");
+ printHeading("testCacheHitsSequential");
int n = initializeStore();
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
for (int i = 0; i < n; i++) {
TestPage p = (TestPage) store.acquire(i);
assertTrue(p.check((byte) i));
@@ -153,27 +136,27 @@
/**
*/
public void testCreate() throws Exception {
- env.printHeading("testCreate");
- PageStore.create(env.getFileName());
- assertTrue(PageStore.exists(env.getFileName()));
+ printHeading("testCreate");
+ PageStore.create(getFileName());
+ assertTrue(PageStore.exists(getFileName()));
}
/**
*/
public void testDelete() throws Exception {
- env.printHeading("testDelete");
- PageStore.delete(env.getFileName());
- assertTrue(!PageStore.exists(env.getFileName()));
+ printHeading("testDelete");
+ PageStore.delete(getFileName());
+ assertTrue(!PageStore.exists(getFileName()));
}
/**
* Tests the log.
*/
public void testLogging1() throws Exception {
- env.printHeading("testLogging1");
- PageStore.delete(env.getFileName());
+ printHeading("testLogging1");
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
testLogPopulate(store);
store.testLogging1();
testLogValidate(store);
@@ -184,10 +167,10 @@
* Tests the log.
*/
public void testLogging2() throws Exception {
- env.printHeading("testLogging2");
- PageStore.delete(env.getFileName());
+ printHeading("testLogging2");
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
testLogPopulate(store);
store.testLogging2();
testLogValidate(store);
@@ -198,10 +181,10 @@
* Tests the log.
*/
public void testLogging3() throws Exception {
- env.printHeading("testLogging3");
- PageStore.delete(env.getFileName());
+ printHeading("testLogging3");
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
testLogPopulate(store);
store.testLogging3();
testLogValidate(store);
@@ -234,14 +217,14 @@
* Tests random reading & writing.
*/
public void testRandomReadWrite() throws Exception {
- env.printHeading("testRandomReadWrite");
- PageStore.delete(env.getFileName());
+ printHeading("testRandomReadWrite");
+ PageStore.delete(getFileName());
int n = 128;
byte[] value = new byte[n];
for (int i = 0; i < n; i++)
value[i] = 0;
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
Random r = new Random(100);
for (int i = 0; i < 2000; i++) {
int k = Math.abs(r.nextInt() % n);
@@ -259,11 +242,11 @@
* Tests read-only access on the store.
*/
public void testReadOnly() throws Exception {
- env.printHeading("testReadOnly");
- PageStore.delete(env.getFileName());
+ printHeading("testReadOnly");
+ PageStore.delete(getFileName());
int n = initializeStore();
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
assertTrue(store.numberOfPages() == n);
for (int i = 0; i < n; i++) {
TestPage p = (TestPage) store.acquire(i);
@@ -278,10 +261,10 @@
* Adds & checks 128 8K pages (1 meg) to the page file.
*/
public void testWrite() throws Exception {
- env.printHeading("testWrite");
- PageStore.delete(env.getFileName());
+ printHeading("testWrite");
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
writeBlock(store);
printStats(store);
store.close();
@@ -291,10 +274,10 @@
* Adds a 64 meg chunk to the page file.
*/
public void testWriteHuge() throws Exception {
- env.printHeading("testWriteHuge");
- PageStore.delete(env.getFileName());
+ printHeading("testWriteHuge");
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
for (int i = 0; i < 64; i++)
writeBlock(store);
printStats(store);
@@ -305,10 +288,10 @@
* Adds a 16 meg chunk to the page file.
*/
public void testWriteLarge() throws Exception {
- env.printHeading("testWriteLarge");
- PageStore.delete(env.getFileName());
+ printHeading("testWriteLarge");
+ PageStore.delete(getFileName());
PageStore store = new PageStore(new TestPagePolicy());
- store.open(env.getFileName());
+ store.open(getFileName());
for (int i = 0; i < 16; i++)
writeBlock(store);
printStats(store);
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedFieldTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedFieldTest.java
deleted file mode 100644
index 2f64e25..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedFieldTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.framework.Test;
-
-public class IntegratedFieldTest {
-
- public static Test suite() {
- TestEnvironment env = new IntegratedTestEnvironment();
- return BasicFieldTest.suite(env);
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedIndexedStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedIndexedStoreTest.java
deleted file mode 100644
index d952786..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedIndexedStoreTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.framework.Test;
-
-public class IntegratedIndexedStoreTest {
-
- public static Test suite() {
- TestEnvironment env = new IntegratedTestEnvironment();
- return BasicIndexedStoreTest.suite(env);
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedObjectStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedObjectStoreTest.java
deleted file mode 100644
index 5a9a709..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedObjectStoreTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.framework.Test;
-
-public class IntegratedObjectStoreTest {
-
- public static Test suite() {
- TestEnvironment env = new IntegratedTestEnvironment();
- return BasicObjectStoreTest.suite(env);
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedPageStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedPageStoreTest.java
deleted file mode 100644
index 37f3705..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedPageStoreTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.framework.Test;
-
-public class IntegratedPageStoreTest {
-
- public static Test suite() {
- TestEnvironment env = new IntegratedTestEnvironment();
- return BasicPageStoreTest.suite(env);
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedTestEnvironment.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedTestEnvironment.java
deleted file mode 100644
index 89c9e3a..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/IntegratedTestEnvironment.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
-
-public class IntegratedTestEnvironment extends EclipseWorkspaceTest implements TestEnvironment {
-
- public String getFileName() {
- return getWorkspace().getRoot().getLocation().append("test.dat").toOSString();
- }
-
- public void print(String s) {
- }
-
- public void print(int n, int width) {
- }
-
- public void println(String s) {
- }
-
- public void printHeading(String s) {
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneFieldTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneFieldTest.java
deleted file mode 100644
index 68c68a3..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneFieldTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.textui.TestRunner;
-
-public class StandAloneFieldTest {
-
- public static void main(String[] args) {
- TestRunner.run(BasicFieldTest.suite(new StandAloneTestEnvironment()));
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneIndexedStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneIndexedStoreTest.java
deleted file mode 100644
index 5398c4e..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneIndexedStoreTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.textui.TestRunner;
-
-public class StandAloneIndexedStoreTest {
-
- public static void main(String[] args) {
- TestRunner.run(BasicIndexedStoreTest.suite(new StandAloneTestEnvironment()));
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneObjectStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneObjectStoreTest.java
deleted file mode 100644
index f023fa2..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneObjectStoreTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.textui.TestRunner;
-
-public class StandAloneObjectStoreTest {
-
- public static void main(String[] args) {
- TestRunner.run(BasicObjectStoreTest.suite(new StandAloneTestEnvironment()));
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAlonePageStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAlonePageStoreTest.java
deleted file mode 100644
index d6fae4c..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAlonePageStoreTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import junit.textui.TestRunner;
-
-public class StandAlonePageStoreTest {
-
- public static void main(String[] args) {
- TestRunner.run(BasicPageStoreTest.suite(new StandAloneTestEnvironment()));
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneTestEnvironment.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneTestEnvironment.java
deleted file mode 100644
index 321f0c1..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/StandAloneTestEnvironment.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-import java.io.*;
-
-public class StandAloneTestEnvironment implements TestEnvironment {
-
- protected final static String sep = File.separator;
- protected final static String driveLetter = "c:";
- protected final static String directoryName = driveLetter + sep + "tests" + sep;
- protected final static String fileName = directoryName + "test.dat";
-
- private PrintWriter out;
-
- public StandAloneTestEnvironment() {
- // out = new PrintWriter(System.out, true);
- try {
- out = new PrintWriter(new FileWriter(directoryName + sep + "test.txt"), true);
- } catch (IOException e) {
- }
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public void print(String s) {
- if (out != null)
- out.print(s);
- }
-
- public void print(int n, int width) {
- StringBuffer b = new StringBuffer(width);
- String s = Integer.toString(n);
- if (s.length() > width) {
- for (int i = 0; i < width; i++)
- b.append("#");
- } else {
- for (int i = 0; i < width - s.length(); i++)
- b.append(" ");
- b.append(s);
- }
- print(b.toString());
- }
-
- public void println(String s) {
- if (out != null)
- out.println(s);
- }
-
- public void printHeading(String s) {
- if (out != null) {
- out.println();
- out.println(s);
- }
- }
-
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestEnvironment.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestEnvironment.java
deleted file mode 100644
index a89d1a1..0000000
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestEnvironment.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.indexing;
-
-public interface TestEnvironment {
-
- /**
- * Returns the file name which will be used as a target for a
- * particular test suite. This will be the name of an IndexedStore,
- * an ObjectStore, or a PageStore file.
- */
- public String getFileName();
-
- /**
- * Prints a string on an output stream. All testcase strings are informational only.
- */
- public void print(String s);
-
- /**
- * Prints a string on an output stream. All testcase strings are informational only.
- */
- public void println(String s);
-
- /**
- * Prints a number on an output stream. All testcase strings are informational only.
- */
- public void print(int n, int width);
-
- /**
- * Prints a blank line first then a full line
- */
- public void printHeading(String s);
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObject.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObject.java
index e2b13be..a57515b 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObject.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObject.java
@@ -11,6 +11,7 @@
package org.eclipse.core.tests.internal.indexing;
import org.eclipse.core.internal.indexing.*;
+import org.eclipse.core.runtime.CoreException;
class TestObject extends StoredObject {
@@ -28,7 +29,7 @@
/**
* Standard constructor -- constructs an object from bytes that came from the store.
*/
- TestObject(Field buffer, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ TestObject(Field buffer, ObjectStore store, ObjectAddress address) throws CoreException {
super(buffer, store, address);
}
@@ -45,7 +46,7 @@
* Places the contents of the buffer into the fields.
* Subclasses should implement and call super.
*/
- protected void extractValues(Field buffer) throws ObjectStoreException {
+ protected void extractValues(Field buffer) throws CoreException {
super.extractValues(buffer);
value = buffer.subfield(2).get();
}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObjectPolicy.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObjectPolicy.java
index 4759a60..67217cb 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObjectPolicy.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestObjectPolicy.java
@@ -11,21 +11,13 @@
package org.eclipse.core.tests.internal.indexing;
import org.eclipse.core.internal.indexing.*;
+import org.eclipse.core.runtime.CoreException;
public class TestObjectPolicy extends AbstractObjectPolicy {
-
- /**
- * Constructor for TestObjectPolicy
+ /* (non-Javadoc)
+ * @see org.eclipse.core.internal.indexing.AbstractObjectPolicy#createObject(org.eclipse.core.internal.indexing.Field, org.eclipse.core.internal.indexing.ObjectStore, org.eclipse.core.internal.indexing.ObjectAddress)
*/
- public TestObjectPolicy() {
- super();
- }
-
- /**
- * @see ObjectPolicy#createObject(Field, ObjectStore, ObjectAddress)
- */
- public StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
+ public StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws CoreException {
return new TestObject(field, store, address);
}
-
}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestPagePolicy.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestPagePolicy.java
index 5a641cb..e8c86a7 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestPagePolicy.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/indexing/TestPagePolicy.java
@@ -13,12 +13,10 @@
import org.eclipse.core.internal.indexing.*;
public class TestPagePolicy extends AbstractPagePolicy {
-
- /**
- * @see PageStorePolicy#createPage(int, byte[], PageStore)
+ /* (non-Javadoc)
+ * @see org.eclipse.core.internal.indexing.AbstractPagePolicy#createPage(int, byte[], org.eclipse.core.internal.indexing.PageStore)
*/
public Page createPage(int pageNumber, byte[] buffer, PageStore pageStore) {
return new TestPage(pageNumber, buffer, pageStore);
}
-
}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java
index e20bb30..a6dfe3a 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java
@@ -2312,7 +2312,7 @@
assertTrue("1.3", myListener.hasBeenTriggered());
}
- private void removeHistoryStoreEntry(IndexedStoreWrapper store, HistoryStoreEntry entry) throws IndexedStoreException {
+ private void removeHistoryStoreEntry(IndexedStoreWrapper store, HistoryStoreEntry entry) throws CoreException {
// This method provided as a convenience for removing a HistoryStoreEntry.
// It is pirated directly from HistoryStore.remove(HistoryStoreEntry)
// which is a protected method.