Uploaded image for project: 'Apache RocketMQ'
  1. Apache RocketMQ
  2. ROCKETMQ-39

Duplicated codes in both filtersrv and namesrv modules

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.1.0-incubating
    • rocketmq-namesrv
    • None

    Description

      In FiltersrvStartup.class and NamesrvStartup.class, exist the exact same code about add jvm shutdown hook, and execute somthing on shutting down.

      Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
      private volatile boolean hasShutdown = false;
      private AtomicInteger shutdownTimes = new AtomicInteger(0);

      @Override
      public void run() {
      synchronized (this) {
      log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet());
      if (!this.hasShutdown)

      { this.hasShutdown = true; long begineTime = System.currentTimeMillis(); controller.shutdown(); long consumingTimeTotal = System.currentTimeMillis() - begineTime; log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal); }

      }
      }
      }, "ShutdownHook"));

      Attachments

        Issue Links

          Activity

            People

              vintagewang Xiaorui Wang
              wu-sheng Sheng Wu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: