# HG changeset patch # User Nobuyasu Oshiro # Date 1389276960 -32400 # Node ID 80126e22fd0232c60ad01df58e62818f897e74b0 # Parent e82fef2df8d6b655ebc0dfe9269cfa1eb5315a6c Modified CassandraBulletInBoard's constructor for change consistency level diff -r e82fef2df8d6 -r 80126e22fd02 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/App.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/App.java Fri Jul 12 22:18:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/App.java Thu Jan 09 23:16:00 2014 +0900 @@ -2,6 +2,8 @@ import javax.servlet.Servlet; +import me.prettyprint.hector.api.HConsistencyLevel; + import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.ServletHandler; import org.mortbay.jetty.servlet.ServletHolder; @@ -18,10 +20,26 @@ if(args.length == 0){ cassaBBS = new JungleBulletinBoard(); }else{ - cassaBBS = new CassandraBulletinBoard("test-cluster","localhost:9160","cassaBBS2"); + for(String arg : args) { + if(arg.equals("-all")) { + System.out.println("ConsistencyLevel ALL"); + cassaBBS = new CassandraBulletinBoard("test-cluster","localhost:9160","cassaBBS2",HConsistencyLevel.ALL); + break; + }else if(arg.equals("-one")){ + System.out.println("ConsistencyLevel ONE"); + cassaBBS = new CassandraBulletinBoard("test-cluster","localhost:9160","cassaBBS2",HConsistencyLevel.ONE); + break; + }else if(arg.equals("-quorum")){ + System.out.println("ConsistencyLevel QUORUM"); + cassaBBS = new CassandraBulletinBoard("test-cluster","localhost:9160","cassaBBS2",HConsistencyLevel.QUORUM); + }else{ + System.out.println("ConsistencyLevel QUORUM"); + cassaBBS = new CassandraBulletinBoard("test-cluster","localhost:9160","cassaBBS2",HConsistencyLevel.QUORUM); + break; + } + } } - String createBoardMessagePath = "/createBoardMessage"; String createBoardPath = "/createBoard"; String editMessagePath = "/editMessage"; diff -r e82fef2df8d6 -r 80126e22fd02 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/CassandraBulletinBoard.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/CassandraBulletinBoard.java Fri Jul 12 22:18:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/CassandraBulletinBoard.java Thu Jan 09 23:16:00 2014 +0900 @@ -1,19 +1,22 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; import org.apache.cassandra.locator.SimpleStrategy; +import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; import me.prettyprint.cassandra.serializers.StringSerializer; import me.prettyprint.cassandra.serializers.UUIDSerializer; -import me.prettyprint.cassandra.service.CassandraHost; import me.prettyprint.cassandra.service.template.SuperCfResult; import me.prettyprint.cassandra.service.template.SuperCfUpdater; import me.prettyprint.cassandra.service.template.ThriftSuperCfTemplate; import me.prettyprint.cassandra.utils.TimeUUIDUtils; import me.prettyprint.hector.api.Cluster; +import me.prettyprint.hector.api.HConsistencyLevel; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.beans.HSuperColumn; import me.prettyprint.hector.api.beans.OrderedSuperRows; @@ -34,16 +37,20 @@ private final String clusterName; private final Cluster cluster; private final String keyspace; + private final ConfigurableConsistencyLevel configurableConsistencyLevel = new ConfigurableConsistencyLevel(); private static final String COLUMN_FAMILY_BOARD = "boards"; - public CassandraBulletinBoard(String _clusterName,String _address,String _keyspaceName) + public CassandraBulletinBoard(String _clusterName,String _address,String _keyspaceName, HConsistencyLevel cLevel) { address = _address; clusterName = _clusterName; keyspace = _keyspaceName; cluster = HFactory.getOrCreateCluster(clusterName,address); - + Map clmap = new HashMap(); + clmap.put(COLUMN_FAMILY_BOARD, cLevel); + configurableConsistencyLevel.setReadCfConsistencyLevels(clmap); + configurableConsistencyLevel.setWriteCfConsistencyLevels(clmap); initialize(); }