how to avoid range ghosts?

2012-10-07 Thread Satoshi Yamada
Hi,
What is the recommended way to avoid range ghost in using get_range()?In my 
case, order of the key is not problem. It seems valid to use random :start_key 
in every query, but i'm new to cassandra and do not know if it'srecommended or 
not.
I use Cassandra 1.1.4 and ruby client. Range ghosts happens when oneprocess 
keeps on inserting data while other process get_range and deletethem.
thanks in advance,satoshi

Re: MBean cassandra.db.CompactionManager TotalBytesCompacted counts backwards

2012-10-07 Thread Edward Capriolo
I have not looked at this JMX object in a while, however the
compaction manager can support multiple threads. Also it moves from
0-filesize each time it has to compact a set of files.

That is more useful for showing current progress rather then lifetime history.



On Fri, Oct 5, 2012 at 7:27 PM, Bryan Talbot btal...@aeriagames.com wrote:
 I've recently added compaction rate (in bytes / second) to my monitors for
 cassandra and am seeing some odd values.  I wasn't expecting the values for
 TotalBytesCompacted to sometimes decrease from one reading to the next.  It
 seems that the value should be monotonically increasing while a server is
 running -- obviously it would start again at 0 when the server is restarted
 or if the counter rolls over (unlikely for a 64 bit long).

 Below are two samples taken 60 seconds apart: the value decreased by
 2,954,369,012 between the two readings.

 reported_metric=[timestamp:1349476449, status:200,
 request:[mbean:org.apache.cassandra.db:type=CompactionManager,
 attribute:TotalBytesCompacted, type:read], value:7548675470069]

 previous_metric=[timestamp:1349476389, status:200,
 request:[mbean:org.apache.cassandra.db:type=CompactionManager,
 attribute:TotalBytesCompacted, type:read], value:7551629839081]


 I briefly looked at the code for CompactionManager and a few related classes
 and don't see anyplace that is performing subtraction explicitly; however,
 there are many additions of signed long values that are not validated and
 could conceivably contain a negative value thus causing the
 totalBytesCompacted to decrease.  It's interesting to note that the all of
 the differences I've seen so far are more than the overflow value of a
 signed 32 bit value.  The OS (CentOS 5.7) and sun java vm (1.6.0_29) are
 both 64 bit.  JNA is enabled.

 Is this expected and normal?  If so, what is the correct interpretation of
 this metric?  I'm seeing the negatives values a few times per hour when
 reading it once every 60 seconds.

 -Bryan



Re: how to avoid range ghosts?

2012-10-07 Thread Edward Capriolo
Read this:

http://wiki.apache.org/cassandra/FAQ#range_ghosts

Then say this to yourself:

http://cn1.kaboodle.com/img/b/0/0/196/4/C1xHoQAAAZZL9w/ghostbusters-logo-i-aint-afraid-of-no-ghost-pinback-button-1.25-pin-badge.jpg?v=1320511953000

On Sun, Oct 7, 2012 at 4:15 AM, Satoshi Yamada
bigtvioletb...@yahoo.co.jpwrote:

 Hi,

 What is the recommended way to avoid range ghost in using get_range()?
 In my case, order of the key is not problem. It seems valid to use random
  :start_key in every query, but i'm new to cassandra and do not know if
 it's
 recommended or not.

 I use Cassandra 1.1.4 and ruby client. Range ghosts happens when one
 process keeps on inserting data while other process get_range and delete
 them.

 thanks in advance,
 satoshi



Re: cql3 and cli composites columns

2012-10-07 Thread Cyril Auburtin
Thanks Aaron,
I don't understand what is the cli equivalent of:

CREATE TABLE timeline (
  user_id varchar,
  tweet_id bigint,
  author varchar,
  body varchar,
  PRIMARY KEY (user_id, tweet_id)
);


2012/10/3 aaron morton aa...@thelastpickle.com

  If it's just a printing issue it's really minor though

 I would guess because  timeline CF has defined columns and line CF does
 not.

 All cqlsh knows is that every column name has two parts, it does not know
 what the column names will be. The difference between a static and dynamic
 CF.

 Hope that helps.

 -
 Aaron Morton
 Freelance Developer
 @aaronmorton
 http://www.thelastpickle.com

 On 2/10/2012, at 10:37 PM, Cyril Auburtin cyril.aubur...@gmail.com
 wrote:

  I wanted to know why the highlighted sections below are printed
 differently, the 2 column families are the same
 
  Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type
  Default column value validator: org.apache.cassandra.db.marshal.UTF8Type
  Columns sorted by:
 org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.LongType,org.apache.cassandra.db.marshal.UTF8Type)
 
  , except one is created from cql3:
 
  If it's just a printing issue it's really minor though
 
  on cql3:
  CREATE TABLE timeline (
  ...   user_id varchar,
  ...   tweet_id bigint,
  ...   author varchar,
  ...   body varchar,
  ...   PRIMARY KEY (user_id, tweet_id)
  ... );
  INSERT INTO timeline (user_id, tweet_id, author, body) VALUES ('gmason',
 1765, 'phenry', 'Give me liberty or give me death');
 
 
  on CLI:
 
  create column family line with comparator = 'CompositeType(LongType,
 UTF8Type)' AND key_validation_class=UTF8Type AND default_validation_class =
 UTF8Type;
  set line['dude']['1545:ok'] = '1';
  set line['dude']['1545:ok1'] = '1';
 
  list timeline;
  RowKey: gmason
  = (column=1765:author, value=phenry, timestamp=1349161331154000)
  = (column=1765:body, value=Give me liberty or give me death,
 timestamp=1349161331154001)
 
  list line;
  RowKey: dude
  = (column=1545:ok, value=1, timestamp=1349162658714000)
  = (column=1545:ok1, value=1, timestamp=1349162638658000)
 
  on cql3:
 
  select * from timeline;
   user_id | tweet_id | author | body
  -+--++--
gmason | 1765 | phenry | Give me liberty or give me death
 
 
  select * from line;
   key  | column1 | column2 | value
  --+-+-+---
   dude |1545 |  ok | 1
   dude |1545 | ok1 | 1
 
 
 
  ps: I have tried
 
  update column family line with comparator = 'CompositeType(LongType,
 UTF8Type)' AND key_validation_class=UTF8Type AND column_metadata = [
  {column_name: tweet_id, validation_class: LongType}
  {column_name: author, validation_class: UTF8Type}
  {column_name: body, validation_class: UTF8Type}
  ];
  for the CF line but it gives:
  java.lang.RuntimeException:
 org.apache.cassandra.db.marshal.MarshalException: unable to make long from
 'tweet_id'
 




Re: cql3 and cli composites columns

2012-10-07 Thread Tupshin Harper
Once you have created the CF from cqlsh, switch over to cassandra-cli
and run describe schema. It will show you the schema for all your
column families in syntax that can be passed back into cassandra-cli
to create them.

The cassandr-cli syntax that you are looking for is probably the and
column_metadata = section.

-Tupshin

On Sun, Oct 7, 2012 at 4:43 PM, Cyril Auburtin cyril.aubur...@gmail.com wrote:
 Thanks Aaron,
 I don't understand what is the cli equivalent of:

 CREATE TABLE timeline (
   user_id varchar,
   tweet_id bigint,
   author varchar,
   body varchar,
   PRIMARY KEY (user_id, tweet_id)
 );



 2012/10/3 aaron morton aa...@thelastpickle.com

  If it's just a printing issue it's really minor though

 I would guess because  timeline CF has defined columns and line CF does
 not.

 All cqlsh knows is that every column name has two parts, it does not know
 what the column names will be. The difference between a static and dynamic
 CF.

 Hope that helps.

 -
 Aaron Morton
 Freelance Developer
 @aaronmorton
 http://www.thelastpickle.com

 On 2/10/2012, at 10:37 PM, Cyril Auburtin cyril.aubur...@gmail.com
 wrote:

  I wanted to know why the highlighted sections below are printed
  differently, the 2 column families are the same
 
  Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type
  Default column value validator: org.apache.cassandra.db.marshal.UTF8Type
  Columns sorted by:
  org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.LongType,org.apache.cassandra.db.marshal.UTF8Type)
 
  , except one is created from cql3:
 
  If it's just a printing issue it's really minor though
 
  on cql3:
  CREATE TABLE timeline (
  ...   user_id varchar,
  ...   tweet_id bigint,
  ...   author varchar,
  ...   body varchar,
  ...   PRIMARY KEY (user_id, tweet_id)
  ... );
  INSERT INTO timeline (user_id, tweet_id, author, body) VALUES ('gmason',
  1765, 'phenry', 'Give me liberty or give me death');
 
 
  on CLI:
 
  create column family line with comparator = 'CompositeType(LongType,
  UTF8Type)' AND key_validation_class=UTF8Type AND default_validation_class =
  UTF8Type;
  set line['dude']['1545:ok'] = '1';
  set line['dude']['1545:ok1'] = '1';
 
  list timeline;
  RowKey: gmason
  = (column=1765:author, value=phenry, timestamp=1349161331154000)
  = (column=1765:body, value=Give me liberty or give me death,
  timestamp=1349161331154001)
 
  list line;
  RowKey: dude
  = (column=1545:ok, value=1, timestamp=1349162658714000)
  = (column=1545:ok1, value=1, timestamp=1349162638658000)
 
  on cql3:
 
  select * from timeline;
   user_id | tweet_id | author | body
  -+--++--
gmason | 1765 | phenry | Give me liberty or give me death
 
 
  select * from line;
   key  | column1 | column2 | value
  --+-+-+---
   dude |1545 |  ok | 1
   dude |1545 | ok1 | 1
 
 
 
  ps: I have tried
 
  update column family line with comparator = 'CompositeType(LongType,
  UTF8Type)' AND key_validation_class=UTF8Type AND column_metadata = [
  {column_name: tweet_id, validation_class: LongType}
  {column_name: author, validation_class: UTF8Type}
  {column_name: body, validation_class: UTF8Type}
  ];
  for the CF line but it gives:
  java.lang.RuntimeException:
  org.apache.cassandra.db.marshal.MarshalException: unable to make long from
  'tweet_id'