5 Replies Latest reply on Jun 8, 2007 10:03 AM by Ales Justin

    Shutdown of controller

    Adrian Brock Master

      I've added a Controller.shutdown()
      which is a feature missing from the old ServiceController.

      Ales, can you check the child controller shutdown code is ok?

        • 1. Re: Shutdown of controller
          Ales Justin Master

           

          "adrian@jboss.org" wrote:
          I've added a Controller.shutdown()
          which is a feature missing from the old ServiceController.


          I think you've got a typo here:
           for (int i = states.size()-1; i>=0; --i)
           {
           ControllerState state = states.get(i);
           result.addAll(contextsByState.get(state));
           result.addAll(errorContexts.values());
           }
          

          Probably adding errorContexts at the end, outside loop? ;-)

          "adrian@jboss.org" wrote:

          Ales, can you check the child controller shutdown code is ok?

          It looked OK when I looked it before this post, but I'll check again. :-)

          • 2. Re: Shutdown of controller
            Adrian Brock Master

             

            "alesj" wrote:

            I think you've got a typo here:
             for (int i = states.size()-1; i>=0; --i)
             {
             ControllerState state = states.get(i);
             result.addAll(contextsByState.get(state));
             result.addAll(errorContexts.values());
             }
            

            Probably adding errorContexts at the end, outside loop? ;-)


            Correct, but it just :-) inefficient since the result is a Set.

            • 3. Re: Shutdown of controller
              Ales Justin Master

               

              "adrian@jboss.org" wrote:
              Correct, but it just :-) inefficient since the result is a Set.

              Hmm ... not really :-), since errorContexts would be right after INSTALLED ones. But since they are in ERROR, this wouldn't effect other contexts while uninstalling them. So, you are right. :-)

              • 4. Re: Shutdown of controller
                Ales Justin Master

                I'm adding some shutdown tests.

                "alesj" wrote:
                "adrian@jboss.org" wrote:

                Ales, can you check the child controller shutdown code is ok?

                It looked OK when I looked it before this post, but I'll check again. :-)


                Nope, it doesn't work as it should. :-(

                But the problem is not in the shutdown code, it's the uninstall by name of scoped beans with the same name - since they eventually get pushed back to underlying Controller on the Pre_Install state. And when another one with the same name is pushed, we get a 'name already exists', as expected.

                So basically this uninstall of scoped beans didn't work as it should even before the shutdown code. But before I didn't see it since we were uninstalling context from the underlying Controller, drilling down to child Controllers. Shutdown does this just the other way around.

                This can all be solved with the GUID naming we talked about doing.
                But I'll have a look what can be done with the current code.

                • 5. Re: Shutdown of controller
                  Ales Justin Master

                   

                  "alesj" wrote:

                  But I'll have a look what can be done with the current code.

                  I was able to handle this by introducing parent Controller to AbstractController.

                  This piece of code does the trick.
                   AbstractController parent = getParentController();
                   while (parent != null)
                   {
                   try
                   {
                   parent.unregisterControllerContext(context);
                   }
                   catch (Throwable t)
                   {
                   log.warn("Error unregistering context in parent controller: " + context.toShortString() + " with name: " + name);
                   }
                   parent = parent.getParentController();
                   }
                  


                  And it is legit, since duplicated names are detected while registering, so this code doesn't remove anything it shouldn't.