Forum Discussion

Fuchan_Tan_3092's avatar
Fuchan_Tan_3092
Icon for Nimbostratus rankNimbostratus
Feb 17, 2012

How to properly construct statsNames?

 

Hi,

 

 

Given the follwing tcl script that create a stats profile:

 

 

profile stats my_stats_profile {

 

defaults from stats

 

field1 total

 

field2 winners

 

}

 

 

To create the profile as described above using iControl Assember, I started the code as follows:

 

 

public void createLocalStatsProfile(String hostName, String profileName) throws Exception{

 

String [] profile_names = new String[1];

 

profile_names[0] = profileName;

 

 

// create profile

 

i_interfaces.getLocalLBProfileUserStatistic().create(profile_names);

 

 

// set statistic_name

 

iControl.LocalLBProfileUserStatisticUserStatisticName[][] statsNames = new iControl.LocalLBProfileUserStatisticUserStatisticName[1][2];

 

 

//help is need here to properly construct statsNames

 

.....

 

.....

 

.....

 

 

i_interfaces.getLocalLBProfileUserStatistic().set_statistic_name(profile_names, statsNames);

 

 

// set default profile String [] defaults = new String[1]; defaults[0] = "stats"; i_interfaces.getLocalLBProfileUserStatistic().set_default_profile(profile_names, defaults);

 

 

}

 

 

 

Thanks in advance.

 

 

Mike Tan

2 Replies

  • Sorry for the delay on the reply, this one slipped by me.

    For the statsNames parameter, you will have to declare it as a 2-d array and then allocate the second dimension with the two field values. Something like this should work

    
    // Create a new 2-d array with the first dimension of size 1 (for the single profile)
    iControl.LocalLBProfileUserStatisticUserStatisticName[][] statsNames = new iControl.LocalLBProfileUserStatisticUserStatisticName[1][]; 
    // Allocate the 2nd dimension for index 0 to a size of 2 (2 keys for the single profile)
    statsNames[0] = new iControl.LocalLBProfileUserStatisticUserStatisticName[2];
    statsNames[0][0] = new iControl.LocalLBProfileUserStatisticUserStatisticName();
    statsNames[0][0].setStatistic_key(iControl.LocalLBProfileUserStatisticUserStatisticKey.USER_STATISTIC_1);
    statsNames[0][0].setStatistic_name(new iControl.LocalLBProfileString());
    statsNames[0][0].getStatistic_name().setValue("total");
    statsNames[0][0].getStatistic_name().setDefault_flag(false);
    statsNames[0][1] = new iControl.LocalLBProfileUserStatisticUserStatisticName();
    statsNames[0][1].setStatistic_key(iControl.LocalLBProfileUserStatisticUserStatisticKey.USER_STATISTIC_2);
    statsNames[0][1].setStatistic_name(new iControl.LocalLBProfileString());  
    statsNames[0][0].getStatistic_name().setValue("winners");
    statsNames[0][0].getStatistic_name().setDefault_flag(false);
    i_interfaces.getLocalLBProfileUserStatistic().set_statistic_name(profile_names, statsNames);

    Hope this helps...