summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-05-04 19:02:42 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-05-04 19:02:42 +0000
commita2298969a765b455dc994fd402da0fbd759eea47 (patch)
tree53ea9145f460a8f208109ea68b17418093da4493 /src/main/java
parentdc708480b286decd4328d52d742cac000faca3f8 (diff)
Revise getCapability.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java16
-rw-r--r--src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java5
2 files changed, 16 insertions, 5 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java
index 3e2894d..f43e043 100644
--- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java
+++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java
@@ -53,6 +53,8 @@ import com.amazon.carbonado.info.Direction;
import com.amazon.carbonado.info.StorableInfo;
import com.amazon.carbonado.info.StorableIntrospector;
+import com.amazon.carbonado.repo.indexed.IndexEntryAccessCapability;
+
import com.amazon.carbonado.spi.StoragePool;
import com.amazon.carbonado.spi.TransactionPair;
@@ -242,7 +244,19 @@ class ReplicatedRepository
return (C) this;
}
- return mReplicaRepository.getCapability(capabilityType);
+ // Favor replica's indexing capabilities, since they are used for queries.
+ boolean favorReplica =
+ IndexInfoCapability.class.isAssignableFrom(capabilityType) ||
+ IndexEntryAccessCapability.class.isAssignableFrom(capabilityType);
+
+ C masterCap = mMasterRepository.getCapability(capabilityType);
+ C replicaCap = mReplicaRepository.getCapability(capabilityType);
+
+ if (favorReplica) {
+ return replicaCap != null ? replicaCap : masterCap;
+ } else {
+ return masterCap != null ? masterCap : replicaCap;
+ }
}
public void close() {
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java
index da242e6..3ab2146 100644
--- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java
+++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java
@@ -36,12 +36,9 @@ import com.amazon.carbonado.spi.BelatedRepositoryCreator;
/**
* Repository builder for the replicated repository.
* <p>
- * In addition to providing all the replica's capabilities, the following extra
- * capabilities are supported:
+ * The following extra capabilities are supported:
* <ul>
* <li>{@link com.amazon.carbonado.capability.ResyncCapability ResyncCapability}
- * <li>{@link com.amazon.carbonado.capability.ShutdownCapability ShutdownCapability}
- * <li>{@link com.amazon.carbonado.capability.StorableInfoCapability StorableInfoCapability}
* </ul>
*
* @author Don Schneider