Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Get last commit info from a CDO Object
[CDO] Get last commit info from a CDO Object [message #1031879] Tue, 02 April 2013 10:17 Go to next message
Marc Gil is currently offline Marc GilFriend
Messages: 81
Registered: July 2009
Member
Hi,

I'm trying to retrieve all the last commit info for a CDO Object, but I'm not able to get it. I try the following:

node.cdoHistory().getLastElement();


But everytime I get the following error:
Caused by: java.lang.IllegalStateException: Can only retrieve current version 4 for OID30 - version requested was BranchVersion[Branch[id=0, name=MAIN], v3]
	at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.readRevisionByVersion(DBStoreAccessor.java:317)
	at org.eclipse.emf.cdo.internal.server.Repository.loadRevisionByVersion(Repository.java:569)
	at org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl.getRevisionByVersion(CDORevisionManagerImpl.java:252)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.LoadRevisionByVersionIndication.responding(LoadRevisionByVersionIndication.java:72)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndication.responding(CDOServerIndication.java:134)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:98)
	at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:298)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:67)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerReadIndication.execute(CDOServerReadIndication.java:36)
	... 5 more


Furthermore, the returned object (last element of the history) is always the same while I'm working in the same view. I mean, once I close the working view and open another one, the history is refreshed, but I always get the error.

What am I doing wrong?

Thanks,
Marc
Re: [CDO] Get last commit info from a CDO Object [message #1034348 is a reply to message #1031879] Fri, 05 April 2013 10:29 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 02.04.2013 12:17, schrieb Marc Gil:
> Hi,
>
> I'm trying to retrieve all the last commit info for a CDO Object, but I'm not able to get it. I try the following:
>
>
> node.cdoHistory().getLastElement();
To me it seems as if the exact call aboce succeeded because the exception below seems unrelated.

> But everytime I get the following error:
>
> Caused by: java.lang.IllegalStateException: Can only retrieve current version 4 for OID30 - version requested was
> BranchVersion[Branch[id=0, name=MAIN], v3]
> at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.readRevisionByVersion(DBStoreAccessor.java:317)
I think this can happen if you access data *in* the CDOCommitInfo for a non-auditing repository. Please check your
repository configuration and make sure you specifiy

<property name="supportingAudits" value="true"/>

Cheers
/Eike

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


> at org.eclipse.emf.cdo.internal.server.Repository.loadRevisionByVersion(Repository.java:569)
> at
> org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl.getRevisionByVersion(CDORevisionManagerImpl.java:252)
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.LoadRevisionByVersionIndication.responding(LoadRevisionByVersionIndication.java:72)
> at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndication.responding(CDOServerIndication.java:134)
> at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:98)
> at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:298)
> at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:67)
> at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerReadIndication.execute(CDOServerReadIndication.java:36)
> ... 5 more
>
>
> Furthermore, the returned object (last element of the history) is always the same while I'm working in the same view.
> I mean, once I close the working view and open another one, the history is refreshed, but I always get the error.
>
> What am I doing wrong?
>
> Thanks,
> Marc


Re: [CDO] Get last commit info from a CDO Object [message #1034361 is a reply to message #1034348] Fri, 05 April 2013 10:46 Go to previous messageGo to next message
Marc Gil is currently offline Marc GilFriend
Messages: 81
Registered: July 2009
Member
Hi Eike,

Indeed in my configuration I have set this option as false. I change it to true and, after creating a new repository cause the old one is unusable as I change this option, the exception is not raised.

But one question, it seems that the call
node.cdoHistory().getLastElement();
is asynchronous, isn't it? Cause if I check the returned value immediately it is null. But if I sleep the Thread some milliseconds, then I get a value. Is it correct?

There exists a way to execute it in a synchronous way?

Thanks Eike!
Marc

[Updated on: Fri, 05 April 2013 10:47]

Report message to a moderator

Re: [CDO] Get last commit info from a CDO Object [message #1034384 is a reply to message #1034361] Fri, 05 April 2013 11:22 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 05.04.2013 12:46, schrieb Marc Gil:
> Hi Eike,
>
> Indeed in my configuration I have set this option as false. I change it to true and, after creating a new repository
> cause the old one is unusable as I change this option, the exception is not raised.
Perfect ;-)

> But one question, it seems that the call node.cdoHistory().getLastElement(); is asynchronous, isn't it? Cause if I
> check the returned value immediately it is null. But if I sleep the Thread some milliseconds, then I get a value. Is
> it correct?
This method's logic is not executed asynchronously but the loading of the entire history happens in a background thread.
That's why there are methods like:

org.eclipse.emf.cdo.common.commit.CDOCommitHistory.isLoading()
org.eclipse.emf.cdo.common.commit.CDOCommitHistory.waitWhileLoading(long)
org.eclipse.emf.cdo.common.commit.CDOCommitHistory.getLoadCount()
org.eclipse.emf.cdo.common.commit.CDOCommitHistory.setLoadCount(int)
org.eclipse.emf.cdo.common.commit.CDOCommitHistory.triggerLoad()
org.eclipse.emf.cdo.common.commit.CDOCommitHistory.triggerLoad(CDOCommitInfoHandler)

You could work with waitWhileLoading().

Cheers
/Eike

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


Re: [CDO] Get last commit info from a CDO Object [message #1034391 is a reply to message #1034384] Fri, 05 April 2013 11:32 Go to previous messageGo to next message
Marc Gil is currently offline Marc GilFriend
Messages: 81
Registered: July 2009
Member
Thanks again Eike.

I think I could work with it. Nevertheless, I think I can't use it, cause setting the repository as auditable means that the DB will grow a lot as explained in the CDO server configuration website, and I think that this is undesirable for the my costumer...

But thanks for this information, it could be very useful for other implementations! Smile

Cheers,
Marc
Re: [CDO] Get last commit info from a CDO Object [message #1034400 is a reply to message #1034391] Fri, 05 April 2013 11:46 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 05.04.2013 13:32, schrieb Marc Gil:
> Thanks again Eike.
>
> I think I could work with it. Nevertheless, I think I can't use it, cause setting the repository as auditable means
> that the DB will grow a lot as explained in the CDO server configuration website, and I think that this is undesirable
> for the my costumer...
Now I'm confused. How can you expect the CDOCommitHistory to work (i.e., return historical change sets) if auditing is
not enabled?

If you just want to access the CDOCommitInfo of the most recent commit you can use the return value of
CDOTransaction.commit().

Cheers
/Eike

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


Re: [CDO] Get last commit info from a CDO Object [message #1034413 is a reply to message #1034400] Fri, 05 April 2013 12:01 Go to previous messageGo to next message
Marc Gil is currently offline Marc GilFriend
Messages: 81
Registered: July 2009
Member
My purpose is that my customized CDO Sessions View shows the last commit information near every CDO Resource:
resource1 [user 05/04/2013 13:30:45]
...

To do that, I modified the content of the getText() method of the CDOItemProvider.

Maybe locally I can update it using the CDOCommitInfo returned by the commit, but I don't know if it's possible to do in the other remote clients. For that reason I'm using the history, but it's not valid for me. I need to investigate a little bit more about that...

The list of commits are stored in the DB even if the repository is not auditable, but I don't know why the history don't work, it always returns me only one Commit Info... Maybe it's a bug? I checked the DB and there are a lot of commits, all of them affects the same resource.

Cheers,
Marc
Re: [CDO] Get last commit info from a CDO Object [message #1034435 is a reply to message #1034413] Fri, 05 April 2013 12:26 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 05.04.2013 14:01, schrieb Marc Gil:
> My purpose is that my customized CDO Sessions View shows the last commit information near every CDO Resource:
> resource1 [user 05/04/2013 13:30:45]
> ..
>
> To do that, I modified the content of the getText() method of the CDOItemProvider.
>
> Maybe locally I can update it using the CDOCommitInfo returned by the commit, but I don't know if it's possible to do
> in the other remote clients. For that reason I'm using the history, but it's not valid for me. I need to investigate a
> little bit more about that...
Then you may want to listen for CDOSessionInvalidationEvent, which are defined as:

public interface CDOSessionInvalidationEvent extends CDOSessionEvent, CDOCommitInfo


>
> The list of commits are stored in the DB even if the repository is not auditable, but I don't know why the history
> don't work, it always returns me only one Commit Info... Maybe it's a bug? I checked the DB and there are a lot of
> commits, all of them affects the same resource.
You seem to create the History with "node.cdoHistory()", which returns a CDOObjectHistory, a subtype of CDOCommitHistory
that only contains CDOCommitInfos related to "node". You may want to use "node.cdoView().getHistory()", which returns a
history for the view's branch. "node.cdoView().getSession().getHistory()" returns a history for all branches.

Cheers
/Eike

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


Previous Topic:CDOServerImporter throws Unique index or primary key violation
Next Topic:Update Site for EMF Validation
Goto Forum:
  


Current Time: Sat Apr 20 00:38:53 GMT 2024

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

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

Back to the top