JavaSpaces

squawkpsychoticΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 9 μήνες)

74 εμφανίσεις

1
JavaSpaces
(LINDA, eh?)
2
Overview

Provides distributed, persistent object system

Modelled
after LINDA

Service provided by
Jini
(
www.jini.org
)

Remote agents interact with each other
indirectly through shared data object spaces

Clients write entries into the space, read
entries from the space, or take entries from
the space
3
What is
Jini
?

Jini


technology is a service oriented
architecture that defines a programming
model which both exploits and extends Java

technology to enable the construction of
secure, distributed systems consisting of
federations of well-behaved network services
and c
lients.
Jini
technology can be used to
build adaptive network systems that are
scalable, evolvable and flexible as typically
required in dynamic computing environments
4
What does
Jini
do?

Jini
is designed to help developers deal
with
The Eight Fallacies of Distributed
Computing
.
Jini
offers a number of
powerful capabilities such as
service
discovery
and
mobile code
.
8 Fallacies: Peter Deutsch
1.
The network is reliable
2.
Latency is zero
3.
Bandwidth is infinite
4.
The network is secure
5.
Topology doesn't change
6.
There is one administrator
7.
Transport cost is zero
8.
The network is homogeneous
5
Architecture
Stress serialization.
6
Operations

Read

Read an entry from the space that matches a
template.

Write

Add an entry to the space.

Take

Read and remove an entry from the space.

Notify

Send a notification through a given event handler
if entries that match a template are added to the
space.
A notification request has a time-out period associated with it: if a
matching entry isn't added within the time-out period, the notify
request fails
and is dropped from the
JavaSpace
.
Multiple basic operations can be assembled into
transactions
that group basic operations into a single, atomic aggregate
operation.
7
API: Classes

Entry

Entry class used to represent entry in
JavaSpace

Group of object references, which represent the
fields in the
Entry

EntryRep

s act as the conduit for
Entry
s
into and out of
JavaSpaces

serialize
Entry
s
before going into a
JavaSpace
during a
write
operation

de-serialize
Entry
s
returned as the result of
read
,
take
, or
notify
operations.

A given
EntryRep

can be written multiple times to
the same
JavaSpace
, which would result in
multiple identical entries in the space
8
API:

Transaction

A
Transaction
is a group of basic
operations that act as an atomic
operation on one or more
JavaSpaces
.

A
Transaction
is atomic:

All or none of the operations in the
Transaction
will be carried out.

On failure,
JavaSpace
is left in original
state
If any of the operations within the
Transaction
fail (e.g., a read fails
to match an entry, or a notify times out before it is triggered), then the
entire
Transaction
fails and any sub-operations that had succeeded
are "rolled back," and the
JavaSpace
is left in the same state it would
have been in if the
Transaction
had never been attempted
9
API:
JavaSpace
interface

write()

void write(
EntryRep
r, Transaction t,
Identity i) throws
RemoteException
,
TransactionException
,
SecurityException

A
write()
call adds an
EntryRep

to the
JavaSpace
. Each field in the enclosed
Entry
is serialized independently, and the
serialized bytes making up the entire
Entry
are sent to the
JavaSpace

for storage and
later lookup.
If a
Transaction
is included in the
write()
call, then the new entry
isn't visible to other clients of the
JavaSpace

until the entire
Transaction
executes. If the entry is taken during the course of the
rest of the
Transaction
, then the
Transaction
, including the write
operation, will succeed, but the new entry will never be seen by other
clients of the
JavaSpace
10
API:
JavaSpace
interface

read()

EntryRep
read(
EntryRep
template,
Transaction t, Identity i) throws
RemoteException
,
TransactionException
,
SecurityException

If an entry in the
JavaSpace

matches the
EntryRep

template, it is returned from the
method call as an
EntryRep

object.
If a
non-
nullTransaction

is included in the
read()
call, then a
matching
EntryRep

will only be returned if the entire
Transaction
succeeds. Any entries that are read during the course of the enclosing
Transaction
are put on a pending list, and can't be taken by other
operations or transactions until the read and its
Transaction
are
finished (successfully executed or aborted). If all entries matching the
read()
's
template entry are pending in unfinished transactions, then a
TransactionConflictException

is thrown.
11
API:
JavaSpace
interface

take()

EntryRep
take(
EntryRep
template,
Transaction t, Identity i) throws
RemoteException
,
TransactionException
,
SecurityException

The
take()
operation on the
JavaSpace
interface behaves much like the
read()
operation, except that a matching entry is
also removed from the space.
If the
Transaction
argument is non-
null
, then a matching entry
won't be returned until the
Transaction
completes. If a
RemoteException

is raised by the
take()
call, then it's possible that
the entry was removed from the space but not returned in its entirety.
12
API:
JavaSpace
interface

notify()

EventRegID
notify(
EntryRep
template,
EventCatcher
c, Transaction t,
Identity i,
int
timeout) throws
RemoteException
,
TransactionException
,
SecurityException

A call to
notify()
serves to register interest
in matching entries for a specific period of
time. If a matching entry is written to the
space before the notification request expires,
then the
notify()
method on the given
EventCatcher

will be called.
The
EventRegID

object returned to the client contains a set of long
values, including an event ID that will come with the notification, a
cookie value that can be used to renew or cancel the notification, and
the actual timeout period assigned to the notification reques
t by the
JavaSpace
. If a
non-
nullTransaction

is passed into the method
call, then the event catcher will be notified of matching entries for the
duration of the enclosing
Transaction
. At the end of the transaction,
the notification request will be dropped from the space
13
API:
JavaSpace
interface

renew()

long renew(long cookie, long
extension) throws
RemoteException
,
NotRegisteredException

This method allows a client to request an
extension to a notification request.
The
cookie
argument is the value returned in the
EventRegID
from the original
notify()
call and the extension is the desired
extension to the registered notification. The method returns the
actual time extension granted by the
JavaSpace
, if any.
14
API:
JavaSpace
interface

cancel()

void cancel(long cookie) throws
RemoteException
,
NotRegisteredException

The notification request associated with
the
cookie
is cancelled.