From a2298969a765b455dc994fd402da0fbd759eea47 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 4 May 2008 19:02:42 +0000 Subject: Revise getCapability. --- .../carbonado/repo/replicated/ReplicatedRepository.java | 16 +++++++++++++++- .../repo/replicated/ReplicatedRepositoryBuilder.java | 5 +---- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/main/java/com') 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. *

- * In addition to providing all the replica's capabilities, the following extra - * capabilities are supported: + * The following extra capabilities are supported: *

* * @author Don Schneider -- cgit v1.2.3