[CDO] CDOSession unsynchronized with server [message #1780155] |
Thu, 18 January 2018 04:15  |
Eclipse User |
|
|
|
Hi,
I'm having hard time using my CDOSession. Sometimes, my session seems to be "unsynchronized": I don't receive any commit from the server and my EContentAdapter arn't called. In this state, I need call refresh() on my session to "re-synchronize" it with the server.
I don't understand when it happens.
edit: it seems to happen when I commit 2 times in a short amount of time (ex: model editing with save and security update using securityManager.modify).
Do you have any clue what is going on ?
Thank you.
Regards,
Arthur.
[Updated on: Thu, 18 January 2018 05:26] by Moderator
|
|
|
|
|
|
|
Re: [CDO] CDOSession unsynchronized with server [message #1780947 is a reply to message #1780301] |
Tue, 30 January 2018 05:03   |
Eclipse User |
|
|
|
I can not reproduce your problem with the following test case:
public void testModifyRealm() throws Exception
{
final IPasswordCredentials credentials = new PasswordCredentials("user", "password");
final String protectedResource = getResourcePath("/protected");
final CDOID[] realmID = { null };
getSecurityManager().modify(new ISecurityManager.RealmOperation()
{
public void execute(Realm realm)
{
realmID[0] = realm.cdoID();
User user = realm.addUser(credentials);
user.getGroups().add(realm.getGroup("Administrators"));
Role role = realm.addRole(protectedResource + " Writer");
role.getPermissions().add(SF.createFilterPermission(Access.WRITE, //
SF.createResourceFilter(protectedResource, PatternStyle.EXACT, true).setModelObjects(true)));
user.getRoles().add(role);
}
});
CDOSession session = openSession(credentials);
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource(protectedResource);
transaction.commit();
// Load entire realm into transaction, so that the next realm operation creates a CDOViewInvalidationEvent.
Realm realm = (Realm)transaction.getObject(realmID[0]);
List<EObject> realmObjects = new ArrayList<EObject>();
for (Iterator<EObject> it = EcoreUtil.getAllContents(realm, false); it.hasNext();)
{
realmObjects.add(it.next());
}
transaction.addListener(new IListener()
{
public void notifyEvent(IEvent event)
{
System.out.println(event);
}
});
getSecurityManager().modify(new ISecurityManager.RealmOperation()
{
public void execute(Realm realm)
{
Role role = realm.addRole("Second Role");
User user = realm.getUser(credentials.getUserID());
user.getRoles().add(role);
}
}, true);
resource.getContents().add(getModel1Factory().createCompany());
transaction.commit();
resource.getContents().add(getModel1Factory().createCompany());
transaction.commit();
resource.getContents().add(getModel1Factory().createCompany());
transaction.commit();
resource.getContents().add(getModel1Factory().createCompany());
transaction.commit();
resource.getContents().add(getModel1Factory().createCompany());
transaction.commit();
}
The console output is as follows:
*******************************************************
Bugzilla_417483_Test.testModifyRealm [MEM-branching, JVM, Native]
*******************************************************
[INFO] Security realm created in /security
CDOViewInvalidationEvent[source=Transaction 1 [MAIN], timeStamp=1517305600219, revisionDeltas={User@OID32=null, Directory@OID4[PROXY]=null}, detachedObjects=[]]]
CDOViewAdaptersNotifiedEvent[source=Transaction 1 [MAIN], timeStamp=1517305600219]
CDOTransactionStartedEvent[source=Transaction 1 [MAIN]]
CDOTransactionFinishedEvent[source=Transaction 1 [MAIN], cause=COMMITTED, idMappings=1]
CDOTransactionStartedEvent[source=Transaction 1 [MAIN]]
CDOTransactionFinishedEvent[source=Transaction 1 [MAIN], cause=COMMITTED, idMappings=1]
CDOTransactionStartedEvent[source=Transaction 1 [MAIN]]
CDOTransactionFinishedEvent[source=Transaction 1 [MAIN], cause=COMMITTED, idMappings=1]
CDOTransactionStartedEvent[source=Transaction 1 [MAIN]]
CDOTransactionFinishedEvent[source=Transaction 1 [MAIN], cause=COMMITTED, idMappings=1]
CDOTransactionStartedEvent[source=Transaction 1 [MAIN]]
CDOTransactionFinishedEvent[source=Transaction 1 [MAIN], cause=COMMITTED, idMappings=1]
LifecycleEvent[source=Transaction 1 [MAIN], kind=ABOUT_TO_DEACTIVATE]
LifecycleEvent[source=CDOTransactionImpl, kind=DEACTIVATED]
Please note that a CDOViewInvalidationEvent is only sent to views that have at least one of the changed or deleted objects loaded. Your session should receive a CDOSessionInvalidationEvent, though.
It's possible that you're doing something special that causes a problem. If you want me to reproduce your problem you'd need to submit a bugzilla and attach an executable test case. Please have a look at our test suites and, for example, try to add a test case to org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_417483_Test .
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07251 seconds