1 / 30

Jini and JavaSpaces as an Enterprise Knowledge Base System

Learn how to create an enterprise knowledge base system using Jini and JavaSpaces. Discover the benefits, review the technologies involved, and get insights into application architecture and implementation. Explore the experimental approach and understand the significance of community-friendly knowledge bases.

Download Presentation

Jini and JavaSpaces as an Enterprise Knowledge Base System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Jini and JavaSpaces as an Enterprise Knowledge Base System O’Reilly Conference on Java Jason Monberg President Carbon Five Jason@carbonfive.com

  2. Introduction Jason Monberg Carbon Five

  3. Project Background • Experiment with Jini and JavaSpaces • Widely applicable problem • Work in progress • What we have experienced and learned

  4. Presentation Structure • 25% Review: Jini, JavaSpaces, Knowledge Base • 70% Application Implementation • 5% Resources, Questions

  5. Jini Review • Lookup Service • Services register • Clients discover and lookup and lookup services • Events and Transactions • Services (Includes Lookup Service) • Lease Jini resources • Register by supplying info and code • Client • Discovery - Bootstrap • Lookup Service using templates • Access Service through downloaded java code • Interact directly with the service

  6. response (unicast) announce (multicast) response (unicast) service ID 01010 01010 request (multicast) register request (unicast) Jini Enabled Service Lookup Service 01010 01010 Jini Interaction Diagram Jini Core 01010 Client 01010

  7. Jini Benefits • Spontaneous and Self recovering • Services come and go • No Jini administration required • ‘Plug and Play’ • Redundant • Scalable • Instances • Performance • Java as proxy for *

  8. JavaSpaces Review • A Jini Service • Distributed Shared Memory • Replication • Persistent Storage • Object Based • Search • Entry: values, class, superclass, interface… • Entry Interface • Tagging Interface, no methods • Public Objects, no primitives • Write, Read, Take - IfExists

  9. Lookup Service 01010 JavaSpaces Diagram Jini Core 01010 JavaSpace Service Client 01010 01010

  10. Knowledge Base Review • Data Store • Data Management • Data Analysis  Knowledge • Implemented Store and Management • Plans for Analysis

  11. Summary and Motive • Jini • Lookup Services, Additional Knowledge Base Services • JavaSpaces • Object Storage • Knowledge Base • Application • Motive • Needed tool to store, share, and manage information • Community friendly knowledge base • Emerging technology • Learn best by doing, experiments!

  12. Application Architecture • Security • HTTP – Resin • RMID • Jini Services: Lookup, Transaction (not used directly), JavaSpaces • Custom Services • Custom Client

  13. Architecture Diagram Jini Server HTTP – Caucho’s Resin RMI Activation Daemon Client Jini Services Jini Specific Lookup: Reggie Transaction Manager: Mahalo JavaSpaces – Front-end: Outrigger Custom Services…

  14. Discovering Services • Jini Service Discovery and Lookup • LookupDiscoveryManager • New in Jini 1.1 • Manages Discovery • multicast request … groups • unicast request. … names • Manages ServiceRegistrars

  15. public class JavaSpaceManager { // initialization of groups, locator and DiscoveryListener // and then start discovering! . . . // Kickoff the discovery process public void startDiscovery() { // Create the LookupDiscoveryManager try { // groups=LDM.ALL_GROUPS, locators = null lstnr = JavaSpacesListener discoveryManager = new LookupDiscoveryManager(groups, locators, discoveryListener); } catch (IOException e) { System.out.println("Creating Lookup DiscoveryListener " + e); } } public JavaSpace getJavaSpace() { . . . } public void setJavaSpaceDiscoveryListener(OxJavaSpaceDiscoveryListener discoveryListener) { . . . } CODE SAMPLE: Discovery and Lookup I – Wrap LDM public class JavaSpaceManager { // initialization of groups, locator and DiscoveryListener // and then start discovering! . . . // Kickoff the discovery process public void startDiscovery() { // Create the LookupDiscoveryManager try { // groups=LDM.ALL_GROUPS, locators = null lstnr = JavaSpacesListener discoveryManager = new LookupDiscoveryManager(groups, locators, discoveryListener); } catch (IOException e) { System.out.println("Creating Lookup DiscoveryListener " + e); } } public JavaSpace getJavaSpace() { . . . } public void setJavaSpaceDiscoveryListener(OxJavaSpaceDiscoveryListener discoveryListener) { . . . }

  16. public class JavaSpaceDiscoveryListener implements DiscoveryListener { public Class [] types = new Class[] { JavaSpace.class }; public ServiceTemplate tmpl = new ServiceTemplate(null, types, null); . . . public void discovered(DiscoveryEvent e) { //When we find a ServiceRegistrar, try to find a JavaSpace regs = e.getRegistrars(); javaSpace = getJavaSpace(); } public JavaSpace getJavaSpace() { if (javaSpace == null) { javaSpace = (JavaSpace)lookForService(regs, tmpl); } return javaSpace; } public Object lookForService(ServiceRegistrar lusvc[], ServiceTemplate tmpl) { //uses ServiceRegistrar.lookup(ServiceTemplate to find services . . . o = lusvc[0].lookup(tmpl); return o; } public class JavaSpaceDiscoveryListener implements DiscoveryListener { . . . public void discovered(DiscoveryEvent e) { //When we find a ServiceRegistrar, try to find a JavaSpace regs = e.getRegistrars(); javaSpace = getJavaSpace(); } public JavaSpace getJavaSpace() { if (javaSpace == null) { javaSpace = (JavaSpace)lookForService(regs, tmpl); } return javaSpace; } public Object lookForService(ServiceRegistrar lusvc[], ServiceTemplate tmpl) { //uses ServiceRegistrar.lookup(ServiceTemplate to find services . . . o = lusvc[0].lookup(tmpl); return o; } CODE SAMPLE: Discovery and Lookup II – JSDL public class JavaSpaceDiscoveryListener implements DiscoveryListener { public Class [] types = new Class[] { JavaSpace.class }; public ServiceTemplate tmpl = new ServiceTemplate(null, types, null); . . . public void discovered(DiscoveryEvent e) { //When we find a ServiceRegistrar, try to find a JavaSpace regs = e.getRegistrars(); javaSpace = getJavaSpace(); } public JavaSpace getJavaSpace() { if (javaSpace == null) { javaSpace = (JavaSpace)lookForService(regs, tmpl); } return javaSpace; } public Object lookForService(ServiceRegistrar lusvc[], ServiceTemplate tmpl) { //uses ServiceRegistrar.lookup(ServiceTemplate to find services . . . o = lusvc[0].lookup(tmpl); return o; }

  17. Storing Data • Long term storage • Front-end space • Non-transactional • Available but not used • Entry Implementation • JavaSpaces write • Entry, transaction, lease

  18. CODE SAMPLE: Entry Implementation public class OxEntry implements Entry { //data fields public Long timestamp = null; public String group = null; public String name = null; public String body = null; public StringBuffer notes = null; public ArrayList links = null; public ArrayList files = null //includes display fields //includes xml container . . . //takes the current data in the object and establishes the xml representation public void syncOxml() { . . . } public String getOxml() { . . .} public void addLink(String link) { . . . } public String getLinks() { . . . } public void setName(String name) { . . . } public String getName() { . . .} public void appendNote(String note) { . . .} public String getNotes() { . . . } } public class OxEntry implements Entry { //data fields public Long timestamp = null; public String group = null; public String name = null; public String body = null; public StringBuffer notes = null; public ArrayList links = null; public ArrayList files = null //includes display fields //includes xml container . . . //takes the current data in the object and establishes the xml representation public void syncOxml() { . . . } public String getOxml() { . . .} public void addLink(String link) { . . . } public String getLinks() { . . . } public void setName(String name) { . . . } public String getName() { . . .} public void appendNote(String note) { . . .} public String getNotes() { . . . } }

  19. Reading and Searching • JavaSpaces object retrieval model • Templates • Entry • Exact matching vs. Pattern Matching • Take vs. Read • First object found • The Great Work Around: • Retrieving groups of entry objects

  20. CODE SAMPLE: Retrieving Result-set Groups public Vector readAllSpace(Entry tmpl) { //verify space is available Vector vec = new Vector(); try { // tmpl – Entry template for matching, null – txn, 1000 – timeout OxEntry token = (OxEntry)space.takeIfExists(tmpl, null, 1000); while (token != null) { vec.add(token); token = (OxEntry)space.takeIfExists(tmpl, null, 1000); } OxEntry[] tmp = new OxEntry[vec.size()]; tmp = (OxEntry[])vec.toArray(tmp); for (int i = 0; i < tmp.length; i++ ) { writeSpace( space, tmp[i] ); } return vec; } catch (IOException e) {} catch (UnusableEntryException e) {} catch (TransactionException e) {} catch (InterruptedException e) {} return null; } public Vector readAllSpace(Entry tmpl) { //verify space is available Vector vec = new Vector(); try { // tmpl – Entry template for matching, null – txn, 1000 – timeout OxEntry[] tmp = new OxEntry[vec.size()]; tmp = (OxEntry[])vec.toArray(tmp); for (int i = 0; i < tmp.length; i++ ) { writeSpace( space, tmp[i] ); } return vec; } catch (IOException e) {} catch (UnusableEntryException e) {} catch (TransactionException e) {} catch (InterruptedException e) {} return null; } public Vector readAllSpace(Entry tmpl) { //verify space is available Vector vec = new Vector(); try { // tmpl – Entry template for matching, null – txn, 1000 – timeout OxEntry token = (OxEntry)space.takeIfExists(tmpl, null, 1000); while (token != null) { vec.add(token); token = (OxEntry)space.takeIfExists(tmpl, null, 1000); } OxEntry[] tmp = new OxEntry[vec.size()]; tmp = (OxEntry[])vec.toArray(tmp); for (int i = 0; i < tmp.length; i++ ) { writeSpace( space, tmp[i] ); } return vec; } catch (IOException e) {} catch (UnusableEntryException e) {} catch (TransactionException e) {} catch (InterruptedException e) {} return null; }

  21. Alt Result Set Retrieval • Entry Tagging • Simultaneous searches? • Transaction Wrapping • Data locking • Take if exists • Client data loss risk • Service oriented searches • Optimize with snapshot() • Other Ideas?

  22. Displaying Data • XML/XSLT • HTML • Swing • Self Aware vs. Interpreters

  23. Updates and Notes • Simple management of data updates within workgroup • Adding Notes to Entries • Embedded Text vs. Appending Objects • Time based • Updating Entries • Update contention • get time (read) > last pub time (current) • Rely on Take – could lose data • Event Based Client Synchronization

  24. Connecting Data • Object Relationships • Easier than RDBM • Automatic Relationship • Implicit search relationships • Explicit automatic relationships • Through a service • Arbitrary Relationships • User imposed relationships

  25. Data Integration Services • File Structure Information Stores • Service to integrate data from existing file store • Heterogeneous Data Stores • File Based • RDBMS • Object DB • Peer to Peer

  26. Lookup Service 01010 Data IntegrationService Diagram RDBMS File Store Jini Lookup Service 01010 01010 Data Integration Service events 01010 events JavaSpace Service Client 01010 01010 01010

  27. Jini in Practice • Administration of the Carbon Five Knowledge Base system • Set-up vs. Using • The ‘kill’ script • Distributed Environments • Most coding is on client side • Quiet Period

  28. Conclusions • Pros • Abstract access to data • Object based • Simple and powerful service and leasing mechanism • JavaSpaces similar to object data base or xml server • Cons • Poor searching support • Performance • Production use growing slowly • Gotchas • Understand set-up • Code Defensively – network resources come and go

  29. Additional Resources • Online • www.jini.org/ • www.litefaden.com/sv/jd/ • www.javacoffeebreak.com/books/extracts/jini/jini.html • www.artima.com/jini/ - Bill Venners • www.carbonfive.com/oreilly - This Presentation • Books • Core Jini, 2nd Edition • W. Keith Edwards • A Programmers Guide to Jini Technology • Jan Newmarch • The Jini Specifications, 2nd Edition • Jim Waldo • JavaSpaces Principles, Patterns, and Practice • Freeman, Hupfer, Arnold

  30. Questions ?

More Related