Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Automatic committing turned on and automatic locking
[CDO] Automatic committing turned on and automatic locking [message #1710610] Wed, 07 October 2015 21:29 Go to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi there,

I've just have a look at the nice documentation that Eike blogged about and I have found highly valuable informations and especially this point it is possible to turn on automatic committing.

Hence, I'm looking where is this option, I cannot find it on transaction.options() or session.options Sad

It could be done through a transactionHandler but I did not find an inherited class with the name AutomaticCommitTransactionHandler...

Does anyone have an idea ?

Regarding automatic locking, is it right to use the CDOAutoLocker class ?

Thanks in advance for your help.

Stéphane.
Re: [CDO] Automatic committing turned on and automatic locking [message #1710662 is a reply to message #1710610] Thu, 08 October 2015 09:12 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 07.10.2015 um 23:29 schrieb Stephane Fournier:
> Hi there,
>
> I've just have a look at the nice documentation that Eike blogged about and I have found highly valuable informations
> and especially this point it is possible to turn on automatic committing.
> Hence, I'm looking where is this option, I cannot find it on transaction.options() or session.options :(
>
> It could be done through a transactionHandler but I did not find an inherited class with the name
> AutomaticCommitTransactionHandler...
> Does anyone have an idea ?
Hm, I thought I provided a small utility class but apparently I did some experiment in CDOCheckoutImpl. That experiment
is currently commented out, but should do the trick:

transaction.addTransactionHandler(new CDODefaultTransactionHandler1()
{
private Job commitJob = new Job("Commit")
{
@Override
protected IStatus run(IProgressMonitor monitor)
{
try
{
synchronized (transaction)
{
if (transaction.isDirty())
{
transaction.commit();
}
}
}
catch (Throwable ex)
{
ex.printStackTrace();
}

return Status.OK_STATUS;
}
};

@Override
public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
{
commitJob.schedule(200);
}
});

I hope that helps.

>
> Regarding automatic locking, is it right to use the CDOAutoLocker class ?
Yes, that's the one.

> Thanks in advance for your help.
You're welcome ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Automatic committing turned on and automatic locking [message #1710862 is a reply to message #1710662] Fri, 09 October 2015 20:32 Go to previous messageGo to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Eike,
Thank you for the answer.

Why do you need to schedule the commit after 200ms ? Is it possible to do it directly in modifying method ?

To do the same feature, I'm using an EditingDomain where all model changes are performed through EMF commands (not based on changeRecorder). Hence, in overriding the commandStack I get the transaction from the impacted objects and I commit the transaction when the command completes.

When I read your great documentation, I was wondering what is the best approach in terms of performances in real time context (multiple JVM modifying data at high pace on the same cdo server) ? I do not need undo / redo capabilities.

Waiting for 200ms could be long in real time context Smile

I will test your suggested code to evaluate this approach.

Stephane.


Eike Stepper wrote on Thu, 08 October 2015 05:12
Am 07.10.2015 um 23:29 schrieb Stephane Fournier:
> Hi there,
>
> I've just have a look at the nice documentation that Eike blogged about and I have found highly valuable informations
> and especially this point it is possible to turn on automatic committing.
> Hence, I'm looking where is this option, I cannot find it on transaction.options() or session.options Sad
>
> It could be done through a transactionHandler but I did not find an inherited class with the name
> AutomaticCommitTransactionHandler...
> Does anyone have an idea ?
Hm, I thought I provided a small utility class but apparently I did some experiment in CDOCheckoutImpl. That experiment
is currently commented out, but should do the trick:

transaction.addTransactionHandler(new CDODefaultTransactionHandler1()
{
private Job commitJob = new Job("Commit")
{
@Override
protected IStatus run(IProgressMonitor monitor)
{
try
{
synchronized (transaction)
{
if (transaction.isDirty())
{
transaction.commit();
}
}
}
catch (Throwable ex)
{
ex.printStackTrace();
}

return Status.OK_STATUS;
}
};

@Override
public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
{
commitJob.schedule(200);
}
});

I hope that helps.


>
> Regarding automatic locking, is it right to use the CDOAutoLocker class ?
Yes, that's the one.

> Thanks in advance for your help.
You're welcome Wink

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Automatic committing turned on and automatic locking [message #1710929 is a reply to message #1710862] Sun, 11 October 2015 09:40 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 09.10.2015 um 22:32 schrieb Stephane Fournier:
> Eike,
> Thank you for the answer.
>
> Why do you need to schedule the commit after 200ms ? Is it possible to do it directly in modifying method ?
That's not strictly needed. At a minimum you'd want to ensure that the commit does not happen on the UI thread. But if
you fork off a new thread you'd probably don't want to queue up many commit threads if the first one would already
commit all changes together. IIRC a call to CDOTransaction.commit() *always* involves a server round-trip, even if the
transaction is not dirty (that's related to releasing potential locks).

> To do the same feature, I'm using an EditingDomain where all model changes are performed through EMF commands (not
> based on changeRecorder). Hence, in overriding the commandStack I get the transaction from the impacted objects and I
> commit the transaction when the command completes.
>
> When I read your great documentation, I was wondering what is the best approach in terms of performances in real time
> context (multiple JVM modifying data at high pace on the same cdo server) ? I do not need undo / redo capabilities.
Certainly an optimistic locking strategy. That would probably involve the ability to "replay" the changes in cases of
ConcurrentAccessExceptions.

> Waiting for 200ms could be long in real time context :)
You can decrease or remove the delay.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> I will test your suggested code to evaluate this approach.
>
> Stephane.
>
>
> Eike Stepper wrote on Thu, 08 October 2015 05:12
>> Am 07.10.2015 um 23:29 schrieb Stephane Fournier:
>> > Hi there,
>> >
>> > I've just have a look at the nice documentation that Eike blogged about and I have found highly valuable
>> informations > and especially this point it is possible to turn on automatic committing.
>> > Hence, I'm looking where is this option, I cannot find it on transaction.options() or session.options :(
>> >
>> > It could be done through a transactionHandler but I did not find an inherited class with the name >
>> AutomaticCommitTransactionHandler...
>> > Does anyone have an idea ?
>> Hm, I thought I provided a small utility class but apparently I did some experiment in CDOCheckoutImpl. That
>> experiment is currently commented out, but should do the trick:
>>
>> transaction.addTransactionHandler(new CDODefaultTransactionHandler1()
>> {
>> private Job commitJob = new Job("Commit")
>> {
>> @Override
>> protected IStatus run(IProgressMonitor monitor)
>> {
>> try
>> {
>> synchronized (transaction)
>> {
>> if (transaction.isDirty())
>> {
>> transaction.commit();
>> }
>> }
>> }
>> catch (Throwable ex)
>> {
>> ex.printStackTrace();
>> }
>>
>> return Status.OK_STATUS;
>> }
>> };
>>
>> @Override
>> public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
>> {
>> commitJob.schedule(200);
>> }
>> });
>>
>> I hope that helps.
>>
>>
>> >
>> > Regarding automatic locking, is it right to use the CDOAutoLocker class ?
>> Yes, that's the one.
>>
>> > Thanks in advance for your help.
>> You're welcome ;)
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://www.esc-net.de
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>


Previous Topic:[CDO] User auth with JVM connectors
Next Topic:[CDO] Server error with MySQL DBStore
Goto Forum:
  


Current Time: Thu Apr 25 12:05:23 GMT 2024

Powered by FUDForum. Page generated in 0.03280 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top