|
|
 |
|
 |
Frequently asked questions |
|
|
 |
General questions
- Anyone using TSpaces commercially?
- How does TSpaces relate to Jini?
- How does TSpaces relate to JavaSpaces?
- Has TSpaces been integrated with a database?
- What documentation is available?
|
Known Problems and Problem Reporting
- What are the known problems with Version 2.1.2?
- Service Pack 2
- What are the known problems with the TSpaces Services Suite version 1.2?
- How do I report problems in using TSpaces for my application?
|
General technical questions
- Does TSpace use reliable multicast or a socket connection for each client?
- I would like to use a stripped-down version of TSpaces that offers just the core functionality of tuplespace systems a la Linda, i.e., no client-server access, no event service, no security, no
transactions. Is that possible?
- Will TSpaces work on all Java platforms?
- Can I use TSpaces across a firewall?
- How may I backup the data in a TSpaces server?
- Are the TSpaces versions compatible?
- I've been throwing objects into a space to see how it performs
and I'm seeing it get out of memory exceptions when it hits Y MB
though I have 10*Y MB of RAM. What should I do?
- Would it potentially be better to split the unrelated spaces into separate servers to improve performance?
- Can I write/read/take complicated objects using TSpaces, or if it is limited to simple tuples?
- Does TSpaces support the concept of lease?
- Is there any kind of offline TSpaces store support?
- Can I write a C++ client that would talk to TSpaces server?
- How to create my own handlers?
- Can I rely on TSpaces (with persistence activated) to store my persistent information.
- Is TSpaces expected to be faster than Javaspace in remote accesses?
- Is there any performance measure for TSpaces?
|
Installation and setup
- After installing TSpaces on Windows,
I am unable to start TSpaces with the supplied
bin\tspaces.bat file. What's wrong?
- I am getting the following message when I start a sample client:
TSCmdSocketImpl: Unable to access Host: localhost; Port: 8200
- I am getting the following exception when I run the examples
or my own application.
TupleSpaceServerException: ClassNotFound Exception: SomeClassName
- I cannot run Example 5. What should I do?
- Problems with checkpointing and UNIX file permissions.
|
Client programming
- How do I define a tuple in TSpaces?
- Is there any way I can guarantee the order of the Tuples taken is the
same as the order of the Tuples written?
- Is there anything inherent in the tuplespace philosophy that prevents
subsequent "reads" from reading the same record over and over?
- Is there any limit for tuple size?
- My client is hanging in the Event Register callback. Why?
- What are the guidelines for EventRegister
and the related callback methods?
- I would like to selectively disconnect only one tuplespace of a given TSpaces server.
What should I do?
- If the TupleSpace object represents a "connection" to the remote server,
then anything related with it should disappear when this object gets garbage
collected (including the events registered). Is this true?
- Is there any way to override the implementation of the
connection object used by TSpaces? Perhaps to add SSL support
- Is there a way to remove the named tuplespace from the server,
even when other clients may still be connected to it?
- Can a client be notified when TSpaces server goes down?
- Can the client schedule the server shutdown?
- How long does the shutdown process take?
- When I issue a shutdown() or exit() command on the server and then restart it,
the client won't reconnect to it. What's wrong?
- How does TSpaces determines matches?
- Is the matching done on server-side or on client side?
- Is there an efficient way to do a blocking read of tuples matching
a template that will only read each tuple one time?
- Can multiple transactions within a single space overlap in time?
- What exactly are the semantics of a transaction if a client drops out before calling commitTrans? Is there a timeout after which the transaction is rolled back? If so, can I set the timeout?
- Is it possible to have a single transaction on multiple tuplespaces?
- Can I put large files on the server as a tuple?
- How can I specify that I want files to be retained indefinitely
when I use URLCopy?
- If I take the tuple that refers to the file and
fail to call URLCopy.copyToLocal(String, false) on it,
does the file just remain or is it garbage collected at some point?
- How do I handle object references across TupleSpaces?
- Is there a way to scan the space for all tuples newer than a
given timestamp that match a specified template?
- Is there a way to read all the Tuple and SubClassableTuple object at once?
- I'm looking for an efficient way to do a blocking read of tuples matching a template that
will only read each tuple one time.
- How are queries evaluated in TSpaces?
- I'm trying to add a "watching" thread to the worker class (in the TSpaces examples) that waits for "poison pills" to be written to a
space, and terminates the worker when it eats one. Has anyone written this sort of thing yet?
- How can I specify that Tuples should expire after some time.
- I want to know for how long time a certain tuple has existed in a tuplespace. The timestamp gives you the time when the Tuple was
posted, but how do you get time the tuple was read (i.e. the current server time)?
- TSpaces doesn't issue an event callback when a tuple expires.
Are there any workarounds to this behavior?
- Will I experience any problems storing an array of bytes (byte[]) in my tuple?
- I use subTuple=new Tuple("SequenceNum", new Integer(sequenceNumber)) to create a new tuple with a single field named "SequenceNum" of
type Integer, however it doesn't work. What's wrong?
|
Server operation
- After stopping the server in a less-than-nice manner (end task from windows) and trying to restart it, the error message told me that
the space has been damaged and I need to restart with the "-b" option that would clear the information and start a fresh space. The problem is
that I am using the space for both transient and persistent information, which I would not like to loose. What should I do?
- Is there a way to shutdown TSpaces through the Web interface?
- How can I control the expiration of tuples?
- What is the official way to disable the Expire-Manager?
- What is reported in the TSServer.status() method?
- What are the meanings of the different checkpoint/file config options and how would you suggest setting them?
- Server hangs on Sun Solaris 2.6?
|
Security issues
- What security support do you have? Do you have support for users, groups, and
passwords?
- I've written a class that starts a TSpaces server, but it seems that the files acldb.ser and passwd.ser get created in my current directory whenever it starts a server.
How do I describe where to put these files?
- How do I setup who is the admin for all the spaces
on the TSpaces server?
- I want only the administrator to be able to create spaces,
what do I have to do?
- How do I create users on the fly?
- Is there a way to choose separately if you want to restore the user and group-information?
- I want to implement a mechanism to contact the space-admin application to create an account.
- When I start a tuplespace in a client, if the named tuplespace does not exist on the server it is created. Is there a way to
request this not happen?
- In my application a client can access the server
(which is admin of the space) via HTTP and I don't want to
send the password as a string.
- When you connect to a space from a client you are associated with your login for all further sessions.
How do I disconnect as a user and reconnect as another one in the same running code?
|
XML
- I cannot get the following code to work
(the server does not parse the XML). What's wrong?
- Can you modify part of the DOM Tuple(s) once it's been entered as a complete document?
- How an XML document is saved?
- Can I query the TSpaces server for nodes in the DOM tree?
- I can compile the TestXTuple.java file but whenever I run it I get many errors. What's wrong?
- I would like to use eventRegister() for an XMLQuery object. What should I do?
|
PDA support
- Where can I find information about TSpaces support for Palm?
- Do you need KVM or other VM like Waba with TSpaces on the Palm?
- Could I write an application that runs under KVM or Waba and takes a tuple from a TSpaces server via a MoDAL application and writes a record to a database on the Palm?
|
|
|
|
|
 |
General questions |
- Anyone using TSpaces commercially?
We have a list of over 50 companies that have been working with TSpaces and are interested
in licensing the technology for various projects. Some of these projects are research, both commercial and higher education, but most will use TSpaces
as a component of their own commercial product or for in-house solutions. Many of these projects are either in production today or are near deployment
or release.
Our team is working hard to move TSpaces into a generally available software product from IBM.
For licensing questions, please contact:
Thomas Truong
Almaden Research Center - MS K57/B3
650 Harry Road
San Jose, CA 95120-6099
truong@almaden.ibm.com
Tel: 408-927-1484
Fax: 408-927-3497
- How does TSpaces relate to Jini?
First, let's see if we can briefly define the two systems. Jini is a set of components for performing automatic
discovery of devices on the local area network (e.g. digital cameras, network storage, or printers), managing those device resources via leasing mechanism,
and coordinating them via distributed events and messages (JavaSpaces).
TSpaces is a coordination system -- a transactional database system that supports asynchronous messaging. The core of TSpaces is often used as a pub/sub system,
an event notification system, a heterogeneous platform messaging system, an object database, an XML store, or a platform for hosting transcoders, data extractors
or gateways.
While there is an overlap in the two systems, they have different purposes. The core of TSpaces is oriented towards coordination, whereas the core of Jini is
oriented towards discovery. So, you could think of it this way: Jini is the singles bar for entities/objects/services (where they get introduced) and TSpaces is the
combination mail/phone/paging system that helps them to communicate once they've been introduced.
You've noticed that in most of the Jini examples the introduction is the major part (finding a printer, camera, etc). Once you know the address (or phone number) of the
thing you want to talk to, then you just call that number. You don't need a coordination system if there's only one message to send. However, if the conversation has multiple
pieces and/or multiple recipients, then things get more complicated. That's what TSpaces is for. It manages those conversations. SUN has something similar to TSpaces (they call
it JavaSpaces) (see question 3).
It's true that both Jini and TSpaces have some similar parts - namely the lookup server. Jini's main purpose is to fill out the lookup server (that's the dynamic discovery of services
part). In TSpaces, the main purpose of the system is to locate entities/resources/services (using the lookup server) and then manage the conversations between them. The TSpaces services suite,
provides a discovery engine that enables the dynamic discovery of services by TSpaces clients.
There have been some comparisons between TSpaces and Jini done by people outside IBM. For example, there's Ben Zhao's presentation that can be found at
http://www.cs.berkeley.edu/~ravenben/research/tuplespace/index.html.
- How does TSpaces relate to JavaSpaces?
The concepts of TupleSpaces was first developed as part of the Linda System at Yale University in the 1980s. JavaSpaces from Sun MicroSystems is also based on Linda and an excellent
book "JavaSpaces: Principles, Patterns, and Practice" has been written that covers the techniques of using "Spaces" for distributed programming.
Although the examples in the book use the JavaSpaces implementation, it is trivial to write the same examples using the TSpaces implementation of Tuplespace. The HelloWorld example,
in the TSpaces Programmer's Guide, is an example of how to convert a JavaSpaces application to TSpaces.
Some of the differences between JavaSpaces and TSpaces, illustrated in the HelloWorld example, are:
· Both have Transaction support but they are implemented quite differently.
· TSpaces does not have Lease objects but you can specify an expiration interval for Tuples. Also, we can show you how to build the equivalent of a leasing mechanism with tuples,
for the time being, but in the next release or two we'll have our own more general purpose "leasing-style" mechanism available.
· Both have methods for requesting to be notified when a Tuple matching a template is written to the space but the implementation is different.
· TSpaces supports many additional commands such as scan(), count(), update() and others that are not implemented in JavaSpaces and although the same end result can be achieved with
JavaSpaces, it is more difficult and often more inefficient.
· TSpaces supports the ability to build indexes on the fields in a Tuple and issue query commands against the indexes.
- Has TSpaces been integrated with a database?
We are planning on JDBC support for TSpaces, which will be available
in a future release. For now, we just use a main memory database,
and keep it persistent with logging of DB writes/deletes and
taking periodic checkpoints of the spaces
(technically, logs are enough to ensure persistent data,
but we also take checkpoints - on a space basis -
to limit the size of the log).
- What documentation is available?
You can view the TSpaces documentation in a number of ways.
- You can use the online documentation at the IBM Almaden site
http://www.almaden.ibm.com/cs/TSpaces/index.html
This will be the most recently updated version.
- You can access the documentation in the downloaded file.
with your browser. For example, if you download on Windows to c:/java,
then you can access the documentation with the following URL:
file:/c:/java/tspaces/index.html
- You can access the documentation from any TSpaces server.
For example, if you started a TSpaces server on your own system,
then you could use the following URL:
http://localhost:8201/index.html
The following documentation is available for developers:
- Installation Guide
- TSpaces Programmer's Guide
- JavaDoc API
- TSpaces Examples
Back to top
 |
Known Problems and Problem Reporting |
- What are the known problems with Version 2.1.2?
Watch this space: as problems are reported, they will be documented
here.
- TSpaces server hangs using FIFO or AndQuery.
A user reported a problem where the TSpaces server will
hang when using waitToTake with FIFO queuing and/or AndQuery. He was
able to build a testcase to demonstrate the problem.
The problem has been found and fixed and the user has verified
the fix in his environment.
Service Pack 2 is available on Alphaworks to fix this problem.
- TSpaces server hangs during Deadlock detection.
The Deadlock detection routine is itself sometimes causing a deadlock.
Service Pack 2 is available on Alphaworks to fix this problem.
You can also workaround the problem by setting the deadlock
detector so that it runs very infrequently (like once an
day).
- XMLQuery can not be used with SubclassableTuple.
Use of XMLQuery for a SubclassableTuple will cause a ClassCastException.
Service Pack 2 is available on Alphaworks to fix this problem.
- Exception on waitToTake with timeout specified.
It should return "null" when a waitToTake times out.
Service Pack 2 is available on Alphaworks to fix this problem.
- File sent to the server using URLCopy are deleted on restart.
When the server is restarted, file that were submitted to the server
using the URLCopy facility are deleted. They should only be deleted if the
specified retention period has expired.
Service Pack 2 is available on Alphaworks to fix this problem.
- Wrong Tuple is taken under heavy load.
Under very heavy load of concurrent writes and takes to a single space,
a Tuple may be taken that does not match the template.
Service Pack 2 is available on Alphaworks to fix this problem.
- XML Query support does not support the FIFO option.
There are a number of problems with XML Query when the space
configuration is specified as FIFO or the system wide FIFO default
is chosen. Service Pack 2 is available on Alphaworks to fix this problem.
- Performance problems with XML support.
There is a serious performance problem when one attempts to write a tuple that contains
an XMLField where the XML has many nodes.
For example: with 1000 nodes the write may take many minutes.
Service Pack 2 is available on Alphaworks to fix this problem.
- Write requests not blocked by scan request under a Transaction.
If one issues a scan request under a Transaction, all writes to that space should be blocked until
the Transaction commit is done. This was not happening when FIFO was specified or IndexQuery was
used.
Service Pack 2 is available on Alphaworks to fix this problem.
- Duplicate space names.
Due to a race condition when creating a new space, it is possible to
end up with 2 Spaces with identical names.
This would only occur when 2 or more threads are
started, each of which does a "new TupleSpace(name)" and the space does
not yet exist.
Workaround: This problem can be avoided by issuing an extra
"new TupleSpace(name)" before starting the multiple threads. This will
ensure that the space is created before the threads obtain their own
reference to the space.
- Service Pack 2
- What are the known problems with the TSpaces Services Suite version 1.2?
- Some of the batch files in the /bin directory have errors.
- The Notify service JAR file has errors.
Please download the patch that replaces
these files.
- How do I report problems in using TSpaces for my application?
Whenever you get something you think should work, but isn't working as expected (and you want our help)
then you should bundle up the simplest example that we can run as a test case and
send it to us together with information about your operating system, JDK version,
and TSpaces release.
Send it to: tspaces@almaden.ibm.com
We'll look at it, evaluate it, and fix it if it's a bug.
By building a simple testcase to demonstrate the problem,
you make it an order of magnitude easier to identify your problem,
develop a fix and then test the fix in our environment.
The extra time you spent building the testcase will be more than
made up for in the shortened turnaround on your problem.
You may want to first report the problem, to ensure that it is a new
problem and then work on building a testcase that demonstrates the
problem.
If you can't build a simple example, then an alternative would be to send us some
or all of the following.
- Description of the problem
- Information about your operating system, JDK version, and TSpaces release
- As much detail as possible about what your application does.
- Console output from the server.
- Status output (see below)
- Thread dump of the server (see below)
- TSpaces trace output. (see below)
- Client debug information (see below)
Status output
If you have started the TSpaces server from a command prompt then the one can enter various subcommands at
the subcommand prompt.
Valid subcommands are:
exit (Abort Server)
quit ( quit prompting)
D (turns on Debug output)
D off (turns off Debug output)
Dmax (turns on maximum Debug output)
q (Display status)
shutdown (Shutdown Server)
Entering the "q" subcommand will query the server for the status of various
active processes. The output can be cut and pasted into an email.
Entering the "D" subcommand will cause the server to produce huge amounts of trace date.
This can be routed to a file via the "DebugFile" operand in tspaces.cfg.
The TSpaces server also includes an HTTP server that can be accessed from your web browser.
If you were running the TSpaces server on a system named "mysystem" using the default port,
then the URL would be http://mysystem:8201.
This HTTP Server allows you to query the status of the server and the contents
of the existing tuplespaces.
Thread Dump output
If the server appears to be "hung", then the Thread Dump diagnostic information from the
Java JVM can be extremely useful in problem determination. To obtain the Thread Dump
on UNIX platforms you can send a quit signal to the Java JVM by using the kill command.
For example, you can use the command
kill -QUIT process_id
where process_id is the process number of the TSpaces server.
Alternatively you can enter the key sequence ctrl\ in the window where the
TSpaces server was started.
To generate a thread dump on Windows platforms, enter the key
sequence ctrl/break in the window where the Java program is running, or click the
Close button on the window.
The Thread Dump output can then be copied and pasted into an email message.
Client Debug information
It may be useful to add the following statements to your application.
TupleSpace.setDebug(true);
... your application TSpaces commands
TupleSpace.setDebug(false);
This will display a lot of internal information on the client console
that includes the Tuples being sent to the Server and the results
returned from the server. It may be hard to analyze,
but you can cut/paste it into the problem report and perhaps it
would be useful to us.
Back to top
 |
General technical questions |
Back to top
 |
Installation and setup |
- After installing TSpaces on Windows,
I am unable to start TSpaces with the supplied
bin\tspaces.bat file. What's wrong?
One possibility is that you are running out of environment space.
The tspaces.bat uses the Win95 environment space.
You can either issue the following commands to start the server manually:
cd yourdir\tspaces
set CLASSPATH=.\lib\tspaces.jar;.\lib\util.jar;.\classes
java com.ibm.tspaces.server.TSServer
or add the following to your c:\config.sys file and reboot:
SHELL=c:\windows\command.com /E:8192 /P
- I am getting the following message when I start a sample client:
TSCmdSocketImpl: Unable to access Host: localhost; Port: 8200
The client is attempting to contact the TSpaces server. In the above message,
the server "localhost" indicates that it is trying to contact a server
that you have started on your local system.
You need to either first start the server (or see why it has stopped running) or
specify that you want to use a server on another system. The specification of the
server is done by the TupleSpace(spacename,hostname) constructor. If you are running
one of the example programs, the server name can be specified on the command line.
The name localhost is the default server name and by convention refers to
your local system. TSpaces assumes that you have TCPIP support and can at least
initiate a TCPIP connection between 2 local programs.
- I am getting the following exception when I run the examples
or my own application.
TupleSpaceServerException: ClassNotFound Exception: SomeClassName
If a client writes an object of "SomeClassName" to the server, then the
SomeClassName.class definition must be available to the Server via the CLASSPATH.
Make sure that, when you start the TSpaces server, the directory that contains the
application classes is available to the server. Refer to the Programer's guide for more
information about this problem and how to avoid it.
- I cannot run Example 5. What should I do?
Example 5 is designed run with different userids so one can see results
of different combinations of password checking and access control lists.
The best way to run it is with:
bin\example Example5 [-h hostname] [-n spacename] userid/password
The userid and password would be what you specify in the tspaces.cfg file.
You can use the admin.bat to bring up the admin panel and set different
combinations userids and acl entries.
- Problems with checkpointing and UNIX file permissions.
A number of problems have been reported where the UNIX file permissions
are incorrect for the checkpoint directories and this causes various
problems and Exceptions on the server. This can happen if you run the server
using different userids. Make sure that the user id that is running the server
has read/write permission to the checkpoint directory and all directories and files
in that directory.
Back to top
 |
Client programming |
- How do I define a tuple in TSpaces?
In TSpaces, there are 2 ways to define a tuple.
- Directly as a Tuple objects, where you directly create the
individual Field instances that make up the Tuple.
- Indirectly by defining your own object that subclasses
SubclassableTuple.
This is covered in the programmer's guide in Example2.
- Is there any way I can guarantee the order of the Tuples taken is the same as the order of the Tuples written?
The tuplespace semantics do not include ordering of the results of an operation. However for many applications it is useful to be able to ask for the next Tuple and get them in FIFO order.
So we added the ability to specify at the time that you create a space, that the Tuples be maintained in a FIFO queue. There are examples in the programmer's guide.
- Is there anything inherent in the tuplespace philosophy that prevents subsequent "reads" from reading the same record over and over?
Basically not. The semantics of Linda, which was the first tuplespace implementation, specifies that an arbitrary matching tuple should be returned. This in fact means, as you state, that in
theory nothing prevents the same tuple from being read over and over.
- Is there any limit for tuple size?
There is no size limit.
You can have as many Fields in the Tuple as you want and
each Field is only restricted by the max size of the
Object that is in it. For example a byte[] object has no limit,
a String object has a limit of 64K (in JDK 1.1 and 1.2).
In some cases you can get by the String restriction by
writing the String as a byte array
Instead of:
_ts.write( new Tuple( bigstr ) );
you can use:
byte[] b = bigstr.getBytes();
_ts.write( new Tuple( b ) );
- My client is hanging in the Event Register callback. Why?
Perhaps you are calling another TupleSpace method from within the call()
routine or a method that is directly invoked from the call() method.
The proper handling is to only set flags in the call() method and have any new
operations be started from other threads.
There is an optional parameter for EventRegister*() that will cause it to
automatically start the callback in a new thread.
This will allow you to issue TSpaces commands from within the callback.
Refer to Example3 in the Programmer's Guide for additional information
- What are the guidelines for EventRegister
and the related callback methods?
They should run on their own threads or they should be small
because of performance reasons.
Refer to Example3 in the Programmer's Guide for additional information
- I would like to selectively disconnect only one tuplespace of a given TSpaces server.
What should I do?
As currently designed, this is not possible. The method cleanup() in the TupleSpace class is static, so it works only for
all the connections a client has to a given server. The "model" is that the client makes a connection to a TSpaces server, identifies itself
(userid/password) and then interacts with any number of TupleSpaces (perhaps hundreds or thousands) all using that same connection between the
client and the server. One connection - many spaces.
- If the TupleSpace object represents a "connection" to the remote server,
then anything related with it should disappear when this object gets garbage
collected (including the events registered). Is this true?
No, it is not. The programming model is that the connection between the client and server is independent of the space and is not the concern of the client
programmer. So there are no methods like ts.connect() or ts.disconnect(). If you had one connection per tuplespace, then the most tuplespaces that you could talk
to would be the number of sockets. Even worse, at the server, the number of sockets available on the operating system would be the limiting factor of how many
clients*spaces could be supported.
So even if the TupleSpace object is garbage collected,
the connection is there until the client issues cleanup() or terminates.
- Is there any way to override the implementation of the
connection object used by TSpaces? Perhaps to add SSL support
Currently there isn't but the next release will have an option
for using SSL for the communication layer.
- Is there a way to remove the named tuplespace from the server,
even when other clients may still be connected to it?
Yes, there is a ts.destroy() command that will remove the space.
It does not protect against problems that will occur if other clients
are connected to the same space.
If in your application, you wanted some way to notify your users
that you were going to shutdown the application or destroy the space
then you could have your own protocol that had every application do
an eventResister for the write of a
"SHUTDOWN" tuple and then before you destroyed the space,
you would write a "SHUTDOWN" tuple and then wait a bit before doing the destroy.
If you turn on access control checking,
then the destroy command requires admin authority.
- Can a client be notified when TSpaces server goes down?
Yes. If you have done an eventRegister() (or can make up a dummy one) then in the callback method
public boolean call(String eventName,String tsName,int seqNum,
SuperTuple tuple,boolean isException) {
if (isException) {
Exception e = (Exception)tuple.getField(0).getValue();
if (e.getMessage().equals("Server crashed") ) {
... handle server crash ...
}
}
- Can the client schedule the server shutdown?
Yes, using the TupleSpace.shutdown() method. It needs to have admin access to the server.
- How long does the shutdown process take?
Shutdown simply notifies all the threads that they should finish ASAP, prevents new requests from being processed, schedules a checkpoint and then waits 15 seconds
before terminating.
It takes about 15 seconds independently of the number of clients
connected to the server plus whatever time is required to checkpoint
any spaces that do not have valid checkpoints.
- When I issue a shutdown() or exit() command on the server and then restart it,
the client won't reconnect to it. What's wrong?
What you need to do on the client when the server crashes or goes down is to recognize
that it has gone down by intercepting the exception in the event register callback or
by catching the exception on the next Tuplespace operation.
Then you need to make a call to cleanup() to cleanup the existing connection
and then reissue the "new TupleSpace(space,server)"
So it might look something like this.
TupleSpace ts = new TupleSpace(space,host);
while (true) {
try {
while ( ts == null) {
sleep(5000);
ts = new TupleSpace(space,host);
}
Tuple result = ts.take(template);
}
catch(TupleSpaceException e) {
System.out.println(e);
TupleSpace.cleanup(ts.getHost(),ts.getPort());
ts = null;
}
}
or in a callback.
public boolean call( String event,String space,
int seq, SuperTuple tuple,boolean isException) {
if ( isException) {
ts = null;
return true;
} else {
...
Obviously one can do better error checking but
hopefully that gives the general idea.
Note: If you had multiple TupleSpace objects
you would only do one cleanup() and then multiple
calls to the TupleSpace constructor
- How does TSpaces determines matches?
There are two types of SuperTuple:
- Tuple: which is final and cannot be subclassed. So matching is only by the ordering and content of the Fields contained
within the Tuple
- SubclasableTuple: which can be subclassed. The template must be an instanceof the SubclassableTuple that is being matched.
For example, if SubTup extends SubclassableTuple and SubSubTup extends SubTup:
SubTup template = new SubTup();
SubSubTup obj = new SubSubTup();
template.matches(obj) is by default true if the order and number of Fields match.
However with SubclassableTuple you can override the
matches() method to have other behavior.
- Is the matching done on server-side or on client side?
The matching via the matches() method is done on the server.
- Is there an efficient way to do a blocking read of tuples matching
a template that will only read each tuple one time?
An event register for writes that match the template will do just that.
You can start with a scan that will pick up the matching Tuples
that were already written.
- Can multiple transactions within a single space overlap in time?
You can in fact have multiple transaction active at any one point of time, you just have to have multiple instances of the TupleSpace object all pointing to the
same Space.
For example:
TupleSpace ts1 = new TupleSpace("space",host);
Transaction tr1 = new Transaction();
tr1.addTupleSpace(t1);
TupleSpace ts2 = new TupleSpace("space",host);
Transaction tr2 = new Transaction();
tr2.addTupleSpace(ts2);
tr1.beginTrans();
tr2.beginTrans();
ts1.write(...
ts2.write(...
tr1.commitTrans();
tr2.commitTrans();
Of course you can have each of these in a separate thread but the idea is the same.
Please also note that you can not have a single Transaction and 2 threads issuing commands to a single TupleSpace unless you ensure that at the time that Trans.commit() is called,
all space operations have finished.
- What exactly are the semantics of a transaction if a client drops out before calling commitTrans? Is there a timeout after which the transaction is rolled back? If so, can I set the timeout?
If the client aborts such that the network connection terminates, then the server will abort the transaction on behalf of the client. In the next release, you will also be able to set a timeout after which if there is no input
from the client, it will abort the connection.
- Is it possible to have a single transaction on multiple tuplespaces?
Yes, it should work with a single transaction on multiple spaces
on the same server.
But we are working on some problems with locking and transactions
in the current distributed version and I strongly suspect
that transactions over multiple spaces will not be reliable.
I would avoid it for now.
- Can I put large files on the server as a tuple?
Tuples reside in main Memory. If your server is running on a system with only 64MB, for example,
then after you store a few 32MB files, your performance is going to seriously degrade.
Moreover, Tuples are transmitted using the Java Serialization routines,
which are not optimized for data transmission speed.
One solution is to use the URLCopy facility.
It will copy the file to the server and keep it as a file so that
only the filename is kept in memory.
URLCopy also uses a separate protocol that is much faster.
You can also do, more or less, the same thing yourself with a
web server on the system where the files reside and using
URLs in a tuple to pass a pointer to the file.
- How can I specify that I want files to be retained indefinitely
when I use URLCopy?
You can use the setRetention() method to set the retention periond
but currently there is no way to specify "retain indefinitely".
You would just have to specify a very large value like 10 years (10*365*24*60*60).
The default is now 24 hours.
In the next release, we will add an ability to specify "forever".
We will also change it so that the default is to let the server set the value based on a config file option.
- If I take the tuple that refers to the file and
fail to call URLCopy.copyToLocal(String, false) on it,
does the file just remain or is it garbage collected at some point?
It is the application responsibility to delete the file if it
needs to be deleted prior to the expiration time.
There may very well be cases where you take or delete
the tuple that contains the URLCopy field but you want the
file to remain available to clients.
The new Timer class in JDK 1.3 would make it easy for
the client to do a take of the tuple and then
issue (copyToLocal(file,false)) after 30 minutes has gone by.
- How do I handle object references across TupleSpaces?
We have the concept of a TupleID that can be used to maintain the references from one tuple to another. A TupleID is persistent and the combination of
TupleSpaceName and TupleID can be maintained across multiple spaces. The String form of the TupleID can be indexed and searched.
- Is there a way to scan the space for all tuples newer than a given timestamp that match a specified template?
You can do this, but there are some things that you need to know that are not documented very well (or at all).
First, you need to specify FIFO for the space so that it will maintain a timestamp index.
config = new ConfigTuple();
config.setOption(ConfigTuple.FIFO,Boolean.TRUE);
TupleSpace ts = new TupleSpace(tsName,host,config);
String indexName = ConfigTuple.TIMESTAMP_INDEX;
You can access the timestamp for a particular Tuple via getTimeStamp()
TupleID tid = ts.write(tuple);
tuple = (Tuple)ts.readTupleById(tid);
long lastTimeStamp = test1.getTimeStamp();
This timestamp is the same type of value (time in ms) that you would get from new Date().getTime() but you want to get it from the server by reading back a Tuple.
Now you can use IndexQuery. (e.g remove all tuples over 1 hour old)
Range range = new Range(null,new Long(lastTimeStamp-60*60*1000));
IndexQuery iq = new IndexQuery(indexName,range);
Tuple result = ts.consumingScan(iq);
Another example:
Tuple template = new Tuple(normal template definition);
Range range = new Range(new Long(lastTimeStamp),null);
IndexQuery iq = new IndexQuery(indexName,range);
MatchQuery mq = new MatchQuery(template);
AndQuery andq = new AndQuery(iq,mq);
Tuple result = ts.scan(andq);
- Is there a way to read all the Tuple and SubClassableTuple object at once?
If I try a scan(new Tuple()) I get back all tuples of class Tuple. If I try scan(new SubclassableTuple())
I get back all tuples which inherit from SubclassableTuple.
I can do a transaction
to read both in at once, but then I have to do two loops to process the results.
This is inconvenient also when I want
to receive an event when ANY tuple is written as I have to register it twice.
The TSpaces design for Tuple matching is that if you use SubclassableTuple, you don't have to worry about a Tuple inadvertently
matching your SublassableTuple just because the structure happens to match. We do have one somewhat exception to this in the DeleteAll command which is unfortunate. At this point, it is probably too late to remove DeleteAll and I hesitate to add a ScanAll command although perhaps that would be reasonable request. But I would not want to add any facility that causes a Tuple template to be a
template match for a SubclassableTuple.
However, you do have control over the matches() method in your SubclassableTuple. So if you want your subclassable Tuple to be able to match a
Tuple, you can do that. Something like this would work for class MySubclassbleTuple
public boolean matches( SuperTuple t_ ) {
if (this.numberOfFields() == 0)
return true;
return super.matches(t_);
}
Then you could have:
MySubclassableTuple all = new MySubclassbleTuple();
Tuple allTuples = ts.scan(all);
This would return all the Tuples and Subclassable Tuples.
- I'm looking for an efficient way to do a blocking read of tuples matching a template that
will only read each tuple one time.
I might have several clients waiting with the same template, and I want them each to see a new matching tuple when it arrives.
Other clients are waiting with different templates at the same time. If I use waitToTake(), only one client (in a group with matching
templates) gets to see a new tuple, because the first client takes it away. If I use waitToRead, the same tuple just gets read repeatedly.
I don't want to use a write event callback, because every client everywhere will have to inspect each new tuple.
What should I do?
You should be able to use the event callback with the specific template that you are interested in - this way, all clients will be able to
see the new tuples. To prevent the tuple from hanging around forever (since no
clients will be doing a take), you can set an expiration time on the tuple ... this means every client that cares about a tuple will be called
when the tuple arrives, AND the tuple will go away by itself. So, in short, I
think the event callback is the best way to go when several clients may need the same tuple.
The JavaSpaces book ("JavaSpaces, Principles, Patterns and Practice", Addison-Wesley, 1999) discusses other solutions for this problem in
Chapter 3.
- How are queries evaluated in TSpaces?
Queries (using named fields) use an index, whereas matches use a space scan. If there are several parts (with AND, OR, etc), then the first
query uses an index scan, then the rest of the predicates are evaluated as "residuals", which means they are checked directly for each tuple.
We don't do any "index Anding", like the relational systems do.
- I'm trying to add a "watching" thread to the worker class (in the TSpaces examples) that waits for "poison pills" to be written to a
space, and terminates the worker when it eats one. Has anyone written this sort of thing yet?
Take a look at the Merger.java class in examples/mergesort. It does exactly what you are looking for. Basically it has a timeout after which
it generates an anonymous inner class that is a Thread that writes a Tuple that satisfies the WaitToTake.
- How can I specify that Tuples should expire after some time.
The setExpire() method is used to set the expire interval for a
Tuple. The default is to not expire the Tuple.
- I want to know for how long time a certain tuple has existed in a tuplespace. The timestamp gives you the time when the Tuple was
posted, but how do you get time the tuple was read (i.e. the current server time)?
Sorry, there is no way to get an accurate server time directly. It doesn't sound like a service that a client really needs. If you wanted
an approximate server time, you could have a "clock" tuple that you wrote and reread immediately. However, this doesn't seem like it would
scale very well if you were fairly time-centric and the server was heavily loaded.
- TSpaces doesn't issue an event callback when a tuple expires.
Are there any workarounds to this behavior?
Well yes, if you write a Tuple that is to expire in 2 minutes
then in 2 minutes it will expire.
There are lots of ways to figure out when 2 minutes will pass!
And if someone else writes the Tuple, you can get the
Tuple in your Write event handler and query the expire time
so you will know when it should expires.
Beause of the number of requests for this,
the next release will support Expire events.
- Will I experience any problems storing an array of bytes (byte[]) in my tuple?
No, you'll not. Java treats an array as a serialiazable object so it is a valid Field value. Here is a fragment of code that I wrote to verify that
TSpaces can store very long arrays of byte.
for ( int s = 1; s<999; s++) {
System.out.println( s );
byte h[] = new byte[ s*1000 ];
for( int i=0;i< s*1000; i++) {
h[i] = 65;
}
String key = "hello"+s;
Tuple t = new Tuple(key, h );
ts.write( t );
Tuple template = new Tuple(key,new Field(byte[].class));
Tuple t2 = ts.read(template);
System.out.println(t2);
ts.delete(template);
}
- I use subTuple=new Tuple("SequenceNum", new Integer(sequenceNumber)) to create a new tuple with a single field named "SequenceNum" of
type Integer, however it doesn't work. What's wrong?
You are generating the Tuple with:
subTuple=new Tuple("SequenceNum", new Integer(sequenceNumber));
with the expectation that this will generate a Tuple with a single Field named "Sequence Number" and with the value of
Integer(seq). What it really generates is a Tuple with two fields, one with the value "SequenceNum" and the 2nd with the
value Integer(seq). This confusion is because of all the overloaded methods that the TupleSpace class is shipped with.
What you really wanted is
Field f1 = new Field("SequenceNum", new Integer(sequenceNumber));
subTuple = new Tuple(f1);
Back to top
 |
Server operation |
- After stopping the server in a less-than-nice manner (end task from windows) and trying to restart it, the error message told me that
the space has been damaged and I need to restart with the "-b" option that would clear the information and start a fresh space. The problem is
that I am using the space for both transient and persistent information, which I would not like to loose. What should I do?
The one problem that I can imagine would generate this message would be if you wrote some Tuples that contained user objects. Then prior to
restarting the server, you made incompatible changes to those user objects. Thus during the restart, it would be unable to reread those Tuples
from the persistent store because it would be unable to deserialize them. This problem is discussed in the programmer's guide. The easiest solution
is to use SerialVer in your user objects.
- Is there a way to shutdown TSpaces through the Web interface?
Not through the existing HTTP server interface but "shutdown" is a client command and you can easily write an applet that requests the userid and password
for the admin user and then issue the shutdown command to the server.
- How can I control the expiration of tuples?
You can control how often the expiring of Tuples happens via the ExpireInterval parameter in the tspaces.cfg file. Setting it high
leaves the Tuples around longer but doing it often may cause erratic behavior because the scan of the entire space to remove the
expired tuples is a high cost operation.
- What is the official way to disable the Expire-Manager?
It doesn't have any value that turns it off, so you should set it to a very very large value like 10 years and it will run once when
you start the server and then again 10 years from now. If the same expire manager is still around in the next release, we will change
it to have a value like 0 to shut it off.
- What is reported in the TSServer.status() method?
Issue the "q" subcommand from the server command line. That is basically the output that status() produces. Up to this point, status() has been used to display information that is useful for statistics and/or
problem determination. As a result, it often changes from release to release and even service pack to service pack.
- What are the meanings of the different checkpoint/file config options and how would you suggest setting them?
There are 3 parameters related to persistence:
CheckpointDir = directory
CheckpointInterval = minutes
checkpointWriteThreshold =
One needs to specify a valid directory for "CheckpointDir" in order to support persistent spaces. The server will use this directory
both to write a copy of the in-memory spaces and to write log records as each command is committed. If you have a failure, at restart the
latest copy of a space will be read and these log records will be read and the copy of the space updated to the point of failure.
The "CheckpointInterval" and "checkpointWriteThreshold" are used to determine how often a new copy of the space is made based on either time or number of updates.
When a new copy of the space is made the log record is reset. So if you have a small space with lots of write and delete activity, the log file will grow rapidly
and it is more efficient to checkpoint it regularly. However a large space with infrequent updates will generate a lot of overhead making frequent copies of the space.
(The space can't be updated while this copy is being made). If the application wants to have more control, there is a "Checkpoint" command that can be issued from the client
(assuming Admin authority).
- Server hangs on Sun Solaris 2.6?
One user encountered a TSpaces 2.1.0 server problem running on
a Sun Sparc Solaris 2.6 system where the server would freeze on socket
operations. The problem occurred after they updated TSpaces to version
2.10 and upgraded the Java to JDK-1.2.1-04.
The problem has been traced to a missing 'recommended' solaris patch
number 105181-05. This patch is required for TSpaces to function
correctly.
The problem is further complicated by a Sun bug in the patching tools
on Solaris 2.6 systems which prevents the needed patch from being
installed.
To install the needed patch (105181-05) a patch to the patching tools,
number 106125-08 must be installed first.
Back to top
 |
Security Issues |
- What security support do you have? Do you have support for users, groups, and
passwords?
Yes, we do have user, group, and password support.
Although it is functional, it still has some rough edges.
The configuration file is distributed with a flag set to
"disable user/group access checking." We recommend
running with this setting for initial testing.
However, the programmer's guide does have an
access control section and a working example
of how to use the access control feature.
- I've written a class that starts a TSpaces server, but it seems that the files acldb.ser and passwd.ser get created in my current directory whenever it starts a server.
How do I describe where to put these files?
Try adding the following to the AccessControl section in the tspaces.cfg file:
AclBackup = filename
PasswordBackup = filename
- How do I setup who is the admin for all the spaces
on the TSpaces server?
When you initially start the server, the config file is used to setup
the initial values for the admin userid and password along with the
initial ACLs and the set of initial users.
Subsequently, you can use the distributed admin GUI utility to change this.
- I want only the administrator to be able to create spaces,
what do I have to do?
The config file has a CreateACL stanza that specifies who can create
spaces. It can be changed to specify that only sysadmin can create spaces.
The comments in the distributed tspaces.cfg file should be helpful.
- How do I create users on the fly?
That's not possible yet. It will be supported in the next version.
- Is there a way to choose separately if you want to restore the user and group-information?
The "boot" command option "-b" will restart without remembering the old space information but it does keep the user group information
from before (from the backup files). The command option "-B" is the same as "-b" but it also does not read the old saved user/group
information from the backup files. So the user/group information is then what ever is in the configuration file.
- I want to implement a mechanism to contact the space-admin application to create an account.
I want to determine if a login already exists in the space. When I try to access a space with login and password there may be two
exceptions "Exception: TupleSpace connection cannot be established. -user does not exist" or "Exception:login for
failed, ********* is not the correct password". How can I figure out which of these problems happened?
Currently there is no good way other than a specific String compare. We are working on revising the Exceptions.
- When I start a tuplespace in a client, if the named tuplespace does not exist on the server it is created. Is there a way to
request this not happen?
Yes, if you turn on access control checking in the config file, you can also (either with the config file or the distributed admin GUI tool)
change the create access list so that only certain users can create spaces. You can also use the TupleSpace.exists(name,server) to find out
if a space exists before you call the constructor.
TupleSpace.setUserName(...);
TupleSpace.setPassword(...);
if (TupleSpace.exists(name,server) {
ts = new TupleSpace(name,server)
...
} else {
System.out.println("Space does not exist");
}
- In my application a client can access the server
(which is admin of the space) via HTTP and I don't want to
send the password as a string.
The problem is that the Netscape and probably the IE browser does not
have the SHA support which is why when one specifies
TupleSpace.appletEnvironment(true);
it then bypasses the SHA code and sends the password in clear text.
You can try not setting appletEnvironment and see if that will
work in your environment. Another solution is to make sure that
your admin always accesses the server from the same machine or
even the same LAN as the server so that the password
never goes outside of your local environment.
Another solution is to implement the administrative functions
in a stand alone Java application
- When you connect to a space from a client you are associated with your login for all further sessions.
This means that if you connect to a space as anonymous and then to another as lets say "sysadmin" you will still
be anonymous and your login (sysadmin) and password will be ignored. Is this the intended behavior?
If yes, then please how do I disconnect as a user and reconnect as another one in the same running code?
Yes, this is the intended behavior. The authorization is setup when you make your initial connection to the server.
So once you talk to a server as "joerg" then you are "joerg" for all further conversations with any spaces on that server.
If you want to talk to one space as "joerg" and then later talk to the same server but perhaps a different space as "joe" you can do the
following. You use the TupleSpace.cleanup(server,post) and it will terminate the connection to the server. You can then issue a new
Tuplespace command specifying a new user and password and it will be used for the new connection.
Now if you want to talk to one space as "joerg" and another space as "joe" you have to use a sleazy hack. Let's assume you want to talk
to the server on "billygates.microsoft.com". So if you did the following:
ts1 = new TupleSpace("space1","billygates.microsoft.com","jorge","pass1");
ts2 = new TupleSpace("space2","BillyGates.microsoft.com","joe","pass2");
Then you would get two separate connections with different user authorizations.
Again, it's a sleazy hack! It exists because someone neglected to ignore case on the server host name when checking for an existing
connection.
Back to top
 |
XML |
- I cannot get the following code to work (the server does not parse the XML). What's wrong?
Field xmlField = new XMLField(xmlstring);
xmlTuple = new Tuple(xmlField);
write(new Tuple(xmlTuple));
This would create a Tuple that contains a Tuple that contains an XMLField. That is legal but the internal Tuple does
not get parsed. If you want to have a Tuple that contains a reference to a Tuple that contain an XMLField, then you
probably want to use TupleID.
TupleID tid = write(xmlTuple);
write(new Tuple(tid));
Or perhaps you meant to add the XMLField to an existing Tuple that you then write:
Tuple t = new Tuple();
...
Field xmlField = new XMLField(xmlstring);
t.add(xmlField)
write(t);
- Can you modify part of the DOM Tuple(s) once it's been entered as a complete document?
Right now, there is no interface for modifying part of a DOM tree individually. But keep in mind that the tupleized
DOM nodes are just tuples with another field, so there's nothing stopping you from doing normal TSpaces operations
on them.
- Can you query across multiple tupleized XML documents?
Yes, XQL style queries are across all existing XML tuples in a given server.
- How an XML document is saved?
It is divided up at the server into a bunch of tuples corresponding to the DOM tree.
- Can I query the TSpaces server for nodes in the DOM tree?
Yes, you can. You will receive them back as tuples.
- Can I replace the nodes with any arbitrary tuple?
You can do that, but it won't make any sense to the server and will probably break stuff.
In order to put an XML-like tuple into a TSpaces you need to construct a tuple with an XTuple field that contains
pointers to any children tuples, as well as its own set of value and attributes. I don't think you would be able
to do that without the JavaDoc from the server source.
- I can compile the TestXTuple.java file but whenever I run it I get many errors. What's wrong?
The TestXTuple sample requires that the tspaces.jar and xerces.jar files be in the classpath at runtime.
- I would like to use eventRegister() for an XMLQuery object. What should I do?
The eventRegister() method only takes a Tuple instance, therefore you have to wrap your XMLQuery object in a tuple. Here is the code taken out of the TestXSuite example.
xql = "invoice//product";
Tuple query = new Tuple(new XMLQuery(xql));
int seq = ts.eventRegister(TupleSpace.WRITE,query,this);
Back to top
 |
PDA support |
- Where can I find information about TSpaces support for Palm?
You can check MoDAL and RMI Lite.
- Do you need KVM or other VM like Waba with TSpaces on the Palm? Or can TSpaces alone be used in developing applications for the Palm?
The MoDAL interpreter (available from AlphaWorks) is a specialized TSpaces client that runs directly on the Palm OS. Since MoDAL is compiled for the Palm-OS,
it installs as any other Palm-OS application and requires no additional Palm-based VM. A proxy running on a PC-based VM manages communication between the MoDAL
interpreter (on the hand-held) and the TSpaces server (somewhere else).
A subset of the TSpaces client lib is also available for Waba and KVM. Information about that can be found at http://post-pc.cs.berkeley.edu/rmilite/
- Could I write an application that runs under KVM or Waba and takes a tuple from a TSpaces server via a MoDAL application and writes a record to a database on the Palm?
No, MoDAL doesn't do that. It does not read from, or write to, the local Pilot database.
MoDAL is a program that runs on the Pilot that
- Reads a MoDAL program and renders the features on the Pilot screen as specified in the MoDAL program (buttons, boxes, forms, etc)
- Sends and receives tuples over the network. Specifically, it speaks to a TSpaces proxy using a private protocol, that in turn translates
the simple pilot messages (which aren't really tuples yet) into real TSpaces tuples. The server takes those tuples and communicates to other network services.
The current implementation of MoDAL does NOT write or read tuples in the local pilot database. So, it doesn't matter what else is running on the Pilot (KVM or Waba).
If you just want to send and receive tuples and then write them to the local Palm DB, then you might consider taking a public package, like RMI Lite. You'll have to do some programming,
but you'll be closer to your goal. RMI Lite has a small client that allows you to send/receive tuples - it also speaks to a proxy that allows you to turn the simple Pilot messages into
tuples or into RMI calls.
Back to top
|