Forum Discussion
tamins_90207
Feb 14, 2007Historic F5 Account
calss adjustment from iRule/iControll
Greetings,
We need a chunk of data somewhere readable and writable by an iRule , and writable by the iControl .
THe idea is to use iRule to match an incoming IP to a weight, then make a LB decision, once that request is connected to a server, then have iCOntrol to reduce the capacity class data of nodes.
Since I can't see a class from iControl, i'll never be able to have the application restore the capacity when a connection is terminated via iControl.
if I put the data into a class, then the iRule can still read the table, but I can't modify it. So i'm unable to decrement the capacity for a server by the weight of a client via iControl. Ideally i want to modify the class data from an iRule, or have iCOntrol somehow change the node capcapacity (perhaps via node Ratios)
please advise!
class ClientWeights {
"TST1 50"
"TST2 70"
"TST3 20"
"TST4 80"
"TST5 15"
"TST6 30"
}
class NodeCapacity {
"server1 100"
"server2 100"
}
when RULE_INIT {
log "RULE_INIT: enter"
log local0. "fix-select-sendercompid rule loading..."
}
when CLIENT_ACCEPTED {
log "CLIENT_ACCEPTED: enter"
log local0. "fix-select-sendercompid: accepted client"
TCP::collect
}
when CLIENT_DATA {
log "CLIENT_DATA: enter"
set clientip [IP::client_addr]
log local0. "fix-select-sendercompid: accepted client- $clientip"
if {! [regexp "^.*\x0149=(.*)\x0156.*$" [TCP::payload] -> SenderCompID]} {
log "Malformed FIX packet. Could not find SenderCompID for client $clientip"
TCP::close
return
}
log "fix-select-sendercompid: $clientip is using SenderCompID $SenderCompID"
set client_weight [findclass $SenderCompID $::ClientWeights " "]
if { $client_weight eq "" } {
log "$clientip with SenderCompID $SenderCompID. Weight was not found."
TCP::close
return
}
log "$SenderCompID weight is $client_weight"
set idx 0
foreach nodeline $::NodeCapacity {
set node [split $nodeline " "]
set server [lindex $node 0]
set capacity [lindex $node 1]
if { $capacity >= $client_weight } {
Subtract the client's weight from the server's capacity
incr capacity -$client_weight
set newval [join "$server $capacity" " "]
lreplace $::NodeCapacity $idx $idx $newval
log "fix-select-sendercompid: forwarding connection for $SenderCompID to node $server who's capacity is now $capacity"
pool $server
TCP::release
return
}
incr idx
}
log "fix-select-sendercompid: WARNING: Found no free node to direct $SenderCompID"
If we're here, then it's probably because the PEs forgot to add this customer to the weight table.
The right thing to do would be to assign a weight and put them on a server, not to simply close the
connection like we are here
TCP::close
}
when CLIENT_CLOSED {
log "fix-select-sendercompid: CLIENT_CLOSED closed client- [IP::client_addr]"
if { [info exists ::active_clients($client_ip)] } {
incr ::active_clients($client_ip) -1
if { $::active_clients($client_ip) <= 0 } {
unset ::active_clients($client_ip)
}
}
}
when SERVER_CLOSED {
log "fix-select-sendercompid: SERVER_CLOSED Server [IP::server_addr] has closed the connection to client"
}
thanks in advance......
No RepliesBe the first to reply
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects