1 2 3 Previous Next 34 Replies Latest reply on Jan 28, 2009 10:20 PM by brian.stansberry Go to original post
      • 15. Re: Sub-Profiles ProfileService changes
        brian.stansberry

        Hah, we're cross-posting. Just read your comment about "if you stop your clustering-hotdeployment directory it would shutdown also the "default" profile". OK, I'll wait for your update.

        All in all, this is good stuff; pretty easy to figure out once I had a chance to poke around. :)

        • 16. Re: Sub-Profiles ProfileService changes
          brian.stansberry

          I mentioned in my first post there was a reason I didn't turn on HASingletonProfileManager as the way to handle deploy-hasingleton. It's because it makes the ProfileService.activateProfile() processing re-entrant which fails.

          ProfileServiceBootstrap.start(Server) --> ProfileService.activateProfile("all") --> HASingletonDeployer bean starts, becomes master --> HASingletonProfileManager.activateProfile() --> ProfileService.activateProfile("deploy-hasingleton")

          This fails because the validate() call in AbstractProfileService.activateProfile() fails during the reentrant call. The outer "all" Profile is still in the middle of activating, which the validate() call treats as an exception condition.

          The workaround I haven't committed is to use a ThreadLocal to detect the reentrant call and skip the validate() call. That's kind of yuck, which is why I didn't commit.

          Another approach would be to have the "deploy-hasingleton" profile depend on "all", but that's not clean would actually break the HASingleton semantic by forcing the undeploy of the deploy-hasingleton/ dir at the start of shutdown, rather than waiting until the HASingletonController stop phase, which does other needed work.

          • 17. Re: Sub-Profiles ProfileService changes
            emuckenhuber

             

            "bstansberry@jboss.com" wrote:

            This fails because the validate() call in AbstractProfileService.activateProfile() fails during the reentrant call. The outer "all" Profile is still in the middle of activating, which the validate() call treats as an exception condition.

            Yes, validate should just validate the current activated profile. I've started to do that,
            but not finished yet - just copied this part from BasicXmlDeployer.

            "bstansberry@jboss.com" wrote:

            Another approach would be to have the "deploy-hasingleton" profile depend on "all", but that's not clean would actually break the HASingleton semantic by forcing the undeploy of the deploy-hasingleton/ dir at the start of shutdown, rather than waiting until the HASingletonController stop phase, which does other needed work.


            Yeah, i thought deploy-hasingleton is independent from the other profiles.
            You might still want to set a dependency on a clustering-deployers profile or something like that?

            I also need to review the shutdown anyway - don't like this much :)

            • 18. Re: Sub-Profiles ProfileService changes
              brian.stansberry

               

              "emuckenhuber" wrote:

              Yeah, i thought deploy-hasingleton is independent from the other profiles.
              You might still want to set a dependency on a clustering-deployers profile or something like that?


              That would have the same problem; before clustering-deployers got undeployed, deploy-hasingleton would be undeployed. It needs to happen as part of the stop() processing of the HASingletonController, which sends messages around the cluster that trigger another node to become master. The undeploy and the messages are part of a coordinated process. Keeping the deploy-hasingleton profile independent allows that.

              • 19. Re: Sub-Profiles ProfileService changes
                emuckenhuber

                So starting to get tired - so just a brief update:

                I committed my current changes to profileService and of course broke your prototype already :)
                As the AbstractProfileFactory was just a way to test xml testing and providing a config
                which behaves similar to the current implementation.
                I will look into providing a ProfileFactory which actually does what you expected - for now i just added a hack to make it compile again...

                The main part which changes is basically to the xml format and i've put a simple example in the AS testsuite.
                You can create the configuration by running: [testsuite]$ ./build.sh embedded-config

                When you then start this configuration it looks into conf/profiles and starts AS based on this configuration.
                In this case it will boot a web-profile. (Although it seems there are quite a lot requirements to deploy a static index.html :)

                As mentioned before i'm not really happy with the implicit dependencies (a sub-profile is just a reference to a different profile)
                which are set when creating the bootstrap profiles, as it always adds a reference to the previous profile.

                Maybe we also want to add a specific root.profile.xml - like bootstrap.xml.
                Where you skip setting implicit dependencies and just activate them based on the ordering (i guess that would be the best way)

                There are some other thoughts/issues i would like to mention e.g. dropping VFSDeployment from the spi
                This for example also has an affect to the AbstractProfile - as i think most things which the DeploymentRepository
                does should be done by the profile itself - or somewhere else

                But i think i'll post about that later :)

                • 20. Re: Sub-Profiles ProfileService changes
                  emuckenhuber

                  So i've hopefully fixed the validate - so that you can activate your profile without being affected by the others which are currently being activated.

                  Furthermore i create a AbtractProfileFactory which just generates a AbstractProfile for now.
                  We most probably are want to change that at one point and make it more useful :)

                  I also updated the ProfileServiceBoostrap to shutdown the profiles it loaded first.
                  Which means that you should now be able to let HASingletonController activate/deactivate the profile.
                  On shutdown it will undeploy the clustering deployers first and you can stop that correctly.

                  • 21. Re: Sub-Profiles ProfileService changes
                    brian.stansberry

                    The validate works. So I switched trunk to use HASingletonProfileManager instead of HASingletonDeploymentScanner.

                    One concern with the validate is you can get unsatisfied dependencies. Say you have a war in deploy-hasingleton. And say during the 'all' profile deploy the cluster/deploy-hasingleton-jboss-beans.xml file is deployed before jboss-web.sar. That will trigger activation of the deploy-hasingleton profile, and the war will not complete deployment pending dependency on jboss-web.sar. Not a problem, since at the end of the whole thing the dependency will be satisfied and the war will deploy. Except, the validate call during the deploy-hasingleton activation will throw an exception.

                    • 22. Re: Sub-Profiles ProfileService changes
                      brian.stansberry

                      I also tried playing with you embedded config to experiment with configuring deploy-hasingleton via XML. Added a clustering.profile with all the clustering infrastructure and made it a subprofile of root.profile. Then added an independent deploy-hasingleton.profile. My hope was the latter would be registered during the bootstrap and then activated when HASingletonProfileActivator became master.

                      Didn't work -- the deploy-hasingleton.profile wasn't registered. ProfileServiceBootstrap only registers the 'embedded' profile and its subprofiles. Independent ones are not registered.

                      OT, I'm starting to think about how to use an independent profile to do farming. A farmed profile would use a different DeploymentRepository impl.

                      • 23. Re: Sub-Profiles ProfileService changes
                        emuckenhuber

                         

                        "bstansberry@jboss.com" wrote:

                        One concern with the validate is you can get unsatisfied dependencies. Say you have a war in deploy-hasingleton. And say during the 'all' profile deploy the cluster/deploy-hasingleton-jboss-beans.xml file is deployed before jboss-web.sar. That will trigger activation of the deploy-hasingleton profile, and the war will not complete deployment pending dependency on jboss-web.sar. Not a problem, since at the end of the whole thing the dependency will be satisfied and the war will deploy. Except, the validate call during the deploy-hasingleton activation will throw an exception.


                        Hmm yes i understand your concern - in general PS is about managing profiles it does and should
                        not really care about the actual type of deployments in a profile.
                        Which basically means that you also need corretly defined profiles :)
                        This leads a bit into the implicit/explicit dependcies and deployment ordering.

                        Basically all profiles need to declare their dependencies - this might get a bit redundant.
                        Therefore implicit dependencies based on ordering.

                        So all profiles defining deployers (maybe also mixed with some runtime beans related to it)
                        need to be activated/deployed first. Your clustering profile would need to get deployed after
                        this like same for a hot-deployment profile.
                        At the moment the legacy behavior of PS is still there - so deploy is activated after deployers,
                        and therefore your HASingleton basically activates the profile correctly.

                        • 24. Re: Sub-Profiles ProfileService changes
                          emuckenhuber

                           

                          "bstansberry@jboss.com" wrote:

                          Didn't work -- the deploy-hasingleton.profile wasn't registered. ProfileServiceBootstrap only registers the 'embedded' profile and its subprofiles. Independent ones are not registered.


                          Yes this is a limitation of the current implementation/example. The original idea was to have something like:
                          common/profiles/ and conf/profiles - where you could then basically say that all profiles in conf/profiles
                          are getting registered. And only the root.profile gets activated (not really sure about that yet)

                          "bstansberry@jboss.com" wrote:

                          OT, I'm starting to think about how to use an independent profile to do farming. A farmed profile would use a different DeploymentRepository impl.


                          independent profile is correct, although i'm not really happy with the DeploymentRepository stuff.
                          if you e.g. look at the FilteredDeploymentRepositoryFactory - where the repository is doing the filtering.
                          IMHO this should actually be done by the Profile itself.

                          Maybe the xml also needs some updating - as currently the profile is more or less defined over
                          it's profile-source. You can basically plugin this process by creating your own ProfileSourceMetaData.

                          You then would need to register this metadata over the singletonSchemaFactory (or whatever this is called)
                          with it's own namespace and your own DeploymentRepositoryFactory, which gets called based on the type
                          of the source metadata.
                          Although this would need to be registered in the bootstrap/profile-service.xml

                          That's how it's basically looks at the moment:
                          <profiles
                           xmlns="urn:jboss:profileservice:profiles:1.0"
                           name="profiles">
                           <profile name="immutable">
                           <profile-source>
                           <source>${jboss.server.home.url}conf</source>
                           </profile-source>
                           <sub-profile>ejb3</sub-profile>
                           <deployment>myEjb3Deployment.ear</deployment>
                           </profile>
                           <profile name="mutable-source">
                           <hotdeployment-source>
                           <source>${jboss.server.home.url}deploy</source>
                           </hotdeployment-source>
                           <sub-profile>immutable</sub-profile>
                           </profile>
                           <profile name="maven-source">
                           <maven-source xmlns="urn:jboss:profileservice:source:maven:1.0">
                           <source>http://repository.jboss.org/maven2</source>
                           </maven-source>
                           <sub-profile>hotdeployment</sub-profile>
                           <deployment>org/jboss/jboss-profileservice/6.0.0-GA/profileservice-spi.jar</deployment>
                           </profile>
                          </profiles>
                          



                          But as said maybe profiles should be defined as <hot-deployment-profile/> <maven-profile/> <ha-singleton-profile/>
                          or something like that ?

                          • 25. Re: Sub-Profiles ProfileService changes
                            brian.stansberry

                             

                            Basically all profiles need to declare their dependencies - this might get a bit redundant. Therefore implicit dependencies based on ordering.

                            So all profiles defining deployers (maybe also mixed with some runtime beans related to it) need to be activated/deployed first. Your clustering profile would need to get deployed after this like same for a hot-deployment profile.


                            Yes. When I was experimenting with the XML-based profiles yesterday I divided the clustering stuff into 3 chunks -- 1) the core clustering stuff, which went earlier in the chain, 2) at the end a "clustered-deployment" profile which contained deploy-hasingleton-jboss-beans.xml and 3) the independent "deploy-hasingleton" profile for the content.

                            That's OK, but fragile. It also forces breaking things up into more fine-grained sub-profiles. It's a bit of a shame to have to do that since the MC can already properly handle the dependencies.

                            I was going to suggest going to the approach of skipping the validation on a re-entrant activateProfile call. But that has a downside too, so I'll just put down a quick pro/con for the record/my memory:

                            PRO: avoids need for black art in ensuring that anything that activates a profile gets put at the right point in the list of subprofiles.

                            CON: code that makes the reentrant call doesn't get an exception if there truly is something wrong with the nested profile. E.g. if HASingletonProfileActivator on node 1 tries to start and activate the deploy-hasingleton profile, but there's a misconfig *on node 1 only*, the HASingletonProfileActivator needs the exception so it doesn't start properly. That should then result in node 2 becoming the master and deploying the content.

                            • 26. Re: Sub-Profiles ProfileService changes
                              brian.stansberry

                               

                              "emuckenhuber" wrote:
                              The original idea was to have something like:
                              common/profiles/ and conf/profiles - where you could then basically say that all profiles in conf/profiles
                              are getting registered. And only the root.profile gets activated (not really sure about that yet)


                              Perhaps this should be explicit a la ControllerMode. There's a lot of black art in what you just described.

                              independent profile is correct, although i'm not really happy with the DeploymentRepository stuff.
                              if you e.g. look at the FilteredDeploymentRepositoryFactory - where the repository is doing the filtering. IMHO this should actually be done by the Profile itself.


                              I'll keep poking around, trying to prototype. I won't commit as I know you are changing stuff. But I'll give you feedback.

                              I was going to move farming off the list for 5.1, but won't just yet. It *really* bugs me that it's gone, and now I'm starting to see a path to getting it back.

                              Although this would need to be registered in the bootstrap/profile-service.xml


                              No problem.

                              But as said maybe profiles should be defined as <profile> <hot-deployment-profile/> <maven-profile/> <ha-singleton-profile/>
                              or something like that ?


                              That seems more understandable

                              • 27. Re: Sub-Profiles ProfileService changes
                                emuckenhuber

                                 

                                "bstansberry@jboss.com" wrote:

                                That's OK, but fragile. It also forces breaking things up into more fine-grained sub-profiles. It's a bit of a shame to have to do that since the MC can already properly handle the dependencies.


                                Well i don't like it - i think it's broken, because it confuses myself too, which is not a very good sign :)

                                I mean what we could do is to resurrect the DeploymentPhase in the xml, where you can say if it's a deployer or an application.
                                Maybe we can also put something there where you can say that it should ignore this profile.

                                That's actually the only reason behind this exercise that all the deployers are fully installed before any app is getting deployed.
                                Otherwise the deployment won't be recognised and nothing would happen.

                                I did not really get what you meant with skipping the validation on a re-entrant activateProfile :-/

                                • 28. Re: Sub-Profiles ProfileService changes
                                  brian.stansberry

                                  Re: resurrecting DeploymentPhase, that wouldn't help with my example case of a war in deploy-hasingleton/. The missing dependency in the example is deploy/jbossweb.sar (the web server) *not* deployers/jbossweb.deployer. (One of the things the war deployers do is establish a dependency on the web server.) So, the MC knows to wait to install the war beans until the webserver is available. But validating the "deploy-hasingleton" profile won't give the MC a chance to be patient.

                                  I did not really get what you meant with skipping the validation on a re-entrant activateProfile :-/


                                  The reentrant call path looks like this:

                                  ProfileServiceBootstrap.start(Server) --> ProfileService.activateProfile("all") --> HASingletonDeployer bean starts, becomes master --> HASingletonProfileManager.activateProfile() --> ProfileService.activateProfile("deploy-hasingleton")

                                  One call to activateProfile() leads to another nested call.

                                  Below is an example of ignoring the validation in a re-entrant call. (This is based on doctoring AbstractProfileService rev 83388 before you change validate() to limit validation to a single context.)

                                  private final ThreadLocal<Boolean> reentrantActivate = new ThreadLocal<Boolean>();
                                  
                                  public void activateProfile(ProfileKey key) throws Exception
                                  {
                                   ...
                                  
                                   ProfileContext context = this.registeredProfiles.get(key);
                                   if(context == null)
                                   throw new NoSuchProfileException("No such profile: "+ key);
                                  
                                   Boolean reentrant = reentrantActivate.get();
                                   reentrantActivate.set(Boolean.TRUE);
                                   try
                                   {
                                   try
                                   {
                                   log.info("Activating profile: " + context.getProfile());
                                   controller.change(context, ControllerState.INSTALLED);
                                   }
                                   catch(Throwable t)
                                   {
                                   throw new RuntimeException(t);
                                   }
                                  
                                   // Check if the profile was activated successfully
                                   if (Boolean.TRUE.equals(reentrant) == false)
                                   {
                                   validate();
                                   }
                                   }
                                   finally
                                   {
                                   reentrantActivate.set(reentrant);
                                   }
                                  }


                                  This validation thing is a pain in general; I vaguely recall some discussion with Scott about a similar issue a year or two back. Perhaps we should move away from automatically validating and instead make it part of the SPI? Let the caller decide when they want a validation check and what to validate?

                                  • 29. Re: Sub-Profiles ProfileService changes
                                    emuckenhuber

                                     

                                    "bstansberry@jboss.com" wrote:
                                    Re: resurrecting DeploymentPhase, that wouldn't help with my example case of a war in deploy-hasingleton/. The missing dependency in the example is deploy/jbossweb.sar (the web server) *not* deployers/jbossweb.deployer. (One of the things the war deployers do is establish a dependency on the web server.) So, the MC knows to wait to install the war beans until the webserver is available. But validating the "deploy-hasingleton" profile won't give the MC a chance to be patient.

                                    ...

                                    This validation thing is a pain in general; I vaguely recall some discussion with Scott about a similar issue a year or two back. Perhaps we should move away from automatically validating and instead make it part of the SPI? Let the caller decide when they want a validation check and what to validate?


                                    Yes we could let the caller decide if he wants to validate the profile or not, but i'm not really sure
                                    what exactly is failing for you. Maybe because of the mainDeployer.process() which is done after each profile ?
                                    As validating the profile does not validate the deployments. mainDeployer.checkComplete() is only done once after the profiles are activated.

                                    Maybe you want to commit your .profile files? so that i can take a look what exactly is failing ?
                                    But i've renamed the root.profile to embedded.profile ;)