Java Object Ltm Pool Member

Problem this snippet solves:

This Java class will wrap the iControl LTM PoolMember 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 PoolMember object and allows a developer to interact with the iControl LTM PoolMember API methods in the context of using an object.

Code :

package iControl.Objects.LTM;

public class PoolMember
{
  private iControl.Interfaces _interfaces = null;

  private Pool _pool = null;
  private String _address = null;
  private long _port = 0;

  //-----------------------------------------------------------------------
  // Member Accessors
  //-----------------------------------------------------------------------
  public iControl.Interfaces getInterfaces() { return _interfaces; }
  public void setInterfaces(iControl.Interfaces interfaces) { _interfaces = interfaces; }

  public String getAddress() { return _address;  }
  public void setAddress(String address) { _address = address; }
  
  public Pool getPool() { return _pool;  }
  public void setPool(Pool pool) { _pool = pool; }
  
  public long getPort() { return _port;  }
  public void setPort(long port) { _port = port; }
  
  //-----------------------------------------------------------------------
  // Constructors
  //-----------------------------------------------------------------------
  public PoolMember(iControl.Interfaces interfaces, Pool pool, String address, long port)
  {
    _interfaces = interfaces;
    _pool = pool;
    _address = address;
    _port = port;
  }
  
  // private Methods
  protected void validateMembers() throws Exception
  {
    if ( (null == _interfaces) || (null == _pool) || 
         (null == _address) || (0 == _port) )
    {
      throw new Exception("Invalid Pool Parameters");
    }
    
  }
  
  //-----------------------------------------------------------------------
  // Attribute Accessors
  //-----------------------------------------------------------------------
  
  // connection_limit
  public void setConnectionLimit(long value) throws Exception
  {
    validateMembers();

    String [] pool_names = { _pool.getName() };

    iControl.LocalLBPoolMemberMemberConnectionLimit memberConnLimit =
      new iControl.LocalLBPoolMemberMemberConnectionLimit();
    memberConnLimit.setMember(new iControl.CommonIPPortDefinition());
    memberConnLimit.getMember().setAddress(_address);
    memberConnLimit.getMember().setPort(_port);
    memberConnLimit.setConnection_limit(value);
    
    iControl.LocalLBPoolMemberMemberConnectionLimit [] memberConnLimitA = 
      { memberConnLimit };
    iControl.LocalLBPoolMemberMemberConnectionLimit [][] memberConnLimitAofA = 
      { memberConnLimitA };
    
    _interfaces.getLocalLBPoolMember().set_connection_limit(
      pool_names, memberConnLimitAofA);
  }
  public long getConnectionLimit() throws Exception
  {
    validateMembers();
    long value = 0;

    String [] pool_names = { _pool.getName() };
    
    iControl.LocalLBPoolMemberMemberConnectionLimit [][] memberConnLimitAofA =
      _interfaces.getLocalLBPoolMember().get_connection_limit(pool_names);

    iControl.LocalLBPoolMemberMemberConnectionLimit [] memberConnLimitA =
      memberConnLimitAofA[0];
    
    for(int i=0; i 0 )
    {
      iControl.LocalLBPoolMemberMemberStatistics [] memberStatsA = 
        _interfaces.getLocalLBPoolMember().get_statistics(pool_list, memberDefAofA);
      
      iControl.LocalLBPoolMemberMemberStatistics memberStats = memberStatsA[0];
      
      iControl.LocalLBPoolMemberMemberStatisticEntry [] statsEntryA = 
        memberStats.getStatistics();
      iControl.LocalLBPoolMemberMemberStatisticEntry  statsEntry = statsEntryA[0];
      
      iControl.CommonStatistic [] statsA = statsEntry.getStatistics();
      
      for(int i=0; i
Published Mar 08, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment