Upload
lowell-elliott
View
219
Download
0
Embed Size (px)
Citation preview
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 1/37
INDEX
1. Coordination Paradigm
1.1 What is Co-ordination
1.2 Co-ordination Language
1.3 What is our goal?
2. Coordination Models
2.1 Necessity of Co-ordination Model
2.2 From Multilingual and Heterogeneous Systems to Coordination Models
2.3 Classification of Co-ordination model
2.3.1 data driven Co-ordination model
2.3.2 Control driven Co-ordination model
3. Special purpose co-ordination languages
3.1 Linda
3.2TSpace
4. Javaspace :Java based coordination language
4.1Introduction to Javaspace
4.2Goals and requirement of Javaspace
4.3Javaspace operations
4.4 Comparisons
5 Extending JavaSpace as J2space
5.1. JINI
5.2 Primitive Implementation
5.2.1CountN
5.2.2 Delete
5.2.3 Scan
5.2.4 ConsumingScan
6 Notifier application
6.1.UML Diagrams
6.2 Modules of notifier application
6.2.1 Login
6.2.2 System tray
6.2.3 Show Notice
6.2.4 Send Notice
6.2.5 Notifying
Conclusion
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 2/37
Abstract
This report discusses various coordination models and coordination languages.
Difference between various coordination model is specified here. The coordination
language Linda, TSpace and Javaspace are studied as coordination languages
Linda is having some limitation as coordination language. So javaspace is good option
for implementation of distributed application. But javaspace language is having limited
primitives compared with another languages and the primitives which are not present in
javaspace are implemented here. JINI contains Javaspace service. Newly implemented
primitives can work with existing primitives.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 3/37
Chapter 1. Coordination Paradigm
Programming for distributed and parallel system can be seen as combination of
computing part and coordination part .The computing part consist of number of process
involved in manipulating the data. Coordination part is responsible for communication &
cooperation between process.
1.1 What is the coordination?
The concept of coordination is closely related to those of multilingualism and
heterogeneity. The actual programming languages used to write computational code play
no important role in setting up the coordination components.
There are many definitions of what is coordination ranging from simple ones such as:
1. “Coordination is managing dependencies between activities.”
2. “Coordination is the additional information processing performed when multiple,
connected actors pursue goals that a single author pursuing the same goals would
not perform.”
3. “Coordination is the process of building programs by gluing together active
pieces”.
4. “A coordination model is the glue that binds separate activities into an ensemble.”
A coordination model can be viewed as a triple (E, M, F),
Where E represents the entities being coordinated,
M the media used to coordinate the entities,
And F the semantic framework the model adheres to.
1.2 Coordination Languages:A coordination language is a language defined specifically to allow two or more parties
or components to communicate, to accomplish specific goal.
Proper functioning of many of today’s application depends on the mutual cooperation &
interaction of computers & human users. Special coordination languages have been
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 4/37
designed, in which one can specify, analyze and control the cooperation between various
system components. Example is Linda.
Many problems can be solved by coordination language such as management of resource
sharing, transfer of information between activities-Producer/consumer. Relationship
occurs in software systems whenever one activity produces some information that is used
by another activity. A coordination process that controls the transfer of information between activities is needed.
Group Decision –It is very common that group of entities working together is confronted
with the problem of making coordinated decision. These decisions cannot be made in
isolation by one of the members, possibly because no individual has enough authority.
Coordination process control group discussion
1.3 What is our goal?
Javaspace is coordination language. It uses data driven coordination model.
Our goal is to identify the limitation of Javaspace in terms of coordination primitives. For
this purpose we can study the various coordination models and languages and compare
those languages with the Javaspace. We are comparing these languages in terms of
primitive set, basic entity being coordinated, mechanism of coordination and coordination
medium of various coordination languages.
We are trying to implement those primitives which are not present in the javaspace but
still they are very important to implement the various distributed applications.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 5/37
Chapter 2. Co-ordination models
2.1 Necessity of Co-ordination Model
Parallel and distributed systems open new horizons for large applications and present newchallenges for software technology. Many applications already take advantage of the
increased raw computational power provided by such parallel systems to achieve shorter
turn-around times. However, the availability of so many processors to work on a single
application presents a new challenge to software technology: coordination and
cooperation of large numbers of concurrent active entities. Classical views of
concurrency in programming languages that are based on extensions of the sequential
programming paradigm are ill-suited to meet the challenge.
Exploiting the full potential of massively parallel systems requires programming models
that explicitly deal with the concurrency of cooperation among very large numbers of
active entities that comprise a single application. This has led to the design and
implementation of a number of coordination models and their associated programming
languages. Almost all of these models share the same intent, namely to provide a
framework which enhances modularity, reuse of existing components, portability and
language interoperability. However, they also differ in how they precisely define the
notion of coordination, what exactly is being coordinated, how coordination is achieved,
and what are the relevant metaphors that must be used.
2.2. From Multilingual and Heterogeneous Systems to Coordination
Models
With the evolution of distributed and parallel systems, new programming paradigms were
developed to make use of the available parallelism and the number of processors in a
system. These languages were able to exploit parallelism, perform communication butalso be fault tolerant. They differed in the granularity or unit of parallelism they offered
and the communication mechanism employed. The increased availability of massively
parallel and open distributed systems lead to the design and implementation of complex
and large applications such as vehicle navigation, air traffic control, intelligent
information retrieval and multimedia based environment.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 6/37
Thus, in order to deal with all these requirements of programming-in-the-large
applications, the notions of multilingualism and heterogeneity came into play.
Multilingual or multiparadigm programming is able to support a number of diverse
paradigms and provide interoperation of these paradigms while at the same time isolate
unwanted interactions between them. Furthermore, a multilingual or multiparadigm
programming environment aims at accommodating the diverse execution models andmechanisms of the various paradigms, manage the resources required for implementing
them, and offer intuitive ways for combining code written in a mixture of paradigms
while at the same time providing orthogonal programming interfaces to the involved
paradigms.
There are basically two ways to produce multilingual or multiparadigm languages: either
design a new super language that offers the facilities of all paradigms intended to be used
or provide an interface between existing languages.
The first approach has the advantage of usually providing a more coherent combination
of different paradigms. However, it has also the disadvantages of introducing yet another
programming language that a programmer must learn plus the fact that such a single
language cannot possibly support all the functionality of the languages it aims to replace.
The second approach can in fact be realized with different degrees of integration ranging
from using the operating system’s communication primitives for inter-component
collaboration to providing concrete integration of the various languages involved, as in
the case of, say, Module Interconnection Languages. Multilingualism is closely related toheterogeneity .since heterogeneous systems demand that a programming language used
must be able to express many useful models of computation. It is, however, usually
impossible to find a single language able to deal satisfactorily with an extensive variety
of such models; a mixture of language models may have to be employed.
2.3Classification of Coordination model
Coordination models can be classified into two classes, such as data-driven coordination
model and conrol driven coordination model.2.3.1 Data-Driven Coordination Models
Almost all coordination models belonging to this category, which used shared data space.
A shared data space is a common, content-addressable data structure. All process
involved in some computation can communicate among themselves only indirectly via
this medium .The activity in a data oriented coordination application tends to center
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 7/37
Fig 2.1 Data-Driven Model
around a shared body of data. The application is essentially concerned with what happens
to data.
In particular, they can post or broadcast information into the medium and also they can
retrieve information from the medium either by actually removing this information out of
the shared medium or taking a copy of it. Since interprocess communication is done only
via the Shared Data space and the medium’s contents are independent of the life history
of the processes involved, this metaphor achieves decoupling of processes in both space
and time. Some processes can send their data into the medium and then carry or doingother things or even terminate execution while other processes asynchronously retrieve
this data; a producer need not know the identity of a consumer or, if the data it has
posted into the medium has been retrieved or read by anyone.
The main characteristic of the data-driven coordination models and languages is the fact
that the state of the computation at any moment in time is defined in terms of both the
values of the data being received or sent and the actual configuration of the coordinated
components. In other words, a coordinator or coordinated process is responsible for both
examining and manipulating data as well as for coordinating either itself and/or other
processes by invoking the coordination mechanism each language provides
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 8/37
2.3.2 Control-driven coordination models
With control-driven coordination models, the state of the computation at any moment in
time is defined in terms of only the coordinated patterns that the processes involved in
some computation . The components being coordinated are considered as black boxes
that produce and consume data on well-defined interfaces to the external World, usually
referred to as ports.
Fig 2.2 Control-driven Model
Idealized Worker Idealized Manager is a control-driven coordination model. There are
two classes of processes: managers and workers. To communicate, a process writes and
reads data on its ports. It is not aware to whom information is transmitted. Workers
basically perform a computational task. Managers create new processes and regulate the
connections between workers by dynamically binding ports of different workers into
connections, or disconnecting existing connection
In control-driven or process-oriented coordination languages, the coordinated framework
evolves by means of observing state changes in processes and, possibly, broadcast of
events. Contrary to the case of the data-driven family where coordinators directly handle
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 9/37
and examine data values, here processes (whether coordination or computational ones)
are treated as black boxes; data handled within a process is of no concern to the
environment of the process. Processes communicate with their environment by means of
clearly defined interfaces, usually referred to as input or output ports.
Producer-consumer relationships are formed by means of setting up stream or channelconnections between output ports of producers and input ports of consumers. By nature,
these connections are point-to-point, although limited broadcasting functionality is
usually allowed by forming 1-n relationships between a producer and n consumers and
vice versa. Certainly though, this scheme contrasts with the Shared Dataspace approach
usually advocated by the coordination languages of the previous family.
In addition to using ports, processes often send out to their environment control messages
or events with the purpose of letting other interested processes know in which state they
are or informing them of any state changes. In particular, the figure shows a configuration
involving one producer with one input and two output ports and two consumers, one with
a single input port and a single output port and the other with two input ports and one
output port. Stream connections have been established between the output ports of the
producer and the input ports of the consumers, sometimes with more than one stream
entering an input port or leaving an output port. Furthermore, the producer and one of the
consumers either raises and observes the presence of some events. and data valueswhereas in other languages events are strictly simple units signifying state changes.
Furthermore, in some languages events are broadcast by means of mechanisms different
from stream connections whereas in other languages events actually travel through
streams. Stream connections themselves can be realized in a number of ways; for
instance, they may or may not support synchronous communication. In some cases
streams are interfaced to some common medium (such as a “data bus”) rather than being
point-to-point connections between ports; even in this latter case however, the medium is
not used for unrestricted broadcasting. Also, some languages support dynamic creation of
ports and exporting of their id for use by other processes whereas others limit such
functionality.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 10/37
Chapter3: Special purpose coordination languages
Linda is model of coordination and communication among several parallel processes. The
process operating upon objects stored in shared space .This model is implemented as
coordination language in which several primitives operating on ordered sequence of
typed data objects. Coordination language is the combination of primitives and particular
host language. Linda and Tspace can be used with C, C++, Python, Erlang languages
3.1Linda
Linda is a coordination language for parallel and distributed processing, providing a
communication mechanism based on a logically shared memory space called tuple space.
Tuplespace is the Linda's name for its shared data space . It is the fundamental data
structure of tuple space. Examples: ('arraydata', dim1, 13, 2).
Tuple are stored in the memory using associative memory model
In associative memory model a tuple is accessed by specifying its contents. From the
programmer's point of view, there is no address associated with a tuple
The original Linda model requires four operations that individual process perform on
the tuples and the tuplespace
3.1.1Linda basic operations
1) out: produces a tuple, writing it into tuplespace
• Generates the data tuple
• Each field is evaluated and put into tuplespace
• Control is returned to the invoking program
2) rd: non-destructively reads a tuplespace
• Uses template to copy data without removing it from the tuplespace.
• Once read it is still available for others
• If no matching tuple is found process will block
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 11/37
3) in: atomically reads and removes -consumes- a tuple from tuplespace
• uses a template to retrieve tuple from tuplespace
• once retrieved it is taken out of the tuplespace and no longer available for other
retrieval
• if no matching tuple is found process will block
• provides for synchronization between process
4) eval: creates new processes to evaluate tuples, writing the result into tuplespace
• Generates process (Active)tuple
• Control is immediately returned to invoking program
• Logically ,each field is evaluated concurrently by a separate process, and then
placed in to tuplespace
Inp,rdp: Same as rd & in But Non-blocking
3.1.2Linda Basic: Template matching
Linda specifies tuple to retrieve actuals or formals fields.
Actuals contains variables, constants or expression that resolve to constant.
Formals contains holders for data to retrieve preceded by a question mark assigned
values of corresponding fields in matched tuple
Example:
Tuple (“arraydata”4,6,8) is present in tuplespace
in("arraydata", ?dim1, ?dim2, ?dim3);
in ("arraydata", 4, ?dim2, ?dim3);
In order to match a tuple :
It must have the same number of fields in the tuple and template
It must have same type, length and values as those in corresponding tuple
fields.
Formals in template must match type and length of corresponding fields
in tuple.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 12/37
The order of evaluation of fields within a tuple or template is undefined:
Example:
out ("string", i++, i);
Can't predict whether i will be incremented before or after it is evaluated for the
third field.
3.1.3Linda Properties It is little like message passing and shared memory
It provides uncoupling in both time and space
Pattern matching is used to retrieve tuple
Linda allows to communicate a wide variety of information
3.1.4Linda Limitations
Tuplespace is unprotected
No hierarchical organization of tuples is provided so naming scope is not present
Blocking calls are present but no notification mechanism is present
3.2 TSpace
Tspace is the coordination language with uses the tuplespace.
The implementation of TSpaces is simple and elegant all that is required is that a single
server process be running on the network. The server makes use of a textual
configuration file, and provides a useful web interface for monitoring and configuration
purposes. Applications wishing to make use of the TSpaces service need only know the
network hostname of the computer running the server.
3.2.1Tspace primitives
TSpaces provides a large number of operations over and above the basic Linda operations
Write
Adds a tuple to the space
Take ( template_tuple )
Performs an associative search for a tuple that matches the template. When
found, the tuple is removed from the space and returned. If none is found,
returns null.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 13/37
Read ( template_tuple )
Like "take" above, except that the tuple is not removed from the tuple space.
WaitToTake ( template_tuple )
Performs an associative search for a tuple that matches the template. Blocks until
match is found. Removes and returns the matched tuple from the space.
countN(template)
This returns the integer count of the number of Tuples that match the specified
template Tuple.
Delete(Template)
This delete the specified tuple from tuplespace
scan(template)
This returns a Tuple that contains a set of Tuples that match the specified template
Tuple.
consumingScan(template)
This returns a Tuple that contains a set of Tuples that match the specified template
Tuple and removes all of the Tuples from the server
The read and take methods return a single matching tuple. If more than one matches,
then it will return the first matching tuple. However there are TupleSpace methods
that will handle multiple matches.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 14/37
Chaptre4:Javaspace:Java based co-ordination language
Distributed systems are hard to build. they require careful thinking about problem that do
not occur in local computation. The javaspace technology is designed to help you solve
problem of distributed persistence and design of distributed algorithms.
4.1 Introduction of JavaSpace
To discuss the advantages and possibilities of the JavaSpaces technology there is a need
for a short flashback to the idea that is behind this technology. The general idea behind
JavaSpaces is the idea of tuple spaces.
Tuple is ordered collection of Possibly heterogeneous information items. The basic
meaning of a tuple is a list of a fixed length. The elements the list contain do not be of
one type and so can be different. This principle is called generic programming. The list is
now made accessible on the local PC and network through different processes
.
Tuple Spaces should be an implementation for associative memory. That means objects
can not be only referenced by their unique id or by their process id but simply by giving
them names. The next step is, that this associative memory is not only available on a
single computer, but through the network as well without any problems. The main aim of
tuple spaces is to easily develop applications that are working parallel easily.
4.2Goals and Requirement of Javaspace
The goals for the design of JavaSpaces technology are:
• Provide a platform for designing distributed computing systems tha Simplifies the
design and implementation of those systems.
• The client side should have few classes, both to keep the client-side mode simple,
and to make downloading of the client classes quick.
• The client side should have a small footprint, because it will run on computers
with limited local memory.
• A variety of server implementations should be possible, including relational
Database storage and object-oriented database storage.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 15/37
• It should be possible to create a replicated JavaSpaces service.
• It must be possible to write a 100% Pure Java client.
• Clients must be oblivious to the implementation details of the server. The same
entries and templates must work in the same ways no matter which server is used.
Virtual machine allow for applications that you write once and run anywhere. Other
issues that have significant impact on designing and implementing distributed
applications include latency, synchronization, and partial failure.
Several technologies can be used to build distributed applications, including low-level
sockets, message passing, and remote method invocation. The JavaSpaces technology
model is different in that it provides persistent object exchange areas or spaces through
which remote Java technology processes coordinate actions and exchange data. Such an
approach can simplify the design and implementation of sophisticated distributed
applications, and it enables you to deal with the challenges of designing and
implementing distributed applications.
4.3 Javaspace operations
A JavaSpace service holds entries, each of which is a typed group of objects expressed
in a class that implements the interface net.jini.core.entry.Entry. Once an entry is written
into a JavaSpaces service, it can be used in future look-up operation. Looking up entries
is performed using templates, which are entry objects that have some or all of their fields,
which are not used in the look up ,are left as wildcards.
There are two look-up operations: read () and take ().The read () method returns either an
entry that matches the template or an indication that no match was found. The take ()
method operates like read(),but if a match is found, the entry is removed from the space.
Distributed events can be used by requesting a JavaSpace services you when an entry that
matches the specified template is written into the space. Each entry in the space can be
taken at most once, but two or more entries may have the exact same values.
Using JavaSpace technology, distributed applications are modeled as a flow of objects
between processes as follows.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 16/37
Objects
Process
Process
Process
Process
Notify
Write
Take
Read
Object Space
Fig4.1 Javaspace Operations
Operations
There are four primary kinds of operations that you can invoke on a JavaSpaces service.
Each operation has parameters that are entries, including some that are templates, which
are a kind of entry. This chapter describes entries, templates, and the details of the
operations, which are:
• Write — Write the given entry into this JavaSpaces service.
• Read — Read an entry from this JavaSpaces service that matches the given
template.
• Take —Read an entry from this JavaSpaces service that matches the given
template, removing it from this space.• Notify— notify a specified object when entries that match the given template are
written into this JavaSpaces service.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 17/37
4.4 Comparisons
In this section Javaspace is compared with Linda and Tspace language. When Javaspace
is compared with Linda ,the various attributed like, multiple space ,identification
mechanism, matching entry with standard template or wild cards and notification
mechanism is discussed.
Attributes Javaspace LindaMultiple tuple space Yes NoMatching with wildcard Yes No Notification mechanism Yes NoIdentification mechanism Yes NoTransaction properties Yes No
Table 4.1 Comparison with Linda
Limitation of Linda are removed in Javaspace.
If we compare the Javaspace with Tspace ,Comparison table shows the primitives which
are not present in the Javaspace but they are important .
Primitives Javaspace TSpaceWrite Yes YesRead Yes YesTake Yes Yes
Notify Yes YesDelete No Yes
CountN No YesScan No Yes
ConsumingScan No Yes Table 4.1 Comparison with Tspace
The primitives which are not present in the Tspace can be implement in the
javaspace.
Chapter5 :Extending Javaspace as J2space
Jini technology is simple infrastructure for providing service in a network and for cratingspontaneous interaction between programs that use those services
5.1Jini
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 18/37
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
clients. Jini technology can be used to build adaptive network systems that are scalable,
evolvable and flexible as typically required in dynamic computing environments. Jini
offers a number of powerful capabilities such as service discovery and mobile code.
Jini adds several advantages comparing to competing technologies, and can generally
provide a more stable, fault-tolerant, scalable, dynamic, and flexible solution. Jini also
provide the ability to do a better job at upgrading systems, keeping everything running
including old clients.
The term Jini refers to both a set of specifications and an implementation; the latter is
referred to as the Jini Starter Kit. We are taking the help of jini specification for
implementing our java space project.
To start the jini service we require jini Starter kit. During the installation of jini starter kit
we should consider ,license agreement, location of installation,choise of java virtual
machine, Policy mechanisms and envirment verification. In environment verification jini
service register to the local host. It contains following services
•
net.jini.event.pulleventmailbox• net.jini.core.transaction.server.TransactionManager
• net.jini.lease.LeaseRenewalservice
• net.jini.space Javaspace
• net.jini.discovery.LookupDiscovery service
• net.jini.core.lookupDiscoveryservice
• net.jini.lookup.serviceregister
5.2 primitive implementation
The javaspace was having very limited primitive set. As we have compared javaspace
with the Tspace and came to know that some primitives are not present in the javaspace.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 19/37
Those primitives can get implemented. Primitive set of javaspace will increase so we can
call this new modified language as “J2Space” which is extending Javaspace.
Class diagram of implementation of primitives is as follows
Fig5.1 Extending javaspace as J2Space
5.1 primitive implementation
As shown in above figure countN(),Delete(),scan(), and consumingScan() primitives are
belongs to J2space.How those primitives are implemented , is explained below.
5.1.1 countN ( )
Function name: countN ( ).
Arguments: Entry tmpl, Transaction txn.
Return Type: Integer.
Code Details:
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 20/37
This function counts the number of entries of specified Entry template in
JavaSpace server space. This function iterate over all entries in JavaSpace server. To
iterate over all the entries in JavaSpace server we need to have admin control. So create
an object of AdminProxy as _ adminProxy.
AdminProxy _adminProxy = new AdminProxy (theStub, theUuid);
AdminProxy Handles all admin related function for Blitz JavaSpace server. Thearguments of AdminProxy are theStub and theUuid, the theStub is nothing but server and
the theUuid is 128 bit universally unique identifier.
Basically to handle JavaSpace server’s administrative functions one interface is
provided which is com.sun.jini.outrigger.JavaSpaceAdmin. This interface contains all the
administrative methods that Outrigger provides to control its JavaSpace service. So need
to cast AdminProxy object to com.sun.jini.outrigger.JavaSpaceAdmin. Then we get
object of JavaSpaceAdmin as,
myJ2SpaceAdmin = (com.sun.jini.outrigger.JavaSpaceAdmin) _adminProxy;
Now we can handle admin related function using this myJ2SpaceAdmin object.
We have to iterate over the all entries in JavaSpace server. So for that purpose we need
iterator and JavaSpace provide an interface for that and it is AdminIterator.
AdminIterator is interface for the iterator returned by the contents( ) method of
JavaSpaceAdmin. So we create an object iter of AdminIterator as,
AdminIterator iter;
JavaSpaceAdmin provide a method contents ( ) that return an AdminItrator that
will iterate over all the entries in the space that match the given template and are visible
under the given transaction. The parameter for method contents ( ) are Entry template
that we have to match with space entries. And second parameter is Transaction of Entry
template. So we call method contents( ) as,
iter = myJ2SpaceAdmin.contents (tmpl, txn);
Control flow diagram
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 21/37
Fig 5.1 control flow diagram of CountN()
Now we get all matched entries of space to iterate in iter Iterator. Now we loop iter and
compare each entry in iter with our Entry template class if it matches then increment
START
Get Entry template
Get Admin proxy
Get Javaspace Admin
Get Javaspace AdminItrator
count
YES
NO
isEntrytemplate
match?Increment counter
IsNext?
End
YES
NO
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 22/37
integer variable count as counter (count++). Do this until iter.next ( ) tends to null. Then
close the iter using close ( ) method.
While true()
{
entry e = iter.next();
if (e= = null}{
Break;
}
Class entryClass = e.getClass
String entryClassName = entryClass.GetName();
If( entryClassName.equals((tmpl.getclass()).getname())
{
totalEntries++
}
}iter.close
}return totalEntries
So we get counter count as number of entries of specified Entry template in space.
Note that Transaction null works like wild character and it matches specified Entry
template under all transactions. And also if any internal content of template is null then
also it work s like wild character and that template content parameter considered as any.
5.1.2 Delete ( )
Function name: delete( ).
Arguments: Entry tmpl, Transaction txn, Long timeout.
Return Type: Boolean.
Code Details:
This function deletes the specified entry from space. This function uses basic method
takeIfExists (). In JavaSpace method takeIfExists () takes specified entry from spacemeans read and remove from space.
myEntry = this.takeIfExists (tmpl, txn, timeout);
In this function simply call the method takeIfExists () with parameter tmpl, txn and
timeout. So according to takeIfExists () logic it takes entry from space (read and delete).
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 23/37
It returns the entry if exists else null hence check for returned entry for null if it is not
null then return true else false as,
if (myEntry != null) {
return true;
} else {
return false;}
Control Flow Diagram:
Fig 5.2 control flow diagram for Delete()
5.1.2.3 scan ()
Function name: scan ().
Arguments: Entry tmpl, Transaction txn, Long timeout.
Return Type: List.
Control Flow Diagram:
START
Get Entry template
Take If exist
True
YES
No
Is entry ? False
End
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 24/37
Fig 5.2 control flow diagram for scan()
Code Details:
This function returns list of all entries that matches with specified Entry tmpl.
This function iterate over all entries in space. To iterate over all the entries in JavaSpace
server we need to have admin control. So create an object of AdminProxy as
_adminProxy.
AdminProxy _adminProxy = new AdminProxy (theStub, theUuid);
START
Get Entry template
Get Admin proxy
Get Javaspace Admin
Get Javaspace AdminItrator
returnlist
YES
NO
isEntrytemplate
match?Add Entry in list
Isnext?
End
YES
NO
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 25/37
AdminProxy handles all admin related function for Blitz JavaSpace server. The
arguments of AdminProxy are theStub and theUuid, the theStub is nothing but server and
the theUuid is 128 bit universally unique identifier.
Basically To handle JavaSpace server’s administrative functions one interface is
provided which is com.sun.jini.outrigger.JavaSpaceAdmin. This interface contains all the
administrative methods that Outrigger provides to control its JavaSpace service. So needto cast AdminProxy object to com.sun.jini.outrigger.JavaSpaceAdmin. Then we get
object of JavaSpaceAdmin as,
myJ2SpaceAdmin = (com.sun.jini.outrigger.JavaSpaceAdmin) _adminProxy;
Now we can handle admin related function using this myJ2SpaceAdmin object.
We have to iterate over the all entries in space. So for that purpose we need iterator and
JavaSpace provide an interface for that and is AdminIterator. AdminIterator is interface
for the iterator returned by the contents() method of JavaSpaceAdmin. So we create an
object iter of AdminIterator as,
AdminIterator iter;
JavaSpaceAdmin provide a method contents () that return an AdminItrator that
will iterate over all the entries in the space that match the given template and are visible
under the given transaction. The parameter for method contents () are Entry template that
we have to match with space entries. And second parameter is Transaction of Entry
template. So we call method contents() as,
iter = myJ2SpaceAdmin.contents (tmpl, txn);
Now we can iterate over all matched entries of space by using iter. So we loop iter
and compare each entry in iter with our Entry template class if it matches then add each
matched entry in List. Do this until iter.next () tends to null as follows
While true()
{
entry e = iter.next();
if (e= = null}
{
Break;
}
Class entryClass = e.getClass
String entryClassName = entryClass.GetName();
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 26/37
If( entryClassName.equals((tmpl.getclass()).getname())
{
Scanentries.add(e)
} count++;
}iter.close
}return ScanentriesscanEntries.add (e);
So we get list of all matched entries of specified Entry template from space. Then
close the iter using close () method.
Note that Transaction null works like wild character and it matches specified
Entry template under all transactions. And also if any internal content of template is null
then also it work s like wild character and that template content parameter considered as
any. And timeout means how long the client is willing to wait for a transitionally proper
matching entry. A timeout NO_WAIT means to wait no time at all; this is equivalent to a
wait of zero.
5.1.4 consumingScan ()
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 27/37
Function name: consumingScan ().
Arguments: Entry tmpl, Transaction txn, Long timeout.
Return Type: List.
Control Flow Diagram:
Fig 5.2 control flow diagram for consumingScan()
Code Details:
This function takes list of all entries that matches with specified Entry tmpl. This
function uses basic method take () and countN () method. In JavaSpace method take ()
takes specified entry from space means read and remove from space.
noEntries = countN (tmpl, txn);
START
Get Entry template
countN( ) , i=0
Return count
YESIs i<countN ( )?
End
NO
Add entry to listTake entry
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 28/37
In this function first we call countN () method to count number of matched entry
tmpl in space. Then simply call the method take () with parameter tmpl, txn and timeout
for noEntries times. So according to take logic it takes entry from space (read and delete).
Then add entries in list as,
Entry tempentry;
Int noEntries = CountN( templ,txn)for (int i = 0; i < noEntries; i++) {
tempEntry = take (tmpl, null, timeout);
scanEntries.add (tempEntry);
} return scanEntries;
So we take list of all matched entries of specified Entry template from space.
Note that Transaction null works like wild character and it matches specified
Entry template under all transactions. And also if any internal content of template is null
then also it work s like wild character and that template content parameter considered as
any. And timeout means how long the client is willing to wait for a transactionally proper
matching entry. A timeout NO_WAIT means to wait no time at all; this is equivalent to a
wait of zero.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 29/37
Chapter 6. Notifier application
This application provides functionalities send notice, read Notice and gives interactive
notifications when notice send by one user to another user. The notice sent is stored in the
shared space from which any authorized user can read it.
When one user is sending notice to another user it is not necessary that recever should
alive or in login state. When receiver does login it will get the notification that some
notices are for him. through system tray and notice toaster.
6.1 UML diagrams
This application can be explained better by using UML diagrams. Class diagram, Usecase
diagram, sequence diagram and activity diagram is provided below
1)Class diagram:
Fig6.1 Class diagram of Notifier application
2)Usecase diageam
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 30/37
Fig6.2 usecase diagram of Notifier application
3)Sequence Diagram
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 31/37
Fig6.3 sequence diagram of Notifier application
Fig6.4 Activity diagram of Notifier application
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 32/37
6.2Modules of Notifier application
Notifier application consist of number of modules.These modules are
1. Login
2. System Tray
3. Show Notice
4. Send Notice
5. Notifying
6.2.1. Login: (Login.java)
This module consist user authentication of application. In this user interface consist
textboxes for Login id and password. In this I defined a function isUser () in which
connection with database created also query fired and user authentication done. Important
thing in this is user types two types of user one- User who have authorization to send
notice (user_type=1) and second- User who have not authorization to send notice
(user_type=2). After login successful it calls Notifier.java (system tray).
6.2.2. System Tray: (Notifier.java, NoticeToaster.java, Toaster.java)
This module initially counts and scan the notices using countN () and scan ()
function. Then show the notification using NoticeToaster. Which have interactive popup
window shows abstract of notice. Then it loads the system tray and pop menu, menu My
Notice, Send Notice and Exit and its event Listeners.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 33/37
J2Space and JavaSpace functions used:
• countN()
In this Application primitive used of J2Space is countN () for counting number of
specific entries in space. It is not possible to count entries using only JavaSpace
functions because in read () function it reads any random specific entry. If we use
counter and read, problem will be there, because it may read same entry again.
• read()
Used to read specific entry from space if countN () =1
• scan()
Scan function used to read all entries at same time and display to notify user. If
we use other function like read() so according to definition it may return same
entry again and if we use take () then it take entry from space and in case user not
able to read notice then problem occurs entry deleted from space before read.
6.2.3. Show Notice: (NoticeWindow.java)
This module shows notices in details. It shows single notice at time and next and
prev button navigations to view another notices. Initially it scans all user specific notices
from space and displays. This module deletes notices which are viewed by user for this
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 34/37
purpose a set variable (listNoticesRead) is used. Finally when Close button clicked then
all notices which are viewed are deleted (delete ()) from space.
J2Space and JavaSpace functions used:
• scan()
• Scan function used to read all entries at same time and display to user. If I use
other function like read () so according to definition it may return same entry
again and if I use take () then it take entry from space and in case user not able to
read notice then problem occurs entry deleted from space before read.
• delete()
• countN()
6.2.4. Send Notice: (J2Notice.java)
This module consist user interface for notice send (i.e. texts for subject, message
body and selection of recipient) and Send button on which action event writes (write ())
notice in space. For selection of recipients user ids are load from database.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 35/37
J2Space and JavaSpace functions used:• write()
6.2.5. Notifying: (Registrar.java, EventListner.java, Toaster.java)
This module consist a space registration, Event Listener and notify to user. In this
space is register for Events and Event Listener listens all events on space if write event
occur it notifies the user about new notification using Toaster popup message.
J2Space and JavaSpace functions used:
• notify()
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 36/37
Chapter7: Conclusions
This report discusses about various coordination models and coordination languages.
Linda is the basic coordination language which uses the shared dataspace for
communication and coordination. It is having some limitations which are recovered in
javaspace. Javaspace is the coordination language which used Java language with
coordination primitives. It uses shard space in which java objectare stored in serilized
form . Jini provides different types of services. Javaspace service is provided by Jini.
Javaspace and Tasapace is compared and came to know that javaspace is
having very limited primitives. Those primitives are delete(),scan(),consumingscan(),
CountN(). Javaspace is extended as J2Space which contains all primitives of
jasvaspace and newly implemented. For tesing of primitives working Notifier
application is developed in which all primitives are used.
8/14/2019 Java Space Current Dec
http://slidepdf.com/reader/full/java-space-current-dec 37/37
Biblography and references:
[1] G. A. Papadopoulos, F. Arbab Coordination Models and Languages, CWI , 1998.
[2] S. Ahuja, N. Carriero and D. Gelernter, Linda and Friends, IEEE Computer 19 (8),
1986
[3] J.-M. Andreoli, H. Gallaire and R. Pareschi, Rule-Based Object Co-ordination, in
[28], pp. 1-13.
[4] J-M.Andreoli, C. Hankin and D. Le Mtayer, Coordination Programming:
Mechanisms, Models and Semantics, World Scienti¯c, 1996.
[5] J.-M. Andreoli and R. Pareschi, Linear Objects: Logical Processes with Built-In
Inheritance, New Generation Computing 9
[6] Javaspace: Principal, pattern and practices By ken Arnold,Erric Freeman
[9]Java:Complete reference By Patrick Naughton
[10]www.google.com
[11]wwwJava.sun.Com