com.datastax.driver.core.QueryLogger Java Examples
The following examples show how to use
com.datastax.driver.core.QueryLogger.
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: QueryLoggerConfiguration.java From james-project with Apache License 2.0 | 6 votes |
public QueryLogger getQueryLogger() { QueryLogger.Builder builder = QueryLogger.builder(); percentileTracker.map(percentileTracker -> slowQueryLatencyThresholdPercentile.map(slowQueryLatencyThresholdPercentile -> builder.withDynamicThreshold(percentileTracker, slowQueryLatencyThresholdPercentile) ) ); constantThreshold.ifPresent(builder::withConstantThreshold); constantThreshold.ifPresent(builder::withConstantThreshold); maxLoggedParameters.ifPresent(builder::withMaxLoggedParameters); maxParameterValueLength.ifPresent(builder::withMaxParameterValueLength); maxQueryStringLength.ifPresent(builder::withMaxQueryStringLength); return builder.build(); }
Example #2
Source File: CassandraStorage.java From cassandra-reaper with Apache License 2.0 | 5 votes |
public CassandraStorage( UUID reaperInstanceId, ReaperApplicationConfiguration config, Environment environment) throws ReaperException { this.reaperInstanceId = reaperInstanceId; CassandraFactory cassandraFactory = config.getCassandraFactory(); overrideQueryOptions(cassandraFactory); overrideRetryPolicy(cassandraFactory); overridePoolingOptions(cassandraFactory); // https://docs.datastax.com/en/developer/java-driver/3.5/manual/metrics/#metrics-4-compatibility cassandraFactory.setJmxEnabled(false); if (!CassandraStorage.UNINITIALISED.compareAndSet(true, false)) { // If there's been a past connection attempt, metrics are already registered cassandraFactory.setMetricsEnabled(false); } cassandra = cassandraFactory.build(environment); if (config.getActivateQueryLogger()) { cassandra.register(QueryLogger.builder().build()); } CodecRegistry codecRegistry = cassandra.getConfiguration().getCodecRegistry(); codecRegistry.register(new DateTimeCodec()); session = cassandra.connect(config.getCassandraFactory().getKeyspace()); version = cassandra.getMetadata().getAllHosts() .stream() .map(h -> h.getCassandraVersion()) .min(VersionNumber::compareTo) .get(); initializeAndUpgradeSchema(cassandra, session, config, version); prepareStatements(); }
Example #3
Source File: CassandraTarget.java From datacollector with Apache License 2.0 | 5 votes |
private Cluster getCluster() throws StageException { RemoteEndpointAwareJdkSSLOptions sslOptions = null; if (conf.tlsConfig.isEnabled()) { // Not certain why we need the downcast here, but we do sslOptions = (RemoteEndpointAwareJdkSSLOptions)RemoteEndpointAwareJdkSSLOptions.builder() .withSSLContext(conf.tlsConfig.getSslContext()) .build(); } SocketOptions socketOptions = new SocketOptions(); socketOptions.setConnectTimeoutMillis(conf.connectionTimeout); socketOptions.setReadTimeoutMillis(conf.readTimeout); QueryOptions queryOptions = new QueryOptions(); queryOptions.setConsistencyLevel(conf.consistencyLevel); Cluster cluster = Cluster.builder() .addContactPoints(contactPoints) .withSSL(sslOptions) // If authentication is disabled on the C* cluster, this method has no effect. .withAuthProvider(getAuthProvider()) .withProtocolVersion(conf.protocolVersion) .withPort(conf.port) .withCodecRegistry(new CodecRegistry().register(SDC_CODECS)) .withSocketOptions(socketOptions) .withQueryOptions(queryOptions) .build(); if (conf.logSlowQueries) { QueryLogger queryLogger = QueryLogger.builder() .withConstantThreshold(conf.slowQueryThreshold) .build(); cluster.register(queryLogger); } return cluster; }
Example #4
Source File: QueryLoggerConfiguration.java From james-project with Apache License 2.0 | 5 votes |
public static QueryLoggerConfiguration from(Configuration configuration) { QueryLoggerConfiguration.Builder builder = QueryLoggerConfiguration.builder(); Optional<Long> constantThreshold = getOptionalIntegerFromConf(configuration, "cassandra.query.logger.constant.threshold") .map(Long::valueOf); constantThreshold.ifPresent(builder::withConstantThreshold); getOptionalIntegerFromConf(configuration, "cassandra.query.logger.max.logged.parameters") .ifPresent(builder::withMaxLoggedParameters); getOptionalIntegerFromConf(configuration, "cassandra.query.logger.max.query.string.length") .ifPresent(builder::withMaxQueryStringLength); getOptionalIntegerFromConf(configuration, "cassandra.query.logger.max.parameter.value.length") .ifPresent(builder::withMaxParameterValueLength); Optional<Double> percentileLatencyConf = getOptionalDoubleFromConf(configuration, "cassandra.query.slow.query.latency.threshold.percentile"); if (!percentileLatencyConf.isPresent() && !constantThreshold.isPresent()) { percentileLatencyConf = Optional.of(QueryLogger.DEFAULT_SLOW_QUERY_THRESHOLD_PERCENTILE); } percentileLatencyConf.ifPresent(slowQueryLatencyThresholdPercentile -> { PerHostPercentileTracker tracker = PerHostPercentileTracker .builder(CASSANDRA_HIGHEST_TRACKABLE_LATENCY_MILLIS) .build(); builder.withDynamicThreshold(tracker, slowQueryLatencyThresholdPercentile); }); return builder.build(); }
Example #5
Source File: MapConfiguredCqlClientFactory.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
@Override protected void prepareCluster(final Cluster cluster) { super.prepareCluster(cluster); final String threshold = (String) configuration.get(TRIDENT_CASSANDRA_QUERY_LOGGER_CONSTANT_THRESHOLD); if (StringUtils.isNotEmpty(threshold)) { final QueryLogger logger = QueryLogger.builder() .withConstantThreshold(Long.parseLong(threshold)) .build(); cluster.register(logger); } }