private boolean metricsEnabled() { return manager.configuration().getMetricsOptions().isEnabled(); }
private void incrementAuthErrorMetric() { if (factory.manager.configuration.getMetricsOptions().isEnabled()) { factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc(); } }
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; } }
/** * 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(); }
/** * 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()); }
/** * 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(); } } }
factory.configuration.getNettyOptions(), factory.configuration.getCodecRegistry(), factory.configuration.getMetricsOptions().isEnabled() ? factory.manager.metrics : null));
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();
/** * 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(); } }
private boolean metricsEnabled() { return manager.configuration().getMetricsOptions() != null; }
private boolean metricsEnabled() { return manager.configuration().getMetricsOptions().isEnabled(); }
private boolean metricsEnabled() { return manager.configuration().getMetricsOptions().isEnabled(); }
private boolean metricsEnabled() { return manager.configuration().getMetricsOptions().isEnabled(); }
private void incrementAuthErrorMetric() { if (factory.manager.configuration.getMetricsOptions().isEnabled()) { factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc(); } }
private void incrementAuthErrorMetric() { if (factory.manager.configuration.getMetricsOptions().isEnabled()) { factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc(); } }
private void incrementAuthErrorMetric() { if (factory.manager.configuration.getMetricsOptions().isEnabled()) { factory.manager.metrics.getErrorMetrics().getAuthenticationErrors().inc(); } }
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); }
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; } }
/** * 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(); }
/** * 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() ); }