Skip to content

Commit 99be618

Browse files
committed
Merge branch 'cassandra-5.0' into trunk
2 parents 136e5fd + e2f74ed commit 99be618

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
* Add the ability to disable bulk loading of SSTables (CASSANDRA-18781)
242242
* Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787)
243243
Merged from 5.0:
244+
* Adding missing configs in system_views.settings to be backward compatible (CASSANDRA-20863)
244245
* Heap dump should not be generated on handled exceptions (CASSANDRA-20974)
245246
* Fix range queries on early-open BTI files (CASSANDRA-20976)
246247
* Avoid re-initializing underlying iterator in LazilyInitializedUnfilteredRowIterator after closing (CASSANDRA-20972)

src/java/org/apache/cassandra/db/virtual/SettingsTable.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@
4242
import org.apache.cassandra.service.ClientWarn;
4343
import org.yaml.snakeyaml.introspector.Property;
4444

45-
final class SettingsTable extends AbstractVirtualTable
45+
@VisibleForTesting
46+
public final class SettingsTable extends AbstractVirtualTable
4647
{
4748
private static final String NAME = "name";
4849
private static final String VALUE = "value";
4950

50-
private static final Map<String, String> BACKWARDS_COMPATABLE_NAMES = ImmutableMap.copyOf(getBackwardsCompatableNames());
51+
public static final Map<String, String> BACKWARDS_COMPATIBLE_NAMES = ImmutableMap.copyOf(getBackwardsCompatibleNames());
5152
protected static final Map<String, Property> PROPERTIES = ImmutableMap.copyOf(getProperties());
5253

5354
private final Config config;
@@ -76,8 +77,8 @@ public DataSet data(DecoratedKey partitionKey)
7677
{
7778
SimpleDataSet result = new SimpleDataSet(metadata());
7879
String name = UTF8Type.instance.compose(partitionKey.getKey());
79-
if (BACKWARDS_COMPATABLE_NAMES.containsKey(name))
80-
ClientWarn.instance.warn("key '" + name + "' is deprecated; should switch to '" + BACKWARDS_COMPATABLE_NAMES.get(name) + "'");
80+
if (BACKWARDS_COMPATIBLE_NAMES.containsKey(name))
81+
ClientWarn.instance.warn("key '" + name + "' is deprecated; should switch to '" + BACKWARDS_COMPATIBLE_NAMES.get(name) + "'");
8182
if (PROPERTIES.containsKey(name))
8283
result.row(name).column(VALUE, getValue(PROPERTIES.get(name)));
8384
return result;
@@ -163,7 +164,7 @@ private static Map<String, Property> getProperties()
163164
assert conflict == null || r.oldName.equals(r.newName) : String.format("New property %s attempted to replace %s, but this property already exists", latest.getName(), conflict.getName());
164165
}
165166
}
166-
for (Map.Entry<String, String> e : BACKWARDS_COMPATABLE_NAMES.entrySet())
167+
for (Map.Entry<String, String> e : BACKWARDS_COMPATIBLE_NAMES.entrySet())
167168
{
168169
String oldName = e.getKey();
169170
if (properties.containsKey(oldName))
@@ -183,7 +184,7 @@ private static Map<String, Property> getProperties()
183184
* There were a handle full of properties which had custom names, names not present in the yaml, this map also
184185
* fixes this and returns the proper (what is accessable via yaml) names.
185186
*/
186-
private static Map<String, String> getBackwardsCompatableNames()
187+
private static Map<String, String> getBackwardsCompatibleNames()
187188
{
188189
Map<String, String> names = new HashMap<>();
189190
// Names that dont match yaml
@@ -192,6 +193,12 @@ private static Map<String, String> getBackwardsCompatableNames()
192193
names.put("server_encryption_options_endpoint_verification", "server_encryption_options.require_endpoint_verification");
193194
names.put("server_encryption_options_legacy_ssl_storage_port", "server_encryption_options.legacy_ssl_storage_port_enabled");
194195
names.put("server_encryption_options_protocol", "server_encryption_options.accepted_protocols");
196+
names.put("authenticator", "authenticator.class_name");
197+
names.put("authorizer", "authorizer.class_name");
198+
names.put("network_authorizer", "network_authorizer.class_name");
199+
names.put("role_manager", "role_manager.class_name");
200+
names.put("internode_authenticator", "internode_authenticator.class_name");
201+
195202

196203
// matching names
197204
names.put("audit_logging_options_audit_logs_dir", "audit_logging_options.audit_logs_dir");

test/unit/org/apache/cassandra/config/ConfigCompatibilityTest.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
import org.apache.cassandra.distributed.upgrade.ConfigCompatibilityTestGenerate;
5555
import org.yaml.snakeyaml.introspector.Property;
5656

57+
import static org.apache.cassandra.db.virtual.SettingsTable.BACKWARDS_COMPATIBLE_NAMES;
58+
5759
/**
5860
* To create the test files used by this class, run {@link ConfigCompatibilityTestGenerate}.
5961
*/
@@ -181,7 +183,9 @@ private void diff(String original, Set<String> ignore, Set<String> expectedError
181183
Map<Class<?>, Map<String, Replacement>> replacements = Replacements.getNameReplacements(type);
182184
Set<String> missing = new HashSet<>();
183185
Set<String> errors = new HashSet<>();
184-
diff(loader, replacements, previous, type, "", missing, errors);
186+
Map<String, String> backwardsCompatNames = BACKWARDS_COMPATIBLE_NAMES;
187+
188+
diff(loader, replacements, previous, type, "", missing, errors, backwardsCompatNames);
185189
missing = Sets.difference(missing, ignore);
186190
errors = Sets.difference(errors, expectedErrors);
187191
StringBuilder msg = new StringBuilder();
@@ -197,7 +201,7 @@ private void diff(String original, Set<String> ignore, Set<String> expectedError
197201
throw new AssertionError(msg);
198202
}
199203

200-
private void diff(Loader loader, Map<Class<?>, Map<String, Replacement>> replacements, ClassTree previous, Class<?> type, String prefix, Set<String> missing, Set<String> errors)
204+
private void diff(Loader loader, Map<Class<?>, Map<String, Replacement>> replacements, ClassTree previous, Class<?> type, String prefix, Set<String> missing, Set<String> errors, Map<String, String> backwardsCompatNames)
201205
{
202206
Map<String, Replacement> replaces = replacements.getOrDefault(type, Collections.emptyMap());
203207
Map<String, Property> properties = loader.getProperties(type);
@@ -228,7 +232,7 @@ private void diff(Loader loader, Map<Class<?>, Map<String, Replacement>> replace
228232
if (node instanceof ClassTree)
229233
{
230234
// current is nested type
231-
diff(loader, replacements, (ClassTree) node, prop.getType(), prefix + name + ".", missing, errors);
235+
diff(loader, replacements, (ClassTree) node, prop.getType(), prefix + name + ".", missing, errors, backwardsCompatNames);
232236
}
233237
else
234238
{
@@ -243,7 +247,19 @@ private void diff(Loader loader, Map<Class<?>, Map<String, Replacement>> replace
243247
// previous is leaf, is current?
244248
Map<String, Property> children = Properties.isPrimitive(prop) || Properties.isCollection(prop) ? Collections.emptyMap() : loader.getProperties(prop.getType());
245249
if (!children.isEmpty())
250+
{
246251
errors.add(String.format("Property %s used to be a value-type, but now is nested type %s", name, prop.getType()));
252+
253+
// Verify SettingsTable maps old name to new nested path for backwards compatibility (e.g., "authenticator" -> "authenticator.class_name")
254+
if (!backwardsCompatNames.containsKey(name))
255+
{
256+
errors.add(String.format(
257+
"Property %s changed to nested type but is missing from SettingsTable.BACKWARDS_COMPATIBLE_NAMES. " +
258+
"Add mapping for '%s' to its new nested property path.",
259+
name, name));
260+
}
261+
}
262+
247263
typeCheck(null, toString(prop.getType()), ((Leaf) node).type, name, errors);
248264
}
249265
}
@@ -332,7 +348,6 @@ else if (type.isArray())
332348
return List.class;
333349
return type;
334350
}
335-
336351
@JsonSerialize(using = NodeSerializer.class)
337352
@JsonDeserialize(using = NodeDeserializer.class)
338353
private interface Node

test/unit/org/apache/cassandra/db/virtual/SettingsTableTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ public void virtualTableBackwardCompatibility() throws Throwable
175175
assertRowsNet(executeNet(q), new Object[] {"credentials_update_interval", null});
176176
q = "SELECT * FROM vts.settings WHERE name = 'credentials_update_interval_in_ms';";
177177
assertRowsNet(executeNet(q), new Object[] {"credentials_update_interval_in_ms", "-1"});
178+
179+
// test non matching auth related properties
180+
q = "SELECT * FROM vts.settings WHERE name = 'authenticator';";
181+
assertRowsNet(executeNet(q), new Object[] {"authenticator", null});
182+
q = "SELECT * FROM vts.settings WHERE name = 'authorizer';";
183+
assertRowsNet(executeNet(q), new Object[] {"authorizer", null});
184+
q = "SELECT * FROM vts.settings WHERE name = 'network_authorizer';";
185+
assertRowsNet(executeNet(q), new Object[] {"network_authorizer", null});
186+
q= "select * from vts.settings where name = 'role_manager';";
187+
assertRowsNet(executeNet(q), new Object[] {"role_manager", null});
178188
}
179189

180190
private void check(String keyspaceTable, String setting, String expected)

0 commit comments

Comments
 (0)