com.datastax.driver.core.Metrics Java Examples

The following examples show how to use com.datastax.driver.core.Metrics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractUpsertOutputOperator.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the metrics that can be sent to Application master.
 * Note that some of the metrics are computed in the cassandra driver itself and hence just
 * extracted from the driver state itself.
 */
@Override
public void endWindow()
{
  super.endWindow();
  Timer timerForThisWindow = session.getCluster().getMetrics().getRequestsTimer();
  totalWriteRequestsAttempted += timerForThisWindow.getCount();
  numberOfHostsWrittenTo = uniqueHostsWrittenToInCurrentWindow.size();
  fifteenMinuteWriteRateLatency = timerForThisWindow.getFifteenMinuteRate();
  fiveMinuteWriteRateLatency = timerForThisWindow.getFiveMinuteRate();
  oneMinuteWriteRateLatency = timerForThisWindow.getOneMinuteRate();
  meanWriteRateLatency = timerForThisWindow.getMeanRate();
  Metrics.Errors errors = session.getCluster().getMetrics().getErrorMetrics();
  totalIgnoresInThisWindow = errors.getIgnores().getCount() - totalIgnoresSinceStart;
  totalIgnoresSinceStart = errors.getIgnores().getCount();
  totalWriteTimeoutsInThisWindow = errors.getWriteTimeouts().getCount() - totalWriteTimeoutsSinceStart;
  totalWriteTimeoutsSinceStart = errors.getWriteTimeouts().getCount();
  totalWriteRetriesInThisWindow =  errors.getRetriesOnWriteTimeout().getCount() - totalWriteRetriesSinceStart;
  totalWriteRetriesSinceStart = errors.getRetriesOnWriteTimeout().getCount();
  try {
    // we do not need any particular state and hence reusing the window id itself
    windowDataManager.save(currentWindowId,currentWindowId);
  } catch (IOException e) {
    LOG.error("Error while persisting the current window state " + currentWindowId + " because " + e.getMessage());
    throw new RuntimeException(e.getMessage());
  }
}
 
Example #2
Source File: CqlCluster.java    From emodb with Apache License 2.0 4 votes vote down vote up
/**
 * Registers metrics for this cluster.  Ideally this would be done before the cluster is started so conflicting
 * metric names could be detected earlier, but since the CQL driver doesn't publish metrics until after it is
 * initialized the metrics cannot be registered until then.
 */
private void registerMetrics() {
    if (_metricName == null) {
        // No metric name was provided; skip registration
        return;
    }

    Metrics metrics = _cluster.getMetrics();

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "connected-to-hosts"),
            metrics.getConnectedToHosts());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "open-connections"),
            metrics.getOpenConnections());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "trashed-connections"),
            metrics.getTrashedConnections());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "executor-queue-depth"),
            metrics.getExecutorQueueDepth());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "blocking-executor-queue-depth"),
            metrics.getBlockingExecutorQueueDepth());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "reconnection-scheduler-task-count"),
            metrics.getReconnectionSchedulerQueueSize());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "task-scheduler-task-count"),
            metrics.getTaskSchedulerQueueSize());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "connection-errors"),
            metrics.getErrorMetrics().getConnectionErrors());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "read-timeouts"),
            metrics.getErrorMetrics().getReadTimeouts());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "write-timeouts"),
            metrics.getErrorMetrics().getWriteTimeouts());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "client-timeouts"),
            metrics.getErrorMetrics().getClientTimeouts());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "ignores"),
            metrics.getErrorMetrics().getIgnores());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "unavailables"),
            metrics.getErrorMetrics().getUnavailables());

    _metricRegistry.register(
            MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "speculative-executions"),
            metrics.getErrorMetrics().getSpeculativeExecutions());
}