com.datastax.oss.driver.api.core.config.DriverConfigLoader Java Examples

The following examples show how to use com.datastax.oss.driver.api.core.config.DriverConfigLoader. 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: CassandraInitializer.java    From spring-fu with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {
	CassandraAutoConfiguration configuration = new CassandraAutoConfiguration();
	context.registerBean(CqlSession.class, () -> configuration.cassandraSession(context.getBean(CqlSessionBuilder.class)));
	context.registerBean(CqlSessionBuilder.class, () -> configuration.cassandraSessionBuilder(properties, context.getBean(DriverConfigLoader.class), context.getBeanProvider(CqlSessionBuilderCustomizer.class)));
	context.registerBean(DriverConfigLoader.class, () -> configuration.cassandraDriverConfigLoader(properties, context.getBeanProvider(DriverConfigLoaderBuilderCustomizer.class)));
}
 
Example #2
Source File: BackplaneConfiguration.java    From elasticactors with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void initialize() {
    String cassandraHosts = env.getProperty("ea.cassandra.hosts","localhost:9042");
    String cassandraKeyspaceName = env.getProperty("ea.cassandra.keyspace","\"ElasticActors\"");
    Integer cassandraPort = env.getProperty("ea.cassandra.port", Integer.class, 9042);

    Set<String> hostSet = StringUtils.commaDelimitedListToSet(cassandraHosts);

    String[] contactPoints = new String[hostSet.size()];
    int i=0;
    for (String host : hostSet) {
        if(host.contains(":")) {
            contactPoints[i] = host.substring(0,host.indexOf(":"));
        } else {
            contactPoints[i] = host;
        }
        i+=1;
    }

    List<InetSocketAddress> contactPointAddresses = Arrays.stream(contactPoints)
            .map(host -> new InetSocketAddress(host, cassandraPort))
            .collect(Collectors.toList());

    DriverConfigLoader driverConfigLoader = DriverConfigLoader.programmaticBuilder()
            .withDuration(DefaultDriverOption.HEARTBEAT_INTERVAL, Duration.ofSeconds(60))
            .withString(DefaultDriverOption.REQUEST_CONSISTENCY, ConsistencyLevel.QUORUM.name())
            .withString(DefaultDriverOption.RETRY_POLICY_CLASS, "DefaultRetryPolicy")
            .withString(DefaultDriverOption.RECONNECTION_POLICY_CLASS, "ConstantReconnectionPolicy")
            .withDuration(DefaultDriverOption.RECONNECTION_BASE_DELAY, Duration.ofSeconds(env.getProperty("ea.cassandra.retryDownedHostsDelayInSeconds",Integer.class,1)))
            .withString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, "DcInferringLoadBalancingPolicy")
            .build();


    cassandraSession = CqlSession.builder()
            .addContactPoints(contactPointAddresses)
            .withConfigLoader(driverConfigLoader)
            .withKeyspace(cassandraKeyspaceName)
            .build();
}
 
Example #3
Source File: CqlSessionCassandraConnectionFactory.java    From embedded-cassandra with Apache License 2.0 4 votes vote down vote up
private CqlSession createSession(Cassandra cassandra) {
	ProgrammaticDriverConfigLoaderBuilder driverBuilder = DriverConfigLoader.programmaticBuilder()
			.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(30))
			.withDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, Duration.ofSeconds(3));
	String username = getUsername();
	String password = getPassword();
	if (username != null && password != null) {
		driverBuilder.withString(DefaultDriverOption.AUTH_PROVIDER_USER_NAME, username)
				.withString(DefaultDriverOption.AUTH_PROVIDER_PASSWORD, password)
				.withClass(DefaultDriverOption.AUTH_PROVIDER_CLASS, PlainTextAuthProvider.class);
	}
	if (isSslEnabled()) {
		driverBuilder.withBoolean(DefaultDriverOption.SSL_HOSTNAME_VALIDATION, isHostnameValidation())
				.withClass(DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS, DefaultSslEngineFactory.class);
		List<String> cipherSuites = getCipherSuites();
		if (!cipherSuites.isEmpty()) {
			driverBuilder.withStringList(DefaultDriverOption.SSL_CIPHER_SUITES, new ArrayList<>(cipherSuites));
		}
		Resource truststore = getTruststore();
		if (truststore != null) {
			driverBuilder.withString(DefaultDriverOption.SSL_TRUSTSTORE_PATH, getPath(truststore).toString());
		}
		String truststorePassword = getTruststorePassword();
		if (truststorePassword != null) {
			driverBuilder.withString(DefaultDriverOption.SSL_TRUSTSTORE_PASSWORD, truststorePassword);
		}
		Resource keystore = getKeystore();
		if (keystore != null) {
			driverBuilder.withString(DefaultDriverOption.SSL_KEYSTORE_PATH, getPath(keystore).toString());
		}
		String keystorePassword = getKeystorePassword();
		if (keystorePassword != null) {
			driverBuilder.withString(DefaultDriverOption.SSL_KEYSTORE_PASSWORD, keystorePassword);
		}
	}
	List<Consumer<? super ProgrammaticDriverConfigLoaderBuilder>> driverConfigLoaderBuilderCustomizers =
			getDriverConfigLoaderBuilderCustomizers();
	driverConfigLoaderBuilderCustomizers.forEach(customizer -> customizer.accept(driverBuilder));
	int port = cassandra.getPort();
	int sslPort = cassandra.getSslPort();
	InetSocketAddress contactPoint = new InetSocketAddress(cassandra.getAddress(),
			(isSslEnabled() && sslPort != -1) ? sslPort : port);
	CqlSessionBuilder sessionBuilder = CqlSession.builder().addContactPoint(contactPoint)
			.withConfigLoader(driverBuilder.build());
	String localDataCenter = getLocalDataCenter();
	if (localDataCenter != null) {
		sessionBuilder.withLocalDatacenter(localDataCenter);
	}
	List<TypeCodec<?>> typeCodecs = getTypeCodecs();
	if (!typeCodecs.isEmpty()) {
		sessionBuilder.addTypeCodecs(typeCodecs.toArray(new TypeCodec[0]));
	}
	List<Consumer<? super CqlSessionBuilder>> sessionBuilderCustomizers = getSessionBuilderCustomizers();
	sessionBuilderCustomizers.forEach(customizer -> customizer.accept(sessionBuilder));
	return sessionBuilder.build();
}
 
Example #4
Source File: CQLStoreManager.java    From grakn with GNU Affero General Public License v3.0 4 votes vote down vote up
private CqlSession initialiseSession() throws PermanentBackendException {
    Configuration configuration = getStorageConfig();
    List<InetSocketAddress> contactPoints;
    String[] hostnames = configuration.get(STORAGE_HOSTS);
    int port = configuration.has(STORAGE_PORT) ? configuration.get(STORAGE_PORT) : DEFAULT_PORT;
    try {
        contactPoints = Array.of(hostnames)
                .map(hostName -> hostName.split(":"))
                .map(array -> Tuple.of(array[0], array.length == 2 ? Integer.parseInt(array[1]) : port))
                .map(tuple -> new InetSocketAddress(tuple._1, tuple._2))
                .toJavaList();
    } catch (SecurityException | ArrayIndexOutOfBoundsException | NumberFormatException e) {
        throw new PermanentBackendException("Error initialising cluster contact points", e);
    }

    CqlSessionBuilder builder = CqlSession.builder()
            .addContactPoints(contactPoints)
            .withLocalDatacenter(configuration.get(LOCAL_DATACENTER));

    ProgrammaticDriverConfigLoaderBuilder configLoaderBuilder = DriverConfigLoader.programmaticBuilder();

    configLoaderBuilder.withString(DefaultDriverOption.SESSION_NAME, configuration.get(SESSION_NAME));
    configLoaderBuilder.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, configuration.get(CONNECTION_TIMEOUT));

    if (configuration.get(PROTOCOL_VERSION) != 0) {
        configLoaderBuilder.withInt(DefaultDriverOption.PROTOCOL_VERSION, configuration.get(PROTOCOL_VERSION));
    }

    if (configuration.has(AUTH_USERNAME) && configuration.has(AUTH_PASSWORD)) {
        configLoaderBuilder
                .withClass(DefaultDriverOption.AUTH_PROVIDER_CLASS, PlainTextAuthProvider.class)
                .withString(DefaultDriverOption.AUTH_PROVIDER_USER_NAME, configuration.get(AUTH_USERNAME))
                .withString(DefaultDriverOption.AUTH_PROVIDER_PASSWORD, configuration.get(AUTH_PASSWORD));
    }

    if (configuration.get(SSL_ENABLED)) {
        configLoaderBuilder
                .withClass(DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS, DefaultSslEngineFactory.class)
                .withString(DefaultDriverOption.SSL_TRUSTSTORE_PATH, configuration.get(SSL_TRUSTSTORE_LOCATION))
                .withString(DefaultDriverOption.SSL_TRUSTSTORE_PASSWORD, configuration.get(SSL_TRUSTSTORE_PASSWORD));
    }

    configLoaderBuilder.withInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE, configuration.get(LOCAL_MAX_CONNECTIONS_PER_HOST));
    configLoaderBuilder.withInt(DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE, configuration.get(REMOTE_MAX_CONNECTIONS_PER_HOST));
    configLoaderBuilder.withInt(DefaultDriverOption.CONNECTION_MAX_REQUESTS, configuration.get(MAX_REQUESTS_PER_CONNECTION));

    // Keep to 0 for the time being: https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/Bc0gQuOVVL0
    // Ideally we want to batch all tables initialisations to happen together when opening a new keyspace
    configLoaderBuilder.withInt(DefaultDriverOption.METADATA_SCHEMA_WINDOW, 0);

    // The following sets the size of Netty ThreadPool executor used by Cassandra driver:
    // https://docs.datastax.com/en/developer/java-driver/4.0/manual/core/async/#threading-model
    configLoaderBuilder.withInt(DefaultDriverOption.NETTY_IO_SIZE, 0); // size of threadpool scales with number of available CPUs when set to 0
    configLoaderBuilder.withInt(DefaultDriverOption.NETTY_ADMIN_SIZE, 0); // size of threadpool scales with number of available CPUs when set to 0


    // Keep the following values to 0 so that when we close the session we don't have to wait for the
    // so called "quiet period", setting this to a different value will slow down Graph.close()
    configLoaderBuilder.withInt(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_QUIET_PERIOD, 0);
    configLoaderBuilder.withInt(DefaultDriverOption.NETTY_IO_SHUTDOWN_QUIET_PERIOD, 0);

    builder.withConfigLoader(configLoaderBuilder.build());

    return builder.build();
}
 
Example #5
Source File: CassandraInterpreter.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public void open() {
  final String[] addresses = getProperty(CASSANDRA_HOSTS, DEFAULT_HOST)
          .trim().split(",");
  final int port = parseInt(getProperty(CASSANDRA_PORT, DEFAULT_PORT));
  Collection<InetSocketAddress> hosts = new ArrayList<>();
  for (String address : addresses) {
    if (!StringUtils.isBlank(address)) {
      logger.debug("Adding contact point: {}", address);
      if (InetAddresses.isInetAddress(address)) {
        hosts.add(new InetSocketAddress(address, port));
      } else {
        hosts.add(InetSocketAddress.createUnresolved(address, port));
      }
    }
  }

  LOGGER.info("Bootstrapping Cassandra Java Driver to connect to {} on port {}",
          getProperty(CASSANDRA_HOSTS), port);

  DriverConfigLoader loader = createLoader();

  LOGGER.debug("Creating cluster builder");
  CqlSessionBuilder clusterBuilder = CqlSession.builder()
          .withApplicationName("Zeppelin")
          .withApplicationVersion("");
  if (!hosts.isEmpty()) {
    LOGGER.debug("Adding contact points");
    clusterBuilder.addContactPoints(hosts);
  }

  String username = getProperty(CASSANDRA_CREDENTIALS_USERNAME, NONE_VALUE).trim();
  String password = getProperty(CASSANDRA_CREDENTIALS_PASSWORD, NONE_VALUE).trim();
  if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password) &&
          !NONE_VALUE.equalsIgnoreCase(username) && !NONE_VALUE.equalsIgnoreCase(password)) {
    LOGGER.debug("Adding credentials. Username = {}", username);
    clusterBuilder.withAuthCredentials(username, password);
  }

  String keyspace = getProperty(CASSANDRA_KEYSPACE_NAME, DEFAULT_KEYSPACE);
  if (StringUtils.isNotBlank(keyspace) && !DEFAULT_KEYSPACE.equalsIgnoreCase(keyspace)) {
    LOGGER.debug("Set default keyspace");
    clusterBuilder.withKeyspace(keyspace);
  }

  final String runWithSSL = getProperty(CASSANDRA_WITH_SSL, "false");
  if ("true".equalsIgnoreCase(runWithSSL)) {
    LOGGER.debug("Using SSL");
    try {
      final SSLContext sslContext;
      {
        final KeyStore trustStore = KeyStore.getInstance("JKS");
        final InputStream stream = Files.newInputStream(Paths.get(
                getProperty(CASSANDRA_TRUSTSTORE_PATH)));
        trustStore.load(stream, getProperty(CASSANDRA_TRUSTSTORE_PASSWORD).toCharArray());

        final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
                TrustManagerFactory.getDefaultAlgorithm());
        trustManagerFactory.init(trustStore);

        sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
      }
      clusterBuilder = clusterBuilder.withSslContext(sslContext);
    } catch (Exception e) {
      LOGGER.error("Exception initializing SSL {}", e.toString());
    }
  } else {
    LOGGER.debug("Not using SSL");
  }

  LOGGER.debug("Creating CqlSession");
  session = clusterBuilder.withConfigLoader(loader).build();
  LOGGER.debug("Session configuration");
  for (Map.Entry<String, Object> entry:
          session.getContext().getConfig().getDefaultProfile().entrySet()) {
    logger.debug("{} = {}", entry.getKey(), entry.getValue().toString());
  }
  LOGGER.debug("Creating helper");
  helper = new InterpreterLogic(session, properties);
}
 
Example #6
Source File: CassandraAppender.java    From karaf-decanter with Apache License 2.0 4 votes vote down vote up
void activate(Dictionary<String, Object> config) {
    this.config = config;
    String host = getValue(config, CASSANDRA_HOST_PROPERTY, CASSANDRA_HOST_DEFAULT);
    Integer port = Integer.parseInt(getValue(config, CASSANDRA_PORT_PROPERTY, CASSANDRA_PORT_DEFAULT));
    this.keyspace = getValue(config, KEYSPACE_PROPERTY, KEYSPACE_DEFAULT);
    this.tableName = getValue(config, TABLE_PROPERTY, TABLE_DEFAULT);

    DriverConfigLoader loader =
            DriverConfigLoader.programmaticBuilder()
                    .withStringList(DefaultDriverOption.CONTACT_POINTS, Arrays.asList(host + ":" + port))
                    .withString(DefaultDriverOption.PROTOCOL_VERSION, "V3")
                    .withString(DefaultDriverOption.PROTOCOL_MAX_FRAME_LENGTH, "256 MB")
                    .withString(DefaultDriverOption.SESSION_NAME, "decanter")
                    .withString(DefaultDriverOption.SESSION_KEYSPACE, keyspace)
                    .withString(DefaultDriverOption.CONFIG_RELOAD_INTERVAL, "0")
                    .withString(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, "500 milliseconds")
                    .withString(DefaultDriverOption.CONNECTION_SET_KEYSPACE_TIMEOUT, "500 milliseconds")
                    .withString(DefaultDriverOption.CONTROL_CONNECTION_AGREEMENT_INTERVAL, "200 milliseconds")
                    .withString(DefaultDriverOption.CONTROL_CONNECTION_AGREEMENT_TIMEOUT, "10 seconds")
                    .withBoolean(DefaultDriverOption.CONTROL_CONNECTION_AGREEMENT_WARN, true)
                    .withInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE, 1)
                    .withInt(DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE, 1)
                    .withInt(DefaultDriverOption.CONNECTION_MAX_REQUESTS, 1024)
                    .withInt(DefaultDriverOption.CONNECTION_MAX_ORPHAN_REQUESTS, 24576)
                    .withString(DefaultDriverOption.HEARTBEAT_INTERVAL, "30 seconds")
                    .withString(DefaultDriverOption.HEARTBEAT_TIMEOUT, "500 milliseconds")
                    .withString(DefaultDriverOption.COALESCER_INTERVAL, "10 microseconds")
                    .withInt(DefaultDriverOption.COALESCER_MAX_RUNS, 5)
                    .withString(DefaultDriverOption.RECONNECTION_POLICY_CLASS, "ExponentialReconnectionPolicy")
                    .withString(DefaultDriverOption.RECONNECTION_BASE_DELAY, "1 second")
                    .withString(DefaultDriverOption.RECONNECTION_MAX_DELAY, "60 seconds")
                    .withBoolean(DefaultDriverOption.RECONNECT_ON_INIT, true)
                    .withString(DefaultDriverOption.LOAD_BALANCING_POLICY, "")
                    .withString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, "DefaultLoadBalancingPolicy")
                    .withString(DefaultDriverOption.RETRY_POLICY, "")
                    .withString(DefaultDriverOption.RETRY_POLICY_CLASS, "DefaultRetryPolicy")
                    .withString(DefaultDriverOption.SPECULATIVE_EXECUTION_POLICY, "")
                    .withString(DefaultDriverOption.SPECULATIVE_EXECUTION_POLICY_CLASS, "NoSpeculativeExecutionPolicy")
                    .withString(DefaultDriverOption.ADDRESS_TRANSLATOR_CLASS, "PassThroughAddressTranslator")
                    .withString(DefaultDriverOption.METADATA_SCHEMA_CHANGE_LISTENER_CLASS, "NoopSchemaChangeListener")
                    .withString(DefaultDriverOption.METADATA_NODE_STATE_LISTENER_CLASS, "NoopNodeStateListener")
                    .withString(DefaultDriverOption.REQUEST_TRACKER_CLASS, "NoopRequestTracker")
                    .withString(DefaultDriverOption.REQUEST_THROTTLER_CLASS, "PassThroughRequestThrottler")
                    .withBoolean(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE, false)
                    .withString(DefaultDriverOption.REQUEST_CONSISTENCY, "LOCAL_ONE")
                    .withInt(DefaultDriverOption.REQUEST_PAGE_SIZE, 5000)
                    .withString(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY, "SERIAL")
                    .withString(DefaultDriverOption.TIMESTAMP_GENERATOR_CLASS, "AtomicTimestampGenerator")
                    .withBoolean(DefaultDriverOption.SOCKET_TCP_NODELAY, true)
                    .withString(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT, "500 milliseconds")
                    .withInt(DefaultDriverOption.NETTY_IO_SIZE, 0)
                    .withInt(DefaultDriverOption.NETTY_IO_SHUTDOWN_QUIET_PERIOD, 2)
                    .withInt(DefaultDriverOption.NETTY_IO_SHUTDOWN_TIMEOUT, 15)
                    .withString(DefaultDriverOption.NETTY_IO_SHUTDOWN_UNIT, "SECONDS")
                    .withInt(DefaultDriverOption.NETTY_ADMIN_SIZE, 2)
                    .withInt(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_QUIET_PERIOD, 2)
                    .withInt(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_TIMEOUT, 15)
                    .withString(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_UNIT, "SECONDS")
                    .withString(DefaultDriverOption.NETTY_TIMER_TICK_DURATION, "100 milliseconds")
                    .withInt(DefaultDriverOption.NETTY_TIMER_TICKS_PER_WHEEL, 2048)
                    .withBoolean(DefaultDriverOption.METADATA_SCHEMA_ENABLED, true)
                    .withString(DefaultDriverOption.METADATA_SCHEMA_WINDOW, "1 second")
                    .withInt(DefaultDriverOption.METADATA_SCHEMA_MAX_EVENTS, 20)
                    .withString(DefaultDriverOption.METADATA_SCHEMA_REQUEST_TIMEOUT, "500 milliseconds")
                    .withInt(DefaultDriverOption.METADATA_SCHEMA_REQUEST_PAGE_SIZE, 5000)
                    .withBoolean(DefaultDriverOption.METADATA_TOKEN_MAP_ENABLED, true)
                    .withString(DefaultDriverOption.METADATA_TOPOLOGY_WINDOW,"1 second")
                    .withInt(DefaultDriverOption.METADATA_TOPOLOGY_MAX_EVENTS,20)
                    .withStringList(DefaultDriverOption.METRICS_SESSION_ENABLED, new ArrayList<>())
                    .withStringList(DefaultDriverOption.METRICS_NODE_ENABLED, new ArrayList<>())
                    .withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(5))
                    .build();
    session = CqlSession.builder()
            .withClassLoader(CqlSession.class.getClassLoader())
            .withConfigLoader(loader)
            .withLocalDatacenter("datacenter1").build();
    useKeyspace(session, keyspace);
    createTable(session, keyspace, tableName);
}
 
Example #7
Source File: CassandraAppenderTest.java    From karaf-decanter with Apache License 2.0 4 votes vote down vote up
private static CqlSession getSession() {

        DriverConfigLoader loader =
                DriverConfigLoader.programmaticBuilder()
                        .withStringList(DefaultDriverOption.CONTACT_POINTS, Arrays.asList(CASSANDRA_HOST + ":" + CASSANDRA_PORT))
                        .withString(DefaultDriverOption.PROTOCOL_VERSION, "V3")
                        .withString(DefaultDriverOption.PROTOCOL_MAX_FRAME_LENGTH, "256 MB")
                        .withString(DefaultDriverOption.SESSION_NAME, "decanter")
                        .withString(DefaultDriverOption.CONFIG_RELOAD_INTERVAL, "0")
                        .withString(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, "500 milliseconds")
                        .withString(DefaultDriverOption.CONNECTION_SET_KEYSPACE_TIMEOUT, "500 milliseconds")
                        .withString(DefaultDriverOption.CONTROL_CONNECTION_AGREEMENT_INTERVAL, "200 milliseconds")
                        .withString(DefaultDriverOption.CONTROL_CONNECTION_AGREEMENT_TIMEOUT, "10 seconds")
                        .withBoolean(DefaultDriverOption.CONTROL_CONNECTION_AGREEMENT_WARN, true)
                        .withInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE, 1)
                        .withInt(DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE, 1)
                        .withInt(DefaultDriverOption.CONNECTION_MAX_REQUESTS, 1024)
                        .withInt(DefaultDriverOption.CONNECTION_MAX_ORPHAN_REQUESTS, 24576)
                        .withString(DefaultDriverOption.HEARTBEAT_INTERVAL, "30 seconds")
                        .withString(DefaultDriverOption.HEARTBEAT_TIMEOUT, "500 milliseconds")
                        .withString(DefaultDriverOption.COALESCER_INTERVAL, "10 microseconds")
                        .withInt(DefaultDriverOption.COALESCER_MAX_RUNS, 5)
                        .withString(DefaultDriverOption.RECONNECTION_POLICY_CLASS, "ExponentialReconnectionPolicy")
                        .withString(DefaultDriverOption.RECONNECTION_BASE_DELAY, "1 second")
                        .withString(DefaultDriverOption.RECONNECTION_MAX_DELAY, "60 seconds")
                        .withBoolean(DefaultDriverOption.RECONNECT_ON_INIT, true)
                        .withString(DefaultDriverOption.LOAD_BALANCING_POLICY, "")
                        .withString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, "DefaultLoadBalancingPolicy")
                        .withString(DefaultDriverOption.RETRY_POLICY, "")
                        .withString(DefaultDriverOption.RETRY_POLICY_CLASS, "DefaultRetryPolicy")
                        .withString(DefaultDriverOption.SPECULATIVE_EXECUTION_POLICY, "")
                        .withString(DefaultDriverOption.SPECULATIVE_EXECUTION_POLICY_CLASS, "NoSpeculativeExecutionPolicy")
                        .withString(DefaultDriverOption.ADDRESS_TRANSLATOR_CLASS, "PassThroughAddressTranslator")
                        .withString(DefaultDriverOption.METADATA_SCHEMA_CHANGE_LISTENER_CLASS, "NoopSchemaChangeListener")
                        .withString(DefaultDriverOption.METADATA_NODE_STATE_LISTENER_CLASS, "NoopNodeStateListener")
                        .withString(DefaultDriverOption.REQUEST_TRACKER_CLASS, "NoopRequestTracker")
                        .withString(DefaultDriverOption.REQUEST_THROTTLER_CLASS, "PassThroughRequestThrottler")
                        .withBoolean(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE, false)
                        .withString(DefaultDriverOption.REQUEST_CONSISTENCY, "LOCAL_ONE")
                        .withInt(DefaultDriverOption.REQUEST_PAGE_SIZE, 5000)
                        .withString(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY, "SERIAL")
                        .withString(DefaultDriverOption.TIMESTAMP_GENERATOR_CLASS, "AtomicTimestampGenerator")
                        .withBoolean(DefaultDriverOption.SOCKET_TCP_NODELAY, true)
                        .withString(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT, "500 milliseconds")
                        .withInt(DefaultDriverOption.NETTY_IO_SIZE, 0)
                        .withInt(DefaultDriverOption.NETTY_IO_SHUTDOWN_QUIET_PERIOD, 2)
                        .withInt(DefaultDriverOption.NETTY_IO_SHUTDOWN_TIMEOUT, 15)
                        .withString(DefaultDriverOption.NETTY_IO_SHUTDOWN_UNIT, "SECONDS")
                        .withInt(DefaultDriverOption.NETTY_ADMIN_SIZE, 2)
                        .withInt(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_QUIET_PERIOD, 2)
                        .withInt(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_TIMEOUT, 15)
                        .withString(DefaultDriverOption.NETTY_ADMIN_SHUTDOWN_UNIT, "SECONDS")
                        .withString(DefaultDriverOption.NETTY_TIMER_TICK_DURATION, "100 milliseconds")
                        .withInt(DefaultDriverOption.NETTY_TIMER_TICKS_PER_WHEEL, 2048)
                        .withBoolean(DefaultDriverOption.METADATA_SCHEMA_ENABLED, true)
                        .withString(DefaultDriverOption.METADATA_SCHEMA_WINDOW, "1 second")
                        .withInt(DefaultDriverOption.METADATA_SCHEMA_MAX_EVENTS, 20)
                        .withString(DefaultDriverOption.METADATA_SCHEMA_REQUEST_TIMEOUT, "500 milliseconds")
                        .withInt(DefaultDriverOption.METADATA_SCHEMA_REQUEST_PAGE_SIZE, 5000)
                        .withBoolean(DefaultDriverOption.METADATA_TOKEN_MAP_ENABLED, true)
                        .withString(DefaultDriverOption.METADATA_TOPOLOGY_WINDOW,"1 second")
                        .withInt(DefaultDriverOption.METADATA_TOPOLOGY_MAX_EVENTS,20)
                        .withStringList(DefaultDriverOption.METRICS_SESSION_ENABLED, new ArrayList<>())
                        .withStringList(DefaultDriverOption.METRICS_NODE_ENABLED, new ArrayList<>())
                        .withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(5))
                        .build();
        return CqlSession.builder()
                .withClassLoader(CqlSession.class.getClassLoader())
                .withConfigLoader(loader)
                .withLocalDatacenter("datacenter1").build();
    }