8 Replies Latest reply on Jul 1, 2009 11:26 PM by Jim Ma

    Delete service issue or misused

    Jim Ma Apprentice

      I wrote a ServiceComponnet which both implements DeleteResourceFacet and OperatonResouceFacet likes the below code . There is an operation named "delete" can remove or delete itself. When I delete this service by invoking the "delete" operation. This service component can not be removed from service discovery list. But when I delete this service by calling "deleteResource" from the ParentComponent inventory panel, this service component will be removed from the management list. There is the same code in delete operation and delete resource method. I debugged the discovery method. The service which I executed delete operation against has been removed, but the management console (discovery list) does not reflect that change . Is this a known issue or I misused the delete operation ?
      Thanks.

      public class MyServiceComponent implements ResourceComponent<MyParentComponent>, MeasurementFacet, DeleteResourceFacet,OperationFacet {
      public OperationResult invokeOperation(String name, Configuration configuration) throws InterruptedException {
       String operataion = name.toUpperCase();
       if ("DELETE".equals(operataion)) {
       message = deleteInstance();
       }
       OperationResult result = new OperationResult(message);
       return result;
      
       }
      }
      
      /* implement the DeleteResourceFacet */
       public void deleteResource() throws Exception {
       ....
       }
      ...
      }
      


        • 1. Re: Delete service issue or misused
          Newbie

          First, let's draw a clear distinction drawn between DELETE and UNINVENTORY functionality. This page describes it nicely:

          http://josephmarques.wordpress.com/2008/05/07/physical-enterprise-vs-logical-inventory/

          Assuming your delete functionality actually removes your resource's binary bits from disk, then the discovery mechanism would not find it during it's next scan. Can you explain in detail what your deleteResouce method does?

          • 2. Re: Delete service issue or misused
            Jim Ma Apprentice

            thanks, joe.

            "joe.marques@jboss.com" wrote:
            Can you explain in detail what your deleteResouce method does?

            Actually the deleteResource method does the physical change : it removes some object from list through JMX methods. The delete opeartion does not make jopr server to update the inventory list, but the deleteResource method can do it .


            • 3. Re: Delete service issue or misused
              Newbie

              That's right. When you click the DELETE button on the inventory page of the parent resource the Jopr systems knows that it's making a change to the resource hierarchy, and so also removes that resource from your inventory as a post-processing hook.

              For an arbitrary operation, Jopr doesn't know whether it's restarting your resource, gathering a snapshot of metrics, generating a report, or deleting your resource - so no post-processing hooks are executed.

              • 4. Re: Delete service issue or misused
                Jim Ma Apprentice

                So the good practice is to delete the resource through deleteResource() defines in DeleteResourceFact interface.The OperationFact is not designed to delete the service resources.

                Thanks for you detailed information again.

                • 5. Re: Delete service issue or misused
                  Newbie

                  Correct, operations were not designed to know which post-processing hooks to execute. So use the DELETE button on the inventory page to achieve what you're looking for.

                  From your plugin developer's perspective, was there any particular reason that you wanted to expose that functionality as an operation? Was is so that you can perform a group operation?

                  • 6. Re: Delete service issue or misused
                    Jim Ma Apprentice

                     

                    "joe.marques@jboss.com" wrote:

                    From your plugin developer's perspective, was there any particular reason that you wanted to expose that functionality as an operation? Was is so that you can perform a group operation?


                    Exactly. For example, when we add an operation named "deleteRelatedResources" or "deleteCascade" to delete couple of resources,the operation name can clearly tell user this is a group delete operation. We also can do the same thing by clicking the DELETE button. But there is no place to tell user this is a group delete. So it would be better to also add this post processing hook to the operation.

                    I also wrote another createResource operation on the ParentServiceComponennet. When this operation executed, the new created child service can always be discovered.

                    • 7. Re: Delete service issue or misused
                      Newbie

                      Yeah, I figured it was for group-wise operations purposes.

                      The intention is to, in future versions of the Jopr platform, extend resource creation and deletion to the group level. A common use case for this is deploy / undeploy to a cluster.

                      Some of that was on the original road map for 2.3, but got pushed out to a future release in favor of developing a programmatic interface to the Jopr business services. The next release (end of summer) will have a client interface (also known as the CLI) which will give you the ability to script any number of core Jopr services together to orchestrate your own workflows or implement functionality that is not directly exposed by the user interface.

                      In your case, you'll be able to programmatically search your inventory for the resources you want to delete, then loop over them calling out to the delete facet.

                      • 8. Re: Delete service issue or misused
                        Jim Ma Apprentice

                         

                        "joe.marques@jboss.com" wrote:
                        In your case, you'll be able to programmatically search your inventory for the resources you want to delete, then loop over them calling out to the delete facet.

                        I tested this approach like the following code . It still does not update my discovery list .It looks like the internal calling delete facet does not trigger that post process hook .
                        public String deleteInstance() {
                         try {
                         deleteResource();
                         } catch (Exception e) {
                         e.printStackTrace();
                         }
                         return "Sucess";
                         }
                        
                         /* implement the DeleteResourceFacet */
                         public void deleteResource() throws Exception {
                         //really delete the resource
                         }