Merge branch 'cassandra-4.1' into trunk

This commit is contained in:
Ekaterina Dimitrova 2022-06-27 19:35:23 -04:00
commit 07d97d7905
4 changed files with 47 additions and 2 deletions

View File

@ -12,6 +12,7 @@
* Add guardrail for ALTER TABLE ADD / DROP / REMOVE column operations (CASSANDRA-17495)
* Rename DisableFlag class to EnableFlag on guardrails (CASSANDRA-17544)
Merged from 4.1:
* Revert breaking change in nodetool clientstats and expose cient options through nodetool clientstats --client-options. (CASSANDRA-17715)
* Fix missed nowInSec values in QueryProcessor (CASSANDRA-17458)
* Revert removal of withBufferSizeInMB(int size) in CQLSSTableWriter.Builder class and deprecate it in favor of withBufferSizeInMiB(int size) (CASSANDRA-17675)
* Remove expired snapshots of dropped tables after restart (CASSANDRA-17619)

View File

@ -121,7 +121,7 @@ New features
- Support for native transport rate limiting via native_transport_rate_limiting_enabled and
native_transport_max_requests_per_second in cassandra.yaml.
- Support for pre hashing passwords on CQL DCL commands
- Expose all client options via system_views.clients and nodetool clientstats.
- Expose all client options via system_views.clients and nodetool clientstats --client-options.
- Support for String concatenation has been added through the + operator.
- New configuration max_hints_size_per_host to limit the size of local hints files per host in mebibytes. Setting to
non-positive value disables the limit, which is the default behavior. Setting to a positive value to ensure

View File

@ -44,6 +44,9 @@ public class ClientStats extends NodeToolCmd
@Option(title = "clear_history", name = "--clear-history", description = "Clear the history of connected clients")
private boolean clearConnectionHistory = false;
@Option(title = "list_connections_with_client_options", name = "--client-options", description = "Lists all connections and the client options")
private boolean clientOptions = false;
@Override
public void execute(NodeProbe probe)
{
@ -84,6 +87,31 @@ public class ClientStats extends NodeToolCmd
}
if (listConnections)
{
List<Map<String, String>> clients = (List<Map<String, String>>) probe.getClientMetric("connections");
if (!clients.isEmpty())
{
TableBuilder table = new TableBuilder();
table.add("Address", "SSL", "Cipher", "Protocol", "Version", "User", "Keyspace", "Requests", "Driver-Name", "Driver-Version");
for (Map<String, String> conn : clients)
{
table.add(conn.get(ConnectedClient.ADDRESS),
conn.get(ConnectedClient.SSL),
conn.get(ConnectedClient.CIPHER),
conn.get(ConnectedClient.PROTOCOL),
conn.get(ConnectedClient.VERSION),
conn.get(ConnectedClient.USER),
conn.get(ConnectedClient.KEYSPACE),
conn.get(ConnectedClient.REQUESTS),
conn.get(ConnectedClient.DRIVER_NAME),
conn.get(ConnectedClient.DRIVER_VERSION));
}
table.printTo(out);
out.println();
}
}
if (clientOptions)
{
List<Map<String, String>> clients = (List<Map<String, String>>) probe.getClientMetric("connections");
if (!clients.isEmpty())

View File

@ -70,7 +70,7 @@ public class ClientStatsTest extends CQLTester
" [(-pp | --print-port)] [(-pw <password> | --password <password>)]\n" +
" [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]\n" +
" [(-u <username> | --username <username>)] clientstats [--all]\n" +
" [--by-protocol] [--clear-history]\n" +
" [--by-protocol] [--clear-history] [--client-options]\n" +
"\n" +
"OPTIONS\n" +
" --all\n" +
@ -82,6 +82,9 @@ public class ClientStatsTest extends CQLTester
" --clear-history\n" +
" Clear the history of connected clients\n" +
"\n" +
" --client-options\n" +
" Lists all connections and the client options\n" +
"\n" +
" -h <host>, --host <host>\n" +
" Node hostname or ip address\n" +
"\n" +
@ -132,6 +135,19 @@ public class ClientStatsTest extends CQLTester
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("clientstats", "--all");
tool.assertOnCleanExit();
String stdout = tool.getStdout();
assertThat(stdout).containsPattern("Address +SSL +Cipher +Protocol +Version +User +Keyspace +Requests +Driver-Name +Driver-Version");
assertThat(stdout).containsPattern("/127.0.0.1:[0-9]+ false undefined undefined [0-9]+ +anonymous +[0-9]+ +DataStax Java Driver 3.11.0");
assertThat(stdout).contains("Total connected clients: 2");
assertThat(stdout).contains("User Connections");
assertThat(stdout).contains("anonymous 2");
}
@Test
public void testClientStatsClientOptions()
{
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("clientstats", "--client-options");
tool.assertOnCleanExit();
String stdout = tool.getStdout();
assertThat(stdout).containsPattern("Address +SSL +Cipher +Protocol +Version +User +Keyspace +Requests +Driver-Name +Driver-Version +Client-Options");
assertThat(stdout).containsPattern("/127.0.0.1:[0-9]+ false undefined undefined [0-9]+ +anonymous +[0-9]+ +DataStax Java Driver 3.11.0");
assertThat(stdout).containsPattern("DRIVER_NAME=DataStax Java Driver");