Search in sources :

Example 1 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method driverConfigLoaderCustomizeControlConnectionOptions.

@Test
void driverConfigLoaderCustomizeControlConnectionOptions() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.controlconnection.timeout=200ms").run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getInt(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT)).isEqualTo(200);
    });
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 2 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project zeppelin by apache.

the class CassandraInterpreterTest method should_set_custom_option.

@Test
public void should_set_custom_option() {
    assertThat(interpreter.session).isNotNull();
    DriverExecutionProfile config = interpreter.session.getContext().getConfig().getDefaultProfile();
    assertThat(config.getInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE, 10)).isEqualTo(1);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.Test)

Example 3 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class ContinuousRequestHandlerBase method onThrottleFailure.

@Override
public void onThrottleFailure(@NonNull RequestThrottlingException error) {
    DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(initialStatement, context);
    session.getMetricUpdater().incrementCounter(DefaultSessionMetric.THROTTLING_ERRORS, executionProfile.getName());
    abortGlobalRequestOrChosenCallback(error);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Example 4 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class ContinuousRequestHandlerBase method onThrottleReady.

// MAIN LIFECYCLE
@Override
public void onThrottleReady(boolean wasDelayed) {
    DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(initialStatement, context);
    if (wasDelayed && // avoid call to nanoTime() if metric is disabled:
    sessionMetricUpdater.isEnabled(DefaultSessionMetric.THROTTLING_DELAY, executionProfile.getName())) {
        session.getMetricUpdater().updateTimer(DefaultSessionMetric.THROTTLING_DELAY, executionProfile.getName(), System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS);
    }
    activeExecutionsCount.incrementAndGet();
    sendRequest(initialStatement, null, 0, 0, specExecEnabled);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Example 5 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class Reflection method buildFromConfig.

/**
 * @param profileName if null, this is a global policy, use the default profile and look for a
 *     one-arg constructor. If not null, this is a per-profile policy, look for a two-arg
 *     constructor.
 */
public static <ComponentT> Optional<ComponentT> buildFromConfig(InternalDriverContext context, String profileName, DriverOption classNameOption, Class<ComponentT> expectedSuperType, String... defaultPackages) {
    DriverExecutionProfile config = (profileName == null) ? context.getConfig().getDefaultProfile() : context.getConfig().getProfile(profileName);
    String configPath = classNameOption.getPath();
    LOG.debug("Creating a {} from config option {}", expectedSuperType.getSimpleName(), configPath);
    if (!config.isDefined(classNameOption)) {
        LOG.debug("Option is not defined, skipping");
        return Optional.empty();
    }
    String className = config.getString(classNameOption);
    return Optional.of(resolveClass(context, profileName, expectedSuperType, configPath, className, defaultPackages));
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Aggregations

DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)140 Test (org.junit.Test)81 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)29 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)20 CqlSession (com.datastax.oss.driver.api.core.CqlSession)19 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)17 Node (com.datastax.oss.driver.api.core.metadata.Node)14 ByteBuffer (java.nio.ByteBuffer)13 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)12 Duration (java.time.Duration)11 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)10 GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)10 Row (com.datastax.oss.driver.api.core.cql.Row)9 Test (org.junit.jupiter.api.Test)9 LoggerTest (com.datastax.oss.driver.internal.core.util.LoggerTest)8 DefaultNodeMetric (com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)7 NodeMetric (com.datastax.oss.driver.api.core.metrics.NodeMetric)7 Message (com.datastax.oss.protocol.internal.Message)7 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)6 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)6