Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2015-01-26 12:18:51 +0000
committerEsteban DUGUEPEROUX2015-01-26 14:23:34 +0000
commit387a51e6fa1c0435b57901be3200ff5908f14cca (patch)
treef30470d7a2d348b1f33df4ea8e7e01c69bba464f
parente86a3e4ec3a954ebfbaaaae198f9fb524818bc1e (diff)
downloadcdo-387a51e6fa1c0435b57901be3200ff5908f14cca.tar.gz
cdo-387a51e6fa1c0435b57901be3200ff5908f14cca.tar.xz
cdo-387a51e6fa1c0435b57901be3200ff5908f14cca.zip
[458279] Avoid useless ChangeSubscriptionRequest when being in
PassiveUpdateMode CHANGES or ADDITIONS Add a boolean parameter to CDOMergingConflictResolver constructor to allow to disable CDOAdapterPolicy use to avoid ChangeSubscriptionRequest sending to server. Change-Id: I660bd5bc77813bc8249d20fa71ecdbb5b79d82df Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458279 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_436246_Test.java89
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java71
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_441136_Test.java69
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_458279_Test.java89
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/RequestCallCounter.java86
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractChangeSetsConflictResolver.java32
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java34
7 files changed, 261 insertions, 209 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_436246_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_436246_Test.java
index afcc8e19e2..919bbf46e4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_436246_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_436246_Test.java
@@ -17,8 +17,6 @@ import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.util.CDOFetchRule;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol;
-import org.eclipse.emf.cdo.internal.net4j.protocol.LoadRevisionsRequest;
import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
@@ -27,17 +25,13 @@ import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.RequestCallCounter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOFetchRuleManager;
import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.net4j.signal.Signal;
-import org.eclipse.net4j.signal.SignalScheduledEvent;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
@@ -47,6 +41,7 @@ import org.junit.Assert;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* Test {@link CDOObject#cdoPrefetch(int)} with branch.
@@ -94,10 +89,7 @@ public class Bugzilla_436246_Test extends AbstractCDOTest
// Test
CDOSession session = openSession();
- InternalCDOSession internalCDOSession = (InternalCDOSession)session;
- CDOClientProtocol cdoClientProtocol = (CDOClientProtocol)internalCDOSession.getSessionProtocol();
- LoadRevisionsRequestCounter loadRevisionsRequestCounter = new LoadRevisionsRequestCounter();
- cdoClientProtocol.addListener(loadRevisionsRequestCounter);
+ RequestCallCounter loadRevisionsRequestCounter = new RequestCallCounter(session);
CDOBranch currentBranch = session.getBranchManager().getMainBranch();
testCDORevisionFetchWithChangesOnAllBranches(session, currentBranch, loadRevisionsRequestCounter, companyCDOID,
@@ -126,9 +118,7 @@ public class Bugzilla_436246_Test extends AbstractCDOTest
InternalCDOSession internalCDOSession = (InternalCDOSession)session;
CDOFetchRuleManager fetchRuleManager = new CustomCDOFetchRuleManager(companyCDOID);
internalCDOSession.setFetchRuleManager(fetchRuleManager);
- CDOClientProtocol cdoClientProtocol = (CDOClientProtocol)internalCDOSession.getSessionProtocol();
- LoadRevisionsRequestCounter loadRevisionsRequestCounter = new LoadRevisionsRequestCounter();
- cdoClientProtocol.addListener(loadRevisionsRequestCounter);
+ RequestCallCounter loadRevisionsRequestCounter = new RequestCallCounter(session);
CDOBranch currentBranch = session.getBranchManager().getMainBranch();
testCDORevisionFetchWithChangesOnAllBranches(session, currentBranch, loadRevisionsRequestCounter, companyCDOID,
@@ -145,17 +135,18 @@ public class Bugzilla_436246_Test extends AbstractCDOTest
}
private void testCDORevisionFetchWithChangesOnAllBranches(CDOSession session, CDOBranch currentBranch,
- LoadRevisionsRequestCounter loadRevisionsRequestCounter, CDOID companyCDOID, int expectedNbCategories,
- boolean prefetch)
+ RequestCallCounter loadRevisionsRequestCounter, CDOID companyCDOID, int expectedNbCategories, boolean prefetch)
{
- CDOView view = session.openView(currentBranch);
+ Map<Short, Integer> nbRequestsCalls = loadRevisionsRequestCounter.getNBRequestsCalls();
+ nbRequestsCalls.put(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS, 0);
- assertEquals(0, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ CDOView view = session.openView(currentBranch);
+ assertEquals(0, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
String resourcePath = getResourcePath(RESOURCE_NAME);
List<String> pathSegments = CDOURIUtil.analyzePath(resourcePath);
CDOResource resource = view.getResource(resourcePath);
- assertEquals(pathSegments.size(), loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size(), (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
if (prefetch)
{
@@ -165,19 +156,19 @@ public class Bugzilla_436246_Test extends AbstractCDOTest
EObject eObject = resource.getContents().get(0);
Assert.assertTrue(eObject instanceof Company);
Company company = (Company)eObject;
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
Assert.assertEquals(expectedNbCategories, company.getCategories().size());
view.getRevision(companyCDOID);
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
view.getResourceSet().eAdapters().add(new EContentAdapter());
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
view.close();
- loadRevisionsRequestCounter.reset();
+ nbRequestsCalls.clear();
}
private CDOID setUpChangesOnBranches() throws Exception
@@ -235,65 +226,31 @@ public class Bugzilla_436246_Test extends AbstractCDOTest
private void testCDORevisionPrefetchOnBranch(CDOSession session, CDOBranch cdoBranch) throws Exception
{
CDOTransaction view = session.openTransaction(cdoBranch);
- InternalCDOSession internalCDOSession = (InternalCDOSession)session;
- CDOClientProtocol cdoClientProtocol = (CDOClientProtocol)internalCDOSession.getSessionProtocol();
- LoadRevisionsRequestCounter loadRevisionsRequestCounter = new LoadRevisionsRequestCounter();
- cdoClientProtocol.addListener(loadRevisionsRequestCounter);
-
- assertEquals(0, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ RequestCallCounter requestCallCounter = new RequestCallCounter(session);
+ Map<Short, Integer> nbRequestsCalls = requestCallCounter.getNBRequestsCalls();
+ nbRequestsCalls.put(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS, 0);
+ assertEquals(0, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
String resourcePath = getResourcePath(RESOURCE_NAME);
List<String> pathSegments = CDOURIUtil.analyzePath(resourcePath);
CDOResource resource = view.getResource(resourcePath);
- assertEquals(pathSegments.size(), loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size(), (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
resource.cdoPrefetch(CDORevision.DEPTH_INFINITE);
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
Company company = (Company)resource.getContents().get(0);
CDOID companyCDOID = CDOUtil.getCDOObject(company).cdoID();
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
view.getRevision(companyCDOID);
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
view.getResourceSet().eAdapters().add(new EContentAdapter());
- assertEquals(pathSegments.size() + 1, loadRevisionsRequestCounter.getNbLoadRevisionsRequestCalls());
-
- }
-
- private static class LoadRevisionsRequestCounter implements IListener
- {
-
- private int nbLoadRevisionsRequestCalls = 0;
-
- public void notifyEvent(IEvent event)
- {
- if (event instanceof SignalScheduledEvent)
- {
- @SuppressWarnings("unchecked")
- SignalScheduledEvent<Object> signalScheduledEvent = (SignalScheduledEvent<Object>)event;
- Signal signal = signalScheduledEvent.getSignal();
- if (signal.getID() == CDOProtocolConstants.SIGNAL_LOAD_REVISIONS && signal instanceof LoadRevisionsRequest)
- {
- nbLoadRevisionsRequestCalls++;
- }
- }
- }
-
- public int getNbLoadRevisionsRequestCalls()
- {
- return nbLoadRevisionsRequestCalls;
- }
-
- public void reset()
- {
- nbLoadRevisionsRequestCalls = 0;
- }
-
+ assertEquals(pathSegments.size() + 1, (int)nbRequestsCalls.get(CDOProtocolConstants.SIGNAL_LOAD_REVISIONS));
}
private class CustomCDOFetchRuleManager implements CDOFetchRuleManager
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java
index 9183a5dd69..ca584fb3b4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java
@@ -15,30 +15,20 @@ import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.RequestCallCounter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.internal.cdo.session.DelegatingSessionProtocol;
-
-import org.eclipse.net4j.signal.Signal;
-import org.eclipse.net4j.signal.SignalScheduledEvent;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EContentAdapter;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -95,7 +85,7 @@ public class Bugzilla_439337_Test extends AbstractCDOTest
private void testCDOLockState(CDOView view, boolean cdoLockStatePrefetchEnabled)
{
view.getResourceSet().eAdapters().add(new EContentAdapterQueringCDOLockState());
- NBRequestsCallsCounter nbRequestsCallsCounter = new NBRequestsCallsCounter(view);
+ RequestCallCounter nbRequestsCallsCounter = new RequestCallCounter(view.getSession());
view.getResource(getResourcePath(RESOURCE_NAME + "?" + CDOResource.PREFETCH_PARAMETER + "=" + Boolean.TRUE));
Map<Short, Integer> nbRequestsCalls = nbRequestsCallsCounter.getNBRequestsCalls();
@@ -120,63 +110,6 @@ public class Bugzilla_439337_Test extends AbstractCDOTest
}
/**
- * {@link IListener} to count sent request and their number.
- */
- private static class NBRequestsCallsCounter implements IListener
- {
- private Map<Short, Integer> nbRequestsCalls = new HashMap<Short, Integer>();
-
- public NBRequestsCallsCounter(CDOView view)
- {
-
- InternalCDOSession internalCDOSession = (InternalCDOSession)view.getSession();
- CDOSessionProtocol sessionProtocol = internalCDOSession.getSessionProtocol();
- CDOClientProtocol cdoClientProtocol = null;
- if (sessionProtocol instanceof CDOClientProtocol)
- {
- cdoClientProtocol = (CDOClientProtocol)sessionProtocol;
- }
- else if (sessionProtocol instanceof DelegatingSessionProtocol)
- {
- DelegatingSessionProtocol delegatingSessionProtocol = (DelegatingSessionProtocol)sessionProtocol;
- CDOSessionProtocol delegate = delegatingSessionProtocol.getDelegate();
- if (delegate instanceof CDOClientProtocol)
- {
- cdoClientProtocol = (CDOClientProtocol)delegate;
- }
- }
- if (cdoClientProtocol != null)
- {
- cdoClientProtocol.addListener(this);
- }
- }
-
- public void notifyEvent(IEvent event)
- {
- if (event instanceof SignalScheduledEvent)
- {
- @SuppressWarnings("unchecked")
- SignalScheduledEvent<Object> signalScheduledEvent = (SignalScheduledEvent<Object>)event;
- Signal signal = signalScheduledEvent.getSignal();
- short signalID = signal.getID();
- Integer nbRequestCalls = nbRequestsCalls.get(signalID);
- if (nbRequestCalls == null)
- {
- nbRequestCalls = 0;
- }
- nbRequestCalls++;
- nbRequestsCalls.put(signalID, nbRequestCalls);
- }
- }
-
- public Map<Short, Integer> getNBRequestsCalls()
- {
- return nbRequestsCalls;
- }
-
- }
-
- /**
* A {@link EContentAdapter} to request {@link CDOLockState} on each object of a {@link ResourceSet}.
*/
private static class EContentAdapterQueringCDOLockState extends EContentAdapter
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_441136_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_441136_Test.java
index bfbbbbc8f8..463dab7236 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_441136_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_441136_Test.java
@@ -15,32 +15,21 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol;
import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.RequestCallCounter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.session.DelegatingSessionProtocol;
import org.eclipse.net4j.signal.IndicationWithMonitoring;
import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.signal.Signal;
import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalScheduledEvent;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
import org.eclipse.core.runtime.NullProgressMonitor;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -76,7 +65,7 @@ public class Bugzilla_441136_Test extends AbstractCDOTest
1000 * CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS);
((CDONet4jSessionImpl)session).setSignalTimeout(10000 * SignalProtocol.DEFAULT_TIMEOUT);
CDOTransaction transaction = session.openTransaction();
- NBRequestsCallsCounter nbRequestsCallsCounter = new NBRequestsCallsCounter(transaction);
+ RequestCallCounter nbRequestsCallsCounter = new RequestCallCounter(session);
CDOResource resource = transaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
Company company = getModel1Factory().createCompany();
resource.getContents().add(company);
@@ -109,60 +98,6 @@ public class Bugzilla_441136_Test extends AbstractCDOTest
}
}
- class NBRequestsCallsCounter implements IListener
- {
- private Map<Short, Integer> nbRequestsCalls = new HashMap<Short, Integer>();
-
- public NBRequestsCallsCounter(CDOView view)
- {
-
- InternalCDOSession internalCDOSession = (InternalCDOSession)view.getSession();
- CDOSessionProtocol sessionProtocol = internalCDOSession.getSessionProtocol();
- CDOClientProtocol cdoClientProtocol = null;
- if (sessionProtocol instanceof CDOClientProtocol)
- {
- cdoClientProtocol = (CDOClientProtocol)sessionProtocol;
- }
- else if (sessionProtocol instanceof DelegatingSessionProtocol)
- {
- DelegatingSessionProtocol delegatingSessionProtocol = (DelegatingSessionProtocol)sessionProtocol;
- CDOSessionProtocol delegate = delegatingSessionProtocol.getDelegate();
- if (delegate instanceof CDOClientProtocol)
- {
- cdoClientProtocol = (CDOClientProtocol)delegate;
- }
- }
- if (cdoClientProtocol != null)
- {
- cdoClientProtocol.addListener(this);
- }
- }
-
- public void notifyEvent(IEvent event)
- {
- if (event instanceof SignalScheduledEvent)
- {
- @SuppressWarnings("unchecked")
- SignalScheduledEvent<Object> signalScheduledEvent = (SignalScheduledEvent<Object>)event;
- Signal signal = signalScheduledEvent.getSignal();
- short signalID = signal.getID();
- Integer nbRequestCalls = nbRequestsCalls.get(signalID);
- if (nbRequestCalls == null)
- {
- nbRequestCalls = 0;
- }
- nbRequestCalls++;
- nbRequestsCalls.put(signalID, nbRequestCalls);
- }
- }
-
- public Map<Short, Integer> getNBRequestsCalls()
- {
- return nbRequestsCalls;
- }
-
- }
-
class CommitTransactionIndicationWaiting implements CDOCommitInfoHandler
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_458279_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_458279_Test.java
new file mode 100644
index 0000000000..c02837030b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_458279_Test.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Esteban Dugueperoux - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.net4j.protocol.ChangeSubscriptionRequest;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.util.RequestCallCounter;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.spi.cdo.CDOMergingConflictResolver;
+
+/**
+ * Bug 458279 about {@link CDOMergingConflictResolver} without {@link ChangeSubscriptionRequest} sent to the server.
+ *
+ * @author Esteban Dugueperoux
+ */
+public class Bugzilla_458279_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE_NAME = "test1.model1";
+
+ /**
+ * Test {@link CDOMergingConflictResolver} without {@link ChangeSubscriptionRequest} sent to the server and using {@link PassiveUpdateMode#ADDITIONS}.
+ */
+ public void testCDOMergingConflictResolverWithoutChangeSubscriptionRequestWithAdditionsPassiveUpdateMode()
+ throws Exception
+ {
+ testCDOMergingConflictResolverWithoutChangeSubscriptionRequest(PassiveUpdateMode.ADDITIONS);
+ }
+
+ /**
+ * Test {@link CDOMergingConflictResolver} without {@link ChangeSubscriptionRequest} sent to the server and using {@link PassiveUpdateMode#ADDITIONS}.
+ */
+ public void testCDOMergingConflictResolverWithoutChangeSubscriptionRequestWithChangesPassiveUpdateMode()
+ throws Exception
+ {
+ testCDOMergingConflictResolverWithoutChangeSubscriptionRequest(PassiveUpdateMode.CHANGES);
+ }
+
+ /**
+ * Test {@link CDOMergingConflictResolver} without {@link ChangeSubscriptionRequest} sent to the server and using {@link PassiveUpdateMode#INVALIDATIONS}.
+ */
+ public void testCDOMergingConflictResolverWithoutChangeSubscriptionRequestWithInvalidationsPassiveUpdateMode()
+ throws Exception
+ {
+ testCDOMergingConflictResolverWithoutChangeSubscriptionRequest(PassiveUpdateMode.INVALIDATIONS);
+ }
+
+ private void testCDOMergingConflictResolverWithoutChangeSubscriptionRequest(PassiveUpdateMode mode) throws Exception
+ {
+ CDOSession session1 = openSession();
+ RequestCallCounter requestCallCounter = new RequestCallCounter(session1);
+ requestCallCounter.getNBRequestsCalls().put(CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION, 0);
+
+ session1.options().setPassiveUpdateMode(mode);
+ CDOTransaction transaction1 = session1.openTransaction();
+ transaction1.options().addConflictResolver(new CDOMergingConflictResolver(false));
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_NAME));
+ Company company = getModel1Factory().createCompany();
+ resource1.getContents().add(company);
+ transaction1.commit();
+
+ company.getCategories().add(getModel1Factory().createCategory());
+
+ CDOSession session2 = openSession();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource resource2 = transaction2.getResource(getResourcePath(RESOURCE_NAME));
+ Company companyFromSession2 = (Company)resource2.getContents().get(0);
+ companyFromSession2.getCategories().add(getModel1Factory().createCategory());
+ commitAndSync(transaction2, transaction1);
+
+ assertEquals(mode == PassiveUpdateMode.INVALIDATIONS ? 1 : 2, company.getCategories().size());
+ int nbCallToChangeSubscriptionRequest = requestCallCounter.getNBRequestsCalls().get(
+ CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION);
+ assertEquals("No ChangeSubscriptionRequest should be send to server", 0, nbCallToChangeSubscriptionRequest);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/RequestCallCounter.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/RequestCallCounter.java
new file mode 100644
index 0000000000..b3d9d7bda6
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/RequestCallCounter.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Esteban Dugueperoux - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.util;
+
+import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol;
+import org.eclipse.emf.cdo.session.CDOSession;
+
+import org.eclipse.emf.internal.cdo.session.DelegatingSessionProtocol;
+
+import org.eclipse.net4j.signal.Signal;
+import org.eclipse.net4j.signal.SignalScheduledEvent;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A {@link IListener} to count request sent to server through {@link CDOClientProtocol}.
+ *
+ * @author Esteban Dugueperoux
+ */
+public class RequestCallCounter implements IListener
+{
+ private Map<Short, Integer> nbRequestsCalls = new HashMap<Short, Integer>();
+
+ public RequestCallCounter(CDOSession session)
+ {
+
+ InternalCDOSession internalCDOSession = (InternalCDOSession)session;
+ CDOSessionProtocol sessionProtocol = internalCDOSession.getSessionProtocol();
+ CDOClientProtocol cdoClientProtocol = null;
+ if (sessionProtocol instanceof CDOClientProtocol)
+ {
+ cdoClientProtocol = (CDOClientProtocol)sessionProtocol;
+ }
+ else if (sessionProtocol instanceof DelegatingSessionProtocol)
+ {
+ DelegatingSessionProtocol delegatingSessionProtocol = (DelegatingSessionProtocol)sessionProtocol;
+ CDOSessionProtocol delegate = delegatingSessionProtocol.getDelegate();
+ if (delegate instanceof CDOClientProtocol)
+ {
+ cdoClientProtocol = (CDOClientProtocol)delegate;
+ }
+ }
+ if (cdoClientProtocol != null)
+ {
+ cdoClientProtocol.addListener(this);
+ }
+ }
+
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof SignalScheduledEvent)
+ {
+ @SuppressWarnings("unchecked")
+ SignalScheduledEvent<Object> signalScheduledEvent = (SignalScheduledEvent<Object>)event;
+ Signal signal = signalScheduledEvent.getSignal();
+ short signalID = signal.getID();
+ Integer nbRequestCalls = nbRequestsCalls.get(signalID);
+ if (nbRequestCalls == null)
+ {
+ nbRequestCalls = 0;
+ }
+ nbRequestCalls++;
+ nbRequestsCalls.put(signalID, nbRequestCalls);
+ }
+ }
+
+ public Map<Short, Integer> getNBRequestsCalls()
+ {
+ return nbRequestsCalls;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractChangeSetsConflictResolver.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractChangeSetsConflictResolver.java
index f4b405a798..859af3ae4a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractChangeSetsConflictResolver.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractChangeSetsConflictResolver.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.spi.cdo;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -21,6 +22,7 @@ import org.eclipse.emf.cdo.transaction.CDOConflictResolver.NonConflictAware;
import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
/**
* If the meaning of this type isn't clear, there really should be more of a description here...
@@ -67,10 +69,21 @@ public abstract class AbstractChangeSetsConflictResolver extends AbstractConflic
private RemoteInvalidationEventQueue remoteInvalidationEvents;
+ private boolean ensureRemoteNotifications = true;
+
public AbstractChangeSetsConflictResolver()
{
}
+ /**
+ * @param ensureRemoteNotifications boolean to disable the use of {@link CDOAdapterPolicy} to ensure remote changes reception for conflict resolution, true by default. Can be disabled to limit network traffic when {@link PassiveUpdateMode} is enabled and in {@link PassiveUpdateMode#CHANGES} or {@link PassiveUpdateMode#ADDITIONS}
+ * @since 4.4
+ */
+ public AbstractChangeSetsConflictResolver(boolean ensureRemoteNotifications)
+ {
+ this.ensureRemoteNotifications = ensureRemoteNotifications;
+ }
+
public CDOChangeSetData getLocalChangeSetData()
{
return getTransaction().getChangeSetData();
@@ -109,22 +122,27 @@ public abstract class AbstractChangeSetsConflictResolver extends AbstractConflic
@Override
protected void hookTransaction(CDOTransaction transaction)
{
- adapter = new CDOChangeSubscriptionAdapter(getTransaction());
- remoteInvalidationEvents = new RemoteInvalidationEventQueue();
+ if (ensureRemoteNotifications)
+ {
+ adapter = new CDOChangeSubscriptionAdapter(getTransaction());
+ transaction.addTransactionHandler(handler);
+ }
- transaction.addTransactionHandler(handler);
+ remoteInvalidationEvents = new RemoteInvalidationEventQueue();
}
@Override
protected void unhookTransaction(CDOTransaction transaction)
{
- transaction.removeTransactionHandler(handler);
+ if (ensureRemoteNotifications)
+ {
+ transaction.removeTransactionHandler(handler);
+ adapter.dispose();
+ adapter = null;
+ }
remoteInvalidationEvents.dispose();
remoteInvalidationEvents = null;
-
- adapter.dispose();
- adapter = null;
}
private CDOChangeSet createChangeSet(CDOChangeSetData changeSetData)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
index 965af855d0..57b48f9a15 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.spi.cdo;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
@@ -32,6 +33,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.emf.cdo.transaction.CDOMerger;
import org.eclipse.emf.cdo.transaction.CDOMerger.ConflictException;
import org.eclipse.emf.cdo.transaction.CDOSavepoint;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
@@ -62,6 +64,16 @@ public class CDOMergingConflictResolver extends AbstractChangeSetsConflictResolv
}
/**
+ * @param ensureRemoteNotifications boolean to disable the use of {@link CDOAdapterPolicy} to ensure remote changes reception for conflict resolution, true by default. Can be disabled to limit network traffic when {@link PassiveUpdateMode} is enabled and in {@link PassiveUpdateMode#CHANGES} or {@link PassiveUpdateMode#ADDITIONS}
+ * @since 4.4
+ */
+ public CDOMergingConflictResolver(CDOMerger merger, boolean ensureRemoteNotifications)
+ {
+ super(ensureRemoteNotifications);
+ this.merger = merger;
+ }
+
+ /**
* @since 4.2
*/
public CDOMergingConflictResolver(DefaultCDOMerger.ResolutionPreference resolutionPreference)
@@ -69,11 +81,33 @@ public class CDOMergingConflictResolver extends AbstractChangeSetsConflictResolv
this(new DefaultCDOMerger.PerFeature.ManyValued(resolutionPreference));
}
+ /**
+ * @param ensureRemoteNotifications boolean to disable the use of {@link CDOAdapterPolicy} to ensure remote changes reception for conflict resolution, true by default. Can be disabled to limit network traffic when {@link PassiveUpdateMode} is enabled and in {@link PassiveUpdateMode#CHANGES} or {@link PassiveUpdateMode#ADDITIONS}
+ * @since 4.4
+ */
+ public CDOMergingConflictResolver(DefaultCDOMerger.ResolutionPreference resolutionPreference,
+ boolean ensureRemoteNotifications)
+ {
+ this(new DefaultCDOMerger.PerFeature.ManyValued(resolutionPreference), ensureRemoteNotifications);
+ }
+
+ /**
+ * @since 4.4
+ */
public CDOMergingConflictResolver()
{
this(new DefaultCDOMerger.PerFeature.ManyValued());
}
+ /**
+ * @param ensureRemoteNotifications boolean to disable the use of {@link CDOAdapterPolicy} to ensure remote changes reception for conflict resolution, true by default. Can be disabled to limit network traffic when {@link PassiveUpdateMode} is enabled and in {@link PassiveUpdateMode#CHANGES} or {@link PassiveUpdateMode#ADDITIONS}
+ * @since 4.4
+ */
+ public CDOMergingConflictResolver(boolean ensureRemoteNotifications)
+ {
+ this(new DefaultCDOMerger.PerFeature.ManyValued(), ensureRemoteNotifications);
+ }
+
public CDOMerger getMerger()
{
return merger;

Back to the top