You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Lukasz Kowalczyk <lu...@jazzpolice.pl> on 2002/08/27 16:40:23 UTC

Using Slide transaction's connection

I have a few tables in the same database that Slide keeps its tables
in and those tables are updated together with modifications in Slide's
repository.

I need to keep changes to Slide and to my tables in synchronization.
My first thought was to use 2-phase commit but PostgreSQL doesn't
support it and I don't know of any other free RDBMS which does (and
which runs on Windows).

Having explained this - is there a way to obtain Slide's connection to
the database after calling NamespaceAccessToken.begin()? This way I
could rollback or commit all changes at once.

-- 
Łukasz Kowalczyk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[4]: Using Slide transaction's connection

Posted by Lukasz Kowalczyk <lu...@jazzpolice.pl>.
Wednesday, August 28, 2002, 5:36:01 PM, you wrote:

TW> Whoo ..  that sounds a lot of work but I probably don't fully understand
TW> what you mean by plug in.  Slide's transaction framework supports XA

I simply meant to replace Slide's TransactionManager with a patched or
brand new version. I have a few services (built upon Jakarta Fulcrum)
and all of them are using the same database. I also put together a
little neat service on top of Slide and that's why I thought of making
a common transaction manager for all the services.

TW> transactions and is a well done grand piece of work (my hat off to the
TW> developers).  Also, at the app layer you only have access to
TW> NameSpaceAccessToken (represents a UserTransaction) so you'll need to get
TW> hold of the transaction somehow.  That's why I suggested using thread
TW> context.

-- 
Łukasz Kowalczyk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Re[2]: Using Slide transaction's connection

Posted by Tom Wang <to...@panscopic.com>.
Whoo ..  that sounds a lot of work but I probably don't fully understand
what you mean by plug in.  Slide's transaction framework supports XA
transactions and is a well done grand piece of work (my hat off to the
developers).  Also, at the app layer you only have access to
NameSpaceAccessToken (represents a UserTransaction) so you'll need to get
hold of the transaction somehow.  That's why I suggested using thread
context.

Tom Wang
Panscopic Corporation
Report All That You Can Report
http://www.panscopic.com/download


> -----Original Message-----
> From: Lukasz Kowalczyk [mailto:lukasz@jazzpolice.pl]
> Sent: Wednesday, August 28, 2002 3:38 AM
> To: Slide Users Mailing List; tomw@panscopic.com
> Subject: Re[2]: Using Slide transaction's connection
>
>
> Tuesday, August 27, 2002, 10:08:04 PM, you wrote:
>
> TW> Lukasz,
>
> TW> The database connections are completely hidden by each store
> implementation.
> TW> I suggest you can modify the store impl (e.g.
> J2EEDescriptorsStore) and add
> TW> a pointer to the connection in the thread context.  This way you can
> TW> retrieve the same connection used by Slide store from the
> thread context
> TW> when updating your own data.
>
> Thanks for idea. It looks like a major hack ;)  I was also thinking
> about plugging my own TransactionManager (or my own Transaction, not
> sure yet). Does this sound feasible to you?
>
> TW> Tom Wang
> TW> Panscopic Corporation
> TW> Web Reporting, Just Add Data
> TW> http://www.panscopic.com/
>
>
> >> -----Original Message-----
> >> From: Lukasz Kowalczyk [mailto:lukasz@jazzpolice.pl]
> >> Sent: Tuesday, August 27, 2002 7:40 AM
> >> To: slide-user@jakarta.apache.org
> >> Subject: Using Slide transaction's connection
> >>
> >>
> >> I have a few tables in the same database that Slide keeps its tables
> >> in and those tables are updated together with modifications in Slide's
> >> repository.
> >>
> >> I need to keep changes to Slide and to my tables in synchronization.
> >> My first thought was to use 2-phase commit but PostgreSQL doesn't
> >> support it and I don't know of any other free RDBMS which does (and
> >> which runs on Windows).
> >>
> >> Having explained this - is there a way to obtain Slide's connection to
> >> the database after calling NamespaceAccessToken.begin()? This way I
> >> could rollback or commit all changes at once.
> >>
> >> --
> >> Łukasz Kowalczyk
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail:
> >> <ma...@jakarta.apache.org>
> >>
> >>
>
>
> TW> --
> TW> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
TW> For additional commands, e-mail:
<ma...@jakarta.apache.org>




--
Łukasz Kowalczyk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[2]: Using Slide transaction's connection

Posted by Lukasz Kowalczyk <lu...@jazzpolice.pl>.
Tuesday, August 27, 2002, 10:08:04 PM, you wrote:

TW> Lukasz,

TW> The database connections are completely hidden by each store implementation.
TW> I suggest you can modify the store impl (e.g. J2EEDescriptorsStore) and add
TW> a pointer to the connection in the thread context.  This way you can
TW> retrieve the same connection used by Slide store from the thread context
TW> when updating your own data.

Thanks for idea. It looks like a major hack ;)  I was also thinking
about plugging my own TransactionManager (or my own Transaction, not
sure yet). Does this sound feasible to you?

TW> Tom Wang
TW> Panscopic Corporation
TW> Web Reporting, Just Add Data
TW> http://www.panscopic.com/


>> -----Original Message-----
>> From: Lukasz Kowalczyk [mailto:lukasz@jazzpolice.pl]
>> Sent: Tuesday, August 27, 2002 7:40 AM
>> To: slide-user@jakarta.apache.org
>> Subject: Using Slide transaction's connection
>>
>>
>> I have a few tables in the same database that Slide keeps its tables
>> in and those tables are updated together with modifications in Slide's
>> repository.
>>
>> I need to keep changes to Slide and to my tables in synchronization.
>> My first thought was to use 2-phase commit but PostgreSQL doesn't
>> support it and I don't know of any other free RDBMS which does (and
>> which runs on Windows).
>>
>> Having explained this - is there a way to obtain Slide's connection to
>> the database after calling NamespaceAccessToken.begin()? This way I
>> could rollback or commit all changes at once.
>>
>> --
>> Łukasz Kowalczyk
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>>
>>


TW> --
TW> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
TW> For additional commands, e-mail: <ma...@jakarta.apache.org>




-- 
Łukasz Kowalczyk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[2]: Using Slide transaction's connection

Posted by Lukasz Kowalczyk <lu...@jazzpolice.pl>.
Thursday, August 29, 2002, 10:47:13 PM, you wrote:

TW> Bita,

TW> I don't have sample code to show you but I'll try to explain better.  Take a
TW> look at J2EEDescriptorsStore.  It maintains a connection map to support
TW> concurrent clients.  This way the store knows which connection to use when
TW> dealing with a specific thread.  What I was suggesting is to save the
TW> connection reference in the current thread context (you'll need to create
TW> the context yourself, maybe using ThreadLocal).  Since at the app layer you
TW> only have the handle to NamespaceAccessToken, which means you can't get to
TW> the connection map since it's hidden by the store impl.  But you can get the
TW> connection from your current thread context.  Am i making sense?

There may be a problem with choosing which connection to pick since
each store has its own. Also, not all stores use JDBC connections
(FileStore for instance). I still think a more general solution could
be useful. It's strange no one predicted that Slide may be only a
small part of a larger system (although, maybe this kind of design,
ie. pluggable transaction manager is not possible with JTA, I don't
know).

-- 
Lukasz Kowalczyk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[2]: Using Slide transaction's connection

Posted by Lukasz Kowalczyk <lu...@jazzpolice.pl>.
Monday, September 02, 2002, 8:02:59 PM, you wrote:


BS> To make it more clear, consider the following operations as one transaction in
BS> a given thread:
BS> try {
BS>    TA.start()
BS>    operation on my tables
BS>   Mkcol method--> which causes some operations on the slide's tables  and is
BS> considered as one transaction in slide.
BS>   operation on my tables
BS>   TA.commit()
BS> } catch ( Exception e) {
BS>   TA.rollback()
BS> }

BS> I know that we can not have nested transaction, so practically
BS> what I have written is wrong, but logically I want to have above
BS> order of transaction and I don't know how can I cancel the
BS> transaction commands in the Mkcol method. Is there any way??

Slide transactions are managed through the use of
NamespaceAccessToken's begin, commit and rollback methods. Still, you
can't write something like

try {
    token.begin()
    mymanager.begin()

    mkcol()
    myOwnOperations()

    token.commit()
    mymanager.commit()
} catch (Exception e) {
    token.rollback()
    mymanager.rollback()
}

because this still may cause inconsistencies in the database. On the
other hand, if you could manage to somehow use connection that one of
Slide store uses:

try {
    token.begin()

    mkcol()
    myOwnOperations(token.getConnection())

    token.commit()
} catch (Exception e) {
    token.rollback()
}

it would be enough to guarantee consistent database updates.

The above code fragment is bogus because there's currently no way of
getting Connection from NAT. But if you patched one of the Slide stores
(the one which is used by all URIs) to put Connection in a thread
context object, you could later fetch this connection and pass it over
to myOwnOperations().

I'm not absolutely sure about this but I think the connection is first
fetched by a store after it performs its first operation. So you
should always perform you own operations *after* Slide.

-- 
Łukasz Kowalczyk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Using Slide transaction's connection

Posted by "B. Shadgar" <sh...@compsci.bristol.ac.uk>.
Tom Wang wrote:

> Bita,
>
> I don't have sample code to show you but I'll try to explain better.  Take a
> look at J2EEDescriptorsStore.  It maintains a connection map to support
> concurrent clients.  This way the store knows which connection to use when
> dealing with a specific thread.  What I was suggesting is to save the
> connection reference in the current thread context (you'll need to create
> the context yourself, maybe using ThreadLocal).  Since at the app layer you
> only have the handle to NamespaceAccessToken, which means you can't get to
> the connection map since it's hidden by the store impl.  But you can get the
> connection from your current thread context.  Am i making sense?
>
> Tom Wang
> Panscopic Corporation
> Web Reporting, Just Add Data
> http://www.panscopic.com/download

Tom & Lukasz

Now I understand your mean quite better. But still I am not clear when there
were some other tables in the same database as slide's tables, and we are going
to consider a bunch of  operations,  whether on the Slide's tables or other
tables, as one transaction. In this case I don't know how the thread context
can help me, or even does it help or not?

To make it more clear, consider the following operations as one transaction in
a given thread:
try {
   TA.start()
   operation on my tables
  Mkcol method--> which causes some operations on the slide's tables  and is
considered as one transaction in slide.
  operation on my tables
  TA.commit()
} catch ( Exception e) {
  TA.rollback()
}

I know that we can not have nested transaction, so practically what I have
written is wrong, but logically I want to have above order of transaction and I
don't know how can I cancel the transaction commands in the Mkcol method.
Is there any way??

Regards,
Bita.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Using Slide transaction's connection

Posted by Tom Wang <to...@panscopic.com>.
Bita,

I don't have sample code to show you but I'll try to explain better.  Take a
look at J2EEDescriptorsStore.  It maintains a connection map to support
concurrent clients.  This way the store knows which connection to use when
dealing with a specific thread.  What I was suggesting is to save the
connection reference in the current thread context (you'll need to create
the context yourself, maybe using ThreadLocal).  Since at the app layer you
only have the handle to NamespaceAccessToken, which means you can't get to
the connection map since it's hidden by the store impl.  But you can get the
connection from your current thread context.  Am i making sense?

Tom Wang
Panscopic Corporation
Web Reporting, Just Add Data
http://www.panscopic.com/download


> -----Original Message-----
> From: shadgar@compsci.bristol.ac.uk
> [mailto:shadgar@compsci.bristol.ac.uk]
> Sent: Thursday, August 29, 2002 11:03 AM
> To: Slide Users Mailing List
> Subject: Re: Using Slide transaction's connection
>
>
> Tom Wang wrote:
>
> > Lukasz,
> >
> > The database connections are completely hidden by each store
> implementation.
> > I suggest you can modify the store impl (e.g.
> J2EEDescriptorsStore) and add
> > a pointer to the connection in the thread context.  This way you can
> > retrieve the same connection used by Slide store from the thread context
> > when updating your own data.
> >
> > Tom Wang
> > Panscopic Corporation
> > Web Reporting, Just Add Data
> > http://www.panscopic.com/
> >
> > > -----Original Message-----
> > > From: Lukasz Kowalczyk [mailto:lukasz@jazzpolice.pl]
> > > Sent: Tuesday, August 27, 2002 7:40 AM
> > > To: slide-user@jakarta.apache.org
> > > Subject: Using Slide transaction's connection
> > >
> > >
> > > I have a few tables in the same database that Slide keeps its tables
> > > in and those tables are updated together with modifications in Slide's
> > > repository.
> > >
> > > I need to keep changes to Slide and to my tables in synchronization.
> > > My first thought was to use 2-phase commit but PostgreSQL doesn't
> > > support it and I don't know of any other free RDBMS which does (and
> > > which runs on Windows).
> > >
> > > Having explained this - is there a way to obtain Slide's connection to
> > > the database after calling NamespaceAccessToken.begin()? This way I
> > > could rollback or commit all changes at once.
> > >
> > > --
> > > #ukasz Kowalczyk
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> Hi,
>
> Unfortunatly, I can't undrestand what you mean exactly, while I
> have the same
> issue as Ukasz. May I ask to reference  me any article or
> resource that make it
> more clear, especially if there was any example code.
> Your help is graetly appreciated,
>
> Bita.
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Using Slide transaction's connection

Posted by "B. Shadgar" <sh...@compsci.bristol.ac.uk>.
Tom Wang wrote:

> Lukasz,
>
> The database connections are completely hidden by each store implementation.
> I suggest you can modify the store impl (e.g. J2EEDescriptorsStore) and add
> a pointer to the connection in the thread context.  This way you can
> retrieve the same connection used by Slide store from the thread context
> when updating your own data.
>
> Tom Wang
> Panscopic Corporation
> Web Reporting, Just Add Data
> http://www.panscopic.com/
>
> > -----Original Message-----
> > From: Lukasz Kowalczyk [mailto:lukasz@jazzpolice.pl]
> > Sent: Tuesday, August 27, 2002 7:40 AM
> > To: slide-user@jakarta.apache.org
> > Subject: Using Slide transaction's connection
> >
> >
> > I have a few tables in the same database that Slide keeps its tables
> > in and those tables are updated together with modifications in Slide's
> > repository.
> >
> > I need to keep changes to Slide and to my tables in synchronization.
> > My first thought was to use 2-phase commit but PostgreSQL doesn't
> > support it and I don't know of any other free RDBMS which does (and
> > which runs on Windows).
> >
> > Having explained this - is there a way to obtain Slide's connection to
> > the database after calling NamespaceAccessToken.begin()? This way I
> > could rollback or commit all changes at once.
> >
> > --
> > #ukasz Kowalczyk
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

Hi,

Unfortunatly, I can't undrestand what you mean exactly, while I have the same
issue as Ukasz. May I ask to reference  me any article or resource that make it
more clear, especially if there was any example code.
Your help is graetly appreciated,

Bita.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Using Slide transaction's connection

Posted by Tom Wang <to...@panscopic.com>.
Lukasz,

The database connections are completely hidden by each store implementation.
I suggest you can modify the store impl (e.g. J2EEDescriptorsStore) and add
a pointer to the connection in the thread context.  This way you can
retrieve the same connection used by Slide store from the thread context
when updating your own data.

Tom Wang
Panscopic Corporation
Web Reporting, Just Add Data
http://www.panscopic.com/


> -----Original Message-----
> From: Lukasz Kowalczyk [mailto:lukasz@jazzpolice.pl]
> Sent: Tuesday, August 27, 2002 7:40 AM
> To: slide-user@jakarta.apache.org
> Subject: Using Slide transaction's connection
>
>
> I have a few tables in the same database that Slide keeps its tables
> in and those tables are updated together with modifications in Slide's
> repository.
>
> I need to keep changes to Slide and to my tables in synchronization.
> My first thought was to use 2-phase commit but PostgreSQL doesn't
> support it and I don't know of any other free RDBMS which does (and
> which runs on Windows).
>
> Having explained this - is there a way to obtain Slide's connection to
> the database after calling NamespaceAccessToken.begin()? This way I
> could rollback or commit all changes at once.
>
> --
> Łukasz Kowalczyk
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>