© chinese university, cse dept. distributed systems / 4 - 1 distributed systems topic 4: rpcs vs....
Post on 22-Dec-2015
219 views
TRANSCRIPT
![Page 1: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/1.jpg)
© 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
![Page 2: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/2.jpg)
© Chinese University, CSE Dept. Distributed Systems / 4 - 2
Outline
1. Conceptual Framework
2. RPCs
3. CORBA
4. Comparison
5. Summary
![Page 3: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/3.jpg)
© 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.
![Page 4: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/4.jpg)
© 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.
![Page 5: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/5.jpg)
© 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
![Page 6: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/6.jpg)
© 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.
![Page 7: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/7.jpg)
© 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;
![Page 8: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/8.jpg)
© 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
![Page 9: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/9.jpg)
© 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);
}
![Page 10: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/10.jpg)
© 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
![Page 11: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/11.jpg)
© 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.
![Page 12: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/12.jpg)
© 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
![Page 13: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/13.jpg)
© 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.
![Page 14: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/14.jpg)
© 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.
![Page 15: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/15.jpg)
© 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!
![Page 16: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/16.jpg)
© 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.
![Page 17: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/17.jpg)
© Chinese University, CSE Dept. Distributed Systems / 4 - 17
3.1 Object Management Architecture
ApplicationObjects
CORBAfacilities
CORBAservices
Object Request Broker
![Page 18: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/18.jpg)
© 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
![Page 19: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/19.jpg)
© 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
![Page 20: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/20.jpg)
© 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.
![Page 21: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/21.jpg)
© 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.
![Page 22: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/22.jpg)
© 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.
![Page 23: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/23.jpg)
© 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
![Page 24: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/24.jpg)
© 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.
![Page 25: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/25.jpg)
© 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);
};
![Page 26: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/26.jpg)
© 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.
![Page 27: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/27.jpg)
© 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.
![Page 28: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/28.jpg)
© 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.
![Page 29: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/29.jpg)
© 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.
![Page 30: © Chinese University, CSE Dept. Distributed Systems / 4 - 1 Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5cb70/html5/thumbnails/30.jpg)
© 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.