RMI Flashcards
What does RMI mean?
Remote method invocation
What are the 3 basic layers of RMI architecture?
- Proxy: Stubs (client) and skeletons (server) - generated by rmic
- Transport layer (TCP/IP. Sockets)
- Remote reference layer
Also Application Layer (client/ server)
Describe the Proxy layer
Stubs and Skeletons.
Stub Layer:
- Proxy representing interface to remote object for client
- Defines complete interface of remote implementation
- Appears to client app as local object
- Communicates with skeleton via Remote Reference Layer
Skeleton layer
- Local interface for remote object
- Interface between remote implementation and Remote Reference Layer
- Communicates with stub via remote reference layer
- Marshall’s any return values or exceptions
Describe the Remote Reference Layer
- Responsible for management of remote objects
- connects clients to remote objects
- Responsible for invocation of remote object methods
- An independent reference protocol
- Provides a transport stream to Stub/Skeleton Layer
Describe the Transport Layer
Responsible for creation and maintenance of connections
- Runs connections over sockets by default
- Can use custom sockets eg SSL.
What is a naming service?
A naming service associates names with objects
- Important for distributed systems as it allows location of objects
A naming service is a dedicated piece of software
- Controls a filespace - database, spreadsheet workbook etc
- Allows association of name to data - binding (filename, column, cellname)
- Name is meaningful within a given space (context: folder, table, sheet)
- Allows lookup of name for data - resolution
How is the naming service provided in RMI?
Java RMI provides a bootstrap naming service called rmiregistry that allows the server side to register or name at least object (and its services) that it wants to expose to a client. The client is then able to look up the basic service and find out what methods have been exposed and then invoke them.
The RMI registry can be started in the command line with start rmiregistry.
Naming Services: Declare that an object is bound to a name
To declare an object is bound to a name:
bind(String name, Remote object)
ie bind("Hello", new Hello("Hello world"); The bind method binds a remote reference to a name in the registry. Similarly the rebind(String name, Remote obj) method can be used to bind an object with another name in the registry.
Naming Services: To retrieve a reference to a remote object with a given name
To retrieve a reference to a remote object
lookup(String name)
The lookup methods returns a reference to an object
naming Services: To retrieve a directory of available objects
To retrieve a directory of available objects:
list()
This method returns an array of the names bound in the registry.
What is meant by Object Serialisation?
Object serialisation is the conversion of an object into bytecode so that it can be transferred in an object stream across a network and then deserialised at the other end. Object serialisation is therefore important to RMI where objects, arguments and parameters are transferred between clients and server implementations.
How is an object serialised in RMI?
bind or rebind method
Naming.rebind(“Hey”, new Hello(“Hello, world!”));
How is an object decerialised in RMI?
lookup method
HelloInterface hello = (HelloInterface) Naming.lookup(“computers_address/Hey”);
What are remote callbacks in RMI?
A remote call back is where a the server side object notifies the registered client of an event it has previously been asked to be notified of. An example of this is a Stocks and Shares app where a user registers their interest in the price of one stock and asks to be notified if the price falls below a certain value. When the event occurs the server then notifies the client.
Programmatically this occurs by the client, for example, registering as a listener of an event source on the server side. This request is passed as a parameter to the server stores this list as a vector which holds a list of registered listeners. When the event occurs the call back is made to the client.
What is the role of the remote interface?
The role of the remote interface is declare which methods can be called by a client remotely. A remote interface allows a remote Java virtual machine to call the declared methods of a remote object. Once a remote interface is implemented by extending java.rmi.Remote then the method can be called on a remote JVM in the stub layer which represents the remote object locally.