HeartSaVioR commented on a change in pull request #26416: [SPARK-29779][CORE] 
Compact old event log files and cleanup
URL: https://github.com/apache/spark/pull/26416#discussion_r355830300
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/deploy/history/EventLogFilterRateCalculator.scala
 ##########
 @@ -0,0 +1,68 @@
+/*
+ * 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.spark.deploy.history
+
+import org.apache.hadoop.fs.{FileSystem, Path}
+
+import org.apache.spark.scheduler.SparkListenerEvent
+
+/**
+ * This class calculates the rate of events being accepted, via two phases 
reading:
+ *
+ * 1) Initialize available [[EventFilterBuilder]] instances, and replay the 
event log files with
+ * builders, so that these builders can gather the information to create 
[[EventFilter]] instances.
+ * 2) Initialize [[EventFilter]] instances from [[EventFilterBuilder]] 
instances, and replay the
+ * event log files with filters. Counts the number of events vs accepted 
events and calculate
+ * the rate.
+ */
+class EventLogFilterRateCalculator(fs: FileSystem) {
+  def calculate(eventLogPaths: Seq[Path]): Double = {
+    val builders = EventFilterBuilder.initializeBuilders(fs, eventLogPaths)
 
 Review comment:
   > if I followed correctly, it's called every time there is a new log file, 
to see if the files can be compacted.
   
   No, it's called only once per application log (app + attempt maybe), and we 
take only one log file (first index when the last index advances beyond first) 
to calculate acceptance rate. `LogInfo` and `AttemptInfoWrapper` are changed to 
store the decision. (Please let me know if you found that the code doesn't do 
the thing correctly.)
   
   That's why I decided not to do rate calculating and compacting together. 
There's still redundant effort for reading a log file twice for rate 
calculating and compacting, but I guess this is OK given the calculation does 
occur only once.
   
   Btw, is that OK to compact these event logs (would take quite times) when 
loading app's UI? My first plan was doing it as one of maintenance workload 
like cleaning code, but as compaction "replaces" some log files with new one, 
there would be thread-safety issue between cleaning and loading app's UI, which 
I wanted to avoid unless I got working code except that, and we would really 
want to.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to