Forum Discussion

SMetcalfe_87199's avatar
SMetcalfe_87199
Icon for Nimbostratus rankNimbostratus
Sep 07, 2010

Java Assembly - Marking down a Node

Hello all,

 

 

I've successfully configured Eclipse and iControl assembly . I am able to communicate with the BIG-IP via iControl

 

 

Originally I used the iControlIntermediary wrappers, but they did not seem to have the ability to mark down an individual pool member (node), only marking down an entire virtual server which doesn't solve my problem. (I understand the wrappers are of limited functionality and not part of the assembly)

 

 

I am attempting to automate some code deployment to webservers, and it requires that I mark the a node down (as you would in the GUI with Disable on the Local Traffic --> Nodes menu). Get a list of Current Connections from the Node properties, and wait for connections to drain before proceeding with the next steps in the program, then finally marking the node back up (Enable)

 

 

Right now the F5 represents the only real remaining challenge in getting this all to work.

 

 

I can create an iControl interface object and retrieve system information such as uptime and BIG IP version.

 

 

I can create a icontrol.LocalLBPoolBindingStub and retrieve pool information.

 

 

What I can't seem to figure out is how to mark a specific Node down and up in Java.

 

 

There are examples for other language code, but using the Assembly, there's has got to be a relatively easy way to do this fundamental step with the iControl.interfaces object and some method calls.

 

 

I don't want to remove nodes from pools, and re-add them. I want to temporarily mark them down, and then mark them back up.

 

 

BIG IP OS is BIG-IP 10.2.0 Build 1707.0 Final

 

 

I have searched the wiki and forum, and can't seem to piece together a solution here. I am not a developer, so any assistance or example for a struggling layman would be appreciated.

 

 

The following is an example of the code I have been using. I have attempted to use NodeAddress stubs, but they don't seem to return an expected value (if they work at all).

 

 

import iControl.*;

 

 

import java.util.Arrays;

 

 

public class rawControl {

 

 

public static void main(String[] args) {

 

 

try {

 

iControl.Interfaces interfaces = new iControl.Interfaces();

 

 

if(interfaces.initialize("ip of f5", "username", "password")) {

 

 

iControl.SystemSystemInfoPortType t = interfaces.getSystemSystemInfo();

 

 

// using the interfaces object, get the pool information by assiging a pool object to it

 

iControl.LocalLBPoolBindingStub pool = interfaces.getLocalLBPool();

 

System.out.println(Arrays.toString(pool.get_list()));

 

 

// attempt to resolve the pool members for a specified pool

 

String[] pool_list = {"beaterbox-pool"};

 

//System.out.println(Arrays.toString(pool.get_member(pool_list)));

 

 

System.out.println(pool.get_version());

 

 

System.out.println((pool.get_active_member_count(pool_list)).toString());

 

System.out.println(pool.get_member(pool_list));

 

 

long uptime = t.get_uptime();

 

String version = t.get_version();

 

System.out.println("uptime=" + uptime);

 

System.out.println();

 

System.out.println("version=" + version);

 

}

 

} catch (Exception e){

 

System.out.println(e.toString());

 

}

 

 

}

 

 

}

 

 

Regards,

 

 

Shaun.

 

4 Replies

  • Hi Shaun, as you've said, we have several examples on the site that deal with gracefully disabling nodes. I'll be focusing the next few months on some tech tips and samples for Java that do the types of things we've done with PowerShell and Perl in the past. That doesn't help you know, but hopefully we'll have more resources in the future.

     

     

    You can go two approaches to shutting down a pool member. First, you could just do a hard stop which severs all existing connections. This can be done with one method call (LocalLB.PoolMember.set_monitor_state). The downside here is that it will have a back user experience if you have a client connection active to one of your pool members. The other option is a graceful shutdown that disables new connections, waits for connections to drop to 0, and then disables it with the set_monitor_state method. I'll explain how to do the second option and if you are OK with 1 then you can just include the last step.

     

     

    Here's a good example to follow the method logic through

     

     

     

     

    There are three methods to look at for the three steps

     

     

    Disabling new connections

     

    The LocalLB.PoolMember.set_session_enabled_state() method is used to enable/disable the ability to send new connections to a pool member. You'll want to call this with the appropriate structures and the STATE_DISABLED flag.

     

     

    Waiting for connections to drop to zero

     

    You'll need to call the LocalLB.PoolMember.get_statistics() method and pull out the STATISTIC_SERVER_SIDE-CURRENT_CONNECTIONS value. Do this in a loop until the value goes down to zero.

     

     

    Disabling the pool member

     

    Use the LocalLB.PoolMember.set_monitor_state() method with STATE_DISABLED to issue a forced down state to the pool member.

     

     

    At this point the pool member will be out of commission. You'll reverse the order to bring it back up by calling the set_monitor_state and then the set_session_enabled_state with the STATE_ENABLED flag.

     

     

    Again, the referenced example in PowerShell has all the logic in the Enable-Member and Disable-Member functions.

     

     

    Let me know if you need any help with the coding and I'll see what I can do...

     

     

    -Joe

     

  • Thank you for the response Joe.

     

     

    I was able to get the following to return the node address and port:

     

     

    String[] pool_list = {"beaterbox-pool"};

     

    iControl.CommonIPPortDefinition node[][] = pool.get_member(pool_list);

     

    System.out.println("Addr : " + node[0][0].getAddress());

     

    System.out.println("Port : " + node[0][0].getPort());

     

     

    However, I can't seem to manipulate the method you indicated.

     

     

    I've tried something like this:

     

     

    iControl.LocalLBPoolMemberBindingStub member = interfaces.getLocalLBPoolMember();

     

     

    But I can't seem to pass the CommonIPPortDefinition object to the interfaces to set any of the status properties.

     

     

    Any demonstration code would be greatly appreciated, it seems like most of the code here is for other languages and has different syntax, objects and properties.

     

     

    Regards,

     

     

    Shaun.

     

  • Shaun, sorry for the delay. Here's a java class that will manage gracefully enabling/disabling servers.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iControl/JavaPoolMemberControl.html

     

     

    Hope this helps...

     

     

    -Joe

     

  • Joe,

     

     

    Amazing!

     

     

    Thank you! That is above and beyond what I could have hoped for!

     

     

    You've made my day. Thanks again!

     

     

    Shaun.