Abstract extension of the defined trait to minimize trait bloat.
Ever wished you could do a multiGet for 10,000 keys, but spread out over several multiGets? Use the BatchedReadableStore.
Adds batched writes to BatchedReadableStore
Generates a com.twitter.storehaus.Store backed by a com.twitter.storehaus.cache.MutableCache.
A store that is made from looking up values in the first store, then using that as the key in the second.
A store that is made from looking up values in the first store, then using that as the key in the second. When used with com.twitter.storehaus.ConvertedStore you can do some powerful sequential processing of stores
A simple JMapStore whose underlying store is a Java ConcurrentHashMap useful if you are going to be modifying a store from many threads, something you in general cannot do unless the docs specifically say that a store is safe for that.
N - total replicas One - 1 successful operation is sufficient to consider the operation as complete Quorum - N/2 + 1 successful operations are sufficient to consider the operation as complete All - N successful operations are required
Convert the keys/values of a store.
Convert the keys/values of a store.
Value conversion returns a Future because V1 => V2 may fail, and we are going to convert to a future anyway (so, a Try is kind of a Future that is not async). Thus we might as well add the flexibility of accepting a V1 => Future[V2], though in practice Future.value/exception will generally be used.
Use an injection on V2,V1 to convert a store of values V2.
Use an injection on V2,V1 to convert a store of values V2. If the value stored in the underlying store cannot be converted back to V2, then you will get a Future.exception containing the string "cannot be converted" TODO: we should add a specific exception type here so we can safely filter these cases to Future.None if we so choose.
1/22/14
Enrichment on the com.twitter.storehaus.ReadableStore trait.
Enrichment on the com.twitter.storehaus.ReadableStore trait. Storehaus uses the enrichment pattern instead of adding these methods directly to the trait because many of the functions (mapValues, for example) have different meanings for ReadableStore, Store and MergeableStore.
import ReadableStore.enrich
to get access to these methods.
TODO: in scala 2.10 this should be a value class
Enrichment on the Store[K, V] trait.
Enrichment on the Store[K, V] trait. Storehaus uses the enrichment pattern instead of adding these methods directly to the trait because many of the functions (mapValues, for example) have different meanings for ReadableStore, Store and MergeableStore.
import Store.enrich
to get access to these methods.
TODO: in scala 2.10 this should be a value class
A type to represent how Seq of futures are collected into a future of Seq[T]
Simple wrapper on IndexedSeq[V] to make it accessible as a ReadableStore
Trait for stores that allow iterating over their key-value pairs.
A Store instance which is backed by a Java Map (by default JHashMap) Obviously, there is no optimization of the multiGet/multiPut methods on this store and these are just implemented using the default implementation from Store.
MapStore is a ReadableStore backed by a scala immutable Map.
Instead of doing a get, this combinator always does a multiGet after enough gets have been created.
This is only thrown when a shard is expected but somehow absent.
This is only thrown when a shard is expected but somehow absent. For instance, in the combinators, we expect all the underlying gets to behave correctly this exception put into a Future when a user tries to put to an invalid shard
This is only thrown when a value is expected but somehow absent.
This is only thrown when a value is expected but somehow absent. For instance, in the combinators, we expect all the underlying gets to behave correctly this exception is used when a dependent store is not returning correct data.
Defines the base of a proxy for a given type.
Defines the base of a proxy for a given type.
A instance of Proxied for type T is intended to use the self
member to forward all methods of an new instance of type T to.
This allows for extensions of type T which can inherit a proxied
instance's behavior without needing to override every method of type T.
class Dazzle { def a: String = "default a" def b: String = "default b" // ... } // define a reusable concrete proxy statisfying Dazzle forwarding // all calls to Proxied method self class DazzleProxy(val self: Dazzle) extends Dazzle with Proxied[Dazzle] { def a: String = self.a def b: String = self.b } val bedazzlable = new Dazzle { // return a new Dazzle with some sizzle def be(sizzle: String): Dazzle = new DazzleProxy(this) { override def b = "%s %s!!!" format(self.b, sizzle) } } val dazzled = bedazzlable.be("dazzled") dazzled.b // default b dazzled!!! dazzled.a // default a
1/14/14
Thrown when a read operation fails due to unsatisfied consistency level
Provides read-through caching on a readable store fronted by a cache.
Provides read-through caching on a readable store fronted by a cache.
Keys are fetched from backing store on cache miss and cache read failures.
All cache operations are best effort i.e. 'get' will return the key from backing store even if adding/updating the cached copy fails.
On the other hand, any failure while reading from backing store is propagated to the client.
Main trait to represent asynchronous readable stores Here you see the tri-state logic:
Main trait to represent asynchronous readable stores Here you see the tri-state logic:
A proxy for ReadableStores.
A proxy for ReadableStores. Methods not overridden in extensions will be forwarded to Proxied self member
Replicates reads to a seq of stores and returns the first successful value (empty or not)
Replicates writes to all stores, and takes the first successful read.
This is thrown when a retryable store runs out of retries when looking for a key.
Use the ReadableStore abstraction when each read from the backend store involves a time-taking task.
Use the ReadableStore abstraction when each read from the backend store involves a time-taking task. A stream of backoffs are passed in so that we only wait for a finite time period for the task to complete.
Delegate put to the underlying store and allow retriable semantics for get.
Returns a ReadableStore that attempts reads out of the supplied Seq[ReadableStore] in order and returns the first non-exceptional value that satisfies the supplied predicate.
Returns a ReadableStore that attempts reads out of the supplied Seq[ReadableStore] in order and returns the first non-exceptional value that satisfies the supplied predicate.
multiGet attempts a full multiGet of the first store, then follows up on missing or failed keys with individual gets to the underlying stores (as failures for each key can happen at different times).
combines a mapping of ReadableStores into one ReadableStore that internally routes Note: if K1 is absent from the routes, you will always get Future.None as a result.
combines a mapping of ReadableStores into one ReadableStore that internally routes Note: if K1 is absent from the routes, you will always get Future.None as a result. you may want to combine this with ReadableStore.composeKeyMapping the change (K => (K1,K2))
combines a mapping of Stores into one Store that internally routes Note: if a K1 is absent from the routes, any put will give a
combines a mapping of Stores into one Store that internally routes Note: if a K1 is absent from the routes, any put will give a
Future.exception(new MissingShardException(k1))
Main trait for stores can be both read from and written to
A Proxy for Stores.
A Proxy for Stores. Methods not overrided in extensions will be forwared to Proxied self member
Replicates reads to a seq of stores and returns the value based on picked read consistency.
Replicates reads to a seq of stores and returns the value based on picked read consistency.
Consistency semantics: One - returns after first successful read, fails if all underlying reads fail Quorum - returns after at least N/2 + 1 reads succeed and return the same value, fails otherwise All - returns if all N reads succeed and return the same value, fails otherwise
Replicates writes to a seq of stores, and returns after picked write consistency is satisfied.
Replicates writes to a seq of stores, and returns after picked write consistency is satisfied.
Consistency semantics: One - returns after first successful write (other writes can complete in the background), fails if no write is successful Quorum - returns after N/2 + 1 writes succeed (other writes can complete in the background), fails otherwise All - returns if all N writes succeed, fails otherwise
Additionally, the following operations are supported: readRepair - read repair any missing or incorrect data (only for Quorum reads) writeRollback - delete the key on all replicas if write fails (only for Quorum writes and All writes)
ReadableStore enrichment which presents a ReadableStore[K, V] over top of a packed ReadableStore[OuterK, Map[InnerK, V]].
Store enrichment which presents a Store[K, V] over top of a packed Store[OuterK, Map[InnerK, V]].
Trait for building mutable store with TTL.
Main trait for mutable stores.
Main trait for mutable stores. Instances may implement EITHER put, multiPut or both. The default implementations are in terms of each other.
A Proxy for WritableStores.
A Proxy for WritableStores. Methods not overriden in extensions will be forwarded to Proxied self member
Thrown when a write operation fails due to unsatisfied consistency level
Provides write-through caching on a store fronted by a cache.
Provides write-through caching on a store fronted by a cache.
All cache operations are best effort. i.e. a write will succeed if the key was written to backing store even when adding/updating the cached copy of the key fails.
On the other hand, any failure while writing to backing store is propagated to the client.
If invalidate flag is set, any keys that fail to write to backing store are attempted to be removed from cache, rather than having the old value still in cache.
Helpful transformations on maps and collections.
Helpful transformations on maps and collections. These are combinators or transformers on collections that should probably be somewhere in the scala collection API, but are not.
Concrete empty store implementation.
Some factory methods and instances of FutureCollector that are used in storehaus
Some combinators on Futures or Seqs of Futures that are used internally These should arguably exist in util-core.
Methods used in the various unpivot stores.
ReadableStore enrichment for ReadableStore[OuterK, ReadableStore[InnerK, V]] on top of a ReadableStore[K, V]
Holds various factory and transformation functions for ReadableStore instances
Factory methods to create ShardedReadableStore instances
Factory methods to create ShardedStore instances
Factory methods and some combinators on Stores
Factory method to create TunableReplicatedStore instances
Abstract extension of the defined trait to minimize trait bloat. Probably mostly useful from Java or in anonymous instances whose return types are constrained to be ReadableStore. Try not to expose AbstractReadableStore in your APIs.