Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make SocketStoreClientFactory wrap getStoreClient with LazyStoreClien…
…t by default
  • Loading branch information
afeinberg committed Jan 12, 2011
1 parent 95705b4 commit 8ec0447
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/java/voldemort/client/AbstractStoreClientFactory.java
Expand Up @@ -237,6 +237,10 @@ public <K, V, T> Store<K, V, T> getRawStore(String storeName,
return serializedStore;
}

protected ClientConfig getConfig() {
return config;
}

protected abstract FailureDetector initFailureDetector(final ClientConfig config,
final Collection<Node> nodes);

Expand Down
21 changes: 21 additions & 0 deletions src/java/voldemort/client/SocketStoreClientFactory.java
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8ec0447

Please sign in to comment.