universal
Class ServerInterceptor

java.lang.Object
  |
  +--org.omg.CORBA.LocalObject
        |
        +--universal.ServerInterceptor
All Implemented Interfaces:
org.omg.CORBA.portable.IDLEntity, org.omg.PortableInterceptor.Interceptor, org.omg.PortableInterceptor.InterceptorOperations, org.omg.CORBA.Object, java.io.Serializable, org.omg.PortableInterceptor.ServerRequestInterceptor, org.omg.PortableInterceptor.ServerRequestInterceptorOperations

public class ServerInterceptor
extends org.omg.CORBA.LocalObject
implements org.omg.PortableInterceptor.ServerRequestInterceptor

This is from this class that everything is going to be done (execution of the request, consensus, sending back of the reply).

This is done here because we want to be as much as possible transparent from the application that doesn't know anything about consensus, leader election,...

See Also:
Serialized Form

Field Summary
(package private)  org.omg.IOP.Codec codec
           
(package private)  org.omg.IOP.CodecFactory factory
           
(package private)  int ft_slot
           
(package private)  org.omg.PortableInterceptor.ORBInitInfo info
           
(package private)  java.lang.String location
           
(package private)  universal.MethSignStr[] methSgn
           
(package private)  int num
          Num is the idea for this server of the next position in the total order, the next request should be.
(package private)  int number_notify
           
(package private)  int number_waiting
          Number of request that wait to be processed
(package private)  java.lang.Object one_by_one
          Permit to synchronized on this object in order to treat each request one after another
(package private)  org.openorb.CORBA.ORB orb
           
(package private)  org.omg.CORBA.ORB orb1
           
(package private)  universal.OutcomeStore store
          The variable store contains the outcome (Request, Reply, Update) for requests that have already been processed and that have not yet expired.
(package private)  universal.MethTable table
          Contains the description of all the methods of the application server.
(package private)  java.io.RandomAccessFile trace_file
          The file which contains the traces.
(package private)  universal.Universal uni
          This object permit to access the implementation of the algorithm (Leader election, consensus)
 
Fields inherited from class org.omg.CORBA.LocalObject
 
Constructor Summary
ServerInterceptor(org.omg.PortableInterceptor.ORBInitInfo inf, int t_slot)
           
 
Method Summary
 void destroy()
           
 java.lang.String name()
           
 void receive_request_service_contexts(org.omg.PortableInterceptor.ServerRequestInfo ri)
          This is precisely from that method that everything is going to be done.
 void receive_request(org.omg.PortableInterceptor.ServerRequestInfo ri)
           
 void send_exception(org.omg.PortableInterceptor.ServerRequestInfo ri)
           
 void send_other(org.omg.PortableInterceptor.ServerRequestInfo ri)
           
 void send_reply(org.omg.PortableInterceptor.ServerRequestInfo ri)
           
 
Methods inherited from class org.omg.CORBA.LocalObject
_create_request, _create_request, _duplicate, _get_domain_managers, _get_interface_def, _get_interface, _get_policy, _hash, _invoke, _is_a, _is_equivalent, _is_local, _non_existent, _orb, _release, _releaseReply, _request, _request, _servant_postinvoke, _servant_preinvoke, _set_policy_override, validate_connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.omg.CORBA.Object
_create_request, _create_request, _duplicate, _get_domain_managers, _get_interface_def, _get_policy, _hash, _is_a, _is_equivalent, _non_existent, _release, _request, _set_policy_override
 

Field Detail

info

org.omg.PortableInterceptor.ORBInitInfo info

ft_slot

int ft_slot

location

java.lang.String location

orb1

org.omg.CORBA.ORB orb1

orb

org.openorb.CORBA.ORB orb

uni

universal.Universal uni
This object permit to access the implementation of the algorithm (Leader election, consensus)


factory

org.omg.IOP.CodecFactory factory

codec

org.omg.IOP.Codec codec

num

int num
Num is the idea for this server of the next position in the total order, the next request should be.


store

universal.OutcomeStore store
The variable store contains the outcome (Request, Reply, Update) for requests that have already been processed and that have not yet expired.
It is useful in case of the same request is sent twice but we don't want to execute it twice.


table

universal.MethTable table
Contains the description of all the methods of the application server.
The description is the name, the modes (IN, INOUT, OUT) and types of the parameters.


methSgn

universal.MethSignStr[] methSgn

one_by_one

java.lang.Object one_by_one
Permit to synchronized on this object in order to treat each request one after another


number_waiting

int number_waiting
Number of request that wait to be processed


number_notify

int number_notify

trace_file

java.io.RandomAccessFile trace_file
The file which contains the traces.

Constructor Detail

ServerInterceptor

public ServerInterceptor(org.omg.PortableInterceptor.ORBInitInfo inf,
                         int t_slot)
Method Detail

receive_request_service_contexts

public void receive_request_service_contexts(org.omg.PortableInterceptor.ServerRequestInfo ri)
                                      throws org.omg.PortableInterceptor.ForwardRequest,
                                             org.omg.CORBA.STOP_REQUESTException
This is precisely from that method that everything is going to be done.
First checks if the request, it has received, is a message from one of the other replicated servers or from the client to inform it in which port and on which IP address they are listenning.
If it is the case the name of the operation is either replicas or client.
We take the informations (port, address) and register them (create the object ProcessDetails).
If it is a request from the client which wants to execute one method of the application server, we do the following steps:
- extracts the service context (retention_id, client_id, request_start_time)
- check if the request has already been processed(OutcomeStore). If it the case, the reply is directly sent back to the client.
- Otherwise the request waits until all the request that has arrived before are processed.
- Check again if during the time the request was waiting, it hasn't already been executed.
- Get the state before the execution
- Execute the method.
- Get the update.
- Check if the server trusts itself as the leader
- If it doesn't, the state as it was before the execution is restored and an exception is sent to the client to inform it that it should resend the request.
- If it was the leader, the consensus is made.
- If the result of the consensus was not the request, it has proposed. It restart from the beginning with the same request but for the next free position.
-If it was the request it has proposed, it sent back the reply to the leader and throw an exception to avoid the request to go until the application.

Specified by:
receive_request_service_contexts in interface org.omg.PortableInterceptor.ServerRequestInterceptorOperations
Parameters:
ri - the client request
org.omg.PortableInterceptor.ForwardRequest
org.omg.CORBA.STOP_REQUESTException

receive_request

public void receive_request(org.omg.PortableInterceptor.ServerRequestInfo ri)
                     throws org.omg.PortableInterceptor.ForwardRequest
Specified by:
receive_request in interface org.omg.PortableInterceptor.ServerRequestInterceptorOperations
org.omg.PortableInterceptor.ForwardRequest

send_reply

public void send_reply(org.omg.PortableInterceptor.ServerRequestInfo ri)
Specified by:
send_reply in interface org.omg.PortableInterceptor.ServerRequestInterceptorOperations

send_exception

public void send_exception(org.omg.PortableInterceptor.ServerRequestInfo ri)
                    throws org.omg.PortableInterceptor.ForwardRequest
Specified by:
send_exception in interface org.omg.PortableInterceptor.ServerRequestInterceptorOperations
org.omg.PortableInterceptor.ForwardRequest

send_other

public void send_other(org.omg.PortableInterceptor.ServerRequestInfo ri)
                throws org.omg.PortableInterceptor.ForwardRequest
Specified by:
send_other in interface org.omg.PortableInterceptor.ServerRequestInterceptorOperations
org.omg.PortableInterceptor.ForwardRequest

name

public java.lang.String name()
Specified by:
name in interface org.omg.PortableInterceptor.InterceptorOperations

destroy

public void destroy()
Specified by:
destroy in interface org.omg.PortableInterceptor.InterceptorOperations