Over time, the client will finish all of his (or her) transactions, and the affinity record will go away. Hence the meaning of the sticky "time". Each affinity record lives for the "stickytime" in seconds. When subsequent connections are received within the stickytime, the affinity record is still valid and the request will go to the same server. If a subsequent connection is not received during the sticky time, the record is purged; a connection which is received after that time will have a new server selected for it (and a new affinity record created!).
Customers can now write their own software to implement an SDA agent, which communicates with a listener in Dispatcher. It can then manipulate the Dispatcher affinity tables to:
Important: Since Dispatcher removes records from the affinity table when it detects a server is dead, the SDA agent is responsible for re-inserting the desired records when the server comes online again.
Note: Because the SDA code uses the IP address to indentify the server, SDA cannot be used in conjunction with the server partitioning feature of Network Dispatcher. In the ND configuration, all servers must have a unique IP address.
Inside Dispatcher, the listener takes each request from the SDA agent, communicates with the appropriate affinity table in the Dispatcher executor kernel, and prepares a response for the SDA agent.
ndcontrol port set MyCluster:MyPort stickytime 1
Sticky time | Resultant behavior |
0 | No affinity (normal load balancing) |
1 | Server Directed Affinity |
Other | Classical Affinity. |
Dispatcher <- Auth ----- SDA Agent <- CIB ------ -- Auth ---->
Dispatcher <- Auth ----- SDA Agent <- Request -- -- Auth ----> -- Resp ---->
Dispatcher <- Auth ----- SDA Agent <- Request -- -- Auth ----> -- Resp ---->
{ /* "MANAGER Copyright (C) International Business Machines 1996" */ 0x4d, 0x41, 0x4e, 0x41, 0x47, 0x45, 0x52, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x43, 0x29, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x20, 0x42, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x20, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x31, 0x39, 0x39, 0x36 };
{ /* SDA communications version in ascii, must be "01.00.00.00" */ 0x30, 0x31, 0x2e, 0x30, 0x30, 0x2e, 0x30, 0x30, 0x2e, 0x30, 0x30, 0x00, /* Name of this SDA Agent in an ascii z-string, for example "Sim" */ 0x53, 0x69, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* four bytes of zeroes */ 0x00, 0x00, 0x00, 0x00 };
{ /* Message Version: must be 1 */ 0x00, 0x00, 0x00, 0x01, /* Command: 1=add, 2=delete, 3=deleteAll, 4=query */ 0x00, 0x00, 0x00, 0x04, /* Return Code: meaningless in a request */ 0x00, 0x00, 0x00, 0x00, /* Cluster Address: for example, 9.37.61.44 */ 0x09, 0x25, 0x3D, 0x2C, /* Port Number, for example 80 */ 0x00, 0x00, 0x00, 0x50, /* Number of affinity records to follow, min=0 max=3000, for example, 0 */ 0x00, 0x00, 0x00, 0x00 }
{ /* Return Code for this individual affinity record, meaningless in a request */ 0x00, 0x00, 0x00, 0x00, /* Client Address: for example, 9.37.62.45 */ 0x09, 0x25, 0x3E, 0x2D, /* Server Address: for example, 9.37.63.46 */ 0x09, 0x25, 0x3F, 0x2E }
{ /* Message Version: must be 1 */ 0x00, 0x00, 0x00, 0x01, /* Command: 1=add, 2=delete, 3=deleteAll, 4=query */ 0x00, 0x00, 0x00, 0x04, /* Response: 0=success */ 0x00, 0x00, 0x00, 0x00, /* Cluster Address: for example, 9.37.61.44 */ 0x09, 0x25, 0x3D, 0x2C, /* Port Number, for example 80 */ 0x00, 0x00, 0x00, 0x50, /* Number of affinity records to follow, min=0 max=3000, for example, 0 */ 0x00, 0x00, 0x00, 0x00 }
{ /* Return code for this individual affinity, 0=success */ 0x00, 0x00, 0x00, 0x00, /* Client Address: for example, 9.37.62.45 */ 0x09, 0x25, 0x3E, 0x2D, /* Server Address: for example, 9.37.63.46 */ 0x09, 0x25, 0x3F, 0x2E }
Value | Meaning |
0 | Success |
-11 | No such server |
-26 | No such record |
-27 | No memory for record |
-28 | Record already exists |
-101 | Too many records |
-102 | Memory allocation error in Dispatcher |
-103 | No such cluster |
-104 | No such port |
-105 | Port not sticky |
-106 | No such affinity table in Dispatcher |
-107 | No such command |
-108 | Invalid stickytime |
-109 | Executor not running |
Other | Unspecified error |