OpenCOM V2: Theory - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

OpenCOM V2: Theory

Description:

OpenCOM V2: Theory & Practice. Jo' Ueyama & Paul Grace. Overview of ... Unit of scope that offers the kernel API. Caplets. Sub-scopes within capsule. Loaders ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 40
Provided by: compLa
Category:
Tags: opencom | scopes | theory

less

Transcript and Presenter's Notes

Title: OpenCOM V2: Theory


1
OpenCOM V2 Theory Practice
  • Jo Ueyama Paul Grace

2
Overview of the talk
  • V2 Concepts in General
  • Applying V2 principles
  • OpenCOMLinux
  • Case Study Microcode C
  • OpenCOMv2Java
  • Exploring the kernel API in detail
  • Case Study Java C

3
Motivation for Version 2
  • Support component deployment in a wide range of
    environments
  • OpenCOM v1 is platform specific
  • Negligible Overheads
  • E.g. Small (15k), simple runtime
  • Fine-grained, language independent and
    format-independent components
  • A Configurable Reconfigurable Component runtime

4
OpenCOM v2 Overall Architecture
Generic support for reconfiguration inspect,
adapt and extend at runtime
Minimal kernel Loads and binds
Caplets, loaders and binders
Component run-time kernel
5
CRTK API
  • template load(comp_type name)
  • Loads component template into the runtime
  • comp_inst instantiate(template t, opaque arg)
  • Create component instance from template
  • status unload(template t)
  • Remove loaded template
  • status destroy(comp_inst comp)
  • Delete a component instance
  • ipnt_inst getinteractionpoint(comp_ist, kind,
    ipnt_type)
  • Obtain Intf or Recp identifier from a component
  • comp_inst bind(ipnt_inst, ipnt_inst receptacle)
  • Bind together specified interface receptacle
    binding is a component that can be destroyed
    (unbind)

6
OpenCOM v2 concepts
  • Capsule
  • Unit of scope that offers the kernel API
  • Caplets
  • Sub-scopes within capsule
  • Loaders
  • Provide various ways of loading component into
    various types of caplet
  • Binders
  • Various ways of binding components both within
    and across different caplet

7
Overview of Capsules, Loaders Binders
8
Extensions Layer
9
Extension Layer API
  • template load(comp_type name, comp_inst loader,
    comp_inst caplet)
  • Loads using specified Loader Caplet
  • comp_inst bind(ipnt_inst interface, ipnt_inst
    receptacle, comp_inst binder)
  • Bind using specified binder
  • comp_inst extend(extension_type ext_type,
    comp_type extension, opaque arg)
  • Load extension component using CRTK loader
  • status setdefaultextension(extension_type
    ext_type, comp_inst extension)
  • Set a default loader, binder or caplet

10
CRTK reflect operation
  • Used by components implementing meta-models or
    architecture management
  • Register for callbacks from run-time
  • Provides information about requests of the
    run-time
  • Loads, binds, etc
  • Two-phase
  • 1st callback -gt whats about to happen
  • Veto
  • 2nd callback -gthappened
  • Update meta-data
  • Plugable Meta-models
  • Add components begin to reify information about
    components
  • Further research into application to
    architecture, interface and interception required

CRTK
Reflect(Callback cb)
Register Callback Interface
11
CRTK putmeta, getmeta
  • status putmeta(ID entity, string key, opaque
    value)
  • opaque getmeta(ID entity, string key)
  • Add meta-data about any component model element
    to an internal CRTK registry
  • Separate meta models?
  • Attach to elements in meta-architecture
    interface
  • Plugable registry?

12
OpenCOMLinux CRTK
  • Implements the API to load and bind components
  • Coded in C
  • OSPL - Operating System Portable Layer is a
    subset of NSPR (e.g. can be easily ported to
    Windows)
  • Components are stored in a Shared Object file
    (.so)
  • Provides dynamic linking

13
OpenCOMLinux CRTK Load/Bind
  • Loading a component
  • Pass the component type and get the componentID
  • Load(componentType, componentID)
  • Instantiating a component
  • Pass the loaded componentID and returns the
    pointer to the component instance
  • Instantiate(componentID, intf, intfID, instID)
  • Binding components
  • Pass the interfaceID and receptacleID
  • Bind(intfID, receptID, connID)

14
Cross Caplet Binder
15
Case Study C Microcode Scenario
Microcode - C Binding
Microcode
C
16
  • A Case Study Java and C Component Integration
    on Win32 Desktops and CE 3.0 Pocket PCs

17
GRIDKit Heterogeneity Problem
ICalculate int Add(int x, int y) int Sub(int x,
int y)
Java Runtime
Java Calculator Component
Java Calculator Component
ISub int Sub(int x, int y)
IAdd int Add(int x, int y)
Java Subtract Component
Java Random Number Component
Java Subtract Component
C Adder Component
C Runtime
C Adder Component
IRandomNumber int GetRandomNumber(int t)
Java Random Number Component
18
Theory versus Practice
  • Theory
  • Practice

Reflective Meta Models
CRTK API
IOpenCOM
CRTK
OpenCOMJ Component runtime
Windows Operating System (Win32 or CE 3.0)
deployment environment (hardware and/or software)
19
Component Run-time Kernel
  • Define What is your base CRTK?
  • Base component-runtime
  • Load components
  • Bind components
  • Many possibilities
  • OpenCOMJ, OpenCOMWin32, OpenCOMLinux, COM, EJB,
    CCM,
  • The primary component development tool for
    Gridkit is OpenCOMJ.
  • ? CRTK OpenCOMJ

20
CRTK API (1)
  • template load(comp_type name)
  • Utilise Java ClassLoader to perform Load
    behaviour
  • Not implemented (yet). Relies on Java automation
  • comp_inst instantiate(template t, opaque arg)
  • CreateInstance(String comp_type, String
    comp_name)
  • Comp_type String Class Name
  • status unload(template t)
  • Cant unload class explicitly in Java
  • status destroy(comp_inst comp)
  • DeleteInstance(IUnknown pComp)
  • Cant explicitly delete the component this just
    supports removal of meta-data.

21
CRTK API (2)
  • ipnt_inst getinteractionpoint(comp_ist, kind,
    ipnt_type)
  • IUnknown QueryInterface(ipnt_type)
  • Implemented per component
  • Cant Get a receptacle
  • No problem to add above behaviour to the runtime
  • comp_inst bind(ipnt_inst, ipnt_inst receptacle)
  • Connect(comp_ist, comp_ist, ipnt_type)
  • Identical behaviour
  • status putmeta(ID entity, String key, opaque
    value)
  • status reflect(Callback callback)
  • Need to examine how these methods relate to
    meta-implementation already in place

22
CRTK Load Bind
OpenCOM runtime new OpenCOM()
IOpenCOM pIOCM (IOpenCOM)
runtime.QueryInterface("OpenCOM.IOpenCOM")
CRTK (OpenCOMJ Runtime)
Java Calculator Component
IUnknown CalcUnk pIOCM.CreateInstance( Calcula
tor, The_Caculator_Component)
Iunknown SubUnk pIOCM.CreateInstance( Subtract
, The_Subtract_Component)
Java Random Number Component
Java Subtract Component
Iunknown Ran pIOCM.CreateInstance( Random,
The_Random_Component)
unsigned long ConnID pIOCM.Connect( CalcUnk,
SubUnk, ISubtract)
23
Extension Caplet (Win32 C)
  • Adder is a C Win32 component
  • we need to create extension caplet to execute it
    in

Calculator Component
  • C Caplet Properties
  • OpenCOMJ component
  • Loaded and Instantiated through PRIMARY java
    caplet
  • Named CAPLETWin32C in primary graph for
    introspection
  • Startup -gt Call JNI Method in JavaConnect DLL
    Load_Caplet()
  • Creates a new OpenCOM runtime
  • Provides Invoke() Service
  • Allows C code to Invoke Java operations
    (CtoJava see later)

Random Number Component
Subtract Component
24
Dual role of Java Connect DLL
  • Implements 5 Java Native Interface Operations 1
    Global DLL variable
  • LoadCaplet() - Create the C caplet with OCM
    runtime
  • Instantiate(CompType, CompName)
  • Load Instantiate components into C caplet
  • Connect(CompName, CompName, Interface)
  • Connect components within the C Caplet
  • Invoke(compname, Interface, method,args)
  • Call operations on Interfaces of components
    within C Caplet
  • Supports Java to C bind
  • Persistent_Reference(Java Object)
  • Manages C reference persistence versus Java
    Garbage Collection
  • Global Variable - Pointer to OCM runtime
  • Could get away without it (OCM singleton) ?
    Performance
  • JavaConnect Component
  • Created / Loaded into Caplet runtime when Caplet
    initiated
  • Interface to Continuous Queued RPC ? to support
    C to Java bind (see later)
  • Proxy to the OCM runtime ? Redirect the above DLL
    operations

25
Load component into extension caplet
  • Loader Properties
  • OpenCOMJ component implements ILOAD
  • Load(Component Type, Component Name)
  • Named LoaderWin32C in primary graph for
    introspection

Java Runtime
C Caplet
C Loader
  • Load Adder What happens ??
  • Load((Comp) Adder, (Name) CAdder)
  • Calls JNI_ Instantiate() in Java Connect DLL
  • Redirect to JavaConnect ?Calls OpenCOM
    createInstance(..) Startup()
  • Surely there is a Type mismatch ??
  • COM uses 16 byte Ids for component types not a
    string!
  • ? Use the registry to find win32 CLSID
  • Assume Java String TypeName relation to CLSID
    e.g. Adder equals CLSID_Adder equals
    89FFFCB1-FC74-481D-ACB1-3C1FE929462A

JNI-DLL Magic
C Runtime
JavaConnect DLL
JavaConnect
26
Components in Extension Caplets
  • Does the primary caplet need to maintain
    information about components in extension caplets
    ?
  • For Java/C Binding Yes (see later)
  • For Meta-space (Architecture, Interface
    Interception) - No but it will simplify
    implementation
  • To support bindings Ive applied a component
    proxy approach
  • Each component in the Extension Caplet has a
    mirror proxy in the Primary Caplet
  • In reality it is an OpenCOMJ stub (No function
    implementation)
  • Implement the interfaces of C component as JNI
    calls
  • DOWNSIDE Has to be coded
  • Feasible it could be generated from the C
    component code
  • Not dynamic e.g. ExposeInterface() of CFs lost

27
System Snapshot After Load
Calculator Component
Adder Proxy Component
C Loader
Random Number Component
Subtract Component
C Caplet
JNI-DLL Magic
C Runtime
JavaConnect DLL
C Adder Component
JavaConnect Component
28
Bind Primary to Extension (Java2C)
  • Java component has receptacle IAdd that must be
    connected to interface of C Adder
  • V2 ? Load the binder
  • However, because we have a stub in place in
    Primary
  • Connect Java component to the proxy in primary
  • Call Connect(CalcUnk, AdderUnk, IAdd)
  • Load returned Unknown pointer
  • Could Wrap this as a binder component if
    necessary
  • Is transparency good or bad here
  • Programming API v Consistent behaviour

Java Runtime
Java2C Binder
C Caplet
C Loader
JNI-DLL Magic
C Runtime
JavaConnect DLL
JavaConnect
29
Adder Proxy Example
  • public int add(int x, int y)
  • Object args new Object2
  • args0 new Integer(x)
  • args1 new Integer(y)
  • Object jresult
  • try
  • jresult invoke("Adder","1EA921FB-5FA
    B-4172-8206-
  • 1BA7880551C0","add",args)
  • catch(Java2CBindException e)
  • throw new OpenCOMReceptacleException(
    Invoke failede)
  • Integer result (Integer) jresult
  • return result.intValue()

30
Snapshot Java to C receptacle
31
Bind Extension (C) component to Primary
component (Java)
  • Surprisingly this is a much harder problem !!
    (Thanks to JNI)
  • C caplet implements a service allowing dynamic
    invocations
  • ?Use same Proxy approach again?
  • Unfortunately not
  • You cannot pass a Java reference to the C
    runtime because all JNI Operations are garbage
    collected
  • The reference is garbage collected after the JNI
    operation that called it returns
  • OKAY Lock a JNI thread pass its reference to
    the runtime fail
  • JNI references only operate in single thread of
    invocation
  • Solution Queued RPC approach

C Adder Component
IRandomNumber
?
InvokeService()
Java Random Number Component
C Caplet
32
JavaConnect Q-RPC
Persistent_Reference(Jobject Caplet)
Adder Receptacle Proxy
JavaConnect
IJavaConnect
Continous Thread
Proxy connects to Java Connect
Java Connect places each receptacle invocation in
the queue
Queue Buffer
Data in Queue ? Invoke Caplet
C Caplet
33
Example Adder receptacle proxy
  • int CAdderProxyGetRandomNumber(int x)
  • FunctionInfo newF
  • strcpy((char) newF.name, (char)
    GetRandomNumber")
  • newF.returnType VT_INT
  • newF.NoParams1
  • VARIANT v1
  • v1.vt VT_INT
  • v1.intVal x
  • newF.list0v1
  • VARIANT result
  • result.vt VT_INT
  • HRESULT hr m_pSR_IJavaConnect-gtInvokeService((L
    PSTR) RandomNumber", newF, result)
  • return result.intVal

34
Snapshot C to Java receptacle
Adder Component
IRandomNumber
Adder Receptacle Proxy
JavaConnect DLL
IJavaConnect
JavaConnect
IRandomNumber
Java Random Number Component
35
Binder Implementation
  • Create the binder component
  • OpenCOMJ component
  • Named Binder CPlusPlus2Java for Introspection
  • Invoke Bind(Adder, Random,IRandomNumber,
    intfID)
  • Loads the receptacle proxy
  • Connects proxy to JavaConnect
  • Connect Adder to its proxy

Java Runtime
C Caplet
C Loader
C2Java Binder
JNI
JNI-DLL Magic
C Runtime
C Adder
JavaConnect DLL
JavaConnect
36
Meta Space (1) Architecture
  • Standard OpenCOMJ graph view
  • Same Interface
  • Info about Components, Connections etc..
  • C proxies represent component in OpenCOM graph
  • Extend meta-architecture to enumerate Loaders,
    Binders, Caplets, Component Frameworks
  • Fails for composite C components
  • JNI_CFMetaInterface ?

IMetaArchitecture
OpenCOMJ Runtime
37
Meta Space (2) Interception
  • Add Interceptors to Java Interfaces
  • Add to proxy component direct
  • AddPre, AddPost, Enumerate
  • Pre/Post interceptors called before and after the
    JNI invocation
  • Maintain Javas improved Interception API
  • Again breaks with composite components
  • Cannot attach interceptor to internal interface

Pre Methods
Post Methods
Adder Proxy Component
38
Meta Space (3) - Interface
  • Fudged to match the Java QI interface
  • QueryInterface gives you proxy interface Not
    the interface of the component
  • Overall Meta-Space Approach Improvements
  • Loadable
  • Consistent across all caplet types
  • It just happens that Java and C integrate
    easily
  • Implement to the V2 Callback style

39
Implementation Availability
  • Java-C
  • Separate components added to Java and C
    runtimes
  • Tested in Win32 environment
  • Preliminary Testing on PPCs (CReMe JVM)
  • Available to use for prototyping
  • Issues
  • Bug in Q-RPC
  • Hit the code hard enough (10000s continuous
    receptacle calls) causes crash ? data
    synchronisation error
  • OpenCOMLinux version
  • Available for prototyping
Write a Comment
User Comments (0)
About PowerShow.com