smiklosovic commented on code in PR #2058:
URL: https://github.com/apache/cassandra/pull/2058#discussion_r1063646283


##########
src/java/org/apache/cassandra/db/streaming/FileStreamMetricsListener.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.cassandra.db.streaming;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import com.codahale.metrics.Counter;
+import org.apache.cassandra.locator.InetAddressAndPort;
+import org.apache.cassandra.metrics.StreamingMetrics;
+import org.apache.cassandra.streaming.ProgressInfo;
+import org.apache.cassandra.utils.FBUtilities;
+
+/**
+ * Used to keep track of the bytes streamed for a given file as bytes of the 
file are transferred and report them to StreamingMetrics.
+ */
+public class FileStreamMetricsListener
+{
+    public static final FileStreamMetricsListener NO_OP = new 
FileStreamMetricsListener(0L, FBUtilities.getLocalAddressAndPort(), 
ProgressInfo.Direction.IN){

Review Comment:
   Should not be the curly bracket at the new line too? There is also a space 
missing `){` vs `) {`. 
   
   It is also a little bit counter-intuitive to have a direction `IN` used for 
NO_OP listener. Why not `OUT`? I think it would be preferrable to define a 
`Direction` called `NO_OP` or `NA` (Not Available) for this purpose.
   
   However, by calling this constructor, we are running through the logic which 
interacts with `StreamingMetrics` etc. I do not think that is necessary at all. 
We could create an empty constructor for `FileStreamMetricsListener` and 
initialise class properties with nulls for counters and 0 for totalSize in it. 
That way we avoid messing with `Direction` too.



-- 
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]

Reply via email to