alex-balikov commented on a change in pull request #35343:
URL: https://github.com/apache/spark/pull/35343#discussion_r794773347



##########
File path: core/src/main/scala/org/apache/spark/util/Clock.scala
##########
@@ -99,3 +101,20 @@ private[spark] class SystemClock extends Clock {
     -1
   }
 }
+
+/**
+ * To return a mocked system clock for testing purposes
+ */
+private[spark] class MockedSystemClock extends ManualClock {
+  override def getTimeMillis(): Long = {
+    currentMockSystemTime
+  }
+}
+
+object MockedSystemClock {

Review comment:
       even though trivial, I would suggest having the habit of adding a top 
level comment on classes and objects. How about:
   
   Allows advancing the global static time of ManualSystemClock (or whatever 
class name you prefer)

##########
File path: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaMicroBatchStream.scala
##########
@@ -73,6 +73,10 @@ private[kafka010] class KafkaMicroBatchStream(
     Utils.timeStringAsMs(Option(options.get(
       
KafkaSourceProvider.MAX_TRIGGER_DELAY)).getOrElse(DEFAULT_MAX_TRIGGER_DELAY))
 
+  // this allows us to mock system clock for testing purposes
+  private[kafka010] val clock: Clock
+  = if (options.containsKey(MOCK_SYSTEM_TIME)) new MockedSystemClock else new 
SystemClock

Review comment:
       I suspect the indentation is not per style guide - 
https://github.com/databricks/scala-style-guide#spacing-and-indentation

##########
File path: core/src/main/scala/org/apache/spark/util/Clock.scala
##########
@@ -99,3 +101,20 @@ private[spark] class SystemClock extends Clock {
     -1
   }
 }
+
+/**
+ * To return a mocked system clock for testing purposes

Review comment:
       the comment seems stale. Also, the class name does not seem to reflect 
the functionality - "MockedSystemClock extends ManualClock" seems semantically 
confusing. How about ManualSystemClock ?

##########
File path: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaSource.scala
##########
@@ -94,6 +94,10 @@ private[kafka010] class KafkaSource(
   private[kafka010] val maxTriggerDelayMs =
     
Utils.timeStringAsMs(sourceOptions.get(MAX_TRIGGER_DELAY).getOrElse(DEFAULT_MAX_TRIGGER_DELAY))
 
+  // this allows us to mock system clock for testing purposes
+  private[kafka010] val clock: Clock
+  = if (sourceOptions.contains(MOCK_SYSTEM_TIME)) new MockedSystemClock else 
new SystemClock

Review comment:
       indentation




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