【发布时间】:2013-04-17 13:33:53
【问题描述】:
我正在尝试使用Pelops client 从Cassandra database 读取数据。我成功地做到了。
现在我已经开始做benchmarking,这意味着从 Cassandra 数据库读取需要多少时间。所以我在下面的代码中添加了我的benchmarking code。
现在我不确定我是否在正确的位置添加了benchmarking code 以使用Pelops client 测量Cassandra database 的读取延迟?
下面是我的代码-
public Map<String, String> getAttributes(final String rowKey, final Collection<String> attributeNames, final String columnFamily) {
final Map<String, String> attributes = new ConcurrentHashMap<String, String>();
try {
final SlicePredicate myPredicate = Selector.newColumnsPredicate(attributeNames.toArray(new String[attributeNames.size()]));
final Selector selector = Pelops.createSelector(CassandraPelopsConnection.getInstance().getPoolName());
// this is the right place to start the timer?
CassandraTimer timer = CassandraTimer.getInstance();
final List<Column> columnList = selector.getColumnsFromRow(columnFamily, rowKey, myPredicate, ConsistencyLevel.ONE);
// And this is the right place to end the timer incase of Pelops client?
timer.getDuration();
for (Column column : columnList) {
attributes.put(new String(column.getName()), new String(column.getValue()));
}
} catch (Exception e) {
}
return attributes;
}
谁能看一下,让我知道我做得对不对?
【问题讨论】: