//============================================================================= /** * @file Load_Balancer.idl * * Interfaces for a simple CORBA Load Balancing service, which can * be used in conjunction with the Naming Service or alone to * improve distributed load balancing. See README file for a short * discussion of other solution approaches for load balancing as * well as use cases for this approach. * * * @author Interfaces in this file came from OrbixNames Load Balancing features with modifications by: Doug Schmidt (schmidt@cs.wustl.edu) Marina Spivak (marina@cs.wustl.edu) */ //============================================================================= module Load_Balancer { // = TITLE // Define a module that allows clients to treat a group // of s, i.e., an , as an equivalence class // to improve distributed load balancing. // // = DESCRIPTION // is used to create s. // There are two logical types of s : // // 1. Round Robin -- This resolves // requests for arbitrary members in round robin order. // // 2. Random -- This resolves // requests for arbitrary members in random order. // // Both types of s have the same interface (i.e., // ) but different behaviour should be provided // in interface implementations appropriately. // = Module-defined exceptions. exception no_such_member {}; exception duplicate_member {}; exception duplicate_group {}; exception no_such_group {}; // = Module-defined types. typedef string Member_ID; typedef sequence Member_ID_List; typedef string Objref; struct Member { Objref obj; // IOR of an member. Member_ID id; // Each member in an is identified by a unique ID. }; typedef string Group_ID; typedef sequence Group_List; // = Forward interface decls. interface Object_Group; interface Object_Group_Factory { // = TITLE // A factory that creates different types of // s and keeps track of them. // // = DESCRIPTION // Currently, operations for two types of s are // defined: random and round robin. Object_Group make_round_robin (in Group_ID id) raises (duplicate_group); // Creates an that resolves requests for arbitrary // members in round robin order. If an , of any // type, with Group_ID has already been created by this // factory, and hasn't been destroyed, a // exception is thrown. void unbind_round_robin (in Group_ID id) raises (no_such_group); // Unbinds a previous incarnation of the Round Robin if any Object_Group make_random (in Group_ID id) raises (duplicate_group); // Creates an that resolves requests for arbitrary // members in random order. If an , of any // type, with Group_ID has already been created by this // factory, and hasn't been destroyed, a // exception is thrown. void unbind_random (in Group_ID id) raises (no_such_group); // Unbinds a previous incarnation of the Random groups. Object_Group resolve (in Group_ID id) raises (no_such_group); // Locates and returns an by its . If // no has of , throw a // exception. Group_List round_robin_groups (); // Lists all the round robin s which were created // by this factory, and haven't been destroyed yet, i.e., return // a sequence of s of all existing round robin // s created by this factory. Group_List random_groups (); // Lists all the random s which were created // by this factory, and haven't been destroyed yet, i.e., return // a sequence of s of all existing random // s created by this factory. }; interface Object_Group { // = TITLE // Holds references for 0 or more objects that form an // equivalence class, and provides load balancing for those // objects. // // = DESCRIPTION // Whenever a client needs to find an object of a certain type // or functionality, it makes a request to the appropriate // . The selects one of its // members in accordance with the implemented policy (i.e., // random or round robin), and returnd it to the client, thus // providing a form of load balancing for its members. // readonly attribute string id; // Each Object Group has its own distinct ID. void bind (in Member mem) raises (duplicate_member); // Adds a new to the . Note that each // in an must be unique. If the // group already contains a member with the same , a // exceptions is thrown. void unbind (in Member_ID id) raises (no_such_member); // Removes a member with the specified from the // . If none of the group's members have a // Member_ID of , exception is thrown. Objref resolve () raises (no_such_member); // Returns a member object from this in accordance with // load balancing policy it implements, i.e., ``random'' or // ``round robin.'' If the group contains no members, // exception is thrown. Objref resolve_with_id (in Member_ID id) raises (no_such_member); // Returns an object with the specified . If this // contains no members with the specified // , exception is thrown. Member_ID_List members (); // Return a sequence of s of all of its members. void destroy (); // Cleanup the resources associated with this . // Subsequent calls to this should fail, and its // should become available. // should no longer list this . }; };