4 Replies Latest reply on Oct 31, 2013 1:10 PM by Andrea Bacchi

    Clustering remote deployment whit farmURIS

    Andrea Bacchi Newbie

      Hi

      I'm working with JbossAS 6.1.0 Final in cluster  and i need to deploy my war in a directory into one of the farmURIS.

      My all/conf/boostrap/profile.xml

      ...

             <property name="farmURIs">

                  <list elementClass="java.net.URI">

                    <value>${jboss.server.home.url}farm</value>

                    <value>${jboss.server.home.url}mydir</value>

                  </list>

              </property>

      ...

       

      If I put my war manually in "mydir", all work fine, and my application is deployed.

      I'd like to deploy using org.jboss.deployers.spi.management.deploy.DeploymentManager.

      In my code, I get org.jboss.profileservice.spi.ProfileService from jndi lookup

       

      ProfileService ps = (ProfileService) ctx.lookup("ProfileService");

       

      Then, I search for profiles

      for (ProfileKey pk : ps.getProfileKeys()) {

                      System.out.println("Cicling profiles: " + pk.getName() + " : " + pk.getClass()); ;

                      }

       

      Here i found only the "farm" profile (for applicationURIs in profile.xml there are "application1", "application2"..one fore each uris) and then load for Deploymentmanager

      DeploymentManager dm = ps.getDeploymentManager();

      dm.loadProfile(pk);

       

      when i invoke distribuite, my war is deployed into "/farm" directory.

      How can I choose "mydir" direcory?

       

      At this link

      http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.jbossas/jboss-as-system/6.1.0.Final/org/jboss/system/server/profileservice/bootstrap/StaticClusteredProfileFactory.java, there are the sources for Profile Creation and for FARM Profile there is  farming.setSource method, but I don't know how to specify other sources when using DeploymentManager.

       

      thanks

        • 1. Re: Clustering remote deployment whit farmURIS
          Radoslav Husar Master

          AS 6... ouch. Have you considered upgrading to AS 7.x, EAP 6.x or even WildFly 8.x?

           

          I am not familiar with this, however I am guessing that you could possibly spoof the profile to only include your desired directory in the list of URIs for the sake of deploying? Seems like the /farm, the default directory, gets picked first (there could be something like of type List<URI>.get(0));

          • 2. Re: Clustering remote deployment whit farmURIS
            Andrea Bacchi Newbie

            Hi Radoslav

             

            many thanks for you reply.

            unfortunately we can't upgrade to another version of jboss, so we need to integrate with AS 6.1.0 Final :-(

            About the list of uri, yes, if I delete "/farm" direcotry and include only "mydir" , it's wotk and the deployemntmanager deploy may app in this dir. But i need to add some dir (mydir1,mydir2..) and I'd like to choose the right dir to use in my code.

            For example, for applicationURIS, if I configure jboss like this (all/conf/boostrap/profile.xml):

            <property name="applicationURIs">
                        <list elementClass="java.net.URI">
                            <value>${jboss.server.home.url}deploy</value>

                            <value>${jboss.server.home.url}mydir1</value>

                            <value>${jboss.server.home.url}mydir2</value>
                        </list>
                    </property>

             

            in my code, i can choose application (to use "deploy") , application1 (to use "mydir1" ) or application2  (to use "mydir2") profile:

            for (ProfileKey pk : ps.getProfileKeys()) {

               if(pk.getName().contains("application1"))

                   //deploy app1 in mydir1

               if(pk.getName().contains("application2"))

                  //deploy app2 in mydir2

            }

             

             

            but with farmURIS, there is only one profile and there isn't (or I'm not able to find this ) a method to get another dir.

            I'm reading various api for spi implementation:

            org.jboss.deployers.spi.management.deploy.DeploymentManager

            org.jboss.profileservice.spi.ProfileKey

            import org.jboss.profileservice.spi.ProfileService

             

            but for now, no result :-(

             

            thanks

            • 3. Re: Re: Clustering remote deployment whit farmURIS
              Radoslav Husar Master

              I am guessing this could be the code that picks the first directory in the list for farm deployment (BasicDeploymentRepository.java):

               

                public URI getUploadUri()
                {
                    if(uploadUri != null)
                      return uploadUri;
              
              
                    if(getRepositoryURIs() != null && getRepositoryURIs().length > 0)
                      return getRepositoryURIs()[0];
                   
                    throw new IllegalArgumentException("No upload uri available.");
                }
              

               

              There is also setUploadUri(URI) you may give it a try..

              • 4. Re: Re: Clustering remote deployment whit farmURIS
                Andrea Bacchi Newbie

                Hi Radoslav

                 

                I have done some test, but i can't find a solution :-(

                About your post, i can't take the DeploymentRepository

                My code is like this :ProfileService DeploymentManager in 5.x and I use the profileservice spi that don't have a method to manage repository

                In my test I find a new behavior  for deplyment: if I deploy and undeploy my app into /server/all/mydir manually, when i retry deployment with DeploymentManager, it use /server/all/mydir and not /server/all/farm. So there is some "choosing phase" to select the path to use for deployment, not only the first.

                 

                During the process

                DeploymentProgress distribute = deployMgr.distribute("testwebapp.war", new File("/tmp/distTWA/testwebapp.war").toURI().toURL(), true);

                //here I don't see the deploy path

                distribute.run();

                repositoryNames = distribute.getDeploymentID().getRepositoryNames(); //here I find the path ( /servr/all/farm for default and /servr/all/mydir if I used this path for deploy/undeploy manually)