Forum Discussion
Sep 07, 2010
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