Skip to content

Commit 2feab3c

Browse files
committed
[#597] Changes following rebase.
1 parent 440bb72 commit 2feab3c

File tree

5 files changed

+33
-181
lines changed

5 files changed

+33
-181
lines changed

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<dependency>
8484
<groupId>com.datastax.oss</groupId>
8585
<artifactId>native-protocol</artifactId>
86-
<version>1.5.3-SNAPSHOT</version>
86+
<version>1.5.2</version>
8787
</dependency>
8888
</dependencies>
8989
</dependencyManagement>

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

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import com.datastax.oss.driver.internal.core.protocol.FrameDecoder;
4141
import com.datastax.oss.driver.internal.core.protocol.FrameEncoder;
4242
import com.datastax.oss.driver.internal.core.protocol.FrameToSegmentEncoder;
43-
import com.datastax.oss.driver.internal.core.protocol.ProtocolFeatureManager;
44-
import com.datastax.oss.driver.internal.core.protocol.ProtocolFeatureParser;
4543
import com.datastax.oss.driver.internal.core.protocol.ProtocolFeatureStore;
4644
import com.datastax.oss.driver.internal.core.protocol.SegmentToBytesEncoder;
4745
import com.datastax.oss.driver.internal.core.protocol.SegmentToFrameDecoder;
@@ -71,7 +69,6 @@
7169
import java.util.List;
7270
import java.util.Map;
7371
import java.util.Objects;
74-
import java.util.Optional;
7572
import net.jcip.annotations.NotThreadSafe;
7673
import org.slf4j.Logger;
7774
import org.slf4j.LoggerFactory;
@@ -97,7 +94,6 @@ class ProtocolInitHandler extends ConnectInitHandler {
9794
private String logPrefix;
9895
private ChannelHandlerContext ctx;
9996
private final boolean querySupportedOptions;
100-
private ProtocolFeatureManager protocolFeatureManager;
10197
private ProtocolFeatureStore featureStore;
10298

10399
/**
@@ -196,12 +192,6 @@ Message getRequest() {
196192
if (featureStore != null) {
197193
featureStore.populateStartupOptions(startupOptions);
198194
}
199-
Optional.ofNullable(protocolFeatureManager)
200-
.ifPresent(m -> m.optionallyAddLwtInfoOption(startupOptions));
201-
Optional.ofNullable(protocolFeatureManager)
202-
.ifPresent(m -> m.optionallyAddTabletInfoOption(startupOptions));
203-
Optional.ofNullable(protocolFeatureManager)
204-
.ifPresent(m -> m.optionallyAddMetadataIdOption(startupOptions));
205195
return request = new Startup(startupOptions);
206196
case GET_CLUSTER_NAME:
207197
return request = CLUSTER_NAME_QUERY;
@@ -231,18 +221,11 @@ void onResponse(Message response) {
231221
ProtocolUtils.opcodeString(response.opcode));
232222
try {
233223
if (step == Step.OPTIONS && response instanceof Supported) {
234-
channel.attr(DriverChannel.OPTIONS_KEY).set(((Supported) response).options);
235-
Supported res = (Supported) response;
236-
featureStore = ProtocolFeatureStore.parseSupportedOptions(res.options);
237-
featureStore.storeInChannel(channel);
238224
Supported supported = (Supported) response;
239-
ProtocolFeatureParser featureParser =
240-
ProtocolFeatureParser.Builder.fromOptions(supported).build();
241-
protocolFeatureManager = featureParser.parse();
242-
protocolFeatureManager.updateOptionsAttributeForChannel(channel);
243-
protocolFeatureManager.updateShardingInfoAttributeForChannel(channel);
244-
protocolFeatureManager.updateLwtInfoAttributeForChannel(channel);
245-
maybeUpdatePipelineWithProtocolOptions(protocolFeatureManager.isMetadataIdEnabled());
225+
channel.attr(DriverChannel.OPTIONS_KEY).set(supported.options);
226+
featureStore = ProtocolFeatureStore.parseSupportedOptions(supported.options);
227+
featureStore.storeInChannel(channel);
228+
maybeUpdatePipelineWithProtocolOptions(featureStore.isMetadataIdEnabled());
246229
step = Step.STARTUP;
247230
send();
248231
} else if (step == Step.STARTUP && response instanceof Ready) {
@@ -457,21 +440,21 @@ private void maybeUpdatePipelineWithProtocolOptions(boolean metadataIdEnabled) {
457440
ProtocolFeatures protocolFeatures = new ProtocolFeatures();
458441
protocolFeatures.addFeature(ProtocolFeatures.Feature.SCYLLA_USE_METADATA_ID);
459442
int maxFrameLength =
460-
(int)
461-
context
462-
.getConfig()
463-
.getDefaultProfile()
464-
.getBytes(DefaultDriverOption.PROTOCOL_MAX_FRAME_LENGTH);
443+
(int)
444+
context
445+
.getConfig()
446+
.getDefaultProfile()
447+
.getBytes(DefaultDriverOption.PROTOCOL_MAX_FRAME_LENGTH);
465448

466449
ChannelPipeline pipeline = ctx.pipeline();
467450
pipeline.replace(
468-
ChannelFactory.FRAME_TO_BYTES_ENCODER_NAME,
469-
ChannelFactory.FRAME_TO_BYTES_ENCODER_NAME,
470-
new FrameEncoder(context.getFrameCodec(), protocolFeatures, maxFrameLength));
451+
ChannelFactory.FRAME_TO_BYTES_ENCODER_NAME,
452+
ChannelFactory.FRAME_TO_BYTES_ENCODER_NAME,
453+
new FrameEncoder(context.getFrameCodec(), protocolFeatures, maxFrameLength));
471454
pipeline.replace(
472-
ChannelFactory.BYTES_TO_FRAME_DECODER_NAME,
473-
ChannelFactory.BYTES_TO_FRAME_DECODER_NAME,
474-
new FrameDecoder(context.getFrameCodec(), protocolFeatures, maxFrameLength));
455+
ChannelFactory.BYTES_TO_FRAME_DECODER_NAME,
456+
ChannelFactory.BYTES_TO_FRAME_DECODER_NAME,
457+
new FrameDecoder(context.getFrameCodec(), protocolFeatures, maxFrameLength));
475458
}
476459
}
477460

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

Lines changed: 0 additions & 95 deletions
This file was deleted.

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

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ public class ProtocolFeatureStore {
1313
private final LwtInfo lwtInfo;
1414
private final ShardingInfo.ConnectionShardingInfo shardingInfo;
1515
private final TabletInfo tabletInfo;
16+
private final boolean metadataIdEnabled;
1617

17-
public static final ProtocolFeatureStore Empty = new ProtocolFeatureStore(null, null, null);
18+
public static final ProtocolFeatureStore Empty =
19+
new ProtocolFeatureStore(null, null, null, false);
1820

1921
ProtocolFeatureStore(
20-
LwtInfo lwtInfo, ShardingInfo.ConnectionShardingInfo shardingInfo, TabletInfo tabletInfo) {
22+
LwtInfo lwtInfo,
23+
ShardingInfo.ConnectionShardingInfo shardingInfo,
24+
TabletInfo tabletInfo,
25+
boolean metadataIdEnabled) {
2126
this.lwtInfo = lwtInfo;
2227
this.shardingInfo = shardingInfo;
2328
this.tabletInfo = tabletInfo;
29+
this.metadataIdEnabled = metadataIdEnabled;
2430
}
2531

2632
public LwtInfo getLwtFeatureInfo() {
@@ -35,12 +41,17 @@ public TabletInfo getTabletFeatureInfo() {
3541
return tabletInfo;
3642
}
3743

44+
public boolean isMetadataIdEnabled() {
45+
return metadataIdEnabled;
46+
}
47+
3848
public static ProtocolFeatureStore parseSupportedOptions(
3949
@NonNull Map<String, List<String>> options) {
4050
LwtInfo lwtInfo = LwtInfo.loadFromSupportedOptions(options);
4151
ShardingInfo.ConnectionShardingInfo shardingInfo = ShardingInfo.parseShardingInfo(options);
4252
TabletInfo tabletInfo = TabletInfo.loadFromSupportedOptions(options);
43-
return new ProtocolFeatureStore(lwtInfo, shardingInfo, tabletInfo);
53+
boolean metadataIdEnabled = MetadataIdInfo.parseMetadataId(options);
54+
return new ProtocolFeatureStore(lwtInfo, shardingInfo, tabletInfo, metadataIdEnabled);
4455
}
4556

4657
public void populateStartupOptions(@NonNull Map<String, String> options) {
@@ -50,6 +61,9 @@ public void populateStartupOptions(@NonNull Map<String, String> options) {
5061
if (tabletInfo != null && tabletInfo.isEnabled()) {
5162
TabletInfo.populateStartupOptions(options);
5263
}
64+
if (metadataIdEnabled) {
65+
MetadataIdInfo.addOption(options);
66+
}
5367
}
5468

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

0 commit comments

Comments
 (0)