Date post: | 22-Dec-2015 |
Category: |
Documents |
View: | 220 times |
Download: | 1 times |
© Chinese University, CSE Dept. Distributed Systems / 4 - 1
Distributed Systems
Topic 4: RPCs vs. CORBADr. Michael R. Lyu
Computer Science & Engineering Department
The Chinese University of Hong Kong
© Chinese University, CSE Dept. Distributed Systems / 4 - 2
Outline
1. Conceptual Framework
2. RPCs
3. CORBA
4. Comparison
5. Summary
© Chinese University, CSE Dept. Distributed Systems / 4 - 3
1 Conceptual Framework
Architecture.
Accessing components from programming languages.
Interfaces to lower layers.
Component identification (to achieve location transparency).
Service invocation styles.
Handling of failures.
© Chinese University, CSE Dept. Distributed Systems / 4 - 4
2 Remote Procedure Calls
Overview of RPC architecture.
Generation of client/server stubs.
RPC interface.
Binding.
Handling of remote procedures.
Failures of RPCs.
© Chinese University, CSE Dept. Distributed Systems / 4 - 5
2.1 RPC Architecture
Client Server
Network
Local Call
ClientStub
RPCInterface
RPCInterface
ServerStub
RemoteProcedure
send receive send receive
© Chinese University, CSE Dept. Distributed Systems / 4 - 6
2.2 The RPC Language
Definition of types (similar to C). Component is described as a PROGRAM. PROGRAM has an identification and a version
number. PROGRAM exports procedures
– Procedures have a result type and a parameter list,
– Procedure can be called from remote components,
– Call can be defined statically or dynamically.
© Chinese University, CSE Dept. Distributed Systems / 4 - 7
2.2 The RPC Language (Example)
/* person.x */
const NL=64;
enum sex_type {
FEMALE = 1,MALE = 2
};
struct Person {
string first_name<NL>;
string last_name<NL>;
sex_type sex;
string city<NL>;
};
program PERSONPROG {
version PERSONVERS {
void PRINT(Person)=0;
int STORE(Person)=1;
Person LOAD(int)=2;
} = 0;
} = 105040;
© Chinese University, CSE Dept. Distributed Systems / 4 - 8
2.2 Generation of Stubs
rpcgen
person.x
client.c server.c
C Compiler, Linker C Compiler, Linker
person.h
person_clnt.c person_svc.c
person_xdr.c
Client Serverincludesgeneratesreads
librpc.a
© Chinese University, CSE Dept. Distributed Systems / 4 - 9
2.2 Implementation of Server
/* server.c */
void * print_0(Person *argp,
struct svc_req * rqstp)
{
static char * result;
printf("%s %s\n%s\n\n",
argp->first_name,
argp->last_name,
argp->city);
return((void *) &result);
}
© Chinese University, CSE Dept. Distributed Systems / 4 - 10
/* client.c */
print_person(char * host, Person * pers) {
...
if (print_0(pers, clnt)==NULL)
/* call failed /*
...
}
2.2 Use of Stubs
© Chinese University, CSE Dept. Distributed Systems / 4 - 11
2.3 RPC Interface
Used by client or server directly:– Locating servers.
– Choosing a transport protocol.
– Authentication and security.
– Invoking RPCs dynamically.
Used by stubs for:– Generating unique message IDs.
– Sending messages.
– Maintaining message history.
© Chinese University, CSE Dept. Distributed Systems / 4 - 12
print_person(char * host, Person * pers) {
CLIENT *clnt;
clnt = clnt_create(host, PERSONPROG,
PERSONVERS, "udp");
if (clnt == (CLIENT *) NULL) {
exit(1);
}
if (print_0(pers, clnt)==NULL)
clnt_perror(clnt, "call failed");
clnt_destroy(clnt);
}
2.3 RPC Interface
© Chinese University, CSE Dept. Distributed Systems / 4 - 13
2.4 Binding
How to locate an RPC server that can execute a given procedure in a network?
Can be done– statically (i.e. at compile-time) or
– dynamically (i.e. at run-time).
Dynamic binding is supported by portmap daemons.
© Chinese University, CSE Dept. Distributed Systems / 4 - 14
2.5 Handling of Remote Procedures
Call handled synchronously by server.
Concurrent RPCs:– serial or– concurrently.
Server availability:– continuous or– on-demand.
© Chinese University, CSE Dept. Distributed Systems / 4 - 15
2.6 Failures of RPCs
Machines or networks can fail at any time.
At most once semantics.
RPC return value indicates success.
Up to the client to avoid maybe semantics!
© Chinese University, CSE Dept. Distributed Systems / 4 - 16
3 CORBA
Object management architecture.
Accessing remote objects.
ORB interface.
Object identification
Activation strategies.
Request vs. notification.
Handling of failures.
© Chinese University, CSE Dept. Distributed Systems / 4 - 17
3.1 Object Management Architecture
ApplicationObjects
CORBAfacilities
CORBAservices
Object Request Broker
© Chinese University, CSE Dept. Distributed Systems / 4 - 18
3.2 Accessing Remote Objects
Dynamic Dynamic InvocationInvocation
ClientClientStubsStubs
ORBORBInterfaceInterface
ServerServerSkeletonSkeleton
ObjectObjectAdapterAdapter
ORB CoreORB Core
ClientClient Object ImplementationObject Implementation
© Chinese University, CSE Dept. Distributed Systems / 4 - 19
3.2 Stub/Skeleton Generation (for C++)
IDL-Compiler
Person.idl
Client.cc Server.cc
C++ Compiler, Linker C++ Compiler, Linker
Personcl.hh
Personcl.cc Personsv.cc
Personsv.hh
Client Server
includesgeneratesreads
© Chinese University, CSE Dept. Distributed Systems / 4 - 20
3.2 Static vs. Dynamic Invocation
Static invocation: IDL operations must have
been defined before client can be developed.
Does not suit every application.
Dynamic invocation interface enables clients
to define operation invocations at run-time.
Interface repository can be used to ensure
that calls are type safe.
© Chinese University, CSE Dept. Distributed Systems / 4 - 21
3.3 ORB Interface
Object type Object.
Initialization of object request broker.
Initialization of client / server applications.
Programming interface to interface repository.
© Chinese University, CSE Dept. Distributed Systems / 4 - 22
3.4 Object Identification
Objects are uniquely identified by object identifiers.
Object identifiers are persistent. Identifiers can be externalized and internalized. Identifiers can be obtained
– from naming service or trading service,
– by reading attributes,
– from an operation result or
– by internalizing an externalized reference.
© Chinese University, CSE Dept. Distributed Systems / 4 - 23
3.5 Activation Strategies
C
Basic ObjectAdapter
ProcessObject
A
B
D A Shared ServerB Unshared ServerC Server per methodD Persistent server
RegistrationActivation
© Chinese University, CSE Dept. Distributed Systems / 4 - 24
3.5 Request vs. Notification
IDL operations are handled synchronously. For notifications, it may not be necessary to
await server, if operation does not– have a return value,
– have out or inout parameters and
– raise specific exceptions. Notification can be implemented as oneway
operations in IDL. Client continues after notification is delivered.
© Chinese University, CSE Dept. Distributed Systems / 4 - 25
3.5 Notification (Example)
/* person.idl */
enum sex_type {
FEMALE, MALE
};
struct Person {
string first_name;
string last_name;
sex_type sex;
string city;
};
interface PersonManager {
oneway void print(in Person);
long store(in Person pers);
Person load(in long pers_id);
};
© Chinese University, CSE Dept. Distributed Systems / 4 - 26
3.6 Failures
CORBA operation invocations may fail for the same reasons as RPCs.
Failures are treated differently.
Exceptions give detailed account why an operation has failed.
System vs. application specific exceptions.
© Chinese University, CSE Dept. Distributed Systems / 4 - 27
4 Comparison
RPC architecture lacks interface repository.
IDL is more expressive than RPCL:
– inheritance,
– attributes and
– exceptions.
IDL has multiple standardized language
bindings.
© Chinese University, CSE Dept. Distributed Systems / 4 - 28
4 Comparison (cont´d)
Component identification is reflexive in IDL.
Basic object adapter provides more flexible activation strategies.
Oneway operations can be used for asynchronous notifications.
Handling of failures with exceptions is more expressive than returning a NULL pointer.
© Chinese University, CSE Dept. Distributed Systems / 4 - 29
4 Comparison (cont´d)
RPCs may be more efficient than CORBA operation invocations.
RPCs come with the UNIX OS whilst you would have to buy a CORBA product.
CORBA is more widely available on non-UNIX platforms.
RPCs are lightweight.
© Chinese University, CSE Dept. Distributed Systems / 4 - 30
5 Summary
What are the basic conceptual framework in procedure call in distributed systems?
What is RPC? How does it work? How does CORBA handle remote
procedures? What are the similarities between RPC and
CORBA? How do they differ? Read Textbook Chapter 5.