Skip to content

Commit e619029

Browse files
szymon-miezalBerenguer Blasi
authored andcommitted
Review feedback
1 parent eab6d29 commit e619029

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

src/java/org/apache/cassandra/gms/EndpointState.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,20 +326,29 @@ private static Map<ApplicationState, VersionedValue> filterOutgoingState(Map.Ent
326326
switch (state.getKey())
327327
{
328328
case INTERNAL_ADDRESS_AND_PORT:
329-
values = vv.value.split(":");
329+
// DSE sends only out this value as a storage port thus it doesn't contain the address part
330+
// If such a state has been saved into the gossip state we cannot read the address out of it
331+
// instead we map it to STORAGE_PORT
332+
values = splitAddressAndPort(vv);
330333
if (values.length > 1)
331334
return Map.of(ApplicationState.values()[7], VersionedValue.unsafeMakeVersionedValue(values[0], vv.version),
332335
ApplicationState.values()[17], VersionedValue.unsafeMakeVersionedValue(values[1], vv.version));
333336
else
334337
return Map.of(ApplicationState.values()[17], VersionedValue.unsafeMakeVersionedValue(vv.value, vv.version));
335338
case NATIVE_ADDRESS_AND_PORT:
336-
values = vv.value.split(":");
339+
// DSE sends only out this value as a native transport port thus it doesn't contain the address part
340+
// If such a state has been saved into the gossip state we cannot read the address out of it
341+
// instead we map it to NATIVE_TRANSPORT_PORT
342+
values = splitAddressAndPort(vv);
337343
if (values.length > 1)
338344
return Map.of(ApplicationState.values()[15], VersionedValue.unsafeMakeVersionedValue(values[1], vv.version));
339345
else
340346
return Map.of(ApplicationState.values()[15], VersionedValue.unsafeMakeVersionedValue(vv.value, vv.version));
341347
case STATUS_WITH_PORT:
342-
values = vv.value.split("[:,]");
348+
// DSE sends only out status without port
349+
// If such a state has been saved into the gossip state we cannot read the port out of it
350+
// instead we map it to STATUS
351+
values = splitStatusAndPort(vv);
343352
if (values.length > 1)
344353
return Map.of(ApplicationState.values()[0], VersionedValue.unsafeMakeVersionedValue(values[0], vv.version));
345354
else
@@ -360,6 +369,16 @@ private static Map<ApplicationState, VersionedValue> filterOutgoingState(Map.Ent
360369
}
361370
}
362371

372+
private static String[] splitStatusAndPort(VersionedValue vv)
373+
{
374+
return vv.value.split("[:,]");
375+
}
376+
377+
private static String[] splitAddressAndPort(VersionedValue vv)
378+
{
379+
return vv.value.split(":");
380+
}
381+
363382
@VisibleForTesting
364383
static Map<ApplicationState, VersionedValue> filterIncomingStates(Map<ApplicationState, VersionedValue> states, int version)
365384
{

0 commit comments

Comments
 (0)