JAVA-1651: Add NO_COMPACT startup option · ws-java/java-driver@b4e444e · GitHub
Skip to content

Commit b4e444e

Browse files
tolbertamolim7t
authored andcommitted
JAVA-1651: Add NO_COMPACT startup option
1 parent d437684 commit b4e444e

5 files changed

Lines changed: 58 additions & 6 deletions

File tree

changelog/README.md

Lines changed: 1 addition & 0 deletions

driver-core/src/main/java/com/datastax/driver/core/Cluster.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ public static class Builder implements Initializer {
687687
private boolean metricsEnabled = true;
688688
private boolean jmxEnabled = true;
689689
private boolean allowBetaProtocolVersion = false;
690+
private boolean noCompact = false;
690691

691692
private Collection<Host.StateListener> listeners;
692693

@@ -1295,6 +1296,24 @@ public Builder withNettyOptions(NettyOptions nettyOptions) {
12951296
return this;
12961297
}
12971298

1299+
/**
1300+
* Enables the <code>NO_COMPACT</code> startup option.
1301+
* <p>
1302+
* When this option is supplied, <code>SELECT</code>, <code>UPDATE</code>, <code>DELETE</code> and
1303+
* <code>BATCH</code> statements on <code>COMPACT STORAGE</code> tables function in "compatibility" mode which
1304+
* allows seeing these tables as if they were "regular" CQL tables.
1305+
* <p>
1306+
* This option only effects interactions with tables using <code>COMPACT STORAGE<code> and is only supported by
1307+
* C* 4.0+ and DSE 6.0+.
1308+
*
1309+
* @return this builder.
1310+
* @see <a href="https://issues.apache.org/jira/browse/CASSANDRA-10857">CASSANDRA-10857</a>
1311+
*/
1312+
public Builder withNoCompact() {
1313+
this.noCompact = true;
1314+
return this;
1315+
}
1316+
12981317
/**
12991318
* The configuration that will be used for the new cluster.
13001319
* <p/>
@@ -1306,7 +1325,7 @@ public Builder withNettyOptions(NettyOptions nettyOptions) {
13061325
*/
13071326
@Override
13081327
public Configuration getConfiguration() {
1309-
ProtocolOptions protocolOptions = new ProtocolOptions(port, protocolVersion, maxSchemaAgreementWaitSeconds, sslOptions, authProvider)
1328+
ProtocolOptions protocolOptions = new ProtocolOptions(port, protocolVersion, maxSchemaAgreementWaitSeconds, sslOptions, authProvider, noCompact)
13101329
.setCompression(compression);
13111330

13121331
MetricsOptions metricsOptions = new MetricsOptions(metricsEnabled, jmxEnabled);

driver-core/src/main/java/com/datastax/driver/core/Connection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ private AsyncFunction<Void, Void> onChannelReady(final ProtocolVersion protocolV
232232
return new AsyncFunction<Void, Void>() {
233233
@Override
234234
public ListenableFuture<Void> apply(Void input) throws Exception {
235-
ProtocolOptions.Compression compression = factory.configuration.getProtocolOptions().getCompression();
236-
Future startupResponseFuture = write(new Requests.Startup(compression));
235+
ProtocolOptions protocolOptions = factory.configuration.getProtocolOptions();
236+
Future startupResponseFuture = write(new Requests.Startup(protocolOptions.getCompression(), protocolOptions.isNoCompact()));
237237
return GuavaCompatibility.INSTANCE.transformAsync(startupResponseFuture,
238238
onStartupResponse(protocolVersion, initExecutor), initExecutor);
239239
}

driver-core/src/main/java/com/datastax/driver/core/ProtocolOptions.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public String toString() {
9999
private final SSLOptions sslOptions; // null if no SSL
100100
private final AuthProvider authProvider;
101101

102+
private final boolean noCompact;
103+
102104
private volatile Compression compression = Compression.NONE;
103105

104106
/**
@@ -118,7 +120,7 @@ public ProtocolOptions() {
118120
* @param port the port to use for the binary protocol.
119121
*/
120122
public ProtocolOptions(int port) {
121-
this(port, null, DEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS, null, AuthProvider.NONE);
123+
this(port, null, DEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS, null, AuthProvider.NONE, false);
122124
}
123125

124126
/**
@@ -135,11 +137,30 @@ public ProtocolOptions(int port) {
135137
* the Cassandra nodes.
136138
*/
137139
public ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider) {
140+
this(port, protocolVersion, maxSchemaAgreementWaitSeconds, sslOptions, authProvider, false);
141+
}
142+
143+
/**
144+
* Creates a new {@code ProtocolOptions} instance using the provided port
145+
* and SSL context.
146+
*
147+
* @param port the port to use for the binary protocol.
148+
* @param protocolVersion the protocol version to use. This can be {@code null}, in which case the
149+
* version used will be the biggest version supported by the <em>first</em> node the driver connects to.
150+
* See {@link Cluster.Builder#withProtocolVersion} for more details.
151+
* @param sslOptions the SSL options to use. Use {@code null} if SSL is not
152+
* to be used.
153+
* @param authProvider the {@code AuthProvider} to use for authentication against
154+
* the Cassandra nodes.
155+
* @param noCompact whether or not to include the NO_COMPACT startup option.
156+
*/
157+
public ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider, boolean noCompact) {
138158
this.port = port;
139159
this.initialProtocolVersion = protocolVersion;
140160
this.maxSchemaAgreementWaitSeconds = maxSchemaAgreementWaitSeconds;
141161
this.sslOptions = sslOptions;
142162
this.authProvider = authProvider;
163+
this.noCompact = noCompact;
143164
}
144165

145166
void register(Cluster.Manager manager) {
@@ -231,4 +252,10 @@ public AuthProvider getAuthProvider() {
231252
return authProvider;
232253
}
233254

255+
/**
256+
* @return Whether or not to include the NO_COMPACT startup option.
257+
*/
258+
public boolean isNoCompact() {
259+
return noCompact;
260+
}
234261
}

driver-core/src/main/java/com/datastax/driver/core/Requests.java

Lines changed: 7 additions & 2 deletions

0 commit comments

Comments
 (0)