Home > Store

JavaSpaces Principles, Patterns, and Practice

Register your product to gain access to bonus material or receive a coupon.

JavaSpaces Principles, Patterns, and Practice

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 1999
  • Dimensions: 7-3/8" x 9-1/4"
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-30955-6
  • ISBN-13: 978-0-201-30955-3

"Ever since I first saw David Gelernter's Linda programming language almost twenty years ago, I felt that the basic ideas of Linda could be used to make an important advance in the ease of distributed and parallel programming. As part of the fruits of Sun's Jini project, we now have the JavaSpaces technology, a wonderfully simple platform for developing distributed applications that takes advantage of the power of the Java programming language. This important book and its many examples will help you learn about distributed and parallel programming. I highly recommend it to students, programmers, and the technically curious." Bill Joy, Chief Scientist and co-founder, Sun Microsystems, Inc.

JavaSpaces technology, a powerful Jini service from Sun Microsystems, facilitates building distributed applications for the Internet and Intranets. The JavaSpaces model involves persistent object exchange "areas" in which remote processes can coordinate their actions and exchange data. It provides a necessary ubiquitous, cross-platform framework for distributed computing, emerging as a key technology in this expanding field.

This book introduces the JavaSpaces architecture, provides a definitive and comprehensive description of the model, and demonstrates how to use it to develop distributed computing applications. The book presents an overview of the JavaSpaces design and walks you through the basics, demonstrating key features through examples. Every aspect of JavaSpaces programming is examined in depth: entries, distributed data structures, synchronization, communication, application patterns, leases, distributed events, and transactions.

You will find information on such vital topics as:

  • Distributed data structures
  • Synchronization techniques
  • Loosely coupled communication
  • Message passing
  • Channel data structures for communication
  • Application patterns such as replicated worker, command pattern, and marketplace
  • Leases and automated lease renewal
  • Using distributed events with spaces
  • Handling partial failure with distributed transactions
  • The official JavaSpaces specification from Sun Microsystems

JavaSpaces Principles, Patterns, and Practice also includes two full-scale applications--one collaborative and the other parallel--that demonstrate how to put the JavaSpaces model to work.



0201309556B04062001

Downloads

Source Code

JavaSpaces Principles, Patterns, and Practice also includes two full-scale applications--one collaborative and the other parallel--that demonstrate how to put the JavaSpaces model to work. Download the example code

Sample Content

Table of Contents

(Most chapters conclude with a Summary and Exercises.)

1. Introduction.

Benefits of Distributed Computing.

Challenges of Distributed Computing.

What Is JavaSpaces Technology?

Key Features.

JavaSpaces Technology in Context.

JavaSpaces Technology Overview.

Entries and Operations.

Going Further.

Putting It All Together.

Advantages of JavaSpaces Technologies.

Chapter Preview.



2. JavaSpaces Application Basics.

Entries.

The Entry Interface.

Instantiating an Entry.

Adding Fields and Methods.

Building an Application.

The SpaceAccessor.

Writing Entries into a Space.

A Closer Look at write.

Reading and Taking Entries.

Associative Lookup.

The Basics of read and take.

The Rules of Matching.

Dealing with null-valued Fields in Entries.

Primitive Fields.

A Closer Look at read and take.

Going Further with the Example.

Subclassing an Entry.

Adding a Few More Methods.

Trying the Game.

Post-Game Analysis.

Serialization and Its Effects.

Entry Serialization.

Matching and Equality.

The No-arg Constructor.

The Entry Interface Revisited.

Improving Entry Serialization Using snapshot.



3. Building Blocks.

Introduction to Distributed Data Structures.

Building Distributed Data Structures with Entries.

Shared Variables.

Atomic Modification.

Additional Operations.

Creating a Web Counter.

Stepping Back.

Unordered Structures.

Bags.

Task Bags and Result Bags.

Ordered Structures.

Distributed Arrays Revisited.



4. Synchronization.

Semaphores.

Implementing a Semaphore.

Implementing a License Manager.

The License Manager Installer.

The License Manager Client Library.

Using Multiple Semaphores.

The Dining Philosophers.

Fairly Sharing a Resource.

Using a Queue to Take Turns.

Round-Robin Synchronization.

Barrier Synchronization.

Advanced Synchronization: The Readers/Writers Problem.

Implementing a Readers/Writers Solution.

Implementing a Counter.

Implementing a Space-based Readers/Writers Application.



5. Communication.

Basic Message Passing.

Playing Ping-Pong.

Characteristics of Space-based Communication.

Tightly Coupled Communication.

Loosely Coupled Communication.

Benefits of Loose Coupling.

Beyond Message Passing.

A Basic Channel.

The Channel Message.

The Channel Tail.

Creating a Channel.

Appending a Message to a Channel.

Implementing a Channel Writer.

Implementing a Channel Reader.

Demonstrating the Channel Writer and Reader.

Building a Chat Application with Channels.

The Graphical User Interface.

Combining Channel Writing and Reading.

A Consumer Channel.

Implementing a Pager Service.

The Pager Message Entry.

Tracking the Start and End of a Channel.

The Index Entry.

Creating a Consumer Channel.

Sending Messages to the Channel.

Reading and Removing Messages from the Channel.

Demonstrating the Pager.

Bounded Channels.

The Status Entry.

Channel Creation Revisited.

Writing to a Bounded Channel.

Taking from a Bounded Channel.

Demonstrating the Bounded Channel.



6. Application Patterns.

The Replicated-Worker Pattern.

Computing the Mandelbrot Set.

Task and Result Entries.

The Master.

The Worker.

The Command Pattern.

Implementing a Compute Server.

The Generic Worker.

The Generic Master.

Creating Specialized Tasks and Results.

Creating a Specialized Master.

Running the Compute Server.

The Marketplace Pattern.

An Automobile Marketplace.

Interaction in the Marketplace.

The Bid Entry.

The Application Framework.

The Buyer.

The Seller.

Running the Marketplace.

Other Patterns.

Specialist Patterns.

Collaborative Patterns.



7. Leases.

Leases on Entries.

The Lease Object.

Lease Expiration.

Renewing a Lease.

Cancelling a Lease.

Lease Maps.

Creating a Lease Map.

Adding and Removing Leases.

Renewing Leases.

Cancelling Leases.

Automated Lease Renewal.

The LeaseManager Interface.

Implementing the Constructors.

Adding Leases.

Cancelling a Lease.

Renewing Leases.

Checking Leases.

Processing Renewal Failures.

Putting It All Together.



8. Distributed Events.

Events in the Distributed Environment.

Hello World Using notify.

The Notification API.

The JavaSpace notify Method.

The EventRegistration Class.

The RemoteEventListener Interface.

The RemoteEvent Object.

Putting the Pieces Together.

The Channel Relay Application.

The Channel Reader Thread.

The Relayer Listener.

The Notify Handler Thread.



9. Transactions.

The Distributed Transaction Model.

Creating a Transaction.

Web Counter Revisited.

The Spaceis Transactional Properties.

Operational Semantics Under Transactions.

Writing Entries Under a Transaction.

Reading Entries Under a Transaction.

read versus readIfExists.

Taking Entries Under a Transaction.

Notifications Under Transactions.



10. A Collaborative Application.

The Messenger.

Implementing a Messenger User.

The Account.

The Account Object.

User Sessions.

The Session Object.

Friends List.

The FriendsList Object.

The FriendsListMonitor Object.

Communication Channel.

Message Entries and Indices.

The Channel Object.

Retrieving Messages from the Channel.

The Messenger Applet.

Logging in via the Login Object.

The loginCallback Method.

Adding to the Friends List.

Chatting with Friends.

Sending Messages.

Listening for Messages.



11. A Parallel Application.

The Compute Server.

The Command Interface Revisited.

The Task Entry.

The Generic Worker.

A Generic Master.

The Crypt Application.

Background.

The Generic Worker and Crypt Task.

The Crypt Master.

Generating Tasks.

Improving Space Usage with Watermarking.

Collecting Results.

A Little Poison.

Exploring Crypt.



12. Further Exploration.

Online Resources.

Related Java and Jini Technologies.

Background Reading.

Distributed Systems.

Transactions.

Historical Resources.



Appendix A: The Jini(TM) Entry Specification.

Entries and Templates.

Operations.

Entry.

Serializing Entry Objects.

Unusable Entry Exception.

Templates and Matching.

Serialized Form.

Comments.



Appendix B: The Jini(TM) Entry Utilities Specification.

Entry Utilities.

Abstract Entry.

Serialized Form.

Comments.



Appendix C: The JavaSpaces(TM) Specification.

Introduction.

The JavaSpaces Application Model and Terms.

Benefits.

JavaSpaces Technology and Databases.

JavaSpaces System Design and Linda Systems.

Goals and Requirements.

Dependencies.

Comments.

Operations.

Entries.

net.jini.space.JavaSpace.

write.

readIfExists and read.

takeIfExists and take.

snapshot.

notify.

Operation Ordering.

Serialized Form.

Transactions.

Operations Under Transactions.

Transactions and ACID Properties.

Further Reading.

Linda Systems.

The Java Platform.

Distributed Computing.



Index. 0201309556T04062001

Preface

Over the next decade the computing landscape will change dramatically as devices become ubiquitous, network-connected, and ready to communicate. As the landscape changes, the way in which we design and build software will change as well: The distributed application (one that involves multiple processes and devices) will become the natural way we build systems, while the standalone desktop application will become nearly extinct.

Designing distributed software is remarkably hard, however. The fundamental characteristics of a networked environment (such as heterogeneity, partial failure, and latency) and the difficulty of "gluing together" multiple, independent processes into a robust, scalable application present the programmer with many challenges that don't arise when designing and building desktop applications.

JavaSpaces(TM) technology is a simple, expressive, and powerful tool that eases the burden of creating distributed applications. Processes are loosely coupled--communicating and synchronizing their activities using a persistent object store called a space, rather than through direct communication. This method of coordinating distributed processes leads to systems that are flexible, scalable, and reliable. While simple, the space-based model is powerful enough to implement advanced distributed applications--from e-commerce systems to groupware to heavy-duty parallel computations. Space-based programming also leverages the Jini(TM) technology's leasing, distributed event, and transaction features, making it suitable for building robust, commercial-quality distributed systems.

This book teaches you how to use JavaSpaces technology to design and build distributed applications. It is intended for computer professionals, students, and Java enthusiasts--anyone who wants experience building networked applications. Through experimentation with the code examples, you'll develop a repertoire of useful techniques and patterns for creating space-based systems. We assume that you already have some programming experience and basic working knowledge of Java programming language fundamentals, but this book doesn't require any specific knowledge of network programming.

JavaSpaces technology is new, and writing a book before the technology is in widespread use presents a unique challenge. We've approached the project from complementary perspectives. Two of the authors, Eric Freeman and Susanne Hupfer, spent much of the past decade designing and building space-based systems as part of the Linda research group at Yale University and used the JavaSpaces technology during the two years of its development. The third, Ken Arnold, was in charge of the JavaSpaces project at Sun Microsystems, working with a team of engineers to design and build the technology this book is all about.

In this book, we present the foundations of programming with JavaSpaces technology, and a set of common patterns and frameworks for approaching space-based programs. As the technology becomes more widely used, the JavaSpace programming community will discover new ways of using it. We would like future editions of this book to incorporate these new patterns, and we invite you to send comments, suggestions, and ideas to javaspaces@awl.com and to make use of the book's web site at http://java.sun.com/docs/books/jini/javaspaces.

How to Access And Run the Example Code

The code examples in this book have been compiled and run against the following packages from Sun Microsystems:

  • The Java(TM) 2 SDK, Standard Edition, v1.2

which is available for download at http://www.java.sun.com/products/, and

  • The Jini Technology Starter Kit (JSK) release 1.0
  • The JavaSpaces Technology Kit (JSTK) release 1.0

both of which are available for download at http://java.sun.com/docs/books/jini/javaspaces. This site is the official web site for the book and contains links to resources and information relating to the JavaSpaces technology, errata, and supplementary material generated after this book went to press.

Acknowledgments

We are indebted to many people for their contributions to the development of the JavaSpaces technology. Bill Joy pushed the Linda-style distributed computing idea hard enough to make Sun take it seriously. Jim Waldo, Ann Wollrath, Roger Riggs, and Bob Scheiffler worked on the design, with input from Peter Jones. Gary Holness and John McClain joined the JavaSpaces implementation team and made a difference both in the detailed semantics and the implementation design. Bob Resendes joined near the end but was important in getting the product finished, and Jimmy Torres and Frank Barnaby built and ran the release processes that got the it out the door. And, of course, nothing could have been done without Helen Leary, but then, nothing ever is.

We are equally grateful to the many people who helped us turn the idea for this book into a reality. We especially want to thank our editor Mike Hendrickson at Addison-Wesley and Series editor Lisa Friendly at Sun Microsystems, who both recognized the value of the project early on. Mike provided enthusiastic support, ideas, push and encouragement along the way. Lisa held the book to the highest standards.

The team at Addison-Wesley was an enormous help at every stage of the project. In particular, Marina Lang and Julie DeBaggis were supportive, made the publishing process run smoothly, and steered us clear of many potholes. Without the dedicated efforts of Sarah Weaver, Marty Rabinowitz, Diane Freed, Bob Russell, Tracy Russ, Katherine Kwack, Sara Connell, Simone Payment, and others working behind the production and marketing scenes, this book would not have been possible.

A number of reviewers greatly improved the bookis content through their careful reading and helpful suggestions. Jen McGinn supplied a thorough technical and editorial review, and was instrumental in refining our usage of Sun Microsystems trademarks. Bob Resendes, Gary Holness, and John McClain provided in-depth technical review of the manuscript based on their intimate knowledge of the technology. Andreas Doerr, Laird Dornin, Howard Lee Harkness, Bruce Hopkins, Pascal Ledru, and Nigel Warren contributed useful technical and editorial commentary. Our appreciation also goes to Elisabeth Freeman for her careful reading of many drafts, and to Peter Sparago for his comments.

The wonderful illustrations throughout the book are due to the creative energy and talent of Jim Dustin. Tony Welch of Sun Microsystems gave helpful advice on the use of trademarks in the illustrations.

We also wish to thank the Jini team at Sun Microsystems, in particular Mark Hodapp and Theresa Lanowitz, who were generous with their time and assistance.

Finally, we'd especially like to thank David Gelernter, who planted the seed for the JavaSpaces technology nearly two decades ago, and who was supportive of this book throughout its development.



0201309556P04062001

Updates

Errata

Click below for Errata related to this title:
Errata

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020