Skip to content

Commit

Permalink
Merge pull request #22 from aiven/dmitry-potepalov-backport-rpc-addre…
Browse files Browse the repository at this point in the history
…ss-system-local

store FBUtilities.getJustBroadcastNativeAddress() in system.local for…
  • Loading branch information
aris-aiven authored May 14, 2024
2 parents b2511b6 + a06f2b6 commit 22be35e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Merged from 3.0:
* Backport CASSANDRA-10508: Remove hard-coded SSL cipher suites (CASSANDRA-18575)
* Suppress CVE-2023-2976 (CASSANDRA-18562)
* Remove dh_python use in Debian packaging (CASSANDRA-18558)
Backported from 4.1:
* Add broadcast_rpc_address to system.local (CASSANDRA-11181)


4.0.10
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/db/SystemKeyspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public static void persistLocalMetadata(Supplier<UUID> nodeIdSupplier)
snitch.getLocalDatacenter(),
snitch.getLocalRack(),
DatabaseDescriptor.getPartitioner().getClass().getName(),
DatabaseDescriptor.getRpcAddress(),
FBUtilities.getJustBroadcastNativeAddress(),
DatabaseDescriptor.getNativeTransportPort(),
FBUtilities.getJustBroadcastAddress(),
DatabaseDescriptor.getStoragePort(),
Expand Down
30 changes: 30 additions & 0 deletions test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@
import org.apache.cassandra.cql3.UntypedResultSet;
import org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken;
import org.apache.cassandra.dht.Token;
import org.apache.cassandra.transport.ProtocolVersion;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.CassandraVersion;

import static java.lang.String.format;
import static org.apache.cassandra.cql3.QueryProcessor.executeInternal;
import static org.apache.cassandra.db.SystemKeyspace.LOCAL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class SystemKeyspaceTest
Expand Down Expand Up @@ -155,6 +160,31 @@ public void snapshotSystemKeyspaceIfUpgrading() throws IOException
Keyspace.clearSnapshot(null, SchemaConstants.SYSTEM_KEYSPACE_NAME);
}

@Test
public void testPersistLocalMetadata()
{
SystemKeyspace.persistLocalMetadata();

UntypedResultSet result = executeInternal(format("SELECT * FROM system.%s WHERE key='%s'", LOCAL, LOCAL));

assertNotNull(result);
UntypedResultSet.Row row = result.one();

assertEquals(DatabaseDescriptor.getClusterName(), row.getString("cluster_name"));
assertEquals(FBUtilities.getReleaseVersionString(), row.getString("release_version"));
assertEquals(QueryProcessor.CQL_VERSION.toString(), row.getString("cql_version"));
assertEquals(String.valueOf(ProtocolVersion.CURRENT.asInt()), row.getString("native_protocol_version"));
assertEquals(DatabaseDescriptor.getEndpointSnitch().getLocalDatacenter(), row.getString("data_center"));
assertEquals(DatabaseDescriptor.getEndpointSnitch().getLocalRack(), row.getString("rack"));
assertEquals(DatabaseDescriptor.getPartitioner().getClass().getName(), row.getString("partitioner"));
assertEquals(FBUtilities.getJustBroadcastNativeAddress(), row.getInetAddress("rpc_address"));
assertEquals(DatabaseDescriptor.getNativeTransportPort(), row.getInt("rpc_port"));
assertEquals(FBUtilities.getJustBroadcastAddress(), row.getInetAddress("broadcast_address"));
assertEquals(DatabaseDescriptor.getStoragePort(), row.getInt("broadcast_port"));
assertEquals(FBUtilities.getJustLocalAddress(), row.getInetAddress("listen_address"));
assertEquals(DatabaseDescriptor.getStoragePort(), row.getInt("listen_port"));
}

private String getOlderVersionString()
{
String version = FBUtilities.getReleaseVersionString();
Expand Down

0 comments on commit 22be35e

Please sign in to comment.