-1
我正在嘗試使用Pelops client
從Cassandra database
讀取數據。我成功地做到了。從Pelops客戶端讀取數據並基準讀取操作
現在我已經開始做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;
}
任何人都可以看看,讓我知道我是否在做正確與否?
感謝您的幫助。我假設這行只有'selector.getColumnsFromRow(columnFamily,rowKey,myPredicate,ConsistencyLevel.ONE);'它會去並從Cassandra數據庫中獲取數據。所以如果我的假設是正確的,我已經把計時器放在正確的地方。是的,關於計時器,我已經有一個靜態地圖,在我以後使用的持續時間方法中。 – ferhan 2013-04-24 16:33:44