Skip to content

Gigaspaces/lrmi-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lrmi-example

Running from within Idea.

  1. Run Server.Main
  2. Run Client.Main

Remote Objects Interface

  1. Should extends Remote each remote method should throws RemoteException, example Service.java

  2. Control flow can be changed using annotations on remote method interfaces @OneWayRemoteCall mark method as one way (not waiting for an answer), AsyncRemoteCall returns the result in a Java Future.

The basic Idea of RMI

  1. Configuration of LRMI is done using the class NIOConfiguration this configuration is passed in when the Exporter is created and from there it passed on to the clients Exporter exporter = new GenericExporter(NIOConfiguration.create());.

  2. The GenericExporter is used to export implementation of remote, it is doing couple of things:

    • Save the handled object in an LRMI map to be used when invoked from network (or embedded)

    • Index all the method for fast access.

    • Create and return an Remote object that when serialized save the address and Id to the original object, this is actually the proxy that can passed to the clients, it can passed serialized as a sequence of bytes throw a global repository in the network or as in our example in a file.

  3. The Proxy Generation

    The idea is to use Java DynamicProxy and provide an InvocationHandler that know how to call back to the server using local LRMI.

    Our Invocation handler is the class DynamicSmartStub it is serailized so it can be sent to remote clients as blob and handle the calls back to the server using its invoke method.

    It is wrapped inside a Dynamic proxy it implements all the Interfaces that marked as Remote in the exported Object.

    It uses the writeExternal / readExternal trick to execute code when deserialize, the local LRMI node is created from this class if needed.

Metworking.

Client side

Initialization is triggered by call on proxy method Connection to the server is done using the class CPeer The main method to send a request to the server is invoke The class uses Reader and Writer to send and read bytes to the other side. Using handshake to prevent buffer overflow when receiving broken messages. And write bytes

Server side

Pivot is the class that manage the socket at the server side handleRequest is the method that get the RequestPacket dispatch it to the remote object and send the result replyPacket [consumeAndHandleRequest] is where the Pivot forward the invoke to the RMI Runtime Each ReadSelectorThread holds an internal Pivot that being used whenever there are some bytes in the channel (socket)

Message format

The first 4 bytes contains the message size, the next bytes are serialized RequestPacket / ReplyPacket

Limitations

  • The protocol does not support pipeline therefore it uses lots of system resources under load.
  • The protocol does not enable custome serialization.
  • It is not possible to negotiate connection filters/setting upon opening.
  • does not allow different filters stack per message.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages