3 Replies Latest reply on Dec 20, 2005 6:34 PM by mnasato

    Setting URLDeploymentScanner.ScanEnabled at runtime

      Disabling ScanEnabled in the URLDeploymentScanner MBean at runtime has no effects.

      It would be useful to disable scanning via JMX console when doing some changes on the filesystem we don't want immediately hot-deployed, and for custom deployment scripts driven by twiddle.

      This wiki page suggests that is should work
      http://wiki.jboss.org/wiki/Wiki.jsp?page=ManageTheDeploymentScannerWithTheJMXConsole

      but this comment in the source code clearly states otherwise, in org.jboss.deployment.scanner.AbstractDeploymentScanner before inner class ScannerThread

       /**
       * Should use Timer/TimerTask instead? This has some issues with
       * interaction with ScanEnabled attribute. ScanEnabled works only
       * when starting/stopping.
       */
      


      I've tried changing the setter method to

       public void setScanEnabled(final boolean flag)
       {
       if (flag != scanEnabled)
       {
       scanEnabled = flag;
       if (scannerThread != null)
       scannerThread.setEnabled(scanEnabled);
       }
       }
      


      and now it seems to work fine, disabling/enabling scanning is applied at runtime. But maybe I'm missing something; what are these issues the comment is referring to? Otherwise I'll open a feature request in Jira.

        • 1. Re: Setting URLDeploymentScanner.ScanEnabled at runtime

          Yes, create a feature request. Providing a patch speeds up the process.

          "mnasato" wrote:

          and now it seems to work fine, disabling/enabling scanning is applied at runtime. But maybe I'm missing something; what are these issues the comment is referring to? Otherwise I'll open a feature request in Jira.


          If this is going to be dynamic, the correct synchronization of the state across threads.
          Including race conditions with the shutdown processing.

          • 2. Re: Setting URLDeploymentScanner.ScanEnabled at runtime

            e.g. Your patch is incorrect if the deployment scanner is in the "stopped" state
            or if somebody sets scanEnabled while it is doing its initial pass in startService()

            • 3. Re: Setting URLDeploymentScanner.ScanEnabled at runtime

               

              "adrian@jboss.org" wrote:
              e.g. Your patch is incorrect if the deployment scanner is in the "stopped" state
              or if somebody sets scanEnabled while it is doing its initial pass in startService()


              Right, because startService() and stopService() use the same "enabled" field in scannerThread... but this actually means that invoking stopService() already does what I was trying to do by setting ScanEnabled to false! Doh.

              So no code changes are really needed, I've just updated that misleading wiki page.