Forum Discussion

lardyboy_lardyb's avatar
lardyboy_lardyb
Icon for Nimbostratus rankNimbostratus
Apr 27, 2005

BEA Weblogic and specific failover using iRules

Can anybody out there help me???????

 

 

I need to be able to query a string in the HTTP header to determine the persistamce to a server, and it's corresponding backup (v9.0.4)

 

 

I will expand on this:

 

 

BEA WEblogic uses a JSESSIONID in the HTTP header to determine which server holds the primary connection and which server will be desingated a backup. I need to be able to load balance to any server, and interogate the JSESSIONID in the header in order to provide persistance, but (and here is the gotcha) I also need to be able to take the secondary server ID and use this to provide the fallback host scenario in the event of a primary server failure.

 

 

the JSESSIONID is constructed as

 

 

JSESSIONID=!!

 

where session ID is 52 characters long, and the primary/secondary IDs are 10 characters each.

 

 

How can I do this easily? (I know it is possible to force a designated backup for each primary server, but the customer does not want to have this level of administration on HIS head!!)

 

 

HELP!!!

4 Replies

  • I'd start here from another post:

     rule WeblogicJSessionPersist { 
        when CLIENT_ACCEPTED { 
           set add_persist 1 
        } 
        when HTTP_RESPONSE { 
           if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } { 
               persist add uie [HTTP::cookie "JSESSIONID"] 
               set add_persist 0 
           } 
        } 
        when HTTP_REQUEST { 
           if { [HTTP::cookie exists "JSESSIONID"] } { 
              persist uie [HTTP::cookie "JSESSIONID"] 
           } else { 
              set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"] 
              if { $jsess != "" } { 
                 persist uie $jsess 
              } 
           } 
        } 
     }

    What you're trying to do is pull out the server names from the cookie. I'm not really familiar with all the fields, but our version looks like this:

    JSESSIONID=!!!!!!!;

    I'm not schooled enough with tcl to instruct you on pulling out the strings between the 2nd and 3rd ! terminator and the 5th and 6th ! terminator and pushing them into variables. You might want to build a class to match your server names as seen in the cookie to IP's so you'll have them available to persist correctly. That would look something like:

    when rule_init {  
        array set ::server_definitions {  
          server1_name 10.1.1.1  
          server2_name 10.1.1.2  
        }  
      }

    Then in the HTTP_REQUEST event, you could set variables with the primary and secondary servers from the cookie, get the actual IPs, then use that to persist, primary in the if statement and secondary in the elseif, else if nothing matches.

    I wish I had the coding experience to help you, I like to participate in the creation of rules, though, it helps me get better.
  • Here's how you can pull out the variables:

     

     

    when HTTP_REQUEST {

     

    set cookie_contents [ findstr [HTTP::uri] "JSESSIONID" 11 ";"]

     

    set jsessionid_values [split $cookie_contents "!"]

     

    set server1 [lindex $jsessionid_values 2]

     

    set port1 [lindex $jsessionid_values 3]

     

    set server2 [lindex $jsessionid_values 6]

     

    set port2 [lindex $jsessionid_values 7]

     

    }

     

    You'll still need a class to match the $server1 and $server2 names to IP addresses.
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Ok, couple of things to add here:

     

     

    It sounds like you are dealing with the older BEA WebLogic JsessionID cookies that have the following format:

     

     

    ! ! !

     

     

    In a clustered environment that have the following additional fields

     

     

    ! ! ! !

     

     

    In this case, the is actually the integer representation of the IPv4 address in little endian format. So, to make sense of that number you may want to look at some of the tricks we did for Window Terminal Servers which use the same type of host representation: Click here

     

    http://devcentral.f5.com/default.aspx?tabid=28&view=topic&forumid=5&postid=1931

     

     

    I will point out that this format is only functional in IPv4 and hence I believe both Microsoft and BEA have stopped utilizing this approach in their newer versions. So, our current implementation of WebLogic persistence uses only the JVMID for persistence (which you've already seen included above).

     

     

    I have not seen the newer format first hand, so I'm not sure if they've simply switched to putting the host name in the header instead of the address as a number. If so, the above mentioned approach may work.

     

  • This looks like a great start but has anyone taken this further to select the BEA secondary server if the primary member is not available to service the request?

     

     

    Once the session is established it would select the primary server if availalable and the secondary if the primary is not available. This needs to occur per request to maintain the user session regardless of a failure of one of the BEA hosts.

     

     

    T