ITPub博客

首页 > IT职业 > IT生活 > hector tips

hector tips

原创 IT生活 作者:oxoxooxx 时间:2011-06-20 13:00:25 0 删除 编辑

hector-v2-client-doc.pdf 读书笔记

LoadBalancingPolicy

Hector uses the slf4j logging API with the Log4J bridge to provide runtime logging.

Hector测试相关的类:
EmbeddedServerHelper
BaseEmbeddedServerTest

创建Keyspace:
Cluster cluster = HFactory.getCreateCluster("TestCluster",
new CassandraHostConfigurator("localhost:9160"));
Keyspace keyspace = HFactory.createKeyspace("Keyspace1",cluster);

StringSerializer
OrderPreservingPartitioner

IndexedSlicesQuery indexedSlicesQuery =
HFactory.createIndexedSlicesQuery(keyspace, se, se,, LongSerializer.get());
indexedSlicesQuery.addEqualsExpression("birthyear", 1975L);
indexedSlicesQuery.setColumnNames("birthdate","firstname");
indexedSlicesQuery.setColumnFamily("Users");
indexedSlicesQuery.setStartKey("");
QueryResult> result =
indexedSlicesQuery.execute();

IndexedSlicesQuery can also have expressions applied on other columns in conjunction with
the addEqualsExpression. There are two important points to note in using additional index
expressions:
● At least one equals expression against an indexed column must always be present via
addEqualsExpression
● The columns for additional clauses do not have have to be configured as indexed for the
ColumnFamily

Maven Repository for Dependencies

hector to store supercolumn:
Mutator mutator =
HFactory.createMutator(keyspace, stringSerializer);
mutator.insert("billing", "Super1", HFactory.createSuperColumn("jsmith",
Arrays.asList(HFactory.createStringColumn("first", "John")),
stringSerializer, stringSerializer, stringSerializer));

SuperColumnQuery superColumnQuery =
HFactory.createSuperColumnQuery(keyspace, stringSerializer,
stringSerializer, stringSerializer, stringSerializer);
superColumnQuery.setColumnFamily("Super1")
.setKey("billing").setSuperName("jsmith");
Result> result = superColumnQuery.execute();

To create your own approach to fail-over, for example to try the next three hosts pausing 200
milliseconds between each, you would construct the following FailoverPolicy:
FailoverPolicy failoverPolicy = new FailoverPolicy(3,200);

attributes exposed via JMX:
status and counters on the connections and pools
aggreate performance statics

If you do not want the overhead of having Pef4j running, it is possible to disable the statistics
gathering entirely by setting the system property com.prettyprint.cassandra.load_hector_log4j
to false at system startup and setting the level in your logging configuretion to WARN for the
appender named: me.prettyprint.hector.TimingLogger

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23937368/viewspace-1051381/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: tips
下一篇: copy a voldemort tools
请登录后发表评论 登录
全部评论
  • 博文量
    178
  • 访问量
    843651