Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store FBUtilities.getJustBroadcastNativeAddress() in system.local for… #22

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading