180 likes | 265 Views
CS603 Communication Mechanisms. 18 January 2002. What is coming. Remote procedure call – specific systems DCE RPC Java RMI SOAP First project. Distributed Computing Environment. DCE: Evolved from CMU research project Same folks that produced AFS
E N D
CS603Communication Mechanisms 18 January 2002
What is coming • Remote procedure call – specific systems • DCE RPC • Java RMI • SOAP • First project
Distributed Computing Environment • DCE: Evolved from CMU research project • Same folks that produced AFS • Incorporates Kerberos, other research projects • Includes several components for building distributed systems • Naming (X.500,DNS) • Authentication (Kerberos) • Data sharing (AFS) • Clock Synchronization (NTP) • Distributed applications (RPC) • Thread support (POSIX based)
DCE RPC • System independent • Runs over multiple protocols • Core feature set implemented on each system • Language independent • Procedures declared in Interface Description Language • Produces stubs that “stand in” for procedure on local system
DCE RPCComponents • IDL Compiler • Produces stubs that “fit” with native code • Run-time • Responds to requests by stubs • Data Conversion • Handles differences between systems
IDL Compiler • IDL is C-like language for specifying semantics of a procedure • Includes some special network support • Example: “Autobind” – declares that procedure will find an execute on another server should the first one fail • Compiles into stubs that are viewed as local procedures on each host
DCE RPCRun-time System • Directory Services • RPC not tied to specific machine name • Network-independent • Hides details of network from RPC applications • Reliability • Manages failure/recovery • Security / Authentication
DCE RPCData Conversion • Caller and callee may have different data representations • Byte order • Structure • Character Set • One solution: Convert to canonical form • Conversion done everywhere • DCE RPC: Leave in native form • Tag with description of native form • Convert on demand • Conversion handled by stub
Sample IDL formessage/reply RPC /* greet.idl * The "greet" interface. */ [uuid(3d6ead56-06e3-11ca-8dd1-826901beabcd), version(1.0)] /* import “like_c_includes.idl” */ /* type declarations (typedef) */ interface greetif { const long int REPLY_SIZE = 100; void greet( [in] handle_t h, [in, string] char client_greeting[], [out, string] char server_reply[REPLY_SIZE] ); }
Interface Attributes [uuid(3d6ead56-06e3-11ca-8dd1-826901beabcd), version(1.0)] • Uuid is required global unique identifier, created with ‘uuidgen’ command • Other attributes: • Version • Endpoint (e.g., if procedure on known machine)
Operation Attributes Idempotent void greet( [in] handle_t h, [in, string] char client_greeting[], [out, string] char server_reply[REPLY_SIZE] ); • First parameter is binding • Explicit (if first parameter is type handle_t) • From configuration file • Automatic • At-most-once • Idempotent (safe to call more than once) • Broadcast – try all servers, only one result to client • Maybe – no response, no guarantee or notice of completion
Using defined interface:Client /* greet_client.c - Client of "greet" interface. usage: greet_client <CDS pathname>*/ #include <stdio.h> #include <dce/rpc.h> #include "greet.h“ #include "util.h" Int main(int argc, char *argv[]) { rpc_ns_handle_t import_context; handle_t binding_h; error_status_t status; idl_char reply[REPLY_SIZE]; /* Start importing servers using the name specified on the command line. */ rpc_ns_binding_import_begin(rpc_c_ns_syntax_default, (unsigned_char_p_t) argv[1], greetif_v1_0_c_ifspec, NULL, &import_context, &status); ERROR_CHECK(status, "Can't begin import"); /* Import the first server (we could iterate here, but we'll just take the first one). */ rpc_ns_binding_import_next(import_context, &binding_h, &status); ERROR_CHECK(status, "Can't import"); /* Make the remote call. */ greet(binding_h, (idl_char *) "hello, server", reply); printf("The Greet Server said: %s\n", reply); }
Using defined interface:Server /* greet_manager.c - Implementation of "greet" interface. */ #include <stdio.h> #include "greet.h" void greet( handle_t h, idl_char *client_greeting, idl_char *server_reply ) { printf("The client says: %s\n", client_greeting); strcpy(server_reply, "Hi, client!"); }
CS603Communication Mechanisms 23 January 2002
Using defined interface:Setting up listener /* greet_server.c - usage: greet_server <CDS pathname> */ #include <stdio.h> #include <dce/dce_error.h> #include <dce/rpc.h> #include "greet.h" #include "util.h" Int main(int argc, char *argv[]) { unsigned32 status; rpc_binding_vector_t *binding_vector; /* Register interface with RPC runtime. */ rpc_server_register_if(greetif_v1_0_s_ifspec, NULL, NULL, &status); ERROR_CHECK(status, "Can't register interface"); /* Use all protocol sequences that are available. */ rpc_server_use_all_protseqs(rpc_c_protseq_max_reqs_default, &status); ERROR_CHECK(status, "Can't use protocol sequences"); /* Get the binding handles generated by the runtime. */ rpc_server_inq_bindings(&binding_vector, &status); ERROR_CHECK(status, "Can't get bindings for server");
Using defined interface:Server /* Register assigned endpoints with endpoint mapper. */ rpc_ep_register(greetif_v1_0_s_ifspec, binding_vector, NULL, (unsigned_char_p_t) "greet server version 1.0", &status); ERROR_CHECK(status, "Can't register with endpoint map"); /* Export ourselves into the CDS namespace. */ rpc_ns_binding_export( rpc_c_ns_syntax_default, (unsigned_char_p_t) argv[1], greetif_v1_0_s_ifspec, binding_vector, NULL, &status); ERROR_CHECK(status, "Can't export into CDS namespace"); /* Start listening for calls. */ printf("Listening...\n"); rpc_server_listen(rpc_c_listen_max_calls_default, &status); ERROR_CHECK(status, "Can't start listening for calls"); }