From acdb57af871cbfef3a768b2dd765246063129d5d Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Sat, 8 Nov 2014 12:56:12 +0000 Subject: QPID-6221 : [Java Broker] Detect low disk space conditions and enforce flow control git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1637558 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/server/store/derby/DerbyConfigurationStore.java | 6 ++++++ .../java/org/apache/qpid/server/store/derby/DerbyMessageStore.java | 6 +++++- .../main/java/org/apache/qpid/server/store/derby/DerbyUtils.java | 7 ++++++- .../qpid/server/store/jdbc/GenericJDBCConfigurationStore.java | 7 +++++++ .../org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java | 7 +++++++ 5 files changed, 31 insertions(+), 2 deletions(-) (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java index 85960cd25b..2764597bd0 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java @@ -220,6 +220,12 @@ public class DerbyConfigurationStore extends AbstractJDBCConfigurationStore return ((FileBasedSettings)_parent).getStorePath(); } + @Override + public File getStoreLocationAsFile() + { + return DerbyUtils.isInMemoryDatabase(getStoreLocation()) ? null : new File(getStoreLocation()); + } + @Override protected Logger getLogger() { diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java index 8ba5af9130..7d1191da2c 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java @@ -109,5 +109,9 @@ public class DerbyMessageStore extends AbstractDerbyMessageStore return ((FileBasedSettings)_parent).getStorePath(); } - + @Override + public File getStoreLocationAsFile() + { + return DerbyUtils.isInMemoryDatabase(getStoreLocation()) ? null : new File(getStoreLocation()); + } } diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java index b3c449747b..df9c48d6f9 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java @@ -57,7 +57,7 @@ public class DerbyUtils public static String createConnectionUrl(final String name, final String databasePath) { // Derby wont use an existing directory, so we append parent name - if (MEMORY_STORE_LOCATION.equals(databasePath)) + if (isInMemoryDatabase(databasePath)) { return "jdbc:derby:" + MEMORY_STORE_LOCATION + "/" + name + ";create=true"; } @@ -79,6 +79,11 @@ public class DerbyUtils } + public static boolean isInMemoryDatabase(final String databasePath) + { + return MEMORY_STORE_LOCATION.equals(databasePath); + } + public static void shutdownDatabase(String connectionURL) throws SQLException { try diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java index 13d5c54ee4..3c3b1da880 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java @@ -19,6 +19,7 @@ package org.apache.qpid.server.store.jdbc; +import java.io.File; import java.nio.charset.Charset; import java.security.PrivilegedAction; import java.sql.Blob; @@ -286,6 +287,12 @@ public class GenericJDBCConfigurationStore extends AbstractJDBCConfigurationStor return GenericJDBCConfigurationStore.this._connectionURL; } + @Override + public File getStoreLocationAsFile() + { + return null; + } + @Override protected Logger getLogger() { diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java index 59e165acc2..a75ca4d685 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java @@ -21,6 +21,7 @@ package org.apache.qpid.server.store.jdbc; +import java.io.File; import java.security.PrivilegedAction; import java.sql.Blob; import java.sql.Connection; @@ -177,6 +178,12 @@ public class GenericJDBCMessageStore extends GenericAbstractJDBCMessageStore return _connectionURL; } + @Override + public File getStoreLocationAsFile() + { + return null; + } + protected String getPlainTextPassword(final JDBCSettings settings) { return Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction() -- cgit v1.2.1