summaryrefslogtreecommitdiff
path: root/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java')
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java45
1 files changed, 30 insertions, 15 deletions
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
index 532cffdac8..8877f6a156 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
@@ -82,6 +82,7 @@ import com.sleepycat.je.rep.vlsn.VLSNRange;
import com.sleepycat.je.utilint.PropUtil;
import com.sleepycat.je.utilint.VLSN;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.store.StoreException;
import org.codehaus.jackson.map.ObjectMapper;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
@@ -371,26 +372,40 @@ public class ReplicatedEnvironmentFacade implements EnvironmentFacade, StateChan
}
@Override
- public DatabaseException handleDatabaseException(String contextMessage, final DatabaseException dbe)
+ public RuntimeException handleDatabaseException(String contextMessage, final RuntimeException dbe)
{
- boolean noMajority = dbe instanceof InsufficientReplicasException || dbe instanceof InsufficientAcksException;
-
- if (noMajority)
+ if (dbe instanceof StoreException || dbe instanceof ConnectionScopedRuntimeException)
{
- ReplicationGroupListener listener = _replicationGroupListener.get();
- if (listener != null)
+ return dbe;
+ }
+ else if (dbe instanceof DatabaseException)
+ {
+ boolean noMajority = dbe instanceof InsufficientReplicasException || dbe instanceof InsufficientAcksException;
+
+ if (noMajority)
+ {
+ ReplicationGroupListener listener = _replicationGroupListener.get();
+ if (listener != null)
+ {
+ listener.onNoMajority();
+ }
+ }
+
+ boolean restart = (noMajority || dbe instanceof RestartRequiredException);
+ if (restart)
{
- listener.onNoMajority();
+ tryToRestartEnvironment((DatabaseException)dbe);
+ return new ConnectionScopedRuntimeException(noMajority ? "Required number of nodes not reachable" : "Underlying JE environment is being restarted", dbe);
}
}
-
- boolean restart = (noMajority || dbe instanceof RestartRequiredException);
- if (restart)
+ else
{
- tryToRestartEnvironment(dbe);
- throw new ConnectionScopedRuntimeException(noMajority ? "Required number of nodes not reachable" : "Underlying JE environment is being restarted", dbe);
+ if (dbe instanceof IllegalStateException && getFacadeState() == State.RESTARTING)
+ {
+ return new ConnectionScopedRuntimeException("Underlying JE environment is being restarted", dbe);
+ }
}
- return dbe;
+ return new StoreException("Unexpected exception occurred in replicated environment", dbe);
}
private void tryToRestartEnvironment(final DatabaseException dbe)
@@ -452,12 +467,12 @@ public class ReplicatedEnvironmentFacade implements EnvironmentFacade, StateChan
}
if (_state.get() != State.OPEN)
{
- throw new IllegalStateException("Environment facade is not in opened state");
+ throw new ConnectionScopedRuntimeException("Environment facade is not in opened state");
}
if (!_environment.isValid())
{
- throw new IllegalStateException("Environment is not valid");
+ throw new ConnectionScopedRuntimeException("Environment is not valid");
}
Database cachedHandle = _cachedDatabases.get(name);