Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-597

Refactor KafkaScheduler

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.8.1
    • None
    • None
    • None

    Description

      It would be nice to cleanup KafkaScheduler. Here is what I am thinking

      Extract the following interface:

      trait Scheduler {
      def startup()
      def schedule(fun: () => Unit, name: String, delayMs: Long = 0, periodMs: Long): Scheduled
      def shutdown(interrupt: Boolean = false)
      }

      class Scheduled {
      def lastExecution: Long
      def cancel()
      }

      We would have two implementations, KafkaScheduler and MockScheduler. KafkaScheduler would be a wrapper for ScheduledThreadPoolExecutor. MockScheduler would only allow manual time advancement rather than using the system clock, we would switch unit tests over to this.

      This change would be different from the existing scheduler in a the following ways:
      1. Would not return a ScheduledFuture (since this is useless)
      2. shutdown() would be a blocking call. The current shutdown calls, don't really do what people want.
      3. We would remove the daemon thread flag, as I don't think it works.
      4. It returns an object which let's you cancel the job or get the last execution time.

      Attachments

        1. KAFKA-597-v1.patch
          31 kB
          Jay Kreps
        2. KAFKA-597-v2.patch
          33 kB
          Jay Kreps
        3. KAFKA-597-v3.patch
          34 kB
          Jay Kreps
        4. KAFKA-597-v4.patch
          34 kB
          Jay Kreps
        5. KAFKA-597-v5.patch
          34 kB
          Jay Kreps
        6. KAFKA-597-v6.patch
          34 kB
          Jay Kreps

        Activity

          People

            jkreps Jay Kreps
            jkreps Jay Kreps
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: