summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java2
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java7
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java10
-rw-r--r--src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java13
-rw-r--r--src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java7
5 files changed, 22 insertions, 17 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java b/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java
index d9e9f32..5141788 100644
--- a/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java
+++ b/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java
@@ -132,7 +132,7 @@ class DependentStorableFetcher<S extends Storable, D extends Storable> {
/**
* @return amount added to list
*/
- public int createIndexEntries(D master, List<Storable> indexEntries) {
+ public int createIndexEntries(D master, List<Storable> indexEntries) throws FetchException {
IndexEntryAccessor[] accessors = mIndexEntryAccessors;
int length = accessors.length;
for (int i=0; i<length; i++) {
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java
index 1b7f910..e3909c8 100644
--- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java
+++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java
@@ -20,6 +20,7 @@ package com.amazon.carbonado.repo.indexed;
import java.util.Comparator;
+import com.amazon.carbonado.FetchException;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Storage;
@@ -46,7 +47,7 @@ public interface IndexEntryAccessor<S extends Storable> extends IndexInfo {
* @param indexEntry source of property values
* @param master master whose primary key properties will be set
*/
- void copyToMasterPrimaryKey(Storable indexEntry, S master);
+ void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException;
/**
* Sets all the properties of the given index entry, using the applicable
@@ -55,7 +56,7 @@ public interface IndexEntryAccessor<S extends Storable> extends IndexInfo {
* @param indexEntry index entry whose properties will be set
* @param master source of property values
*/
- void copyFromMaster(Storable indexEntry, S master);
+ void copyFromMaster(Storable indexEntry, S master) throws FetchException;
/**
* Returns true if the properties of the given index entry match those
@@ -65,7 +66,7 @@ public interface IndexEntryAccessor<S extends Storable> extends IndexInfo {
* @param indexEntry index entry whose properties will be tested
* @param master source of property values
*/
- boolean isConsistent(Storable indexEntry, S master);
+ boolean isConsistent(Storable indexEntry, S master) throws FetchException;
/**
* Repairs the index by inserting missing entries and fixing
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java
index 8219ac1..e730c6e 100644
--- a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java
+++ b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java
@@ -146,17 +146,17 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> {
}
// Required by IndexEntryAccessor interface.
- public void copyToMasterPrimaryKey(Storable indexEntry, S master) {
+ public void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException {
mAccessor.copyToMasterPrimaryKey(indexEntry, master);
}
// Required by IndexEntryAccessor interface.
- public void copyFromMaster(Storable indexEntry, S master) {
+ public void copyFromMaster(Storable indexEntry, S master) throws FetchException {
mAccessor.copyFromMaster(indexEntry, master);
}
// Required by IndexEntryAccessor interface.
- public boolean isConsistent(Storable indexEntry, S master) {
+ public boolean isConsistent(Storable indexEntry, S master) throws FetchException {
return mAccessor.isConsistent(indexEntry, master);
}
@@ -561,7 +561,7 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> {
}
// If index entry already exists, then index might be corrupt.
- {
+ try {
Storable freshEntry = mIndexEntryStorage.prepare();
mAccessor.copyFromMaster(freshEntry, userStorable);
indexEntry.copyVersionProperty(freshEntry);
@@ -571,6 +571,8 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> {
// user error.
return !isUnique();
}
+ } catch (FetchException e) {
+ throw e.toPersistException();
}
// Run the repair outside a transaction.
diff --git a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java
index 778b4ac..f83be02 100644
--- a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java
+++ b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java
@@ -24,6 +24,7 @@ import java.lang.reflect.UndeclaredThrowableException;
import java.util.Comparator;
import java.util.Iterator;
+import com.amazon.carbonado.FetchException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.cursor.SortedCursor;
@@ -109,11 +110,11 @@ public class SyntheticStorableReferenceAccess<S extends Storable> {
* @param reference source of property values
* @param master master whose primary key properties will be set
*/
- public void copyToMasterPrimaryKey(Storable reference, S master) {
+ public void copyToMasterPrimaryKey(Storable reference, S master) throws FetchException {
try {
mCopyToMasterPkMethod.invoke(reference, master);
} catch (Exception e) {
- ThrowUnchecked.fireFirstDeclaredCause(e);
+ ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class);
}
}
@@ -124,11 +125,11 @@ public class SyntheticStorableReferenceAccess<S extends Storable> {
* @param reference reference whose properties will be set
* @param master source of property values
*/
- public void copyFromMaster(Storable reference, S master) {
+ public void copyFromMaster(Storable reference, S master) throws FetchException {
try {
mCopyFromMasterMethod.invoke(reference, master);
} catch (Exception e) {
- ThrowUnchecked.fireFirstDeclaredCause(e);
+ ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class);
}
}
@@ -140,11 +141,11 @@ public class SyntheticStorableReferenceAccess<S extends Storable> {
* @param reference reference whose properties will be tested
* @param master source of property values
*/
- public boolean isConsistent(Storable reference, S master) {
+ public boolean isConsistent(Storable reference, S master) throws FetchException {
try {
return (Boolean) mIsConsistentMethod.invoke(reference, master);
} catch (Exception e) {
- ThrowUnchecked.fireFirstDeclaredCause(e);
+ ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class);
// Not reached.
return false;
}
diff --git a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
index a06c557..75f1701 100644
--- a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
+++ b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import com.amazon.carbonado.FetchException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.SupportException;
import com.amazon.carbonado.info.Direction;
@@ -350,7 +351,7 @@ public class SyntheticStorableReferenceBuilder<S extends Storable>
* @deprecated call getReferenceAccess
*/
@Deprecated
- public void copyToMasterPrimaryKey(Storable indexEntry, S master) {
+ public void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException {
getReferenceAccess().copyToMasterPrimaryKey(indexEntry, master);
}
@@ -363,7 +364,7 @@ public class SyntheticStorableReferenceBuilder<S extends Storable>
* @deprecated call getReferenceAccess
*/
@Deprecated
- public void copyFromMaster(Storable indexEntry, S master) {
+ public void copyFromMaster(Storable indexEntry, S master) throws FetchException {
getReferenceAccess().copyFromMaster(indexEntry, master);
}
@@ -379,7 +380,7 @@ public class SyntheticStorableReferenceBuilder<S extends Storable>
* @deprecated call getReferenceAccess
*/
@Deprecated
- public boolean isConsistent(Storable indexEntry, S master) {
+ public boolean isConsistent(Storable indexEntry, S master) throws FetchException {
return getReferenceAccess().isConsistent(indexEntry, master);
}