Mercurial > hg > Members > shoshi > jungle > bulletinboard
changeset 4:80126e22fd02
Modified CassandraBulletInBoard's constructor for change consistency level
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 09 Jan 2014 23:16:00 +0900 |
parents | e82fef2df8d6 |
children | 30717a443cd5 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/App.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/CassandraBulletinBoard.java |
diffstat | 2 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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";
--- 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<String, HConsistencyLevel> clmap = new HashMap<String, HConsistencyLevel>(); + clmap.put(COLUMN_FAMILY_BOARD, cLevel); + configurableConsistencyLevel.setReadCfConsistencyLevels(clmap); + configurableConsistencyLevel.setWriteCfConsistencyLevels(clmap); initialize(); }