Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce CassandraSessionConfigurator #23899

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/main/sphinx/connector/cassandra.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following configuration properties are available:
| `cassandra.native-protocol-port` | The Cassandra server port running the native client protocol, defaults to `9042`. |
| `cassandra.consistency-level` | Consistency levels in Cassandra refer to the level of consistency to be used for both read and write operations. More information about consistency levels can be found in the [Cassandra consistency] documentation. This property defaults to a consistency level of `ONE`. Possible values include `ALL`, `EACH_QUORUM`, `QUORUM`, `LOCAL_QUORUM`, `ONE`, `TWO`, `THREE`, `LOCAL_ONE`, `ANY`, `SERIAL`, `LOCAL_SERIAL`. |
| `cassandra.allow-drop-table` | Enables {doc}`/sql/drop-table` operations. Defaults to `false`. |
| `cassandra.security` | Should be set to `PASSWORD` for password based authentication. Defaults to `NONE`. |
| `cassandra.username` | Username used for authentication to the Cassandra cluster. This is a global setting used for all connections, regardless of the user connected to Trino. |
| `cassandra.password` | Password used for authentication to the Cassandra cluster. This is a global setting used for all connections, regardless of the user connected to Trino. |
| `cassandra.protocol-version` | It is possible to override the protocol version for older Cassandra clusters. By default, the value corresponds to the default protocol version used in the underlying Cassandra java driver. Possible values include `V3`, `V4`, `V5`, `V6`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import com.google.common.collect.ImmutableList;
import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;
import io.airlift.configuration.ConfigSecuritySensitive;
import io.airlift.configuration.DefunctConfig;
import io.airlift.configuration.validation.FileExists;
import io.airlift.units.Duration;
import io.airlift.units.MaxDuration;
import io.airlift.units.MinDuration;
Expand All @@ -31,10 +29,10 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.io.File;
import java.util.List;
import java.util.Optional;

import static io.trino.plugin.cassandra.CassandraClientConfig.CassandraAuthenticationType.NONE;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;

Expand All @@ -55,6 +53,12 @@
})
public class CassandraClientConfig
{
public enum CassandraAuthenticationType
{
NONE,
PASSWORD;
}

private ConsistencyLevel consistencyLevel = ConsistencyLevel.ONE;
private int fetchSize = 5_000;
private List<String> contactPoints = ImmutableList.of();
Expand All @@ -64,8 +68,6 @@ public class CassandraClientConfig
private int batchSize = 100;
private Long splitsPerNode;
private boolean allowDropTable;
private String username;
private String password;
private Duration clientReadTimeout = new Duration(12_000, MILLISECONDS);
private Duration clientConnectTimeout = new Duration(5_000, MILLISECONDS);
private Integer clientSoLinger;
Expand All @@ -79,10 +81,7 @@ public class CassandraClientConfig
private Duration speculativeExecutionDelay = new Duration(500, MILLISECONDS);
private ProtocolVersion protocolVersion;
private boolean tlsEnabled;
private File keystorePath;
private String keystorePassword;
private File truststorePath;
private String truststorePassword;
private CassandraAuthenticationType authenticationType = NONE;

@NotNull
@Size(min = 1)
Expand Down Expand Up @@ -201,31 +200,6 @@ public CassandraClientConfig setAllowDropTable(boolean allowDropTable)
return this;
}

public String getUsername()
{
return username;
}

@Config("cassandra.username")
public CassandraClientConfig setUsername(String username)
{
this.username = username;
return this;
}

public String getPassword()
{
return password;
}

@Config("cassandra.password")
@ConfigSecuritySensitive
public CassandraClientConfig setPassword(String password)
{
this.password = password;
return this;
}

@MinDuration("1ms")
@MaxDuration("1h")
public Duration getClientReadTimeout()
Expand Down Expand Up @@ -392,53 +366,15 @@ public CassandraClientConfig setTlsEnabled(boolean tlsEnabled)
return this;
}

public Optional<@FileExists File> getKeystorePath()
{
return Optional.ofNullable(keystorePath);
}

@Config("cassandra.tls.keystore-path")
public CassandraClientConfig setKeystorePath(File keystorePath)
{
this.keystorePath = keystorePath;
return this;
}

public Optional<String> getKeystorePassword()
{
return Optional.ofNullable(keystorePassword);
}

@Config("cassandra.tls.keystore-password")
@ConfigSecuritySensitive
public CassandraClientConfig setKeystorePassword(String keystorePassword)
{
this.keystorePassword = keystorePassword;
return this;
}

public Optional<@FileExists File> getTruststorePath()
{
return Optional.ofNullable(truststorePath);
}

@Config("cassandra.tls.truststore-path")
public CassandraClientConfig setTruststorePath(File truststorePath)
{
this.truststorePath = truststorePath;
return this;
}

public Optional<String> getTruststorePassword()
public CassandraAuthenticationType getAuthenticationType()
{
return Optional.ofNullable(truststorePassword);
return authenticationType;
}

@Config("cassandra.tls.truststore-password")
@ConfigSecuritySensitive
public CassandraClientConfig setTruststorePassword(String truststorePassword)
@Config("cassandra.security")
public CassandraClientConfig setAuthenticationType(CassandraAuthenticationType authenticationType)
{
this.truststorePassword = truststorePassword;
this.authenticationType = authenticationType;
return this;
}
}
Loading