Author: orudyy
Date: Fri Oct 10 18:56:23 2014
New Revision: 1630956
URL: http://svn.apache.org/r1630956
Log:
QPID-6144: Throw ConnectionScopedRuntimeException for IllegalStateException
thrown from JE environment on restart
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacade.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/DatabasePinger.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
Fri Oct 10 18:56:23 2014
@@ -107,7 +107,7 @@ public abstract class AbstractBDBMessage
{
new Upgrader(getEnvironmentFacade().getEnvironment(),
getParent()).upgradeIfNecessary();
}
- catch(DatabaseException e)
+ catch(RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot
upgrade store", e);
}
@@ -138,7 +138,7 @@ public abstract class AbstractBDBMessage
MESSAGE_METADATA_SEQ_CONFIG);
newMessageId = mmdSeq.get(null, 1);
}
- catch (DatabaseException de)
+ catch (RuntimeException de)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot get
sequence value for new message", de);
}
@@ -216,7 +216,7 @@ public abstract class AbstractBDBMessage
}
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot visit
message instances", e);
}
@@ -259,7 +259,7 @@ public abstract class AbstractBDBMessage
entries.add(entry);
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot visit
message instances", e);
}
@@ -306,7 +306,7 @@ public abstract class AbstractBDBMessage
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot
recover distributed transactions", e);
}
@@ -350,7 +350,7 @@ public abstract class AbstractBDBMessage
return mdd;
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Error
reading message metadata for message with id "
+ messageId
@@ -424,7 +424,7 @@ public abstract class AbstractBDBMessage
tx.abort();
}
}
- catch(DatabaseException e2)
+ catch(RuntimeException e2)
{
getLogger().warn(
"Unable to abort transaction after
LockConflictException on removal of message with id "
@@ -465,7 +465,7 @@ public abstract class AbstractBDBMessage
}
while(!complete);
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
getLogger().error("Unexpected BDB exception", e);
@@ -550,7 +550,7 @@ public abstract class AbstractBDBMessage
}
return written;
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Error
getting AMQMessage with id "
+ messageId
@@ -587,7 +587,7 @@ public abstract class AbstractBDBMessage
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Error
getting AMQMessage with id "
+ messageId
@@ -618,7 +618,7 @@ public abstract class AbstractBDBMessage
}
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw environmentFacade.handleDatabaseException("Cannot visit
messages", e);
}
@@ -630,7 +630,7 @@ public abstract class AbstractBDBMessage
{
cursor.close();
}
- catch(DatabaseException e)
+ catch(RuntimeException e)
{
throw environmentFacade.handleDatabaseException("Cannot
close cursor", e);
}
@@ -659,7 +659,7 @@ public abstract class AbstractBDBMessage
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw environmentFacade.handleDatabaseException("Cannot visit
messages", e);
}
@@ -697,7 +697,7 @@ public abstract class AbstractBDBMessage
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Error
writing AMQMessage with id "
+ messageId
@@ -740,7 +740,7 @@ public abstract class AbstractBDBMessage
getLogger().debug("Storing message metadata for message id " +
messageId + " in transaction " + tx);
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Error
writing message metadata with id "
+ messageId
@@ -779,7 +779,7 @@ public abstract class AbstractBDBMessage
}
getDeliveryDb().put(tx, key, value);
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
getLogger().error("Failed to enqueue: " + e.getMessage(), e);
throw getEnvironmentFacade().handleDatabaseException("Error
writing enqueued message with id "
@@ -838,7 +838,7 @@ public abstract class AbstractBDBMessage
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
getLogger().error("Failed to dequeue message " + messageId + " in
transaction " + tx, e);
@@ -879,7 +879,7 @@ public abstract class AbstractBDBMessage
getXidDb().put(txn, key, value);
return postActions;
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
getLogger().error("Failed to write xid: " + e.getMessage(), e);
throw getEnvironmentFacade().handleDatabaseException("Error
writing xid to database", e);
@@ -910,7 +910,7 @@ public abstract class AbstractBDBMessage
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
getLogger().error("Failed to remove xid in transaction " + txn, e);
@@ -963,7 +963,7 @@ public abstract class AbstractBDBMessage
{
tx.abort();
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Error
aborting transaction: " + e.getMessage(), e);
}
@@ -975,7 +975,7 @@ public abstract class AbstractBDBMessage
{
storedSizeChange(delta);
}
- catch(DatabaseException e)
+ catch(RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Stored size
change exception", e);
}
@@ -1415,7 +1415,7 @@ public abstract class AbstractBDBMessage
txn =
getEnvironmentFacade().getEnvironment().beginTransaction(
null, null);
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw
getEnvironmentFacade().handleDatabaseException("failed to begin transaction",
e);
}
@@ -1476,7 +1476,7 @@ public abstract class AbstractBDBMessage
{
_txn =
getEnvironmentFacade().getEnvironment().beginTransaction(null, null);
}
- catch(DatabaseException e)
+ catch(RuntimeException e)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot
create store transaction", e);
}
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
Fri Oct 10 18:56:23 2014
@@ -140,7 +140,7 @@ public class BDBConfigurationStore imple
}
_initialRecords = new ConfiguredObjectRecord[0];
}
- catch(DatabaseException e)
+ catch (RuntimeException e)
{
throw _environmentFacade.handleDatabaseException("Cannot upgrade
store", e);
}
@@ -156,7 +156,7 @@ public class BDBConfigurationStore imple
doVisitAllConfiguredObjectRecords(handler);
handler.end();
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw _environmentFacade.handleDatabaseException("Cannot visit
configured object records", e);
}
@@ -243,7 +243,7 @@ public class BDBConfigurationStore imple
_environmentFacade.close();
_environmentFacade = null;
}
- catch(DatabaseException e)
+ catch (RuntimeException e)
{
throw new StoreException("Exception occurred on message store
close", e);
}
@@ -268,7 +268,7 @@ public class BDBConfigurationStore imple
txn.commit();
txn = null;
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw _environmentFacade.handleDatabaseException("Error creating
configured object " + configuredObject
+ " in database: " + e.getMessage(), e);
@@ -305,7 +305,7 @@ public class BDBConfigurationStore imple
txn = null;
return removed.toArray(new UUID[removed.size()]);
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw _environmentFacade.handleDatabaseException("Error deleting
configured objects from database", e);
}
@@ -334,7 +334,7 @@ public class BDBConfigurationStore imple
txn.commit();
txn = null;
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw _environmentFacade.handleDatabaseException("Error updating
configuration details within the store: " + e,e);
}
@@ -408,7 +408,7 @@ public class BDBConfigurationStore imple
}
writeHierarchyRecords(txn, configuredObject);
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
throw _environmentFacade.handleDatabaseException("Error writing
configured object " + configuredObject
+ " to database: " + e.getMessage(), e);
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java
Fri Oct 10 18:56:23 2014
@@ -38,7 +38,7 @@ public class BDBUtils
{
cursor.close();
}
- catch(DatabaseException e)
+ catch (RuntimeException e)
{
// We need the possible side effect of the facade restarting
the environment but don't care about the exception
throw environmentFacade.handleDatabaseException("Cannot close
cursor", e);
@@ -55,7 +55,7 @@ public class BDBUtils
tx.abort();
}
}
- catch (DatabaseException e)
+ catch (RuntimeException e)
{
// We need the possible side effect of the facade restarting the
environment but don't care about the exception
environmentFacade.handleDatabaseException("Cannot abort
transaction", e);
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacade.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacade.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacade.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacade.java
Fri Oct 10 18:56:23 2014
@@ -57,7 +57,7 @@ public interface EnvironmentFacade
StoreFuture commit(com.sleepycat.je.Transaction tx, boolean sync);
- DatabaseException handleDatabaseException(String contextMessage,
DatabaseException e);
+ RuntimeException handleDatabaseException(String contextMessage,
RuntimeException e);
String getStoreLocation();
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java
Fri Oct 10 18:56:23 2014
@@ -37,6 +37,7 @@ import com.sleepycat.je.SequenceConfig;
import com.sleepycat.je.Transaction;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.StoreFuture;
public class StandardEnvironmentFacade implements EnvironmentFacade
@@ -266,13 +267,17 @@ public class StandardEnvironmentFacade i
}
@Override
- public DatabaseException handleDatabaseException(String contextMessage,
DatabaseException e)
+ public RuntimeException handleDatabaseException(String contextMessage,
RuntimeException e)
{
if (_environment != null && !_environment.isValid())
{
closeEnvironmentSafely();
}
- return e;
+ if (e instanceof StoreException)
+ {
+ return e;
+ }
+ return new StoreException("Unexpected exception occurred on store
operation", e);
}
@Override
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/DatabasePinger.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/DatabasePinger.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/DatabasePinger.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/DatabasePinger.java
Fri Oct 10 18:56:23 2014
@@ -79,7 +79,7 @@ public class DatabasePinger
}
}
}
- catch (DatabaseException de)
+ catch (RuntimeException de)
{
facade.handleDatabaseException("DatabaseException from
DatabasePinger ", de);
}
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
Fri Oct 10 18:56:23 2014
@@ -82,6 +82,7 @@ import com.sleepycat.je.rep.vlsn.VLSNRan
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
}
@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)
Modified:
qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java?rev=1630956&r1=1630955&r2=1630956&view=diff
==============================================================================
---
qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
(original)
+++
qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
Fri Oct 10 18:56:23 2014
@@ -315,7 +315,7 @@ public class BDBMessageStoreTest extends
catch (RuntimeException e)
{
assertEquals("Unexpected exception message", "Offset 15 is greater
than message size 10 for message id "
- + messageid_0_8 + "!", e.getMessage());
+ + messageid_0_8 + "!", e.getCause().getMessage());
}
// buffer is smaller then message size
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]