com.datastax.driver.core.Configuration.getMetricsOptions()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中com.datastax.driver.core.Configuration.getMetricsOptions()方法的一些代码示例,展示了Configuration.getMetricsOptions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getMetricsOptions()方法的具体详情如下:
包路径:com.datastax.driver.core.Configuration
类名称:Configuration
方法名:getMetricsOptions

Configuration.getMetricsOptions介绍

[英]Returns the metrics configuration, if metrics are enabled.

Metrics collection is enabled by default but can be disabled at cluster construction time through Cluster.Builder#withoutMetrics.
[中]如果启用了度量,则返回度量配置。
默认情况下,度量集合处于启用状态,但可以通过集群在构建集群时禁用。建筑商#没有指标。

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private boolean metricsEnabled() {
 return manager.configuration().getMetricsOptions().isEnabled();
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private void incrementAuthErrorMetric() {
 if (factory.manager.configuration.getMetricsOptions().isEnabled()) {
  factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc();
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

Metrics(Cluster.Manager manager) {
 this.manager = manager;
 this.executorQueueDepth =
   registry.register("executor-queue-depth", buildQueueSizeGauge(manager.executorQueue));
 this.blockingExecutorQueueDepth =
   registry.register(
     "blocking-executor-queue-depth", buildQueueSizeGauge(manager.blockingExecutorQueue));
 this.reconnectionSchedulerQueueSize =
   registry.register(
     "reconnection-scheduler-task-count",
     buildQueueSizeGauge(manager.reconnectionExecutorQueue));
 this.taskSchedulerQueueSize =
   registry.register(
     "task-scheduler-task-count", buildQueueSizeGauge(manager.scheduledTasksExecutorQueue));
 if (manager.configuration.getMetricsOptions().isJMXReportingEnabled()) {
  this.jmxReporter =
    JmxReporter.forRegistry(registry).inDomain(manager.clusterName + "-metrics").build();
  this.jmxReporter.start();
 } else {
  this.jmxReporter = null;
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Validates that metrics are enabled and exposed by JMX by default by checking that {@link
 * Cluster#getMetrics()} is not null and 'clusterName-metrics:name=connected-to' MBean is present.
 *
 * @test_category metrics
 */
@Test(groups = "short")
public void should_enable_metrics_and_jmx_by_default() throws Exception {
 assertThat(cluster().getMetrics()).isNotNull();
 ObjectName clusterMetricsON =
   ObjectName.getInstance(cluster().getClusterName() + "-metrics:name=connected-to");
 MBeanInfo mBean = server.getMBeanInfo(clusterMetricsON);
 assertThat(mBean).isNotNull();
 assertThat(cluster().getConfiguration().getMetricsOptions().isEnabled()).isTrue();
 assertThat(cluster().getConfiguration().getMetricsOptions().isJMXReportingEnabled()).isTrue();
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Copy constructor.
 *
 * @param toCopy the object to copy from.
 */
protected Configuration(Configuration toCopy) {
 this(
   toCopy.getPolicies(),
   toCopy.getProtocolOptions(),
   toCopy.getPoolingOptions(),
   toCopy.getSocketOptions(),
   toCopy.getMetricsOptions(),
   toCopy.getQueryOptions(),
   toCopy.getThreadingOptions(),
   toCopy.getNettyOptions(),
   toCopy.getCodecRegistry());
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
  * Validates that when metrics are enabled but JMX reporting is disabled via {@link
  * Cluster.Builder#withoutJMXReporting()} that {@link Cluster#getMetrics()} is not null and
  * 'clusterName-metrics:name=connected-to' MBean is present.
  *
  * @test_category metrics
  */
 @Test(groups = "short", expectedExceptions = InstanceNotFoundException.class)
 public void should_be_no_jmx_mbean_when_jmx_is_disabled() throws Exception {
  Cluster cluster =
    register(
      Cluster.builder()
        .addContactPoints(getContactPoints())
        .withPort(ccm().getBinaryPort())
        .withoutJMXReporting()
        .build());
  try {
   cluster.init();
   assertThat(cluster.getMetrics()).isNotNull();
   assertThat(cluster.getConfiguration().getMetricsOptions().isEnabled()).isTrue();
   assertThat(cluster.getConfiguration().getMetricsOptions().isJMXReportingEnabled()).isFalse();
   ObjectName clusterMetricsON =
     ObjectName.getInstance(cluster.getClusterName() + "-metrics:name=connected-to");
   server.getMBeanInfo(clusterMetricsON);
  } finally {
   cluster.close();
  }
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

factory.configuration.getNettyOptions(),
factory.configuration.getCodecRegistry(),
factory.configuration.getMetricsOptions().isEnabled()
  ? factory.manager.metrics
  : null));

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

this.connectionFactory = new Connection.Factory(this, configuration);
this.controlConnection = new ControlConnection(this);
this.metrics = configuration.getMetricsOptions().isEnabled() ? new Metrics(this) : null;
this.preparedQueries = new MapMaker().weakValues().makeMap();

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Validates that when metrics are disabled using {@link Cluster.Builder#withoutMetrics()} that
 * {@link Cluster#getMetrics()} returns null and 'clusterName-metrics:name=connected-to' MBean is
 * not present.
 *
 * @test_category metrics
 */
@Test(groups = "short", expectedExceptions = InstanceNotFoundException.class)
public void metrics_should_be_null_when_metrics_disabled() throws Exception {
 Cluster cluster =
   register(
     Cluster.builder()
       .addContactPoints(getContactPoints())
       .withPort(ccm().getBinaryPort())
       .withoutMetrics()
       .build());
 try {
  cluster.init();
  assertThat(cluster.getMetrics()).isNull();
  assertThat(cluster.getConfiguration().getMetricsOptions().isEnabled()).isFalse();
  ObjectName clusterMetricsON =
    ObjectName.getInstance(cluster.getClusterName() + "-metrics:name=connected-to");
  server.getMBeanInfo(clusterMetricsON);
 } finally {
  cluster.close();
 }
}

代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core

private boolean metricsEnabled() {
  return manager.configuration().getMetricsOptions() != null;
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

private boolean metricsEnabled() {
  return manager.configuration().getMetricsOptions().isEnabled();
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

private boolean metricsEnabled() {
  return manager.configuration().getMetricsOptions().isEnabled();
}

代码示例来源:origin: com.yugabyte/cassandra-driver-core

private boolean metricsEnabled() {
  return manager.configuration().getMetricsOptions().isEnabled();
}

代码示例来源:origin: com.yugabyte/cassandra-driver-core

private void incrementAuthErrorMetric() {
  if (factory.manager.configuration.getMetricsOptions().isEnabled()) {
    factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc();
  }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

private void incrementAuthErrorMetric() {
  if (factory.manager.configuration.getMetricsOptions().isEnabled()) {
    factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc();
  }
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

private void incrementAuthErrorMetric() {
  if (factory.manager.configuration.getMetricsOptions().isEnabled()) {
    factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc();
  }
}

代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core

private Manager(String clusterName, List<InetSocketAddress> contactPoints, Configuration configuration, Collection<Host.StateListener> listeners) {
  logger.debug("Starting new cluster with contact points " + contactPoints);
  this.clusterName = clusterName == null ? generateClusterName() : clusterName;
  this.configuration = configuration;
  this.configuration.register(this);
  this.executor = makeExecutor(Runtime.getRuntime().availableProcessors(), "Cassandra Java Driver worker-%d");
  this.blockingExecutor = makeExecutor(2, "Cassandra Java Driver blocking tasks worker-%d");
  this.metadata = new Metadata(this);
  this.contactPoints = contactPoints;
  this.connectionFactory = new Connection.Factory(this, configuration);
  this.controlConnection = new ControlConnection(this);
  this.metrics = configuration.getMetricsOptions() == null ? null : new Metrics(this);
  this.listeners = new CopyOnWriteArraySet<Host.StateListener>(listeners);
}

代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core

Metrics(Cluster.Manager manager) {
  this.manager = manager;
  if (manager.configuration.getMetricsOptions().isJMXReportingEnabled()) {
    this.jmxReporter = JmxReporter.forRegistry(registry).inDomain(manager.clusterName + "-metrics").build();
    this.jmxReporter.start();
  } else {
    this.jmxReporter = null;
  }
}

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

/**
 * Validates that metrics are enabled and exposed by JMX by default by checking that {@link
 * Cluster#getMetrics()} is not null and 'clusterName-metrics:name=connected-to' MBean is present.
 *
 * @test_category metrics
 */
@Test(groups = "short")
public void should_enable_metrics_and_jmx_by_default() throws Exception {
 assertThat(cluster().getMetrics()).isNotNull();
 ObjectName clusterMetricsON =
   ObjectName.getInstance(cluster().getClusterName() + "-metrics:name=connected-to");
 MBeanInfo mBean = server.getMBeanInfo(clusterMetricsON);
 assertThat(mBean).isNotNull();
 assertThat(cluster().getConfiguration().getMetricsOptions().isEnabled()).isTrue();
 assertThat(cluster().getConfiguration().getMetricsOptions().isJMXReportingEnabled()).isTrue();
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

/**
 * Copy constructor.
 *
 * @param toCopy the object to copy from.
 */
protected Configuration(Configuration toCopy) {
  this(
      toCopy.getPolicies(),
      toCopy.getProtocolOptions(),
      toCopy.getPoolingOptions(),
      toCopy.getSocketOptions(),
      toCopy.getMetricsOptions(),
      toCopy.getQueryOptions(),
      toCopy.getThreadingOptions(),
      toCopy.getNettyOptions(),
      toCopy.getCodecRegistry()
  );
}

相关文章