180 likes | 197 Views
Advanced Communication Among Distributed Objects. Outline Request synchronization Request multiplicity Request reliability. Request Synchronization. Request synchronization Synchronous Wait for the results Oneway Do not expect any results or exceptions
E N D
Advanced Communication Among Distributed Objects • Outline • Request synchronization • Request multiplicity • Request reliability Advanced Comm. between Distributed Objects
Request Synchronization • Request synchronization • Synchronous • Wait for the results • Oneway • Do not expect any results or exceptions • Request returns control to client as soon as the middleware accepts the request • Server and Client execute concurrently • Deferred synchronous • Dynamic • Explicit request object • Invoke more than one concurrent operations with single thread • Asynchronous • Callback from the server to client • Non-synchronous requests can be achieved by synchronous requests and multi-threading • COBRA provide direct support for all 4 different requests Advanced Comm. between Distributed Objects
Oneway Request • Using thread • Spawn a child thread to make synchronous request • Terminate the child thread once the request is finished • Performance penalty Advanced Comm. between Distributed Objects
Oneway Request Class PrintSquas { static void main(string[] args){ Team team; Date date; // initialization .. OnewayReq a = new OnewayReq (team, date); a.start(); // continue … } } Class OnewayReq extends Thread { Team team; Date date; OnewayReq (Team t, Date d){ team = t; date = d;} public void run(){ team.print(date); // call remote method } } Advanced Comm. between Distributed Objects
Oneway Request • Using thread • Spawn a child thread to make synchronous request • Terminate the child thread once the request is finished • Performance penalty • CORBA • Static and dynamic invocation support oneway request • IDL defines oneway operations • Precondition: • No out, or inout parameter • Viod return type • No type-specific exceptions • Static invocation, Server decides this synchronization scheme • Dynamic invocation, client can choose oneway request (review the Request object, send operation.) Advanced Comm. between Distributed Objects
Oneway Request • CORBA • IDL defines oneway operations • Static invocation, Server decides this synchronization scheme • Dynamic invocation, client can choose oneway request interface Team { oneway void mail_timetable (in Date date); … }; :Server :Client r =create_request() r:Request send_oneway Op() delete() Advanced Comm. between Distributed Objects
Oneway Request • Comparison • Thread • Less efficient (Create/delete thread) • IDL (oneway) • Less flexible • Type safe • DII • Flexible using different flag with send • Type unsafe • Less efficient (Create/delete request object) Advanced Comm. between Distributed Objects
Deferred Request • Using thread • Spawn a child thread to make synchronous request • Wait for termination of the child request thread • Obtain the result • Performance penalty Advanced Comm. between Distributed Objects
Deferred Request --- Using Thread class PrintSquad { public void print (Team team, Date date) { DefsyncReqPrintSquad a = new DefSyncReqPrintSquad (team, date); // do something here. a.join(this) ;// wait for request thread to die System.out.println(a.getResult()); } } class DefSyncReqPrintSquad extends Thread { … DefsyncReqPrintSquad (Team t, Date d); Public String getResult(); Public void run() { strings; s = team.asString(date); // call remote method and die } } Advanced Comm. between Distributed Objects
Deferred Request • CORBA • Only dynamic invocation interface support deferred synchronous request • Cannot be issued using client stub • get_response: no-wait returns control back to client with indication if the result is ready :Server :Client r =create_request() r:Request send_defeered() Op() get_response() delete() Advanced Comm. between Distributed Objects
Asynchronous Request • Using thread • Similar to deferred synchronous request • Request thread invokes a call back operation • Request thread join the main thread Advanced Comm. between Distributed Objects
Asynchronous Request --- Using Thread Interface Callback { public void result (String s); } class PrintSquad implements Callback { public void print (Team team, Date date) { AsyncReqPrintSquad a = new AsyncReqPrintSquad (team, date, this); a.start(); // continue to do some work here } public void result (String s) {// callback System.out.println(s); } } class AsyncReqPrintSquad extends Thread { Team team; Date date; Callback call; AsyncReqPrintSquad (Team t, Date d, Callback c); Public void run() { string s; s = team.asString(date); // call remote method call.result(s); // pass result to parent thread } } Advanced Comm. between Distributed Objects
Asynchronous Request • CORBA :Server :Client r =create_request() r:Request send() Op() Callback () Advanced Comm. between Distributed Objects
Asynchronous Request • Using Message Queues Request Queue enter remove Client Server remove enter Reply Queue Advanced Comm. between Distributed Objects
Request Multiplicity • Request multiplicity • Unicast (from one client to one server) • Group request • same operations from multiple server objects • Group requests are anonymous • Group composition is managed by a channel • Group membership is unknown to the request producer • Group members are request consumers • Multiple request • Different operations from different server objects that are known to the client • Requested operations are independent with each other with no precedence relation • Client can collect results as they become available Advanced Comm. between Distributed Objects
Request Multiplicity • Implementing group request • Channel (Example 7.5) • CORBA Event channel (Example 7.6) • Implementing multiple request • Thread • Tuple space (Example 7.8) • Out • In (blocking call) • Rd (blocking call) • Performance and development overhead • DII (Example 7.9) Advanced Comm. between Distributed Objects
Request Reliability • Unicast Request Reliability • Exactly-once • Highest reliability • Depends on middleware, fault-tolerant, hardware, os platforms • Expensive • Atomic • Avoid side-effects when a failure occurs • Transactions • At-least-once • Middleware guarantees the execution • Multiple execution of a single request due to reply lose • If request modify server’s state, this semantics is not desirable • At-most-once • If not executed, errors are raised • Maybe • No guarantee of execution • Client doesn’t know the failure • Oneway request in CORBA Advanced Comm. between Distributed Objects
Request Reliability • Group and Multiple Request Reliability • K-reliability • Totally ordered • Best effort • Trade off between performance and Reliability Advanced Comm. between Distributed Objects