Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-07-24 17:29:48 +0000
committerEike Stepper2008-07-24 17:29:48 +0000
commitb4d654c5afb962c26f7803baee1773a66a9ac90f (patch)
treef2c5974ed6c1e8deeac534b368b74f38ee5f7416
parentaee8018368b33588062d596152fb7e7088ff17a9 (diff)
downloadcdo-b4d654c5afb962c26f7803baee1773a66a9ac90f.tar.gz
cdo-b4d654c5afb962c26f7803baee1773a66a9ac90f.tar.xz
cdo-b4d654c5afb962c26f7803baee1773a66a9ac90f.zip
[241464] Make timeouts in read-access requests configurable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=241464
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/.classpath2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla241464_Test.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java1
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java43
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java9
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java11
11 files changed, 139 insertions, 25 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java
index 80f2fac94b..293ec56aeb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.internal.server.SessionManager;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
/**
* @author Eike Stepper
@@ -51,17 +52,29 @@ public abstract class CDOServerIndication extends IndicationWithResponse
protected IStore getStore()
{
- return getRepository().getStore();
+ IStore store = getRepository().getStore();
+ if (LifecycleUtil.isActive(store))
+ {
+ throw new IllegalStateException("Store has been deactivated");
+ }
+
+ return store;
}
protected Repository getRepository()
{
- return getSessionManager().getRepository();
+ Repository repository = getSessionManager().getRepository();
+ if (!repository.isActive())
+ {
+ throw new IllegalStateException("Repository has been deactivated");
+ }
+
+ return repository;
}
protected Session getSession()
{
- return (Session)getProtocol().getSession();
+ return getProtocol().getSession();
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java
index 939af7b48f..d5a8402b00 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java
@@ -69,7 +69,7 @@ public class AllTests
// suite.addTestSuite(GeneratedEcoreTest.class);
// Chunking is not supported by Hibernate
- // suite.addTestSuite(ChunkingTest.class);
+ // suite.addTestSuite(Bugzilla241464_Test.class);
// failures: /testWriteNative, testChunkWithTemporaryObject
// suite.addTestSuite(ChunkingWithMEMTest.class);
// failures testReadNative, testWriteNative
diff --git a/plugins/org.eclipse.emf.cdo.tests/.classpath b/plugins/org.eclipse.emf.cdo.tests/.classpath
index e7a55df766..6e84b7ccb5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/.classpath
+++ b/plugins/org.eclipse.emf.cdo.tests/.classpath
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="model"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="model"/>
<classpathentry kind="src" path="net4j"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
index b931242932..970a74431c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
@@ -34,6 +34,7 @@ Export-Package: base;version="2.0.0",
interface_.impl;version="2.0.0",
interface_.util;version="2.0.0",
org.eclipse.emf.cdo.tests;version="2.0.0",
+ org.eclipse.emf.cdo.tests.bugzilla;version="2.0.0",
org.eclipse.emf.cdo.tests.store.logic;version="2.0.0",
org.eclipse.net4j.tests;version="2.0.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate,org.eclipse.emf.cdo.tests.hibernate.client",
reference;version="2.0.0",
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla241464_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla241464_Test.java
new file mode 100644
index 0000000000..a77c433c55
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla241464_Test.java
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla241464_Test extends AbstractCDOTest
+{
+ public void testBugzilla241464() throws Exception
+ {
+ {
+ Customer customer = Model1Factory.eINSTANCE.createCustomer();
+ customer.setName("customer");
+
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ resource.getContents().add(customer);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openModel1Session();
+ session.getFailOverStrategy().setDefaultTimeout(5000L);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/test1");
+
+ LifecycleUtil.deactivate(getRepository());
+
+ Customer customer = (Customer)resource.getContents().get(0);
+ System.out.println(customer.getName());
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 34e16184de..8b3a1d3193 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -47,6 +47,7 @@ import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.signal.failover.IFailOverEvent;
import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.Container;
@@ -196,12 +197,17 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
this.referenceChunkSize = referenceChunkSize;
}
- public IFailOverStrategy getFailOverStrategy()
+ public synchronized IFailOverStrategy getFailOverStrategy()
{
- return failOverStrategy == null ? IFailOverStrategy.NOOP : failOverStrategy;
+ if (failOverStrategy == null)
+ {
+ failOverStrategy = new NOOPFailOverStrategy();
+ }
+
+ return failOverStrategy;
}
- public void setFailOverStrategy(IFailOverStrategy failOverStrategy)
+ public synchronized void setFailOverStrategy(IFailOverStrategy failOverStrategy)
{
if (this.failOverStrategy != null)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index e5d783682f..13800d4404 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -738,6 +738,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
catch (RuntimeException ex)
{
OM.LOG.error(ex);
+ throw ex;
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java
new file mode 100644
index 0000000000..ec56cbcddf
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.signal.failover;
+
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.signal.SignalActor;
+import org.eclipse.net4j.util.event.Notifier;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class AbstractFailOverStrategy extends Notifier implements IFailOverStrategy
+{
+ private long defaultTimeout = SignalActor.NO_TIMEOUT;
+
+ public AbstractFailOverStrategy()
+ {
+ }
+
+ public long getDefaultTimeout()
+ {
+ return defaultTimeout;
+ }
+
+ public void setDefaultTimeout(long defaultTimeout)
+ {
+ this.defaultTimeout = defaultTimeout;
+ }
+
+ public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception
+ {
+ return send(request, defaultTimeout);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java
index ed591f7f01..033adab410 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java
@@ -13,27 +13,20 @@ package org.eclipse.net4j.signal.failover;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalActor;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.event.Notifier;
import java.util.concurrent.TimeoutException;
/**
* @author Eike Stepper
*/
-public abstract class FailOverStrategy extends Notifier implements IFailOverStrategy
+public abstract class FailOverStrategy extends AbstractFailOverStrategy
{
public FailOverStrategy()
{
}
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception
- {
- return send(request, SignalActor.NO_TIMEOUT);
- }
-
public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception
{
for (;;)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java
index 0bdcc642ac..c156202e86 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java
@@ -18,7 +18,15 @@ import org.eclipse.net4j.util.event.INotifier;
*/
public interface IFailOverStrategy extends INotifier
{
- public static final IFailOverStrategy NOOP = NOOPFailOverStrategy.INSTANCE;
+ /**
+ * @since 2.0
+ */
+ public long getDefaultTimeout();
+
+ /**
+ * @since 2.0
+ */
+ public void setDefaultTimeout(long defaultTimeout);
public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java
index 2230a08acc..c717ba5b31 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java
@@ -16,28 +16,23 @@ import org.eclipse.net4j.util.event.IListener;
/**
* @author Eike Stepper
*/
-public class NOOPFailOverStrategy implements IFailOverStrategy
+public class NOOPFailOverStrategy extends AbstractFailOverStrategy
{
- public static final NOOPFailOverStrategy INSTANCE = new NOOPFailOverStrategy();
-
public NOOPFailOverStrategy()
{
}
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception
- {
- return request.send();
- }
-
public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception
{
return request.send(timeout);
}
+ @Override
public void addListener(IListener listener)
{
}
+ @Override
public void removeListener(IListener listener)
{
}

Back to the top