Skip to content

Commit a367d0a

Browse files
committed
Pull TabletInfo into ProtocolFeatureStore
1 parent f9239c6 commit a367d0a

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/channel/ProtocolInitHandler.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@
3838
import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
3939
import com.datastax.oss.driver.internal.core.protocol.BytesToSegmentDecoder;
4040
import com.datastax.oss.driver.internal.core.protocol.FrameToSegmentEncoder;
41-
import com.datastax.oss.driver.internal.core.protocol.LwtInfo;
4241
import com.datastax.oss.driver.internal.core.protocol.ProtocolFeatureStore;
4342
import com.datastax.oss.driver.internal.core.protocol.SegmentToBytesEncoder;
4443
import com.datastax.oss.driver.internal.core.protocol.SegmentToFrameDecoder;
45-
import com.datastax.oss.driver.internal.core.protocol.TabletInfo;
4644
import com.datastax.oss.driver.internal.core.util.ProtocolUtils;
4745
import com.datastax.oss.driver.internal.core.util.concurrent.UncaughtExceptions;
4846
import com.datastax.oss.protocol.internal.Message;
@@ -94,7 +92,6 @@ class ProtocolInitHandler extends ConnectInitHandler {
9492
private ChannelHandlerContext ctx;
9593
private final boolean querySupportedOptions;
9694
private ProtocolFeatureStore featureStore;
97-
private TabletInfo tabletInfo;
9895

9996
/**
10097
* @param querySupportedOptions whether to send OPTIONS as the first message, to request which
@@ -190,9 +187,6 @@ Message getRequest() {
190187
case STARTUP:
191188
Map<String, String> startupOptions = new HashMap<>(context.getStartupOptions());
192189
featureStore.populateStartupOptions(startupOptions);
193-
if (tabletInfo != null && tabletInfo.isEnabled()) {
194-
TabletInfo.addOption(startupOptions);
195-
}
196190
return request = new Startup(startupOptions);
197191
case GET_CLUSTER_NAME:
198192
return request = CLUSTER_NAME_QUERY;
@@ -225,7 +219,6 @@ void onResponse(Message response) {
225219
channel.attr(DriverChannel.OPTIONS_KEY).set(((Supported) response).options);
226220
Supported res = (Supported) response;
227221
featureStore = ProtocolFeatureStore.parseSupportedOptions(res.options);
228-
tabletInfo = TabletInfo.parseTabletInfo(res.options);
229222
featureStore.storeInChannel(channel);
230223
step = Step.STARTUP;
231224
send();

core/src/main/java/com/datastax/oss/driver/internal/core/protocol/ProtocolFeatureStore.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ public class ProtocolFeatureStore {
1212

1313
private final LwtInfo lwtInfo;
1414
private final ShardingInfo.ConnectionShardingInfo shardingInfo;
15+
private final TabletInfo tabletInfo;
1516

16-
ProtocolFeatureStore(LwtInfo lwtInfo, ShardingInfo.ConnectionShardingInfo shardingInfo) {
17+
ProtocolFeatureStore(
18+
LwtInfo lwtInfo, ShardingInfo.ConnectionShardingInfo shardingInfo, TabletInfo tabletInfo) {
1719
this.lwtInfo = lwtInfo;
1820
this.shardingInfo = shardingInfo;
21+
this.tabletInfo = tabletInfo;
1922
}
2023

2124
public LwtInfo getLwtFeatureInfo() {
@@ -26,16 +29,24 @@ public ShardingInfo.ConnectionShardingInfo getShardingInfo() {
2629
return shardingInfo;
2730
}
2831

32+
public TabletInfo getTabletFeatureInfo() {
33+
return tabletInfo;
34+
}
35+
2936
public static ProtocolFeatureStore parseSupportedOptions(Map<String, List<String>> options) {
3037
LwtInfo lwtInfo = LwtInfo.loadFromSupportedOptions(options);
3138
ShardingInfo.ConnectionShardingInfo shardingInfo = ShardingInfo.parseShardingInfo(options);
32-
return new ProtocolFeatureStore(lwtInfo, shardingInfo);
39+
TabletInfo tabletInfo = TabletInfo.loadFromSupportedOptions(options);
40+
return new ProtocolFeatureStore(lwtInfo, shardingInfo, tabletInfo);
3341
}
3442

3543
public void populateStartupOptions(Map<String, String> options) {
3644
if (lwtInfo != null) {
3745
lwtInfo.populateStartupOptions(options);
3846
}
47+
if (tabletInfo != null && tabletInfo.isEnabled()) {
48+
TabletInfo.populateStartupOptions(options);
49+
}
3950
}
4051

4152
public static ProtocolFeatureStore loadFromChannel(@NonNull Channel channel) {

core/src/main/java/com/datastax/oss/driver/internal/core/protocol/TabletInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ public boolean isEnabled() {
1919
return enabled;
2020
}
2121

22-
public static TabletInfo parseTabletInfo(Map<String, List<String>> supported) {
22+
public static TabletInfo loadFromSupportedOptions(Map<String, List<String>> supported) {
2323
List<String> values = supported.get(SCYLLA_TABLETS_STARTUP_OPTION_KEY);
2424
return new TabletInfo(
2525
values != null
2626
&& values.size() == 1
2727
&& values.get(0).equals(SCYLLA_TABLETS_STARTUP_OPTION_VALUE));
2828
}
2929

30-
public static void addOption(Map<String, String> options) {
30+
public static void populateStartupOptions(Map<String, String> options) {
3131
options.put(SCYLLA_TABLETS_STARTUP_OPTION_KEY, SCYLLA_TABLETS_STARTUP_OPTION_VALUE);
3232
}
3333
}

0 commit comments

Comments
 (0)