Permalink
Browse files

Make SocketStoreClientFactory wrap getStoreClient with LazyStoreClien…

…t by default
  • Loading branch information...
afeinberg committed Jan 5, 2011
1 parent 95705b4 commit 8ec0447011c810d33d868ba093c86a9a1eb9968a
@@ -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);
@@ -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;
/**
@@ -71,6 +73,25 @@ public SocketStoreClientFactory(ClientConfig config) {
JmxUtils.registerMbean(storeFactory, JmxUtils.createObjectName(storeFactory.getClass()));
}
+ @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 {

0 comments on commit 8ec0447

Please sign in to comment.