Skip to content
Merged
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 jdbc/src/main/java/tech/ydb/jdbc/settings/YdbConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public DriverPropertyInfo[] toPropertyInfo() throws SQLException {
YdbConnectionProperties.USE_METADATA.toInfo(properties),
YdbConnectionProperties.IAM_ENDPOINT.toInfo(properties),
YdbConnectionProperties.METADATA_URL.toInfo(properties),
YdbConnectionProperties.GRPC_COMPRESSION.toInfo(properties),

YdbClientProperties.KEEP_QUERY_TEXT.toInfo(properties),
YdbClientProperties.SESSION_KEEP_ALIVE_TIME.toInfo(properties),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tech.ydb.auth.iam.CloudAuthHelper;
import tech.ydb.core.auth.StaticCredentials;
import tech.ydb.core.grpc.BalancingSettings;
import tech.ydb.core.grpc.GrpcCompression;
import tech.ydb.core.grpc.GrpcTransportBuilder;
import tech.ydb.jdbc.YdbDriver;

Expand Down Expand Up @@ -47,6 +48,10 @@ public class YdbConnectionProperties {
static final YdbProperty<String> METADATA_URL = YdbProperty.content("metadataURL",
"Custom URL for the metadata service authentication");

static final YdbProperty<String> GRPC_COMPRESSION = YdbProperty.string(
"grpcCompression", "Use specified GRPC compressor (supported only none and gzip)"
);

private final String username;
private final String password;

Expand All @@ -60,6 +65,7 @@ public class YdbConnectionProperties {
private final YdbValue<Boolean> useMetadata;
private final YdbValue<String> iamEndpoint;
private final YdbValue<String> metadataUrl;
private final YdbValue<String> grpcCompression;

public YdbConnectionProperties(YdbConfig config) throws SQLException {
this.username = config.getUsername();
Expand All @@ -77,6 +83,7 @@ public YdbConnectionProperties(YdbConfig config) throws SQLException {
this.useMetadata = USE_METADATA.readValue(props);
this.iamEndpoint = IAM_ENDPOINT.readValue(props);
this.metadataUrl = METADATA_URL.readValue(props);
this.grpcCompression = GRPC_COMPRESSION.readValue(props);
}

String getLocalDataCenter() {
Expand Down Expand Up @@ -175,6 +182,17 @@ public GrpcTransportBuilder applyToGrpcTransport(GrpcTransportBuilder builder) {
}
}

if (grpcCompression.hasValue()) {
String value = grpcCompression.getValue();
if ("none".equalsIgnoreCase(value)) {
builder = builder.withGrpcCompression(GrpcCompression.NO_COMPRESSION);
} else if ("gzip".equalsIgnoreCase(value)) {
builder = builder.withGrpcCompression(GrpcCompression.GZIP);
} else {
LOGGER.log(Level.WARNING, "Unknown value for option 'grpcCompression' : {0}", value);
}
}

return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class YdbConnectionImplTest {
private static final YdbHelperExtension ydb = new YdbHelperExtension();

@RegisterExtension
private static final JdbcConnectionExtention jdbc = new JdbcConnectionExtention(ydb);
private static final JdbcConnectionExtention jdbc = new JdbcConnectionExtention(ydb)
.withArg("grpcCompression", "gzip");

private static final SqlQueries QUERIES = new SqlQueries("ydb_connection_test");
private static final String SELECT_2_2 = "select 2 + 2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public class YdbTableConnectionImplTest {

@RegisterExtension
private static final JdbcConnectionExtention jdbc = new JdbcConnectionExtention(ydb)
.withArg("useQueryService", "false");
.withArg("useQueryService", "false")
.withArg("grpcCompression", "none");

private static final SqlQueries QUERIES = new SqlQueries("ydb_connection_test");
private static final String SELECT_2_2 = "select 2 + 2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ static DriverPropertyInfo[] defaultPropertyInfo(@Nullable String localDatacenter
new DriverPropertyInfo("useMetadata", ""),
new DriverPropertyInfo("iamEndpoint", ""),
new DriverPropertyInfo("metadataURL", ""),
new DriverPropertyInfo("grpcCompression", ""),
new DriverPropertyInfo("keepQueryText", ""),
new DriverPropertyInfo("sessionKeepAliveTime", ""),
new DriverPropertyInfo("sessionMaxIdleTime", ""),
Expand Down Expand Up @@ -360,6 +361,7 @@ static DriverPropertyInfo[] customizedPropertyInfo() {
new DriverPropertyInfo("useMetadata", "true"),
new DriverPropertyInfo("iamEndpoint", "iam.endpoint.com"),
new DriverPropertyInfo("metadataURL", "https://metadata.com"),
new DriverPropertyInfo("grpcCompression", "gzip"),
new DriverPropertyInfo("keepQueryText", "true"),
new DriverPropertyInfo("sessionKeepAliveTime", "15m"),
new DriverPropertyInfo("sessionMaxIdleTime", "5m"),
Expand Down