Skip to content

Instantly share code, notes, and snippets.

@afeinberg
Created July 5, 2010 20:26
Show Gist options
  • Select an option

  • Save afeinberg/464658 to your computer and use it in GitHub Desktop.

Select an option

Save afeinberg/464658 to your computer and use it in GitHub Desktop.
(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