Skip to content

Commit

Permalink
Merge pull request #741 from shintasmith/add_metric
Browse files Browse the repository at this point in the history
add querylogger, locator metric, minor log changes
  • Loading branch information
shintasmith authored Sep 27, 2016
2 parents 4bc9f0e + 8d64b23 commit 58ffc09
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ public class ALocatorIO implements LocatorIO {
*/
@Override
public void insertLocator(Locator locator) throws IOException {
Timer.Context timer = Instrumentation.getWriteTimerContext(CassandraModel.CF_METRICS_LOCATOR_NAME);
try {
MutationBatch mutationBatch = AstyanaxIO.getKeyspace().prepareMutationBatch();
AstyanaxWriter.getInstance().insertLocator(locator, mutationBatch);
mutationBatch.execute();
} catch (Exception e) {
throw new IOException(e);
} finally {
timer.stop();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.rackspacecloud.blueflood.io.Instrumentation;
import com.rackspacecloud.blueflood.io.LocatorIO;
import com.rackspacecloud.blueflood.types.Locator;
import com.rackspacecloud.blueflood.utils.Util;
import com.rackspacecloud.blueflood.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -82,7 +82,7 @@ private void createPreparedStatements() {
.value(VALUE, bindMarker());
putValue = DatastaxIO.getSession()
.prepare(insert)
.setConsistencyLevel( ConsistencyLevel.ONE); // TODO: remove later; required by the cassandra-maven-plugin 2.0.0-1
.setConsistencyLevel( ConsistencyLevel.ONE ); // TODO: remove later; required by the cassandra-maven-plugin 2.0.0-1
// (see https://issues.apache.org/jira/browse/CASSANDRA-6238)

}
Expand All @@ -99,9 +99,14 @@ public void insertLocator(Locator locator) throws IOException {
// get shard this locator would belong to
long shard = (long) Util.getShard(locator.toString());

// bound values and execute
BoundStatement bs = putValue.bind(shard, locator.toString(), "");
session.execute(bs);
Timer.Context timer = Instrumentation.getWriteTimerContext(CassandraModel.CF_METRICS_LOCATOR_NAME);
try {
// bound values and execute
BoundStatement bs = putValue.bind(shard, locator.toString(), "");
session.execute(bs);
} finally {
timer.stop();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ private static void connect() {
CodecRegistry codecRegistry = new CodecRegistry();

cluster = Cluster.builder()
.withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc("datacenter1").build()))
.withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc("datacenter1").build(), false))
.withPoolingOptions(getPoolingOptions(dbHosts.size()))
.withCodecRegistry(codecRegistry)
.withSocketOptions(getSocketOptions())
.addContactPointsWithPorts(dbHosts)
.build();

QueryLogger queryLogger = QueryLogger.builder()
.withConstantThreshold(5000)
.build();

cluster.register(queryLogger);

if ( LOG.isDebugEnabled() ) {
logDebugConnectionInfo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public void run() {
} catch (Exception e) {
LOG.error("Rollup failed; Locator: {}, Source Granularity: {}, For period: {}", new Object[]{
singleRollupReadContext.getLocator(),
singleRollupReadContext.getRange().toString(),
srcGran.name(),
singleRollupReadContext.getRange().toString(),
e});
} finally {
executionContext.decrementReadCounter();
Expand Down

0 comments on commit 58ffc09

Please sign in to comment.