You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/07/31 12:42:14 UTC
qpid-broker-j git commit: [QPID-8215] Fix Sybase support for the
link-store
Repository: qpid-broker-j
Updated Branches:
refs/heads/master ee33d2f41 -> ac3b1d0e9
[QPID-8215] Fix Sybase support for the link-store
This closes #11
https://github.com/apache/qpid-broker-j/pull/11
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/ac3b1d0e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/ac3b1d0e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/ac3b1d0e
Branch: refs/heads/master
Commit: ac3b1d0e93a9b78d461171858f816d92b3c34e0e
Parents: ee33d2f
Author: overmeulen <ov...@murex.com>
Authored: Wed Jun 27 13:57:19 2018 +0200
Committer: Alex Rudyy <or...@apache.org>
Committed: Tue Jul 31 13:40:24 2018 +0100
----------------------------------------------------------------------
.../protocol/v1_0/store/jdbc/JDBCLinkStore.java | 4 +-
.../v1_0/store/jdbc/JDBCLinkStoreTest.java | 1 +
.../qpid/server/store/jdbc/JDBCDetails.java | 57 ++++++++++++++------
.../qpid/server/store/jdbc/JDBCDetailsTest.java | 2 +
4 files changed, 47 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/ac3b1d0e/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java b/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
index 4441d6a..fd38509 100644
--- a/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
+++ b/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
@@ -73,6 +73,7 @@ public class JDBCLinkStore extends AbstractLinkStore
private final JDBCContainer _jdbcContainer;
private final String _tableNamePrefix;
private final String _sqlBlobType;
+ private final String _sqlTimestampType;
private final boolean _isUseBytesMethodsForBlob;
private final Action<Connection> _cleanUpAction;
@@ -82,6 +83,7 @@ public class JDBCLinkStore extends AbstractLinkStore
_tableNamePrefix = jdbcContainer.getTableNamePrefix();
JDBCDetails jdbcDetails = jdbcContainer.getJDBCDetails();
_sqlBlobType = jdbcDetails.getBlobType();
+ _sqlTimestampType = jdbcDetails.getTimestampType();
_isUseBytesMethodsForBlob = jdbcDetails.isUseBytesMethodsForBlob();
_cleanUpAction = this::cleanUp;
jdbcContainer.addDeleteAction(_cleanUpAction);
@@ -256,7 +258,7 @@ public class JDBCLinkStore extends AbstractLinkStore
{
stmt.execute(String.format("CREATE TABLE %s"
+ " (version varchar(10) PRIMARY KEY ,"
- + " version_time TIMESTAMP)", versionTableName));
+ + " version_time %s)", versionTableName, _sqlTimestampType));
}
updateVersion(conn, ModelVersion.fromString(BrokerModel.MODEL_VERSION));
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/ac3b1d0e/broker-plugins/amqp-1-0-jdbc-store/src/test/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-jdbc-store/src/test/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStoreTest.java b/broker-plugins/amqp-1-0-jdbc-store/src/test/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStoreTest.java
index bb9712f..84e6593 100644
--- a/broker-plugins/amqp-1-0-jdbc-store/src/test/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStoreTest.java
+++ b/broker-plugins/amqp-1-0-jdbc-store/src/test/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStoreTest.java
@@ -40,6 +40,7 @@ public class JDBCLinkStoreTest extends LinkStoreTestCase
{
final JDBCDetails details = mock(JDBCDetails.class);
when(details.getBlobType()).thenReturn("blob");
+ when(details.getTimestampType()).thenReturn("timestamp");
when(details.isUseBytesMethodsForBlob()).thenReturn(false);
JDBCContainer jdbcContainer = mock(JDBCContainer.class);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/ac3b1d0e/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
----------------------------------------------------------------------
diff --git a/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java b/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
index 0cdf2c6..6f374a5 100644
--- a/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
+++ b/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
@@ -34,6 +34,7 @@ public abstract class JDBCDetails
public static final String CONTEXT_JDBCSTORE_BIGINTTYPE = "qpid.jdbcstore.bigIntType";
public static final String CONTEXT_JDBCSTORE_VARBINARYTYPE = "qpid.jdbcstore.varBinaryType";
public static final String CONTEXT_JDBCSTORE_BLOBTYPE = "qpid.jdbcstore.blobType";
+ public static final String CONTEXT_JDBCSTORE_TIMESTAMPTYPE = "qpid.jdbcstore.timestampType";
public static final String CONTEXT_JDBCSTORE_USEBYTESFORBLOB = "qpid.jdbcstore.useBytesForBlob";
public abstract String getVendor();
@@ -44,6 +45,8 @@ public abstract class JDBCDetails
public abstract String getBigintType();
+ public abstract String getTimestampType();
+
public abstract boolean isUseBytesMethodsForBlob();
public abstract boolean isKnownVendor();
@@ -52,21 +55,20 @@ public abstract class JDBCDetails
static class KnownJDBCDetails extends JDBCDetails
{
- private static final JDBCDetails FALLBACK = new KnownJDBCDetails("fallback", "blob", "varchar(%d) for bit data", "bigint", false,
- false);
- private static final JDBCDetails ORACLE = new KnownJDBCDetails("oracle", "blob", "raw(%d)", "number", false,
- true);
- private static final JDBCDetails SYBASE = new KnownJDBCDetails("sybase", "image", "varbinary(%d)", "bigint", false,
- true);
- private static final JDBCDetails POSTGRES = new KnownJDBCDetails("postgresql", "bytea", "bytea", "bigint", true,
- true);
- private static final JDBCDetails DERBY = new KnownJDBCDetails("derby", "blob", "varchar(%d) for bit data", "bigint", false,
- true);
- private static final JDBCDetails MYSQL = new KnownJDBCDetails("mysql", "longblob", "varbinary(%d)", "bigint", false,
- true);
-
- private static final JDBCDetails MARIA_DB = new KnownJDBCDetails("mariadb", "longblob", "varbinary(%d)",
- "bigint", false, true);
+ private static final JDBCDetails FALLBACK = new KnownJDBCDetails("fallback", "blob", "varchar(%d) for bit data", "bigint", "timestamp",
+ false, false);
+ private static final JDBCDetails ORACLE = new KnownJDBCDetails("oracle", "blob", "raw(%d)", "number", "timestamp",
+ false, true);
+ private static final JDBCDetails SYBASE = new KnownJDBCDetails("sybase", "image", "varbinary(%d)", "bigint", "datetime",
+ false, true);
+ private static final JDBCDetails POSTGRES = new KnownJDBCDetails("postgresql", "bytea", "bytea", "bigint", "timestamp",
+ true, true);
+ private static final JDBCDetails DERBY = new KnownJDBCDetails("derby", "blob", "varchar(%d) for bit data", "bigint", "timestamp",
+ false, true);
+ private static final JDBCDetails MYSQL = new KnownJDBCDetails("mysql", "longblob", "varbinary(%d)", "bigint", "timestamp",
+ false, true);
+ private static final JDBCDetails MARIA_DB = new KnownJDBCDetails("mariadb", "longblob", "varbinary(%d)", "bigint", "timestamp",
+ false, true);
static
{
@@ -94,6 +96,7 @@ public abstract class JDBCDetails
private final String _blobType;
private final String _varBinaryType;
private final String _bigintType;
+ private final String _timestampType;
private final boolean _useBytesMethodsForBlob;
private final boolean _isKnownVendor;
@@ -101,6 +104,7 @@ public abstract class JDBCDetails
String blobType,
String varBinaryType,
String bigIntType,
+ String timestampType,
boolean useBytesMethodsForBlob,
boolean knownVendor)
{
@@ -108,6 +112,7 @@ public abstract class JDBCDetails
_blobType = blobType;
_varBinaryType = varBinaryType;
_bigintType = bigIntType;
+ _timestampType = timestampType;
_useBytesMethodsForBlob = useBytesMethodsForBlob;
_isKnownVendor = knownVendor;
}
@@ -143,6 +148,12 @@ public abstract class JDBCDetails
}
@Override
+ public String getTimestampType()
+ {
+ return _timestampType;
+ }
+
+ @Override
public boolean isKnownVendor()
{
return _isKnownVendor;
@@ -164,6 +175,7 @@ public abstract class JDBCDetails
", blobType='" + getBlobType() + '\'' +
", varBinaryType='" + getVarBinaryType() + '\'' +
", bigIntType='" + getBigintType() + '\'' +
+ ", timestampType='" + getTimestampType() + '\'' +
", useBytesMethodsForBlob=" + isUseBytesMethodsForBlob() +
", knownVendor=" + isKnownVendor() +
", overridden=" + isOverridden() +
@@ -208,6 +220,10 @@ public abstract class JDBCDetails
{
return false;
}
+ if (getTimestampType() != null ? !getTimestampType().equals(that.getTimestampType()) : that.getTimestampType() != null)
+ {
+ return false;
+ }
if (getVendor() != null ? !getVendor().equals(that.getVendor()) : that.getVendor() != null)
{
return false;
@@ -223,6 +239,7 @@ public abstract class JDBCDetails
result = 31 * result + (getBlobType() != null ? getBlobType().hashCode() : 0);
result = 31 * result + (getVarBinaryType() != null ? getVarBinaryType().hashCode() : 0);
result = 31 * result + (getBigintType() != null ? getBigintType().hashCode() : 0);
+ result = 31 * result + (getTimestampType() != null ? getTimestampType().hashCode() : 0);
result = 31 * result + (isUseBytesMethodsForBlob() ? 1 : 0);
result = 31 * result + (isKnownVendor() ? 1 : 0);
result = 31 * result + (isOverridden() ? 1 : 0);
@@ -361,6 +378,13 @@ public abstract class JDBCDetails
}
@Override
+ public String getTimestampType()
+ {
+ return contextMap.containsKey(CONTEXT_JDBCSTORE_TIMESTAMPTYPE)
+ ? String.valueOf(contextMap.get(CONTEXT_JDBCSTORE_TIMESTAMPTYPE)) : details.getTimestampType();
+ }
+
+ @Override
public boolean isUseBytesMethodsForBlob()
{
return contextMap.containsKey(CONTEXT_JDBCSTORE_USEBYTESFORBLOB)
@@ -379,7 +403,8 @@ public abstract class JDBCDetails
return contextMap.containsKey(CONTEXT_JDBCSTORE_USEBYTESFORBLOB)
|| contextMap.containsKey(CONTEXT_JDBCSTORE_BIGINTTYPE)
|| contextMap.containsKey(CONTEXT_JDBCSTORE_VARBINARYTYPE)
- || contextMap.containsKey(CONTEXT_JDBCSTORE_BLOBTYPE);
+ || contextMap.containsKey(CONTEXT_JDBCSTORE_BLOBTYPE)
+ || contextMap.containsKey(CONTEXT_JDBCSTORE_TIMESTAMPTYPE);
}
};
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/ac3b1d0e/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java b/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java
index df31fe0..4c65a0f 100644
--- a/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java
+++ b/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java
@@ -88,6 +88,7 @@ public class JDBCDetailsTest extends UnitTestBase{
contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_VARBINARYTYPE, "myvarbin");
contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_BIGINTTYPE, "mybigint");
contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_BLOBTYPE, "myblob");
+ contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_TIMESTAMPTYPE, "mytimestamp");
contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_USEBYTESFORBLOB, "true");
JDBCDetails details = JDBCDetails.getJdbcDetails("sybase", contextMap);
@@ -95,6 +96,7 @@ public class JDBCDetailsTest extends UnitTestBase{
assertEquals("myvarbin", details.getVarBinaryType());
assertEquals("mybigint", details.getBigintType());
assertEquals("myblob", details.getBlobType());
+ assertEquals("mytimestamp", details.getTimestampType());
assertEquals(true, details.isUseBytesMethodsForBlob());
assertTrue(details.isKnownVendor());
assertTrue(details.isOverridden());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org