cancel
Showing results for 
Search instead for 
Did you mean: 

Problem this snippet solves:

This Java class will wrap the iControl LTM Pool interface to make it look like an object.

This class is part of the "Java iControl Objects" series of Articles on DevCentral. This class creates a Pool object and allows a developer to interact with the iControl LTM Pool API methods in the context of using an object.

Code :

package iControl.Objects.LTM;

public class Pool {
  private iControl.Interfaces _interfaces = null;
  private String _name = null;
  
  
  //-----------------------------------------------------------------------
  // Member Accessors
  //-----------------------------------------------------------------------
  public iControl.Interfaces getInterfaces() { return _interfaces; }
  public void setInterfaces(iControl.Interfaces interfaces) { _interfaces = interfaces; }

  public String getName() { return _name;  }
  public void setName(String name) { _name = name; }
  
  //-----------------------------------------------------------------------
  // Constructors
  //-----------------------------------------------------------------------
  public Pool(iControl.Interfaces interfaces, String name)
  {
    _interfaces = interfaces; 
    _name = name;
  }

  protected void validateMembers() throws Exception
  {
    if ( (null == _interfaces) || (null == _name) )
    {
      throw new Exception("Invalid Pool Parameters");
    }
  }

  //-----------------------------------------------------------------------
  // Attribute Accessors
  //-----------------------------------------------------------------------
  
  // action_on_service_down
  public void setActionOnServiceDown(iControl.LocalLBServiceDownAction service_action) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.LocalLBServiceDownAction [] action_list = { service_action };
    
    _interfaces.getLocalLBPool().set_action_on_service_down(pool_names, action_list);
  }
  public iControl.LocalLBServiceDownAction getActionOnServiceDown() throws Exception
  {
    validateMembers();

    String [] pool_names = { _name };
    
    iControl.LocalLBServiceDownAction [] action_list = 
      _interfaces.getLocalLBPool().get_action_on_service_down(pool_names);
    
    return action_list[0];
  }
  
  // active_member_count
  public long getActiveMemberCount() throws Exception
  {
    validateMembers();

    String [] pool_names = { _name };
    
    long [] values = 
      _interfaces.getLocalLBPool().get_active_member_count(pool_names);
    
    return values[0];
  }
  
  // aggregate_dynamic_ratio
  public long getAggregateDynamicRatio() throws Exception
  {
    validateMembers();

    String [] pool_names = { _name };
    
    long [] values = 
      _interfaces.getLocalLBPool().get_aggregate_dynamic_ratio(pool_names);
    
    return values[0];
  }
  
  
  // allow_nat_state
  public void setAllowNATState(iControl.CommonEnabledState state) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonEnabledState [] states = { state };
    
    _interfaces.getLocalLBPool().set_allow_nat_state(pool_names, states);
  }
  public iControl.CommonEnabledState getAllowNATState() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonEnabledState [] states = 
      _interfaces.getLocalLBPool().get_allow_nat_state(pool_names);
    
    return states[0];
  }
  
  // allow_snat_state
  public void setAllowSNATState(iControl.CommonEnabledState state) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonEnabledState [] states = { state };
    
    _interfaces.getLocalLBPool().set_allow_snat_state(pool_names, states);
  }
  public iControl.CommonEnabledState getAllowSNATState() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonEnabledState [] states = 
      _interfaces.getLocalLBPool().get_allow_snat_state(pool_names);
    
    return states[0];
  }
  
  // client_ip_tos
  public void setClientIPTos(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_client_ip_tos(pool_names, values);
  }
  public long getClientIPTos() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_client_ip_tos(pool_names);

    return values[0];
  }
  
  // client_link_qos
  public void setClientLinkQos(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_client_link_qos(pool_names, values);
  }
  public long getClientLinkQos() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_client_link_qos(pool_names);

    return values[0];
  }
  
  // gateway_failsafe_unit_id
  public void setGatewayFailsafeUnitId(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_gateway_failsafe_unit_id(pool_names, values);
  }
  public long getGatewayFailsafeUnitId() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_gateway_failsafe_unit_id(pool_names);
    
    return values[0];
  }
  
  // lb_method
  public void setLBMethod(iControl.LocalLBLBMethod lbMethod) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.LocalLBLBMethod [] lb_methods = { lbMethod};
    
    _interfaces.getLocalLBPool().set_lb_method(pool_names, lb_methods);
  }
  public iControl.LocalLBLBMethod getLBMethod() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.LocalLBLBMethod [] lb_methods = 
      _interfaces.getLocalLBPool().get_lb_method(pool_names);
    
    return lb_methods[0];
  }
  
  // minimum_active_member
  public void setMinimumActiveMember(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_minimum_active_member(pool_names, values);
  }
  public long getMinimumActiveMember() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_minimum_active_member(pool_names);
    
    return values[0];
  }
  
  // minimum_up_member
  public void setMinimumUpMember(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_minimum_up_member(pool_names, values);
  }
  public long getMinimumUpMember() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_minimum_up_member(pool_names);
    
    return values[0];
  }
  
  // minimum_up_member_action
  public void setMinimumUpMemberAction(iControl.CommonHAAction action) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonHAAction [] actions = { action };
    
    _interfaces.getLocalLBPool().set_minimum_up_member_action(pool_names, actions);
  }
  public iControl.CommonHAAction getMinimumUpMemberAction() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonHAAction [] actions =     
      _interfaces.getLocalLBPool().get_minimum_up_member_action(pool_names);
    
    return actions[0];
  }
  
  // minimum_up_member_enabled_state
  public void setMinimumUpMemberEnabledState(iControl.CommonEnabledState state) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonEnabledState [] states = { state };
    
    _interfaces.getLocalLBPool().set_minimum_up_member_enabled_state(pool_names, states);
  }
  public iControl.CommonEnabledState getMinimumUpMemberEnabledState() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonEnabledState [] states =     
      _interfaces.getLocalLBPool().get_minimum_up_member_enabled_state(pool_names);
    
    return states[0];
  }
  
  // monitor_association
  public void setMonitorAssociation(iControl.LocalLBPoolMonitorAssociation association) throws Exception
  {
    validateMembers();
    
    iControl.LocalLBPoolMonitorAssociation [] associations = { association };
    
    _interfaces.getLocalLBPool().set_monitor_association(associations);
  }
  public iControl.LocalLBPoolMonitorAssociation getMonitorAssociation() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.LocalLBPoolMonitorAssociation [] associations = 
      _interfaces.getLocalLBPool().get_monitor_association(pool_names);
  
    return associations[0];
  }
  public void removeMontitorAssociations() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    
    _interfaces.getLocalLBPool().remove_monitor_association(pool_names);
  }
  
  // server_ip_tos
  public void setServerIPTos(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_server_ip_tos(pool_names, values);
  }
  public long getServerIPTos() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_server_ip_tos(pool_names);
    
    return values[0];
  }
  
  // server_link_qos
  public void setServerLinkQOS(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_server_link_qos(pool_names, values);
  }
  public long getServerLinkQOS() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_server_link_qos(pool_names);
    
    return values[0];
  }
  
  // simple_timeout
  public void setSimpleTimeout(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_simple_timeout(pool_names, values);
  }
  public long getSimpleTimeout() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_simple_timeout(pool_names);
    
    return values[0];
  }
  
  // slow_ramp_time
  public void setSlowRampTime(long value) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = { value };
    
    _interfaces.getLocalLBPool().set_slow_ramp_time(pool_names, values);
  }
  public long getSlowRampTime() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    long [] values = 
      _interfaces.getLocalLBPool().get_slow_ramp_time(pool_names);
    
    return values[0];
  }
  
  //-----------------------------------------------------------------------
  // Public Methods
  //-----------------------------------------------------------------------

  public void create(iControl.LocalLBLBMethod lbMethod, iControl.CommonIPPortDefinition [] members) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.LocalLBLBMethod [] lb_methods = { lbMethod };
    iControl.CommonIPPortDefinition [][] membersAofA = { members };
    
    _interfaces.getLocalLBPool().create(pool_names, lb_methods, membersAofA);
  }
  
  public void remove() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    
    _interfaces.getLocalLBPool().delete_pool(pool_names);
  }
  
  public void deletePersistenceRecords(iControl.LocalLBPersistenceMode mode) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.LocalLBPersistenceMode [] modes = { mode };
    
    _interfaces.getLocalLBPool().delete_persistence_record(pool_names, modes);
  }
  
  public iControl.CommonIPPortDefinition [] getMembers() throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonIPPortDefinition [][] membersAofA =
      _interfaces.getLocalLBPool().get_member(pool_names);
    
    return membersAofA[0];
  }
  
  public void addMember(iControl.CommonIPPortDefinition member) throws Exception
  {
    iControl.CommonIPPortDefinition [] memberA = { member };
    addMembers(memberA);
  }
  
  public void addMembers(iControl.CommonIPPortDefinition [] members) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonIPPortDefinition [][] membersAofA = { members };
    
    _interfaces.getLocalLBPool().add_member(pool_names, membersAofA);
  }
  
  public void removeMember(iControl.CommonIPPortDefinition member) throws Exception
  {
    iControl.CommonIPPortDefinition [] memberA = { member };
    removeMembers(memberA);
  }
  
  public void removeMembers(iControl.CommonIPPortDefinition [] members) throws Exception
  {
    validateMembers();
    
    String [] pool_names = { _name };
    iControl.CommonIPPortDefinition [][] membersAofA = { members };
    
    _interfaces.getLocalLBPool().remove_member(pool_names, membersAofA);
  }
  
  public iControl.CommonStatistic getStatistic(iControl.CommonStatisticType type) throws Exception
  {
    validateMembers();
    
    iControl.CommonStatisticType [] types = { type };
    iControl.CommonStatistic [] values = getStatistics(types);
    
    return values[0];
  }
  
  public iControl.CommonStatistic [] getStatistics(iControl.CommonStatisticType [] types) throws Exception
  {
    validateMembers();
    
    iControl.CommonStatistic [] values = null;
    
    String [] pool_list = { _name };

    iControl.LocalLBPoolPoolStatistics stats = 
      _interfaces.getLocalLBPool().get_statistics(pool_list);
    
    iControl.LocalLBPoolPoolStatisticEntry [] statsEntryA = stats.getStatistics();
    
    iControl.LocalLBPoolPoolStatisticEntry statsEntry = statsEntryA[0];
    iControl.CommonStatistic [] statsA = statsEntry.getStatistics();
    
    if ( null == types )
    {
      values = new iControl.CommonStatistic[statsA.length];
      for(int i=0; i
Version history
Last update:
‎07-Mar-2015 16:01
Updated by:
Contributors