Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-05 13:54:56 -0400
committerEike Stepper2011-07-05 13:54:56 -0400
commite352dd435bffd43cd0ea22e04f58b599ef8ce43c (patch)
tree07e77d344b14b5a2a0917ce6bc016c371f694722 /plugins
parent5c9815ec29491aec1433b5175d32c2c9a758087a (diff)
downloadcdo-e352dd435bffd43cd0ea22e04f58b599ef8ce43c.tar.gz
cdo-e352dd435bffd43cd0ea22e04f58b599ef8ce43c.tar.xz
cdo-e352dd435bffd43cd0ea22e04f58b599ef8ce43c.zip
[350146] Make protocol timeout on the CDO server configurable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350146
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java20
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Timeouter.java5
5 files changed, 66 insertions, 10 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF
index 96699516df..29e957f56c 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.net4j; singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.0.100.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -11,17 +11,17 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.internal.net4j;version="4.0.0";
+Export-Package: org.eclipse.emf.cdo.internal.net4j;version="4.0.100";
x-friends:="org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.defs,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.examples",
- org.eclipse.emf.cdo.internal.net4j.bundle;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.net4j.messages;version="4.0.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.net4j.protocol;version="4.0.0";
+ org.eclipse.emf.cdo.internal.net4j.bundle;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.internal.net4j.messages;version="4.0.100";x-internal:=true,
+ org.eclipse.emf.cdo.internal.net4j.protocol;version="4.0.100";
x-friends:="org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.defs,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.examples",
- org.eclipse.emf.cdo.net4j;version="4.0.0"
+ org.eclipse.emf.cdo.net4j;version="4.0.100"
Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java
index c774989667..1053635196 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java
@@ -39,6 +39,7 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.internal.cdo.object.CDOObjectReferenceImpl;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
@@ -60,6 +61,8 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionRequest.class);
+ private static long sleepMillisForTesting = 0L;
+
private CDOIDProvider idProvider; // CDOTransaction
private String comment;
@@ -149,6 +152,11 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com
for (CDOIDAndVersion newObject : newObjects)
{
out.writeCDORevision((CDORevision)newObject, CDORevision.UNCHUNKED);
+
+ if (sleepMillisForTesting != 0L)
+ {
+ ConcurrencyUtil.sleep(sleepMillisForTesting);
+ }
}
if (TRACER.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
index 0186f78164..0b2f6b1dca 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
@@ -30,6 +31,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.io.IOUtil;
@@ -39,6 +41,7 @@ import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.emf.common.notify.Notification;
import java.io.File;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -480,4 +483,32 @@ public class TransactionTest extends AbstractCDOTest
transaction.commit();
}
+
+ public void _testLongCommit2() throws Exception
+ {
+ OMPlatform.INSTANCE.setDebugging(true);
+ Field field = ReflectUtil.getField(CommitTransactionRequest.class, "sleepMillisForTesting");
+
+ try
+ {
+ ReflectUtil.setValue(field, null, 1000L);
+
+ org.eclipse.emf.cdo.net4j.CDOSession session = (org.eclipse.emf.cdo.net4j.CDOSession)openSession();
+ session.options().setCommitTimeout(60);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test1"));
+
+ for (int i = 0; i < 300; i++)
+ {
+ resource.getContents().add(getModel1Factory().createCompany());
+ }
+
+ transaction.commit();
+ }
+ finally
+ {
+ ReflectUtil.setValue(field, null, 0L);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
index 47491b2d42..6557b79f40 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
@@ -51,6 +51,8 @@ import java.util.Set;
*/
public abstract class SessionConfig extends Config implements ISessionConfig
{
+ public static final String PROP_TEST_SESSION_CONFIGURATION = "test.session.SessionConfiguration";
+
public static final String PROP_TEST_CREDENTIALS_PROVIDER = "test.session.CredentialsProvider";
private static final long serialVersionUID = 1L;
@@ -79,8 +81,17 @@ public abstract class SessionConfig extends Config implements ISessionConfig
public CDOSession openSession(String repositoryName)
{
- CDOSessionConfiguration configuration = createSessionConfiguration(repositoryName);
- configuration.getAuthenticator().setCredentialsProvider(getTestCredentialsProvider());
+ CDOSessionConfiguration configuration = getTestSessionConfiguration();
+ if (configuration == null)
+ {
+ configuration = createSessionConfiguration(repositoryName);
+ }
+
+ IPasswordCredentialsProvider credentialsProvider = getTestCredentialsProvider();
+ if (credentialsProvider != null)
+ {
+ configuration.getAuthenticator().setCredentialsProvider(credentialsProvider);
+ }
CDOSession session = configuration.openSession();
configureSession(session);
@@ -148,6 +159,11 @@ public abstract class SessionConfig extends Config implements ISessionConfig
}
}
+ protected CDOSessionConfiguration getTestSessionConfiguration()
+ {
+ return (CDOSessionConfiguration)getTestProperty(PROP_TEST_SESSION_CONFIGURATION);
+ }
+
protected IPasswordCredentialsProvider getTestCredentialsProvider()
{
return (IPasswordCredentialsProvider)getTestProperty(PROP_TEST_CREDENTIALS_PROVIDER);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Timeouter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Timeouter.java
index 89325fcf6a..52bac72f68 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Timeouter.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Timeouter.java
@@ -27,13 +27,14 @@ public abstract class Timeouter
private TimerTask timeoutTask;
- private long touched;
+ private volatile long touched;
public Timeouter(Timer timer, long timeout)
{
this.timer = timer;
this.timeout = timeout;
- touched = System.currentTimeMillis();
+
+ touch();
scheduleTimeout();
}

Back to the top