Created
July 5, 2010 20:26
-
-
Save afeinberg/464658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns voldemort | |
| (:import (voldemort.client | |
| ClientConfig SocketStoreClientFactory StoreClient UpdateAction) | |
| (voldemort.versioning | |
| VectorClock))) | |
| (defn store-client-factory | |
| ([urls] (store-client-factory (new ClientConfig) urls)) | |
| ([#^ClientConfig client-config urls] | |
| (new SocketStoreClientFactory (doto client-config | |
| (.setBootstrapUrls urls))))) | |
| (defn increment-version | |
| ([#^VectorClock version #^Integer node] | |
| (increment-version version node (System/currentTimeMillis))) | |
| ([#^VectorClock version #^Integer node #^Long ts] | |
| (doto version | |
| (.incrementVersion node ts)))) | |
| (defn apply-update | |
| ([store-client #^StoreClient update-fn] | |
| (apply-update store-client update-fn (fn []))) | |
| ([store-client #^StoreClient update-fn rollback-fn] | |
| (.applyUpdate store-client | |
| (proxy [UpdateAction] [] | |
| (update [#^StoreClient client] | |
| (update-fn client)) | |
| (rollback [] | |
| (rollback-fn)))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment