GettingStarted

boneill42 edited this page Jul 7, 2012 · 3 revisions
Clone this wiki locally

First install triggers. Then...

0. Up the logging level

Add the following line to conf/log4j-server.properties

log4j.logger.com.hmsonline=DEBUG

1. Configure some test data.

With CLI:

create keyspace world;
use world;
create column family hello with column_type = 'Standard' and comparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and key_validation_class = 'UTF8Type';
set hello['test']['triggers']='123';

1. Enable the Commit Log

With CLI:

use triggers;                                    
set Configuration['CommitLog']['enabled']='true';

2. Enable the test trigger

We bundle a test trigger. To enable it with CLI:

use triggers;    
create column family Triggers with column_type = 'Standard' and comparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and key_validation_class = 'UTF8Type';                                
set Triggers['world:hello']['com.hmsonline.cassandra.triggers.TestTrigger']='enabled';

3. Bounce Cassandra and CLI then insert some data

use world
set hello['test']['triggers']='123';

4. Watch it go

In the logs you should see the triggers fire:

DEBUG 14:26:51,351 Started Trigger Task thread.
DEBUG 14:26:51,355 Did not create [triggers:Triggers] (probably already there)
INFO 14:26:51,357 Did not create [triggers:Triggers] (probably already there)
DEBUG 14:26:51,357 Instantiated trigger store.
DEBUG 14:26:51,359 Adding trigger [world:hello] --> [class com.hmsonline.cassandra.triggers.TestTrigger]
DEBUG 14:26:51,359 time in getTriggers: 2
DEBUG 14:26:51,367 Processing [0] logEntries.
DEBUG 14:26:51,372 Mutation for [triggers] with consistencyLevel [ONE]
DEBUG 14:26:51,378 Mutation for [triggers] with consistencyLevel [ONE]
DEBUG 14:26:52,377 Processing [1] logEntries.
DEBUG 14:26:52,377 Processing Entry [52290b30-c861-11e1-0000-242d50cf1fbf]:[world]:[hello]
DEBUG 14:26:52,379 time in getTriggers: 0
DEBUG 14:26:52,381 TestTrigger processing : [52290b30-c861-11e1-0000-242d50cf1fbf]
DEBUG 14:26:52,381 Processing [1] logEntries.
DEBUG 14:26:52,381 Mutation for [triggers] with consistencyLevel [ONE]
DEBUG 14:26:53,385 Processing [0] logEntries.
DEBUG 14:26:54,388 Processing [0] logEntries.