JavaSpaces

  Search Here
Searching XAP 6.0 Documentation

                                               

Section Summary: JavaSpaces is the native API of the space, based on four methods: write(), read(), take(), and notify(). JavaSpaces supports local and distributed transactions, and allows applications to register for notifications on space data.

Overview

JavaSpaces is a service specification from Sun Microsystems that provides a simple yet powerful infrastructure for building distributed applications. The JavaSpaces specification defines a reliable distributed repository for objects, along with support for distributed transactions, events and leasing. In the JavaSpaces programming model, applications are viewed as a group of processes, cooperating via the flow of objects into and out of spaces.

The JavaSpaces API provides software developers with a simple and effective tool for solving coordination problems in distributed systems, especially in domains like parallel processing and distributed persistence. The developer designs the solution as a flow of objects instead of a traditional request/reply message-based scenario.

JavaSpaces is an integral part of Jini (see specification). A contributed source, Outrigger, is bundled with Sun's Jini Starter Kit.

Inspired by David Gelernter's Tuple-Spaces

JavaSpaces is based on the concept of Tuple-Spaces, first described in 1982 in the Linda programming language and system, originally propounded by Dr. David Gelernter at Yale University. The public-domain Linda system is a coordination language that expresses parallel processing algorithms without reference to any specific computer or network architecture. The Linda system also provides inter-process coordination via virtual shared memories, or tuple-spaces, that can be accessed associatively.

The tuple-space model is especially useful for concurrent algorithms. Although JavaSpaces technology is strongly influenced by the Linda system, it differs from it in several ways. For example, Java contains richer typing, object orientation, subtype matching, and transactional support spanning multiple spaces, leasing, and events.

The JavaSpaces API

The JavaSpaces API consists of 4 main method types:

  • write() – writes an entry to a space.
  • read() – reads an entry from a space.
  • take() – reads an entry and deletes it from a space.
  • notify() – registers interest in entries arriving at a space.

In addition, the API enables JavaSpaces' clients (applications) to provide optimization hints to space implementation (the snapshot method).

This minimal API set reduces the learning curve, making it easier to adopt JavaSpaces. The API is also natural to Jini developers, since it is built on top of Jini specifications (entries, leases, service, etc.). Jini itself is built on Java and RMI, so there is no need to understand complex distributed Java technologies, like EJB or CORBA.

Transactions

JavaSpaces enables full use of transactions, leveraging the default semantics of the Jini Distributed Transactions model. Developers can build transactional, secure distributed applications using JavaSpaces as a coordination mechanism. Since Jini transactions can span more than one Jini Service, and a JavaSpace instance is a Jini Service, a transaction may span more than one space.

Block Time

The JavaSpaces read and take operations can block for a user-defined period of time, in case no matching Entry is found in the space. This allows application instances to wait for data to be written by other instances. Defining a limited block time prevents the application from being blocked indefinitely in case the data does not arrive or the space is in deadlock.

Leases

JavaSpaces also makes extensive use of Jini leases, as it mandates leasing of entries in the space (they expire at a certain time unless renewed by a client). This eliminates out-of-date entries and removes the need for manual cleanup administration work.

Notifications

JavaSpaces notifications are a great tool for developers who wish to build event-driven, distributed applications. The notifications make use of Jini Remote Events, thus enabling a large number of event-handling design patterns, like the famous Jini MailBox Service.

Section Contents

  • About EntriesAn Entry is a typed set of objects, each of which may be tested for exact match with a template.
  • About JiniJini is an open architecture that allows the implementation of network services - One such service is JavaSpaces.
  • About Space OperationsA description of Entries, templates, the four primary kinds of operations – write, read, take, and notify, and the UpdateModifiers.UPDATE_OR_WRITE modifier.
  • Batch OperationsAn extension of the JavaSpaces API, enabling operations with multiple objects in one call.
  • Compute Server - Master-Worker PatternDemonstrates how the master-worker is used to implement a parallel computing engine that calculates whether or not a given number is prime.
  • Continuous QueryEnables continuous queries of the space with advanced matching, including boolean operators and inequalities.
  • Custom Query PatternThe purpose of the custom query pattern is to extend the existing query capabilities by enabling users to write code and execute it as part of the query path.
  • ExternalEntryA wrapper that allows any Java class to be written to the space, even if it does not comply with JavaSpaces requirements.
    • IGSEntryEach instance of this class contains a reference to the Entry value plus any other necessary information about the Entry; including its class name, field types, and field values.
  • Externalizable SupportUsing Externalizable to boost remote space performance with JavaSpaces operations.
  • FIFO SupportHow to get objects in the same order in which they were written to the space.
  • Inheritance SupportGigaSpaces provides implicit access to the inheritence capabilities in the JavaSpaces specification.
  • JavaSpaces IteratorUsed to read objects matching multiple templates in one call.
  • JavaSpaces NotificationsRegistering to receive notifications when objects are added or modified in the space – unicast, multicast and tokenized notifications.
    • JavaSpaces Multicast NotificationsIP supports multicasting, where a source device can send to a group of devices. With Multicast, traffic is sent to a single address, but is processed by multiple hosts.
    • JavaSpaces Tokenized NotificationsThe NotifyDelegator is a convenient and efficient mechanism for registering notifications. These notifications are delivered as remote events for matching Entries.
  • JavaSpaces POJOGigaSpaces JavaSpaces API Plain Old Java Object support - the POJO.
  • JavaSpaces Transaction SupportHow to use distributed transactions (with Jini Transaction Manager), or local transactions.
    • Jini Transaction ManagerThe Jini Distributed Transactions provide a two-phase commit protocol.
    • Local Transaction ManagerThe transactional operation enables distributed transactions - i.e. performing a series of operations on several distributed transactional resources in a single logical transaction.
    • XA Transaction SupportThe XA specification and its Java version (JTA) introduce a standard way to control and manage distributed transactions among different participants.
  • JavaSpaces UID SupportHow to access space objects using their unique identifiers (UID).
  • Managing Resources LeaseThe LeaseRenewalManager provides systematic renewal and overall management of a set of leases associated with one or more remote entities on behalf of a local entity.
  • Moving From Outrigger to GigaSpacesHow to migrate from Outrigger with no re-compilation or re-deployment of code to clients.
  • Partial UpdateUpdating only some of the fields of an object in the space.
  • POJO Class and Field Level AnnotationsPOJO class and field level decorations using annotations and XML configuration files.
  • Querying the SpaceAn extension to the JavaSpaces API which allows object matching by SQL syntax or regular expression.
  • Schema EvolutionThe space schema can be evolved using codebase downloading and Java extentions, or an explicit data migration process.
  • Session Based Messaging APIThe new Notify Session API provides a unified and consistent mechanism for event registration.
  • Space Administration APIAllows applications to start and stop a space; get status, statistics, and cluster mode; and shutdown a container.
  • Space Locking and BlockingUsing optimistic and pessimistic locking to preserve the integrity of changes in multi-user scenarios.
    • GigaSpaces Read ModifiersGigaSpaces EXCLUSIVE_READ_LOCK, READ_COMMITTED, DIRTY_READ, and REPEATABLE_READ modifiers.
    • Optimistic LockingWith optimistic locking, you write your program under the assumption that an update operation has a chance of failing, if your updated object has been changed by someone else since you read it.
    • Pessimistic LockingIn the pessimistic locking approach, your program must explicitly obtain a lock using transaction on one or more objects before making any changes.
  • Typical JavaSpaces WorkflowHow an application allocates a space and then uses the space to share information with another application.


GigaSpaces 6.0 Documentation Contents (Current Page in Bold)

    Java

    C++

    .NET

    Middleware Capabilities

    Configuration and Management

Add GigaSpaces wiki search to your browser search engines!
(works on Firefox 2 and Internet Explorer 7)

Labels

 
(None)