6 Replies Latest reply on Jan 26, 2007 6:35 PM by Charles Crouch

    ManagementView refresh

    Scott Stark Master

      As a status, I am reving the profile service ManagementView to better align with the jsr88 notions, expose the deployment structure, and support the component type notion Charles wanted.

      The two main query by type methods of the ManagementView become:

       /**
       * Get the deployments of a type.
       * @param type - the deployment or module type.
       * @return the possibly empty set of deployment with the given type.
       * @throws Exception
       */
       public Set<ManagedDeployment> getDeploymentsForType(String type)
       throws Exception;
      
       /**
       * Get the components of a type. The
       * @param type - the component type.
       * @return the possibly empty set of components with the given type.
       * @throws Exception
       */
       public Set<ManagedComponent> getComponentsForType(ComponentType type)
       throws Exception;
      


      The associated ManagedDeployment, ManagedComponent and ComponentType are:
      /**
       * A collection of ManagedComponent and structural information
       * about a deployment.
       *
       * @author Scott.Stark@jboss.org
       * @version $Revision:$
       */
      public interface ManagedDeployment
      {
       public String getName();
       public DeploymentPhase getDeploymentPhase();
       /**
       * Get the deployment/module types.
       * @return deployment types
       */
       public Set<String> getType();
       public ManagedObject getManagedObject();
       /**
       * Get the ManagedComponents for the deployment module.
       * @return ManagedComponents for the deployment module.
       */
       public List<ManagedComponent> getComponents();
       /**
       * Get the nested deployment modules.
       * @return nested deployment modules.
       */
       public List<ManagedDeployment> getChildren();
      
       /**
       * Get the DeploymentTemplate names for components
       * that can be added to this deployment.
       * @return
       */
       public Set<String> getComponentTemplateNames();
       public DeploymentTemplateInfo getTemplate(String name);
       /**
       * Add a component to this deployment
       * @param info
       * @return
       */
       public ManagedComponent addComponent(DeploymentTemplateInfo info);
       public void removeComponent(ManagedComponent mc);
      
       /**
       * Get the DeploymentTemplate names for deployments
       * that can be added to this deployment.
       * @return
       */
       public Set<String> getDeploymentTemplateNames();
       /**
       * Add a deployment
       * @param info
       * @return
       */
       public ManagedDeployment addModule(DeploymentTemplateInfo info);
      }
      
      /**
       * A runtime component associated with a deployment.
       *
       * @author Scott.Stark@jboss.org
       * @version $Revision:$
       */
      public interface ManagedComponent
      {
       /**
       * The component name, typically only unique within the ManagedDeployment
       * @return omponent name
       */
       public String getName();
       /**
       * The component classification as a type/subtype.
       * @return component type.
       */
       public ComponentType getType();
       /**
       * The component ManagedObject.
       * @return component ManagedObject.
       */
       public ManagedObject getManagedObject();
       /**
       * The deployment the component is associated with.
       * @return component deployment.
       */
       public ManagedDeployment getDeployment();
      }
      
      /**
       * A simple type/subtype key for a ManagedComponent. Example
       * type/subtypes include: DataSource/{XA,LocalTx,NoTX}, JMSDestination/{Queue,Topic},
       * EJB/{StatelessSession,StatefulSession,Entity,MDB}, MBean/{Standard,XMBean,Dynamic},
       * ...
       *
       * @author Scott.Stark@jboss.org
       * @version $Revision:$
       */
      public class ComponentType
      {
       private String type;
       private String subtype;
      
       public String getType()
       {
       return type;
       }
       public void setType(String type)
       {
       this.type = type;
       }
      
       public String getSubtype()
       {
       return subtype;
       }
       public void setSubtype(String subtype)
       {
       this.subtype = subtype;
       }
      }
      



        • 1. Re: ManagementView refresh
          Scott Stark Master

          I have checked in the current api changes. To get the update scenario working and have persistence of the changes there needs to be better integration between the deployers and profile service to load the attachments with the correct class loader. There are a few implementation changes that need to be addressed to correct this and other deployment issues.

          First, the ComponentType needs to integrated into the deployments and working with ManagedComponents validated. That is what I'm currently working on.

          • 2. Re: ManagementView refresh
            Charles Crouch Expert

            Running ProfileServiceUnitTestCase from eclipse I just get two failures:

            testUpdateDataSource()

            org.jboss.profileservice.spi.NoSuchDeploymentException: name=testAddDataSource-dsf.xml, phase=null
             at org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository.getDeployment(SerializableDeploymentRepository.java:283)
             at org.jboss.system.server.profile.repository.ProfileImpl.getDeployment(ProfileImpl.java:122)
             at org.jboss.profileservice.management.ManagementViewImpl.getDeployment(ManagementViewImpl.java:205)
            


            testRemoveDataSource()
            org.jboss.profileservice.spi.NoSuchDeploymentException: Failed to find deployment for name: testAddDataSource-dsf.xml
             at org.jboss.profileservice.management.ManagementViewImpl.getMatchingDeploymentName(ManagementViewImpl.java:175)
            
            


            • 3. Re: ManagementView refresh
              Charles Crouch Expert

               

              "charles.crouch@jboss.com" wrote:
              Running ProfileServiceUnitTestCase from eclipse I just get two failures:


              This was just me not reading the tests properly and the tests themselves not being repeatable. The tests work fine the first time after a Server restart, then fail everytime after that, because one test removes a DataSource, which both tests reference.

              • 4. Re: ManagementView refresh
                Charles Crouch Expert

                I've added a couple more methods to ProfileServiceUnitTestCase to try out the new ManagedComponent api.

                Let me know if I'm not using the API in the correct way, and if you have any comments on my inline comments below..

                 public void testListComponents () throws Exception
                 {
                 ManagementView mgtView = getManagementView();
                
                 // maybe needs a ctor which takes type,subtype ?
                 ComponentType type = new ComponentType();
                 type.setType("DataSource");
                 type.setType("LocalTX");
                 Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
                
                 if (comps != null)
                 {
                 for (ManagedComponent comp : comps)
                 {
                 String name = comp.getName();
                 Map<String,ManagedProperty> props = comp.getProperties();
                 }
                 }
                 }
                
                 /**
                 * test api usage only
                 * @throws Exception
                 */
                 public void testRemoveComponent () throws Exception
                 {
                 String componentName = "defaultDS";
                 ManagementView mgtView = getManagementView();
                
                 ComponentType type = new ComponentType();
                 type.setType("DataSource");
                 type.setType("LocalTX");
                 Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
                
                 // maybe a mgtView.getComponentByNameAndType(type, componentName) would be helpful
                 // i'm assuming componentName and type will be unique in a given profile.
                
                 if (comps != null)
                 {
                 for (ManagedComponent comp : comps)
                 {
                 if (componentName.equals(comp.getName()))
                 {
                 ManagedDeployment deployment = comp.getDeployment();
                 deployment.removeComponent(comp);
                 break;
                 }
                 }
                 }
                 }
                


                • 5. Re: ManagementView refresh
                  Scott Stark Master

                   

                  "charles.crouch@jboss.com" wrote:
                  I've added a couple more methods to ProfileServiceUnitTestCase to try out the new ManagedComponent api.

                  Let me know if I'm not using the API in the correct way, and if you have any comments on my inline comments below..

                   public void testListComponents () throws Exception
                   {
                   ManagementView mgtView = getManagementView();
                  
                   // maybe needs a ctor which takes type,subtype ?
                   ComponentType type = new ComponentType();
                   type.setType("DataSource");
                   type.setType("LocalTX");
                   Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
                  
                   if (comps != null)
                   {
                   for (ManagedComponent comp : comps)
                   {
                   String name = comp.getName();
                   Map<String,ManagedProperty> props = comp.getProperties();
                   }
                   }
                   }
                  


                  Needs to use type.setSubtype("LocalTX"), and there is a ctor now. I just checked it in as well. We will need enums for the standard component types as well.

                  "charles.crouch@jboss.com" wrote:

                   /**
                   * test api usage only
                   * @throws Exception
                   */
                   public void testRemoveComponent () throws Exception
                   {
                   String componentName = "defaultDS";
                   ManagementView mgtView = getManagementView();
                  
                   ComponentType type = new ComponentType();
                   type.setType("DataSource");
                   type.setType("LocalTX");
                   Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
                  
                   // maybe a mgtView.getComponentByNameAndType(type, componentName) would be helpful
                   // i'm assuming componentName and type will be unique in a given profile.
                  
                   if (comps != null)
                   {
                   for (ManagedComponent comp : comps)
                   {
                   if (componentName.equals(comp.getName()))
                   {
                   ManagedDeployment deployment = comp.getDeployment();
                   deployment.removeComponent(comp);
                   break;
                   }
                   }
                   }
                   }
                  

                  The component name will not be unique in a profile in general because of scoped components like mdbs, local ejbs which only need unique names within their deployment. For admin type objects like data sources, jms destinations, that would be true. Many components would have a unique name if its tied to a global name like jndi or object name. I'm not sure how we can provide this in the general case though, and because of this, not sure if it makes sense to support it on a hit or miss basis.


                  • 6. Re: ManagementView refresh
                    Charles Crouch Expert

                     

                    "scott.stark@jboss.org" wrote:

                    The component name will not be unique in a profile in general because of scoped components like mdbs, local ejbs which only need unique names within their deployment.


                    Understood. -1 on getComponentByNameAndType.