Copyright 2005 by Codemesh, Inc. All Rights Reserved 1
Welcome
Jini and JavaSpacesin an SOA World
by
Alexander Krapf
WebTech MeetingJuly 19th, 2005
Copyright 2005 by Codemesh, Inc. All Rights Reserved 2
Speaker
Co-founder & President of Codemesh, Inc.
mostly involved with language interoperability
“interested bystander” in Jini and distributed computing
Copyright 2005 by Codemesh, Inc. All Rights Reserved 3
Agenda
What is Jini?
What is JavaSpaces?
How does it compare with Web Services?
Q & A
Copyright 2005 by Codemesh, Inc. All Rights Reserved 4
And the question is…
What is Jini?
Copyright 2005 by Codemesh, Inc. All Rights Reserved 5
Common Misconceptions…
I dream of !Jeannie
Copyright 2005 by Codemesh, Inc. All Rights Reserved 6
Common Misconceptions…
Jini is designed for devices
Jini is Java-only
Jini is not ready for primetime
Jini is not supported by Sun
Copyright 2005 by Codemesh, Inc. All Rights Reserved 7
So what is Jini?
Jini is the original SOA
Jini is Java-centric
Jini is more than ready for primetime (just ask Orbitz)
Jini is increasingly better supported by SunStill not part of J2SE platform, now available underApache 2.0 license, small (yet fiercely dedicated) team, small marketing budget
Copyright 2005 by Codemesh, Inc. All Rights Reserved 8
If Jini is one, then what is an SOA?
A system for linking resources on demand. In an SOA, resources are made available to other participants in the network as independent services that are accessed in a standardized way. This provides for more flexible loose coupling of resources than in traditional systems architectures.
An application architecture in which all functions, or services, are defined using a description language and have invokable interfaces that are called to perform business processes. Each interaction is independent of each and every other interaction and the interconnect protocols of the communicating devices (i.e., the infrastructure components that determine the communication system do not affect the interfaces). Because interfaces are platform-independent, a client from any device using any operating system in any language can use the service. Though built on similar principles, SOA is not the same as Web services, which indicates a collection of technologies, such as SOAP and XML. SOA is more than a set of technologies and runs independent of any specific technologies.
Webopedia
whatis.com
Copyright 2005 by Codemesh, Inc. All Rights Reserved 9
Common SOA characteristics…
DeviceIndependent
ProtocolIndependent*
Distributed
Stateless
Scalable
ReliableResilient
Dynamic
Secure
Easy***** to use
Interface-basedLoosely coupled
OS Independent LanguageIndependent
Copyright 2005 by Codemesh, Inc. All Rights Reserved 10
…and how Jini stacks up
Characteristic JiniOS Independence via Java
Language Independence via Codemesh tools, Judy project, …
Device Independence via Java, Surrogates, Psinaptics, …
Protocol Independence RMI is default, protocols easily pluggable
Statelessness yes, by design
Distributed yes, by design
Interface-based yes, by design
Scalable yes, more than anything free I’m aware of!
Resilient yes, more than any other architecture I’m aware of!
Reliable yes, more than any other architecture I’m aware of!
Secure yes, configurable security models (SSL, Kerberos, …)
Dynamic extremely, via Java, RMI, RIO project, …
Easy to use at least for a distributed object technology!
Copyright 2005 by Codemesh, Inc. All Rights Reserved 11
So, really, what is Jini?
the embodied consequence of Jim Waldo et als “A Note on Distributed Computing”
a specification of several core Services providing discovery, transactions, and persistence
comes packaged in a starter kit, not a reference implementation!
based on the acknowledgement that failure is a normal mode of operation!
Copyright 2005 by Codemesh, Inc. All Rights Reserved 12
Jini key concepts
Discovery/Join protocol for bootstrapping
the Service as a discoverable entity the LookupService as the gateway to every other Service
the Lease as a mechanism for resilient Service life-cycle management
Copyright 2005 by Codemesh, Inc. All Rights Reserved 13
A Typical Jini Example
public interface Hello { public String sayHello() throws RemoteException; }
The Hello Service
There is no Service interface that needsto be extended!
Copyright 2005 by Codemesh, Inc. All Rights Reserved 14
A Service Implementation
public class HelloImpl implements Hello { public String sayHello() throws RemoteException { return “Hello!”; } }
The Hello Service Implementation
Copyright 2005 by Codemesh, Inc. All Rights Reserved 15
A Server Implementation
public class HelloServer extends HelloImpl, ServerProxyTrust, ProxyAccessor { public static void main( String[] args ) { Configuration config = ConfigurationProvider.getInstance( args ); Hello serverProxy = (Hello) getExporter( config ).export(this); Proxy smartProxy = Proxy.create(serverProxy); DiscoveryManagement discovery = new LookupDiscovery( null, config ); JoinManager join = new JoinManager( smartProxy, null, getServiceID(), discovery, null, config ); }
... }
The Hello Server Implementation
Copyright 2005 by Codemesh, Inc. All Rights Reserved 16
A Client Implementation
public class HelloClient { public static void main( String[] args ) { Hello server = (Hello)lookup( Hello.class, 10 );
System.out.println( "Server says: " + server.sayHello() ); System.exit( 0 ); }
...}
The Hello Client Implementation
lookup() is ten line boilerplate code!
Copyright 2005 by Codemesh, Inc. All Rights Reserved 17
Important omitted Details…
The Hello client only leased the service
The lease interval defines the application’s reactivity to network failure Lookup can be by type and attribute
What code needs to be deployed on client?
Copyright 2005 by Codemesh, Inc. All Rights Reserved 18
A Typical Jini Example
Client
Lookup Service
Lookup Service
Looking for a Hello service
Lo
okin
g fo
r a Hello
service
“Server”
HelloImplJoin
HelloImplProxy
HelloImplProxy
Dow
nload
Proxy to Impl protocol could be anythingor even nothing! Proxy could just be a dynamically loaded interface implementation!
Copyright 2005 by Codemesh, Inc. All Rights Reserved 19
Jini Example Key Features
Scalability via multiple Service instances
Resilience via multiple Service instances and Lease mechanism
Client only requires service interface, everything else is downloaded dynamically there can but does not have to be a channel between the client and the service
any code downloads or communications can be protected by standard security
Copyright 2005 by Codemesh, Inc. All Rights Reserved 20
What’s missing?
higher-level features related to dynamic deployment, QoS/SLA of Services (RIO project, ServiceContainer project, IncaX, Valaran Inc., etc.)
Inter-Service communications
Distributed data persistence
Workflow/scheduling
JavaSpaces
Copyright 2005 by Codemesh, Inc. All Rights Reserved 21
And the question is…
What is JavaSpaces?
Copyright 2005 by Codemesh, Inc. All Rights Reserved 22
Common Misconceptions…
What do we have on the screen there lieutenant?
It must be a JSpace, captain!
j
Copyright 2005 by Codemesh, Inc. All Rights Reserved 23
Common Misconceptions…
JavaSpaces is a database
JavaSpaces is slow
JavaSpaces is a research project
Copyright 2005 by Codemesh, Inc. All Rights Reserved 24
So what is JavaSpaces?
JavaSpaces is not a database but it may optionally use one
JavaSpaces is a Jini Service thereby inheriting all Jini advantages
JavaSpaces is … JavaSpaces
a distributed object store/cache
a work orchestration/distribution mechanism
best defined through its use
Copyright 2005 by Codemesh, Inc. All Rights Reserved 25
The usual illustration…
there can be multiple space instances
read, write, take are the most common operations
no modification of entries in space (take out – modify - put back)
Copyright 2005 by Codemesh, Inc. All Rights Reserved 26
JavaSpaces key concepts
Space contains implementations of Entry
Entries are mobile Java objects, not just data! Entries are leased from the space
Entry operations can be transacted
Entries are queried by example
Copyright 2005 by Codemesh, Inc. All Rights Reserved 27
A Computation Server Example
public class Task implements Entry {
public String priority = null; public String jobid = null; public String owner = null; public Boolean done = null;
public void execute() {};}
public class ModelingTask extends Task {
public int[] inputs = null; public int[] outputs = null;
public void execute() { … }}
The interface for all computations
A concrete tasks
Copyright 2005 by Codemesh, Inc. All Rights Reserved 28
A Computation Server Example
JavaSpace space = getSpace();
ModelingTask mt1 = new ModelingTask( “NORMAL”, “job1”, “alex” ); mt1.inputs = new int[] { 10, 20, 30 };
ModelingTask mt2 = new ModelingTask( “NORMAL”, “job1”, “alex” ); mt2.inputs = new int[] { 20, 40, 60, 80 };
space.write( mt1, null, Lease.FOREVER );space.write( mt2, null, Lease.FOREVER );
Client-side: Posting the problem
Copyright 2005 by Codemesh, Inc. All Rights Reserved 29
A Computation Server Example
JavaSpace space = getSpace();
ModelingTask template = new ModelingTask( null, “job1”, null ); template.done = Boolean.TRUE;
ArrayList results = new ArrayList();long waitUntil = System.currentTimeMillis() + 60 * 1000;
while ( true ) { long maxWait = waitUntil – System.currentTimeMillis();
if( maxWait < 0 ) break;
Entry e = space.take( template, null, maxWait ); results.add( e );}
Client-side: Retrieving the solution
Copyright 2005 by Codemesh, Inc. All Rights Reserved 30
A Computation Server Example
JavaSpace space = getSpace();
Task template = new Task( null, null, null ); template.done = Boolean.FALSE;
while ( true ) { Transaction txn = createTransaction( 10 * 60 * 1000 ); try { Task t = null; t = (Task)space.take( template, txn, Long.MAX_VALUE ); if( t != null ) { t.execute(); space.write( t, txn, Lease.FOREVER ); txn.commit(); } } catch( Exception e ) { txn.abort(); }}
Server-side: Processing the problem
Copyright 2005 by Codemesh, Inc. All Rights Reserved 31
And Web Services?
Are not nearly as dynamic
Have the “industry standard” advantage
Are becoming less transparent/easy as they get closer to being an SOA Have one big advantage: language independence! (as long as a full protocol stack is available)
Codemesh JunC++ion and JuggerNET
Copyright 2005 by Codemesh, Inc. All Rights Reserved 32
Proxy-Based Solution
What does this look like at runtime?
Java Server
Service
.NET Client
Proxy’
RuntimeLibrary
Service
JVM
Proxy
ProxyProxy’
Client Process Server Process
Copyright 2005 by Codemesh, Inc. All Rights Reserved 33
Proxy-Based Solution
JVM C
JNI
DLL
GeneratedProxy
Classes(C#)
C#
PInvoke
assembly
API
.NETUser
Architectural Diagram
Copyright 2005 by Codemesh, Inc. All Rights Reserved 34
Key Differentiators
Jini provides mobile code capabilities
In Jini, you can choose where the service is run (client or server)
Smart clients are trivially easy to develop and deploy with Jini
Security available without extensions, third-party products
Copyright 2005 by Codemesh, Inc. All Rights Reserved 35
Thank you!
Codemesh, Inc.P.O.Box 620Carlisle, MA 01741
http://[email protected]
Let’s chatand have some drinks!