swuferhong commented on code in PR #2080:
URL: https://github.com/apache/fluss/pull/2080#discussion_r2600693683
##########
fluss-server/src/main/java/org/apache/fluss/server/metrics/group/TableMetricGroup.java:
##########
@@ -222,6 +249,48 @@ public Counter failedPrefixLookupRequests() {
}
}
+ // ------------------------------------------------------------------------
+ // user groups
+ // ------------------------------------------------------------------------
+ private UserMetricGroup getOrCreateUserMetricGroup(String principalName) {
+ return userMetricGroups.computeIfAbsent(
+ principalName,
+ name -> {
+ return new UserMetricGroup(this, principalName);
Review Comment:
Replace with lambda expression.
##########
fluss-server/src/main/java/org/apache/fluss/server/replica/ReplicaManager.java:
##########
@@ -450,21 +451,30 @@ public void appendRecordsToLog(
int timeoutMs,
int requiredAcks,
Map<TableBucket, MemoryLogRecords> entriesPerBucket,
+ LogUserContext userContext,
Consumer<List<ProduceLogResultForBucket>> responseCallback) {
if (isRequiredAcksInvalid(requiredAcks)) {
throw new InvalidRequiredAcksException("Invalid required acks: " +
requiredAcks);
}
long startTime = System.currentTimeMillis();
Map<TableBucket, ProduceLogResultForBucket> appendResult =
- appendToLocalLog(entriesPerBucket, requiredAcks);
+ appendToLocalLog(entriesPerBucket, requiredAcks, userContext);
LOG.debug("Append records to local log in {} ms",
System.currentTimeMillis() - startTime);
// maybe do delay write operation.
maybeAddDelayedWrite(
timeoutMs, requiredAcks, entriesPerBucket.size(),
appendResult, responseCallback);
}
+ public void appendRecordsToLog(
Review Comment:
ditto, do not split.
##########
fluss-server/src/main/java/org/apache/fluss/server/entity/LogUserContext.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.fluss.server.entity;
+
+import org.apache.fluss.security.acl.FlussPrincipal;
+
+/** The context information of user who writes or reads table. */
+public class LogUserContext {
Review Comment:
Why this name called `LogUserContext`. What `Log` means.
##########
fluss-server/src/main/java/org/apache/fluss/server/metrics/group/TableMetricGroup.java:
##########
@@ -222,6 +249,48 @@ public Counter failedPrefixLookupRequests() {
}
}
+ // ------------------------------------------------------------------------
+ // user groups
+ // ------------------------------------------------------------------------
+ private UserMetricGroup getOrCreateUserMetricGroup(String principalName) {
+ return userMetricGroups.computeIfAbsent(
+ principalName,
+ name -> {
+ return new UserMetricGroup(this, principalName);
+ });
+ }
+
+ private static class UserMetricGroup extends AbstractMetricGroup {
+ private final String principalName;
+ protected final Counter bytesIn;
+ protected final Counter bytesOut;
+ protected final Counter messagesIn;
Review Comment:
do we need messagesIn?
##########
fluss-server/src/main/java/org/apache/fluss/server/replica/ReplicaManager.java:
##########
@@ -514,6 +535,16 @@ public void putRecordsToKv(
timeoutMs, requiredAcks, entriesPerBucket.size(), kvPutResult,
responseCallback);
}
+ public void putRecordsToKv(
Review Comment:
Don't split this method into two just for testing purposes. If you feel the
test changes are extensive, you can extract a common method within the test
itself.
##########
fluss-server/src/main/java/org/apache/fluss/server/replica/ReplicaManager.java:
##########
@@ -997,8 +1031,8 @@ private Map<TableBucket, PutKvResultForBucket>
putToLocalKv(
tableMetrics.incKvMessageIn(entry.getValue().getRecordCount());
tableMetrics.incKvBytesIn(entry.getValue().sizeInBytes());
// metric for cdc log of kv
- tableMetrics.incLogBytesIn(appendInfo.validBytes());
- tableMetrics.incLogMessageIn(appendInfo.numMessages());
+ tableMetrics.incLogBytesIn(appendInfo.validBytes(),
userContext);
Review Comment:
I'm not entirely sure whether CDC logs need to be collected. Personally, I
think we should collect them—even if we don't yet have a clear pricing model
for KV. What do you think?
--
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]