You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@river.apache.org by Niclas Hedhman <ni...@hedhman.org> on 2008/09/26 13:01:59 UTC

Transactions & Javaspaces

Hi,

Although I have used Jini a lot in the past, I never ventured beyond
Lookup and in-house services. So, I never had a go at Transactions
until now. I have a fairly simple test case, which doesn't seem to
behave as expected.

1) Lookup Javaspace and TransactionManager services.

2) Create the Transaction.
     Transaction.Created created = TransactionFactory.create(
transactionService.service, 60000 );
     Transaction transaction = created.transaction;

 3) Write my entry to the space.
    spaceService.write( new StorageEntry( id, entry ),
currentTransaction(), 6000 );

If I commit that and read it back --> No problems.


But if I abort the transaction after writing the entry to the space, I
can then start a new transaction and still receive the written entry.
So, I thought that I didn't have a transaction (currentTransaction()
returning null), but that is not the case either. I have a whole set
of testcases, and all the ones that verify commit correctness works,
whereas all testing for abort correctness fails.


Any suggestions?


Cheers
Niclas

Re: Transactions & Javaspaces

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Sat, Sep 27, 2008 at 2:54 PM, Niclas Hedhman <ni...@hedhman.org> wrote:

> Well, since I am always assuming I am a complete idiot, I added an
> Iteration test. And now my confidence is hitting a real low;
>
>  * If I store 6 entries of the above "kualaLumpur", the
> MatchSet.next() will only return 5!! before giving me a null. Any
> number minus one.

Forget this part; I had (of course) a next() as left-over in the code
that I didn't notice.

Sorry about that. Still tracking my abort() problems, though...


Cheers
Niclas

Re: Transactions & Javaspaces

Posted by Gregg Wonderly <ge...@cox.net>.
Niclas Hedhman wrote:
> On Sat, Sep 27, 2008 at 2:54 PM, Niclas Hedhman <ni...@hedhman.org> wrote:
> 
>>>> But if I abort the transaction after writing the entry to the space, I
>>>> can then start a new transaction and still receive the written entry.
> 
> Problem solved; I managed to 'loose' the transaction under certain
> circumstances, which lead to 'null' being passed and bla bla bla...

I was going to ask where the renewals on the Transaction Leases were occurring at...

Gregg Wonderly

Re: Transactions & Javaspaces

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Sat, Sep 27, 2008 at 2:54 PM, Niclas Hedhman <ni...@hedhman.org> wrote:

>>> But if I abort the transaction after writing the entry to the space, I
>>> can then start a new transaction and still receive the written entry.

Problem solved; I managed to 'loose' the transaction under certain
circumstances, which lead to 'null' being passed and bla bla bla...

Thanks for your patience.

Cheers
Niclas

Re: Transactions & Javaspaces

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Sat, Sep 27, 2008 at 5:33 AM, Bob Scheifler <Bo...@sun.com> wrote:
> Niclas Hedhman wrote:
>>
>>  3) Write my entry to the space.
>>    spaceService.write( new StorageEntry( id, entry ),
>> currentTransaction(), 6000 );
>>
>> If I commit that and read it back --> No problems.
>>
>> But if I abort the transaction after writing the entry to the space, I
>> can then start a new transaction and still receive the written entry.
>
> Are you sure you aren't just reading the previously committed entry again?

Uhhhh... Well, my testcases ends with remove the stuff that has been
added, and I make sure the entry doesn't exist before the test is
started. But also, I have opposite testcases;

        SpaceTransaction transaction = space().newTransaction();
        Assert.assertNull( space().readIfExists( "123" ) );
        City kualaLumpur = createKualaLumpur();
        space().write( "123", kualaLumpur );
        Assert.assertNotNull( space().readIfExists( "123" ) );
        transaction.abort();
        Assert.assertNull( space().readIfExists( "123" ) );  // <-- Fails

And

        SpaceTransaction transaction = space().newTransaction();
        City kualaLumpur = createKualaLumpur();
        space().write( "123", kualaLumpur );
        Assert.assertNotNull( space().readIfExists( "123" ) );
        transaction.commit();
        transaction = space().newTransaction();
        City clone = (City) space().takeIfExists( "123" );
        Assert.assertNotNull( clone );
        Assert.assertNull( space().readIfExists( "123" ) );
        transaction.abort();
        Assert.assertNotNull( space().readIfExists( "123" ) ); // <-- Fails

Well, since I am always assuming I am a complete idiot, I added an
Iteration test. And now my confidence is hitting a real low;

 * If I store 6 entries of the above "kualaLumpur", the
MatchSet.next() will only return 5!! before giving me a null. Any
number minus one.

I'll see if I can locate the Jini testcases and find out what I am
doing differently...


Cheers
Niclas

Re: Transactions & Javaspaces

Posted by Bob Scheifler <Bo...@Sun.COM>.
Niclas Hedhman wrote:
>  3) Write my entry to the space.
>     spaceService.write( new StorageEntry( id, entry ),
> currentTransaction(), 6000 );
> 
> If I commit that and read it back --> No problems.
> 
> But if I abort the transaction after writing the entry to the space, I
> can then start a new transaction and still receive the written entry.

Are you sure you aren't just reading the previously committed entry again?

- Bob