Like everything else in Cassandra, If you need full consistency you need to make sure that you have the right combination of (write consistency level) + (read consistency level)
if W = write consistency level R = read consistency level N = replication factor then W + R > N Shimi On Thu, Mar 29, 2012 at 10:09 AM, Tamar Fraenkel <ta...@tok-media.com>wrote: > Hi! > Asking again, as I didn't get responses :) > > I have a ring with 3 nodes and replication factor of 2. > I have counter cf with the following definition: > > CREATE COLUMN FAMILY tk_counters > with comparator = 'UTF8Type' > and default_validation_class = 'CounterColumnType' > and key_validation_class = 'CompositeType(UTF8Type,UUIDType)' > and replicate_on_write = true; > > In my code (Java, Hector), I increment a counter and then read it. > Is it possible that the value read will be the value before increment? > If yes, how can I ensure it does not happen. All my reads and writes are > done with consistency level one. > If this is consistency issue, can I do only the actions on tk_counters > column family with a higher consistency level? > What does replicate_on_write mean? I thought this should help, but maybe > even if replicating after write, my read happen before replication > finished and it returns value from a still not updated node. > > My increment code is: > Mutator<Composite> mutator = > HFactory.createMutator(keyspace, > CompositeSerializer.get()); > mutator.incrementCounter(key,"tk_counters", columnName, inc); > mutator.execute(); > > My read counter code is: > CounterQuery<Composite,String> query = > createCounterColumnQuery(keyspace, > CompositeSerializer.get(), StringSerializer.get()); > query.setColumnFamily("tk_counters"); > query.setKey(key); > query.setName(columnName); > QueryResult<HCounterColumn<String>> r = query.execute(); > return r.get().getValue(); > > Thanks, > *Tamar Fraenkel * > Senior Software Engineer, TOK Media > > [image: Inline image 1] > > ta...@tok-media.com > Tel: +972 2 6409736 > Mob: +972 54 8356490 > Fax: +972 2 5612956 > > > >
<<tokLogo.png>>