How to call functions in another entity ?

Tagged:
    • Dhanasekar
      Participant
      2 years, 4 months ago #2399

      Can you share the code snippet to call the functions in another entity ?

      Eg. I’ve created 1 windows node and 10 services attached to it
      I want to get status of 5 services
      from my custom function in windows entity.

    • Gautham M P
      Participant
      2 years, 3 months ago #3311
      Up
      1
      Down
      ::

      you can use GraphQuery.node for getting respective node and call the function on that node. You can refer the below document for this:

      https://digitate.atlassian.net/wiki/spaces/ID/pages/1575387453/Knowledge+Modeling+Guidelines

      • This reply was modified 2 years, 3 months ago by Gautham M P.
    • gnana
      Participant
      2 years, 3 months ago #3318
      Up
      1
      Down
      ::

      We have 2 options.

      1. write code to traverse in BP.
      2.Write code in query builder.

      1. Here is the script to traverse from windows entity to service entity

      Write a function at Service Level to get the status (GetRunnableStatus).

      Write a custom groovy function at windows level. Call the above function after you traverse.

      nodeWindowsTarget = subject;
      com.digitate.ignio.data.graph.model.criteria.Filter filterAcademy = new com.digitate.ignio.data.graph.model.criteria.Filter();
      filterAcademy.setField(“HostName”);
      filterAcademy.setValue(subject.nodeProperties.HostName);
      filterAcademy.setOperator(“=”);
      List<com.digitate.ignio.data.graph.model.criteria.Filter> listFilter = new ArrayList<>();
      listFilter.add(filterAcademy);
      com.digitate.ignio.data.graph.model.criteria.Filters filtersAcademy = new com.digitate.ignio.data.graph.model.criteria.Filters();
      filtersAcademy.setFilters(listFilter);
      nodeWindowsTarget.setFilters(filtersAcademy);
      com.digitate.ignio.utils.ceb.model.NodeRelationship relationshipAcademy = new com.digitate.ignio.utils.ceb.model.NodeRelationship();
      relationshipAcademy.setDirection(com.digitate.ignio.data.graph.model.Direction.OUT);
      relationshipAcademy.setRelationshipType(“has”);
      nodeWindowsTarget.setNodeRelationship(relationshipAcademy);
      def ServiceNode;
      def myNode = new IgnioNode()
      myNode = node.getRelatedNodeByRelationship(nodeWindowsTarget, true);
      for (Object nodeRelationship : myNode.getNodeRelationships())
      {
      boolean nodeFound = false;
      if (nodeRelationship != null) {
      for (IgnioNode rNode : nodeRelationship.getRelatedNodes()) {
      def rLabel = rNode.getLabel();
      if (rLabel.trim().equals(“Academy_Service”)) {
      ServiceNode = rNode;
      nodeFound = true;
      break;
      }
      }
      }
      if (nodeFound) break;
      }
      retMap = ServiceNode.getRunnableStatus();

      A sample script for Query Builder:

      String query = “GraphQuery.node(‘tom:TomcatApplication’).out(‘r1:StoreDataOn’, null).node(‘oraDB:OracleDatabase’).properties(‘tom.Name’, ‘ACME’, ‘oraDB.DBName’, ‘DB01’)”

      try {
      def iNode = node.executeQuery(query)

      for (Object node : iNode)
      {
      def outMap = node.getRunnableStatus()
      }
      } catch (Exception ex) {

      }

    • laxv
      Participant
      2 years, 3 months ago #3267
      Up
      0
      Down
      ::

      Can you not use the health check instead to get the status of all the services? I mean health check on the Windows entity given that the services are attached to the Windows entity.

      • This reply was modified 2 years, 3 months ago by laxv.
    • Dhanasekar
      Participant
      2 years, 3 months ago #3269
      Up
      0
      Down
      ::

      In healthcheck, ignio get the status of all the services attached (here 10 services). We can’t restrict it to the service of our interest.

    • laxv
      Participant
      2 years, 3 months ago #3316
      Up
      0
      Down
      ::

      Thanks Gautham for the reference. “Thumbs up!!” . Couldnt add an emoticon 🙂

Viewing 5 reply threads

You must be logged in to reply to this topic.