[ 
https://issues.apache.org/jira/browse/CASSANDRA-6572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13993673#comment-13993673
 ] 

Benedict commented on CASSANDRA-6572:
-------------------------------------

Points 1 and 2 need to be atomic, so you calculate how much room you need, then 
in a loop you get the current value of the queue pointer, check there is room 
in the queue for the record, and then cas the current value to the new value 
(old + size). If it succeeds you exit the loop and then you can write to the 
buffer. No need to offload to another thread. The flush needs to make sure that 
all prior appends have finished before flushing though, and the best way to do 
this is with an OpOrder. See CommitLogSegment for examples. The appends would 
do something like:

{code}
OpOrder.Group opGroup = order.start();
try
{
 int size = calcSize();
 QueryQueue q; 
 int position;
 while (true)
 {
  int position = q.currentPosition
  if (position + size < q.buffer.length && 
q.currentPosition.compareAndSet(position, position + size))
   break;
 }
 doAppend(q, position);
} 
finally
{
 opGroup.close()
}
{code}

and the flush would do something like

{code}
        OpOrder.Barrier barrier = order.newBarrier();
        barrier.issue();
        barrier.await();
        doFlush();
{code}

> Workload recording / playback
> -----------------------------
>
>                 Key: CASSANDRA-6572
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6572
>             Project: Cassandra
>          Issue Type: New Feature
>          Components: Core, Tools
>            Reporter: Jonathan Ellis
>            Assignee: Lyuben Todorov
>             Fix For: 2.1.1
>
>         Attachments: 6572-trunk.diff
>
>
> "Write sample mode" gets us part way to testing new versions against a real 
> world workload, but we need an easy way to test the query side as well.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to