JavaSpaces¿ Principles, Patterns, and Practice

by ; ;
Edition: 1st
Format: Paperback
Pub. Date: 1999-06-15
Publisher(s): Addison-Wesley Professional
List Price: $39.95

Rent Book

Select for Price
There was a problem. Please try again later.

New Book

We're Sorry
Sold Out

Used Book

We're Sorry
Sold Out

eBook

We're Sorry
Not Available

How Marketplace Works:

  • This item is offered by an independent seller and not shipped from our warehouse
  • Item details like edition and cover design may differ from our description; see seller's comments before ordering.
  • Sellers much confirm and ship within two business days; otherwise, the order will be cancelled and refunded.
  • Marketplace purchases cannot be returned to eCampus.com. Contact the seller directly for inquiries; if no response within two days, contact customer service.
  • Additional shipping costs apply to Marketplace purchases. Review shipping costs at checkout.

Summary

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

Author Biography

Eric Freeman is co-founder and CTO of Mirror Worlds Technologies, a Java and Jini-based software company. Dr. Freeman previously worked at Yale University on space-based systems, and is a Fellow at Yale's Center for Internet Studies. Susanne Hupfer is Director of Product Development for Mirror Worlds Technologies and a Fellow of the Yale University Center for Internet Studies. Dr. Hupfer previously taught Java network programming as an Assistant Professor of Computer Science at Trinity College. Ken Arnold is the lead engineer of the JavaSpaces product at Sun. He is one of the original architects of the Jini platform and is co-author of The Java Programming Language, Second Edition.

Table of Contents

Preface xv
Foreword xix
Introduction
1(20)
Benefits of Distributed Computing
2(1)
Challenges of Distributed Computing
3(1)
What Is JavaSpaces Technology?
4(5)
Key Features
6(2)
JavaSpaces Technology in Context
8(1)
JavaSpaces Technology Overview
9(5)
Entries and Operations
9(2)
Going Further
11(3)
Putting It All Together
14(2)
Advantages of JavaSpaces Technologies
16(1)
Chapter Preview
17(2)
Exercises
19(2)
JavaSpaces Application Basics
21(30)
Entries
22(3)
The Entry Interface
22(1)
Instantiating an Entry
23(1)
Adding Fields and Methods
23(2)
Building an Application
25(3)
The SpaceAccessor
26(2)
Writing Entries into a Space
28(3)
A Closer Look at write
30(1)
Reading and Taking Entries
31(7)
Associative Lookup
31(1)
The Basics of read and take
32(1)
The Rules of Matching
33(2)
Dealing with null-valued Fields in Entries
35(1)
Primitive Fields
36(1)
A Closer Look at read and take
36(2)
Going Further with the Example
38(6)
Subclassing an Entry
39(1)
Adding a Few More Methods
40(2)
Trying the Game
42(2)
Post-Game Analysis
44(1)
Serialization and Its Effects
44(5)
Entry Serialization
45(2)
Matching and Equality
47(1)
The No-arg Constructor
47(1)
The Entry Interface Revisited
48(1)
Improving Entry Serialization Using snapshot
48(1)
Summary
49(2)
Building Blocks
51(24)
Introduction to Distributed Data Structures
52(4)
Building Distributed Data Structures with Entries
53(3)
Shared Variables
56(7)
Atomic Modification
57(1)
Additional Operations
58(1)
Creating a Web Counter
59(3)
Stepping Back
62(1)
Unordered Structures
63(3)
Bags
64(1)
Task Bags and Result Bags
65(1)
Ordered Structures
66(7)
Distributed Arrays Revisited
67(6)
Summary
73(1)
Exercises
74(1)
Synchronization
75(32)
Semaphores
76(5)
Implementing a Semaphore
77(2)
Implementing a License Manager
79(1)
The License Manager Installer
79(1)
The License Manager Client Library
80(1)
Using Multiple Semaphores
81(6)
The Dining Philosophers
82(5)
Fairly Sharing a Resource
87(8)
Using a Queue to Take Turns
88(4)
Round-Robin Synchronization
92(3)
Barrier Synchronization
95(2)
Advanced Synchronization: The Readers/Writers Problem
97(8)
Implementing a Readers/Writers Solution
98(1)
Implementing a Counter
99(2)
Implementing a Space-based Readers/Writers Application
101(4)
Summary
105(1)
Exercises
105(2)
Communication
107(46)
Basic Message Passing
108(5)
Playing Ping-Pong
109(4)
Characteristics of Space-based Communication
113(3)
Tightly Coupled Communication
113(1)
Loosely Coupled Communication
114(1)
Benefits of Loose Coupling
115(1)
Beyond Message Passing
116(1)
A Basic Channel
116(11)
The Channel Message
117(1)
The Channel Tail
118(1)
Creating a Channel
118(1)
Appending a Message to a Channel
119(2)
Implementing a Channel Writer
121(2)
Implementing a Channel Reader
123(3)
Demonstrating the Channel Writer and Reader
126(1)
Building a Chat Application with Channels
127(3)
The Graphical User Interface
127(1)
Combining Channel Writing and Reading
128(2)
A Consumer Channel
130(11)
Implementing a Pager Service
131(2)
The Pager Message Entry
133(1)
Tracking the Start and End of a Channel
133(1)
The Index Entry
134(1)
Creating a Consumer Channel
135(1)
Sending Messages to the Channel
136(2)
Reading and Removing Messages from the Channel
138(3)
Demonstrating the Pager
141(1)
Bounded Channels
141(8)
The Status Entry
142(1)
Channel Creation Revisited
143(1)
Writing to a Bounded Channel
144(2)
Taking from a Bounded Channel
146(2)
Demonstrating the Bounded Channel
148(1)
Summary
149(1)
Exercises
149(4)
Application Patterns
153(44)
The Replicated-Worker Pattern
153(13)
Computing the Mandelbrot Set
155(2)
Task and Result Entries
157(2)
The Master
159(5)
The Worker
164(2)
The Command Pattern
166(10)
Implementing a Compute Server
167(1)
The Generic Worker
167(2)
The Generic Master
169(1)
Creating Specialized Tasks and Results
170(3)
Creating a Specialized Master
173(2)
Running the Compute Server
175(1)
The Marketplace Pattern
176(16)
An Automobile Marketplace
176(1)
Interaction in the Marketplace
177(3)
The Bid Entry
180(1)
The Application Framework
181(1)
The Buyer
182(4)
The Seller
186(5)
Running the Marketplace
191(1)
Other Patterns
192(2)
Specialist Patterns
192(1)
Collaborative Patterns
193(1)
Summary
194(1)
Exercises
194(3)
Leases
197(20)
Leases on Entries
197(2)
The Lease Object
199(3)
Lease Expiration
200(1)
Renewing a Lease
200(1)
Cancelling a Lease
201(1)
Lease Maps
202(4)
Creating a Lease Map
202(1)
Adding and Removing Leases
203(1)
Renewing Leases
204(1)
Cancelling Leases
205(1)
Automated Lease Renewal
206(9)
The LeaseManager Interface
206(1)
Implementing the Constructors
207(1)
Adding Leases
208(1)
Cancelling a Lease
209(1)
Renewing Leases
210(1)
Checking Leases
211(2)
Processing Renewal Failures
213(1)
Putting It All Together
214(1)
Summary
215(1)
Exercises
215(2)
Distributed Events
217(20)
Events in the Distributed Environment
217(3)
Hello World Using notify
220(2)
The Notification API
222(4)
The JavaSpace notify Method
223(1)
The EventRegistration Class
224(1)
The RemoteEventListener Interface
225(1)
The RemoteEvent Object
225(1)
Putting the Pieces Together
226(8)
The Channel Relay Application
227(2)
The Channel Reader Thread
229(1)
The Relayer Listener
229(2)
The Notify Handler Thread
231(3)
Summary
234(1)
Exercises
234(3)
Transactions
237(10)
The Distributed Transaction Model
238(1)
Creating a Transaction
239(1)
Web Counter Revisited
240(3)
The Space's Transactional Properties
243(1)
Operational Semantics Under Transactions
244(2)
Writing Entries Under a Transaction
244(1)
Reading Entries Under a Transaction
245(1)
read versus readIfExists
245(1)
Taking Entries Under a Transaction
245(1)
Notifications Under Transactions
246(1)
Summary
246(1)
Exercises
246(1)
A Collaborative Application
247(34)
The Messenger
247(2)
Implementing a Messenger User
249(1)
The Account
249(5)
The Account Object
250(4)
User Sessions
254(3)
The Session Object
255(2)
Friends List
257(6)
The FriendsList Object
258(3)
The FriendsListMonitor Object
261(2)
Communication Channel
263(7)
Message Entries and Indices
263(2)
The Channel Object
265(2)
Retrieving Messages from the Channel
267(3)
The Messenger Applet
270(9)
Logging in via the Login Object
271(2)
The loginCallback Method
273(1)
Adding to the Friends List
274(1)
Chatting with Friends
275(2)
Sending Messages
277(1)
Listening for Messages
278(1)
Summary
279(1)
Exercises
279(2)
A Parallel Application
281(22)
The Compute Server
281(6)
The Command Interface Revisited
281(1)
The Task Entry
282(1)
The Generic Worker
283(2)
A Generic Master
285(2)
The Crypt Application
287(14)
Background
287(1)
The Generic Worker and Crypt Task
288(3)
The Crypt Master
291(3)
Generating Tasks
294(2)
Improving Space Usage with Watermarking
296(1)
Collecting Results
297(2)
A Little Poison
299(2)
Exploring Crypt
301(1)
Summary
301(1)
Exercises
302(1)
Further Exploration
303(4)
Online Resources
303(1)
Related Java and Jini Technologies
304(1)
Background Reading
304(1)
Distributed Systems
304(1)
Transactions
305(1)
Historical Resources
305(2)
Appendix A: The Jini™ Entry Specification 307(6)
A.1 Entries and Templates
307(6)
A.1.1 Operations
307(1)
A.1.2 Entry
308(1)
A.1.3 Serializing Entry Objects
308(1)
A.1.4 UnusableEntryException
309(2)
A.1.5 Templates and Matching
311(1)
A.1.6 Serialized Form
311(1)
A.1.7 Comments
311(2)
Appendix B: The Jini™ Entry Utilities Specification 313(2)
B.1 Entry Utilities
313(2)
B.1.1 AbstractEntry
313(1)
B.1.2 Serialized Form
314(1)
B.1.3 Comments
314(1)
Appendix C: The JavaSpaces™ Specification 315(19)
C.1 Introduction
315(8)
C.1.1 The JavaSpaces Application Model and Terms
315(3)
C.1.2 Benefits
318(1)
C.1.3 JavaSpaces Technology and Databases
319(1)
C.1.4 JavaSpaces System Design and Linda Systems
320(2)
C.1.5 Goals and Requirements
322(1)
C.1.6 Dependencies
322(1)
C.1.7 Comments
323(1)
C.2 Operations
323(7)
C.2.1 Entries
323(1)
C.2.2 net.jini.space.JavaSpace
323(3)
C.2.3 write
326(1)
C.2.4 readIfExists and read
326(1)
C.2.5 takeIfExists and take
327(1)
C.2.6 snapshot
327(1)
C.2.7 notify
328(1)
C.2.8 Operation Ordering
329(1)
C.2.9 Serialized Form
330(1)
C.3 Transactions
330(2)
C.3.1 Operations Under Transactions
330(1)
C.3.2 Transactions and ACID Properties
331(1)
C.4 Further Reading
332(2)
C.4.1 Linda Systems
332(1)
C.4.2 The Java Platform
333(1)
C.4.3 Distributed Computing
333(1)
Index 334

Excerpts

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 aspace,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 CodeThe 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.2which 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.0both of which are avai

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

Digital License

You are licensing a digital product for a set duration. Durations are set forth in the product description, with "Lifetime" typically meaning five (5) years of online access and permanent download to a supported device. All licenses are non-transferable.

More details can be found here.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.