Skip to content
Browse files

Make SocketStoreClientFactory wrap getStoreClient with LazyStoreClien…

…t by default
  • Loading branch information...
1 parent 95705b4 commit 8ec0447011c810d33d868ba093c86a9a1eb9968a @afeinberg afeinberg committed Jan 4, 2011
View
4 src/java/voldemort/client/AbstractStoreClientFactory.java
@@ -237,6 +237,10 @@ public AbstractStoreClientFactory(ClientConfig config) {
return serializedStore;
}
+ protected ClientConfig getConfig() {
+ return config;
+ }
+
protected abstract FailureDetector initFailureDetector(final ClientConfig config,
final Collection<Node> nodes);
View
21 src/java/voldemort/client/SocketStoreClientFactory.java
@@ -21,6 +21,7 @@
import java.net.URI;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import voldemort.VoldemortException;
@@ -38,6 +39,7 @@
import voldemort.store.socket.clientrequest.ClientRequestExecutorPool;
import voldemort.utils.ByteArray;
import voldemort.utils.JmxUtils;
+import voldemort.versioning.InconsistencyResolver;
import voldemort.versioning.Versioned;
/**
@@ -72,6 +74,25 @@ public SocketStoreClientFactory(ClientConfig config) {
}
@Override
+ public <K, V> StoreClient<K, V> getStoreClient(final String storeName,
+ final InconsistencyResolver<Versioned<V>> resolver) {
+ // TODO HIGH: FIX testBootstrapServerDown, testUknownStoreName
+ if(getConfig().isLazyEnabled())
+ return new LazyStoreClient<K, V>(new Callable<StoreClient<K, V>>() {
+
+ public StoreClient<K, V> call() throws Exception {
+ return getParentStoreClient(storeName, resolver);
+ }
+ });
+
+ return getParentStoreClient(storeName, resolver);
+ }
+
+ private <K, V> StoreClient<K, V> getParentStoreClient(String storeName, InconsistencyResolver<Versioned<V>> resolver) {
+ return super.getStoreClient(storeName, resolver);
+ }
+
+ @Override
protected List<Versioned<String>> getRemoteMetadata(String key, URI url) {
try {
return super.getRemoteMetadata(key, url);

0 comments on commit 8ec0447

Please sign in to comment.
Something went wrong with that request. Please try again.