Java RMI vrs CORBA y el objeto Parallel
Java RMI vrs. CORBA y el objeto Parallel CORBA Parallel and Distributed Computing Using Java Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
CONTENIDO n n Introducción a CORBA Vrs. RMI Parallel CORBA Object Conclusiones Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Que es CORBA? n Acrónimo de: Common Object Request Broker Architecture. n Estándar desarrollado y mantenido por OMG (Object Management Group). n Intenta ser un marco genérico para trabajar con objetos en forma distribuida. n Independiente de la plataforma y del lenguaje de programación. n Integración con sistemas heredados y nuevas tecnologías. n Transparencia de redes, lenguajes, OS, modelo de objetos, paradigma, administración et. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Arquitectura Básica CORBA. (1/3) Consiste de : n Object Request Broker (ORB), que provee los medios para la comunicación cliente / servidor. n Interface Definition Languge (IDL), usado para la definición de interfases estáticas de los objetos. n Dinamic Invocation Interface (DII) y Dinamic Scheleton Interface (DSI), utilizada para obtener interfaces dinamicamente desde un repositorio. n n n Permiten acceder a objetos sin “stubs” y “skeletons” de un tipo especifico. En tiempo de ejecución el cliente pude determinar la Interface a un objeto del cual a recibido referencia. Llamar objetos sin tener que conocer su Interface también en tiempo de ejecución Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Arquitectura Básica CORBA. (2/3) n También especifica un protocolo de comunicación entre ORBs llamado Internet Inter_ORB Protocol (IIOP) n “Stubs” que son procedimientos locales correspondientes a una única operación, que ejecutan cuando son llamados. n Esqueletos de Objetos “Object skeleton”. n Los “Stubs” y los esqueletos de objetos sirven como proxis para clientes y servidores. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Arquitectura Básica CORBA. (3/3) Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Como funciona CORBA? (1/3) n Se debe compilar la IDL en “stubs” y “object skeletons”. n Se escribe un un objeto y su cliente. n “Stubs” y “Skeletons” actúan como proxis para el cliente y el servidor respectivamente. n IDL define la interfaz tan estrictamente que el “stub” en el cliente no tiene incompatibilidad con el “eskeleton” en el servidor. n Esto sucede incluso si se utilizan diferentes lenguajes u ORBs de diferentes proveedores. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Como funciona CORBA? (2/3) n Cada objeto CORBA tiene un identificador único (object reference). n Los clientes utilizan estas referencias para dirigir sus invocaciones. n De esta manera indican al ORB cual es la instancia exacta que se invoca. n El cliente actúa como si estaría actuando sobre el objeto pero lo hace sobre el “stub” IDL que actúa como proxi. n Este pedido atraviesa el “stub” continua por el ORB y en lado de la implementación a través del “skeleton” para obtener el objeto donde se ejecuta. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Como funciona CORBA? (3/3) n Para una invocación remota utiliza el mismo código pero con la referencia remota. n Cuando el ORB detecta que se trata de un objeto remoto lo direcciona por la red. n Para esto se requiere dos cosas: n Que el cliente sepa exactamente que operaciones puede ejecutar. n Que el cliente y la implementación estén de acuerdo en el protocolo (IIOP). Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Algunos servicios CORBA. Service Description Object life cycle Defines how CORBA objects are created, removed, and copied Naming Defines how CORBA objects can have friendly symbolic names Events Decouples the communication between distributed objects Relationships Provides arbitrary typed n-ary relationships between CORBA objects Externalization Coordinates the transformation of CORBA objects to and from external media Transactions Coordinates atomic access to CORBA objects Concurrency Control Provides a locking service for CORBA objects in order to ensure serializable access Property Supports the association of name-value pairs with CORBA objects Trader Supports the finding of CORBA objects based on properties describing the service offered by the object Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Implementaciones de CORBA para Java? n Existen varios proveedores: The Java 2 ORB comes with Sun's Java 2 SDK. It is missing several features. Visi. Broker for Java A popular Java ORB from Inprise Corporation. Visi. Broker is also embedded in other products. For example, it is the ORB that is embedded in the Netscape Communicator browser. Orbix. Web A popular Java ORB from Iona Technologies. Web. Sphere A popular application server with an ORB from IBM. Netscape Communicator Netscape browsers have a version of Visi. Broker embedded in them. Applets can issue request on CORBA objects without downloading ORB classes into the browser. They are already there. Various free or shareware ORBs CORBA implementations for various languages are available for download on the web from various sources. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA n Desde la versión 1. 1 de JDK, java tiene su propio ORB llamado RMI (no compatible con el ORB de CORBA). n RMI es nativo de Java, una extensión del lenguaje. n Depende de muchas características propias de Java: n Serializacion de objetos. n Portable. n Implementaciones de objetos descargables. n Java Interface Definitions. n Como Consecuencia es muy natural para los programadores Java, que no necesitaran aprender tecnologías “extranjeras” Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Programación vrs. integración) 1/4 n Java con extensión RMI es considerada una tecnología de programación n CORBA por su parte es considerada una tecnología de integración. n Para ilustrarlo consideremos lo siguiente: Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Programación vrs. integración) 2/4 n Java provee un API llamada JNI (Java Native Interface) para interactuar con otro lenguajes primariamente C y C++. n RMI es una tecnología Java. n Si se quiere que Java se comunique con un objeto remoto en otro lenguaje se lo debe hacer por medio de un intermediario. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Programación vrs. integración) 3/4 n CORBA es una tecnología de integración, diseñada para ser el pegamento para unir tecnologías diferentes. n No existe como un punto en el espacio de programación, sino que ocupa el espacio entre los diferentes lenguajes. n Cuando un cliente utiliza java para comunicarse con un objeto C++, tanto el programador Java como el programador C++ trabajan en su propio lenguaje. n CORBA ORB presenta el cliente Java con un “stub” Java y al programador C++ un “skeleton”” C++. n CORBA se encarga de los problemas de transferencia de lenguajes. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Programación vrs. integración) 4/4 Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Ejemplo - Interface) CORBA – IDL Java/RMI – Interface definition module Simple. Stocks { interface Stock. Market { float get_price( in string symbol ); }; }; package Simple. Stocks; import java. rmi. *; import java. util. *; File : Stock. Market. idl File : Stock. Market. java Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java public interface Stock. Market extends java. rmi. Remote { float get_price( String symbol ) throws Remote. Exception; }
RMI vrs. CORBA (Ejemplo-Cliente del objeto distribuido) CORBA – Client implementation Java/RMI – Client implementation // // Stock. Market. Client // import org. omg. CORBA. *; import org. omg. Cos. Naming. *; import Simple. Stocks. *; // // Stock. Market. Client // import java. rmi. *; import java. rmi. registry. *; import Simple. Stocks. *; public class Stock. Market. Client { public static void main(String[] args) { try { ORB orb = ORB. init(); Naming. Context root = Naming. Context. Helper. narrow( orb. resolve_initial_references("Name. Service") ); Name. Component[] name = new Name. Component[1] ; name[0] = new Name. Component("NASDAQ", ""); public class Stock. Market. Client { public static void main(String[] args)throws Exception { if(System. get. Security. Manager() == null) { System. set. Security. Manager(new RMISecurity. Manager()); } Stock. Market market = (Stock. Market)Naming. lookup("rmi: //localhost/NASDAQ"); System. out. println( "The price of MY COMPANY is " + market. get_price("MY_COMPANY") ); } } Stock. Market market = Stock. Market. Helper. narrow(root. resolve(name)); System. out. println("Price of MY COMPANY is " + market. get_price("MY_COMPANY")); } catch( System. Exception e ) { System. err. println( e ); }}} File : Stock. Market. Client. java Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java File : Stock. Market. Client. java
RMI vrs. CORBA (Ejemplo- Servidor del objeto distribuido) CORBA – Server implementation Java/RMI – Server implementation // // Stock. Market. Server // import org. omg. CORBA. *; import Simple. Stocks. *; // Stock. Market. Server package Simple. Stocks; import java. rmi. *; import java. rmi. server. Unicast. Remote. Object; public class Stock. Market. Impl extends _Stock. Market. Impl. Base { public float get_price( String symbol ) { float price = 0; for(int i = 0; i < symbol. length(); i++) { price += (int) symbol. char. At( i ); } price /= 5; return price; } public Stock. Market. Impl( String name ) { super( name ); } File : Stock. Market. Impl. java Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java public class Stock. Market. Impl extends Unicast. Remote. Object implements Stock. Market { public float get_price( String symbol ) { float price = 0; for( int i = 0; i < symbol. length(); i++ ) { price += (int) symbol. char. At( i ); } price /= 5; return price; } public Stock. Market. Impl( String name ) throws Remote. Exception { try { Naming. rebind( name, this ); } catch( Exception e ) { System. out. println( e ); }}} File : Stock. Market. Impl. java
RMI vrs. CORBA (Ejemplo- Servidor del objeto MAIN) CORBA – Server Main Java/RMI – Server Main // Stock. Market. Server Main import org. omg. CORBA. *; import org. omg. Cos. Naming. *; import Simple. Stocks. *; public class Stock. Market. Server { public static void main(String[] args) { try { ORB orb = ORB. init(); BOA boa = orb. BOA_init(); Stock. Market. Impl stock. Market. Impl = new Stock. Market. Impl("NASDAQ"); boa. obj_is_ready( stock. Market. Impl ); org. omg. CORBA. Object object = orb. resolve_initial_references("Name. Service"); Naming. Context root = Naming. Context. Helper. narrow( object ) ; Name. Component[] name = new Name. Component[1]; name[0] = new Name. Component("NASDAQ", ""); root. rebind(name, stock. Market. Impl); // Stock. Market. Server Main import java. rmi. *; import java. rmi. server. Unicast. Remote. Object; import Simple. Stocks. *; public class Stock. Market. Server { public static void main(String[] args) throws Exception { if(System. get. Security. Manager() == null) { System. set. Security. Manager(new RMISecurity. Manager()); } Stock. Market. Impl stock. Market. Impl = new Stock. Market. Impl("NASDAQ"); } } boa. impl_is_ready(); } catch( Exception e ) { e. print. Stack. Trace(); }}} File : Stock. Market. Server. java Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java File : Stock. Market. Server. java
RMI vrs. CORBA (Comparando la Implementación) 1/4 CORBA Java/RMI Supports multiple inheritance at the interface level Every interface inherits from CORBA. Object Every server object implements java. rmi. Remote Uniquely identifies remote server objects through object references(objref), which serves as the object handle at run-time. Uniquely identifies remote server objects with the Obj. ID, which serves as the object handle at run-time. Uniquely identifies a named implementation of of the server object by its mapping to a URL in the name in the Implementation Repository Registry The remote server object reference generation is performed on the wire protocol by the Object Adapter The remote server object reference generation is performed by the call to the method Unicast. Remote. Object. export. Object(this) The constructor implicitly performs common tasks like object registration, skeleton instantiation etc The RMIRegistry performs common tasks like object registration through the Naming class. Unicast. Remote. Object. export. Object(this) method performs skeleton instantiation and it is implicitly called in the object constructor. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Comparando la Implementación) 2/4 CORBA Java/RMI Uses the Internet Inter-ORB Protocol(IIOP) as its underlying remoting protocol Uses the Java Remote Method Protocol(JRMP) as its underlying remoting protocol (at least for now) When a client object needs to activate When a client object needs a server object reference, it has to do a lookup() a server object, it binds to a naming or a trader service on the remote server object's URL name. The object handle that the client uses is the Object Reference The mapping of Object Name to its Implementation is handled by the Implementation Repository The mapping of Object Name to its Implementation is handled by the RMIRegistry The type information for methods is held in the Interface Repository Any type information is held by the Object itself which can be queried using Reflection and Introspection The responsibility of locating an object implementation falls on the Object Request Broker (ORB) The responsibility of locating an object implementation falls on the Java Virtual Machine (JVM) Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Comparando la Implementación) 3/4 CORBA Java/RMI The responsibility of locating an object The responsibility of activating an object implementation falls on the Object Adapter implementation falls on the Java Virtual (OA) - either the Basic Object Adapter Machine (JVM) (BOA) or the Portable Object Adapter (POA) The client side stub is called a proxy or stub The server side stub is called a skeleton When passing parameters between the client and the remote server object, all interface types are passed by reference. All other objects are passed by value including highly complex data types When passing parameters between the client and the remote server object, all objects implementing interfaces extending java. rmi. Remote are passed by remote reference. All other objects are passed by value Does not attempt to perform general-purpose distributed garbage collection. Attempts to perform distributed garbage collection of remote server objects using the mechanisms bundled in the JVM Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI vrs. CORBA (Comparando la Implementación) 4/4 CORBA Java/RMI Any Serializable Java object can be Complex types that will cross interface boundaries must be declared passed as a parameter across processes. in the IDL Will run on any platform as long as there is a CORBA ORB implementation for that platform (like Inprise's Visi. Broker) Will run on any platform as long as there is a Java Virtual Machine implementation for that platform (provided by a whole lot of companies in addition to Java. Soft and Microsoft) Since this is just a specification, Since it relies heavily on Java Object diverse programming languages can Serialization, these objects can only be be used to code these objects as long coded in the Java language as there are ORB libraries you can use to code in that language Exception handling is taken care of by Allows throwing exceptions which are Exception Objects. When a distributed then serialized and marshaled across the object throws an exception object, the wire. ORB tranparently serializes and marshals it across the wire. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
RMI Pros y cons Pros Cons Portable across many platforms Tied only to platforms with Java support Can introduce new code to foreign JVMs Security threats with remote code execution, and limitations on functionality enforced by security restrictions Java developers may already have Learning curve for developers that experience with RMI (available since have no RMI experience is JDK 1. 02) comparable with CORBA Existing systems may already use Can only operate with Java systems RMI - the cost and time to convert to - no support for legacy systems a new technology may be prohibitive written in C++, Ada, Fortran, Cobol, and others (including future languages). Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
CORBA Pros y cons Pros Cons Services can be written in many different languages, executed on many different platforms, and accessed by any language with an interface definition language (IDL) mapping. Describing services require the use of IDL which must be learned. Implementing or using services require an IDL mapping to your required language - writing one for a language that isn't supported would take a large amount of work. With IDL, the interface is clearly separated from implementation, and developers can create different implementations based on the same interface. IDL to language mapping tools create code stubs based on the interface - some tools may not integrate new changes with existing code. CORBA supports primitive data types, and a wide range of data structures, as parameters CORBA does not support the transfer of objects, or code. CORBA is ideally suited to use with legacy systems, and to ensure that applications written now will be accessible in the future. The future is uncertain - if CORBA fails to achieve sufficient adoption by industry, then CORBA implementations become the legacy systems. CORBA is an easy way to link objects and systems together Some training is still required, and CORBA specifications are still in a state of flux. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Parallel CORBA Object 1/3 n Busca proveer de una técnica eficiente para encapsular código paralelo basado en el uso de librerías MPI. n Un código paralelo MPI puede verse como un conjunto de procesos idénticos SPMD. n Usualmente se utiliza una aproximación maestro esclavo. n Se selecciona un proceso como maestro que es el único que se encapsula en un objeto CORBA. n Este se conecta a los esclavos mediante una capa de comunicación MPI. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Parallel CORBA Object 1/4 n Esta solución requiere modificar los códigos MPI si no siguen la estructura maestro esclavo. n El maestro puede ser un cuello de botella importante cuando dos códigos MPI se deben comunicar entre si. n El cliente obtiene los datos generados por el primer código y es enviado al segundo, este los coloca en los procesos MPI esclavos, los procesa, obtiene los resultados y los envía al cliente n No ofrece una solución escalable, si el numero de procesos SPMD o el tamaño del problema se incrementa (cantidad de datos transmitidos entre dos procesos paralelos) habrá un importante costo por sobrecarga en comunicaciones. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Parallel CORBA Object 3/4 n La solución requiere que todos los procesos SPMD se encapsulen en objetos CORBA. n Esto permitirá que todos los procesos SPMD se comunique a través del ORB. n Sin embargo es necesario que no se exponga el paralelismo al cliente. n Eso quiere decir que el cliente tiene que ver una entidad en lugar de de todos los objetos CORBA que encapsulan procesos SPMD. n También si el cliente tiene que transmitir datos entre los objetos CORBA tiene que hacerlo lo mas transparentemente. n Estos dos requerimientos transparencia y rendimiento han concluido en el concepto de un nuevo objeto, el CORBA Paralelo: Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Parallel CORBA Object 4/4 n Un objeto CORBA encapsula un proceso SPMD. n Todos los objetos CORBA pertenecientes a una colección pueden ser manipulados como una única entidad por el sistema. n La invocación de una operación por el cliente resultara en la ejecución del método asociado por todos lo objetos de la colección en el servidor. n Esta activación paralela se hace transparentemente y la distribución de datos entre objetos de una colección es manejad por el sistema. n Una Interface a un objeto paralelo se describe como una extensión el IDL llamada “Extended IDL”. n Se han creado un conjunto de nuevas palabras clave para especificar el numero de objetos en una colección y la distribución de datos. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Interface Parallel CORBA. n interface[*: 2*n] Matrix. Operations { const long SIZE=100; typedef double Vector[SIZE]; typedef double Matrix[SIZE]; void multiply(in dist[BLOCK][*] Matrix A, in Vector B, out dist[BLOCK] Vector C ); void skal(in dist[BLOCK] Vector C, out csum double val); }; Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Cliente y Servidor CORBA Paralelo Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Conclusiones n Existen varias implementaciones de CORBA para java actualmente en el mercado, lo cual hace viable su utilización con este lenguaje. n CORBA no debe verse como una competencia de RMI sino como una solución complementaria para ciertos problemas. n Se están haciendo importantes esfuerzos para extender CORBA y permitir su mejor utilización en ambientes paralelos. n Es indiscutible el éxito que han tenido tanto Java como CORBA y por tanto es de esperarse una mayor colaboración de estas tecnologías complementarias a futro. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Bibliografia GENERAL CORBA: http: //www. corba. org http: //developer. java. sun. com/developer/online. Training/corba. html COMPARATIVO RMI / CORBA: n Gopalan Suresh Raj, “A Detailed Comparison of CORBA, DCOM and Java/RMI”. http: //www. execpc. com/~gopalan/misc/compare. htm n David Curtis, “Java, RMI and CORBA” (1997 Object Management Group). http//: cgi. omg. org/library/wpjava. html n Michael W. Gilbode, “A Comparison of CORBA and Java RMI”. http//: www. csc. villanova. edu/~mgilbode/8530/corba-rmi. html CORBA PARALELO: n T. Priol, C. René, “Parallel CORBA Object”. http: //www. irisa. fr/paris/nanglais/paco. htm n C. Perez, T. Priol, “Grid Computing with Off-the-Shelves Middleware Technologies”. http//: www. ercim. org/publication/Ercim_News/enw 45/priol. html n C. René, T. Priol, “MPI Code Encapsulation using Parallel CORBA Object”. INRIA, Rapport de recherche No. 3648 Marzo de 1999. n C. René, T. Priol, G. Alléon, “Programming SCI Clusters using Paraller CORBA Objects”. INRIA, Rapport de recherche No. 3649 Marzo de 1999. Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
Juan Pablo Carvallo V. , Parallel and Distributed Computing Using Java
- Slides: 35