Skip to content

Commit 7c9a37f

Browse files
committed
Pull TabletInfo into ProtocolFeatureStore
1 parent e193c80 commit 7c9a37f

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import com.datastax.oss.driver.internal.core.protocol.ProtocolFeatureStore;
4242
import com.datastax.oss.driver.internal.core.protocol.SegmentToBytesEncoder;
4343
import com.datastax.oss.driver.internal.core.protocol.SegmentToFrameDecoder;
44-
import com.datastax.oss.driver.internal.core.protocol.TabletInfo;
4544
import com.datastax.oss.driver.internal.core.util.ProtocolUtils;
4645
import com.datastax.oss.driver.internal.core.util.concurrent.UncaughtExceptions;
4746
import com.datastax.oss.protocol.internal.Message;
@@ -93,7 +92,6 @@ class ProtocolInitHandler extends ConnectInitHandler {
9392
private ChannelHandlerContext ctx;
9493
private final boolean querySupportedOptions;
9594
private ProtocolFeatureStore featureStore;
96-
private TabletInfo tabletInfo;
9795

9896
/**
9997
* @param querySupportedOptions whether to send OPTIONS as the first message, to request which
@@ -191,9 +189,6 @@ Message getRequest() {
191189
if (featureStore != null) {
192190
featureStore.populateStartupOptions(startupOptions);
193191
}
194-
if (tabletInfo != null && tabletInfo.isEnabled()) {
195-
TabletInfo.addOption(startupOptions);
196-
}
197192
return request = new Startup(startupOptions);
198193
case GET_CLUSTER_NAME:
199194
return request = CLUSTER_NAME_QUERY;
@@ -226,7 +221,6 @@ void onResponse(Message response) {
226221
channel.attr(DriverChannel.OPTIONS_KEY).set(((Supported) response).options);
227222
Supported res = (Supported) response;
228223
featureStore = ProtocolFeatureStore.parseSupportedOptions(res.options);
229-
tabletInfo = TabletInfo.parseTabletInfo(res.options);
230224
featureStore.storeInChannel(channel);
231225
step = Step.STARTUP;
232226
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,17 +29,25 @@ public ShardingInfo.ConnectionShardingInfo getShardingInfo() {
2629
return shardingInfo;
2730
}
2831

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

3644
public void populateStartupOptions(@NonNull Map<String, String> options) {
3745
if (lwtInfo != null) {
3846
lwtInfo.populateStartupOptions(options);
3947
}
48+
if (tabletInfo != null && tabletInfo.isEnabled()) {
49+
TabletInfo.populateStartupOptions(options);
50+
}
4051
}
4152

4253
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)