smiklosovic commented on code in PR #3085:
URL: https://github.com/apache/cassandra/pull/3085#discussion_r1478711216
##########
src/java/org/apache/cassandra/metrics/ClientMetrics.java:
##########
@@ -51,20 +84,62 @@ public final class ClientMetrics
private Meter protocolException;
private Meter unknownException;
+ private static String AUTH_SUCCESS = "AuthSuccess";
+
+ private static String AUTH_FAILURE = "AuthFailure";
+
+ private static String CONNECTED_NATIVE_CLIENTS = "ConnectedNativeClients";
+
private ClientMetrics()
{
}
+ /**
+ * @deprecated by {@link #markAuthSuccess(String)}
+ */
+ @Deprecated(since="5.1", forRemoval = true)
public void markAuthSuccess()
{
- authSuccess.mark();
+ markAuthSuccess(null);
+ }
+
+ public void markAuthSuccess(final String mode)
+ {
+ markAuthMeter(authSuccess, AUTH_SUCCESS, mode);
}
+ /**
+ * @deprecated by {@link #markAuthFailure(String)}
+ */
+ @Deprecated(since="5.1", forRemoval = true)
public void markAuthFailure()
{
authFailure.mark();
}
+ public void markAuthFailure(final String mode)
+ {
+ markAuthMeter(authFailure, AUTH_FAILURE, mode);
+ }
+
+ private void markAuthMeter(final Meter meter, final String meterPrefix,
final String mode)
+ {
+ meter.mark();
+
+ if (mode != null)
+ {
+ Map<String, Meter> meterMap = meterPrefix.equals(AUTH_SUCCESS) ?
authSuccessByMode : authFailureByMode;
+
+ // if there is no meter for this mode, the authenticator must have
surfaced a mode that it doesn't
+ // list in 'getSupportedAuthenticationModes', in this case, just
don't mark.
+ Meter modeMeter = meterMap.get(mode);
+ if (modeMeter != null)
+ {
Review Comment:
technically you dont need braces here, it is just a single-statement block.
This could be just simplified to more idiomatic one-liner
Optional.ofNullable(meterMap.get(mode)).ifPresent(Meter::mark);
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]