Forum Discussion

Aditya_01_13899's avatar
Aditya_01_13899
Icon for Nimbostratus rankNimbostratus
Dec 23, 2013

Unable to Set Health Monitor on a Pool using iControl Java

I am able to create a pool using the iControl java api. However, I am not able to set any health monitors on the pool. Here is thecode: I want to do it only for one node right now

LocalLBMonitorRule mr = new LocalLBMonitorRule();
    String[] mt = {"tcp"};
    mr.setMonitor_templates(mt); 
    mr.setType(LocalLBMonitorRuleType.MONITOR_RULE_TYPE_SINGLE);
    obj[0][0].setMonitor_rule(mr);

    _interfaces.getLocalLBPoolMember().set_monitor_association(new String[]{_name},obj);

Can someone please let me know what the issue could be?

1 Reply

  • Ok so I found the answer to my own question 🙂

     

    Here is the sample code if anyone wants to use it

     

    iControl.LocalLBPoolBindingStub stub  = _interfaces.getLocalLBPool();
      String[] monitors = new String[1];
      monitors[0] = "http";
      iControl.LocalLBMonitorRule rule = new iControl.LocalLBMonitorRule();
      rule.setQuorum(0L);
      rule.setType(iControl.LocalLBMonitorRuleType.MONITOR_RULE_TYPE_AND_LIST);
      rule.setMonitor_templates(monitors);
      iControl.LocalLBPoolMonitorAssociation[] monitor_associations = new       iControl.LocalLBPoolMonitorAssociation[1];
      monitor_associations[0] = new  iControl.LocalLBPoolMonitorAssociation();
      monitor_associations[0].setMonitor_rule(rule);
      monitor_associations[0].setPool_name("TestPool");
      stub.set_monitor_association(monitor_associations);
    

    Hope no one falls into the same pit that I fell into 🙂