activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [4/5] activemq-artemis git commit: Added MySQL Support
Date Wed, 01 Jun 2016 21:33:19 GMT
Added MySQL Support


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/634fc1b4
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/634fc1b4
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/634fc1b4

Branch: refs/heads/master
Commit: 634fc1b4827f139b089be660889dc93257d7b507
Parents: fda6789
Author: Martyn Taylor <mtaylor@redhat.com>
Authored: Wed Jun 1 12:33:36 2016 +0100
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Wed Jun 1 19:04:25 2016 +0100

----------------------------------------------------------------------
 artemis-jdbc-store/pom.xml                      |  1 +
 .../activemq/artemis/jdbc/store/JDBCUtils.java  | 10 +++
 .../store/drivers/mysql/MySQLSQLProvider.java   | 64 ++++++++++++++++++++
 .../artemis/tests/util/ThreadLeakCheckRule.java |  4 ++
 pom.xml                                         |  2 +-
 tests/integration-tests/pom.xml                 |  1 +
 6 files changed, 81 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/634fc1b4/artemis-jdbc-store/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/pom.xml b/artemis-jdbc-store/pom.xml
index bb54c12..80f69c4 100644
--- a/artemis-jdbc-store/pom.xml
+++ b/artemis-jdbc-store/pom.xml
@@ -63,6 +63,7 @@
       <dependency>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
+         <scope>provided</scope>
       </dependency>
 
       <dependency>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/634fc1b4/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
index 04ac242..8ce08c6 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
@@ -24,6 +24,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 
 import org.apache.activemq.artemis.jdbc.store.drivers.derby.DerbySQLProvider;
+import org.apache.activemq.artemis.jdbc.store.drivers.mysql.MySQLSQLProvider;
 import org.apache.activemq.artemis.jdbc.store.drivers.postgres.PostgresSQLProvider;
 import org.apache.activemq.artemis.jdbc.store.drivers.postgres.PostgresSequentialSequentialFileDriver;
 import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver;
@@ -75,6 +76,9 @@ public class JDBCUtils {
       else if (driverClass.contains("postgres")) {
          return new PostgresSQLProvider(tableName);
       }
+      else if (driverClass.contains("mysql")) {
+         return new MySQLSQLProvider(tableName);
+      }
       else {
          return new GenericSQLProvider(tableName);
       }
@@ -96,6 +100,12 @@ public class JDBCUtils {
          dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
          dbDriver.setJdbcDriverClass(driverClass);
       }
+      else if (driverClass.contains("mysql")) {
+         dbDriver = new JDBCSequentialFileFactoryDriver();
+         dbDriver.setSqlProvider(new MySQLSQLProvider(tableName));
+         dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
+         dbDriver.setJdbcDriverClass(driverClass);
+      }
       else {
          dbDriver = new JDBCSequentialFileFactoryDriver();
          dbDriver.setSqlProvider(new GenericSQLProvider(tableName));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/634fc1b4/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
new file mode 100644
index 0000000..1400382
--- /dev/null
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jdbc.store.drivers.mysql;
+
+import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
+
+public class MySQLSQLProvider extends GenericSQLProvider {
+
+   private static final int MAX_BLOB_SIZE = 4 * 1024 * 1024 * 1024; // 4GB
+
+   private final String createFileTableSQL;
+
+   private final String createJournalTableSQL;
+
+   private final String copyFileRecordByIdSQL;
+
+   public MySQLSQLProvider(String tName) {
+      super(tName.toLowerCase());
+
+      createFileTableSQL = "CREATE TABLE " + tableName +
+         "(ID INTEGER NOT NULL AUTO_INCREMENT," +
+         "FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA LONGBLOB, PRIMARY KEY(ID)) ENGINE=InnoDB;";
+
+      createJournalTableSQL = "CREATE TABLE " + tableName +
+         "(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId BIGINT,userRecordType
SMALLINT,variableSize INTEGER,record LONGBLOB,txDataSize INTEGER,txData LONGBLOB,txCheckNoRecords
INTEGER,seq BIGINT) ENGINE=InnoDB;";
+
+      copyFileRecordByIdSQL = " UPDATE " + tableName + ", (SELECT DATA AS FROM_DATA FROM
" + tableName +
+         " WHERE id=?) SELECT_COPY SET DATA=FROM_DATA WHERE id=?;";
+   }
+
+   @Override
+   public int getMaxBlobSize() {
+      return MAX_BLOB_SIZE;
+   }
+
+   @Override
+   public String getCreateFileTableSQL() {
+      return createFileTableSQL;
+   }
+
+   @Override
+   public String getCreateJournalTableSQL() {
+      return createJournalTableSQL;
+   }
+
+   @Override
+   public String getCopyFileRecordByIdSQL() {
+      return copyFileRecordByIdSQL;
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/634fc1b4/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
index 3b53d53..fa881d5 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
@@ -185,6 +185,10 @@ public class ThreadLeakCheckRule extends ExternalResource {
          // The derby engine is initialized once, and lasts the lifetime of the VM
          return true;
       }
+      else if (threadName.contains("Abandoned connection cleanup thread")) {
+         // MySQL Engine checks for abandoned connections
+         return true;
+      }
       else if (threadName.contains("Timer")) {
          // The timer threads in Derby and JDBC use daemon and shutdown once user threads
exit.
          return true;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/634fc1b4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d8e4f11..d0327fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -236,7 +236,7 @@
             <scope>provided</scope>
             <!-- postgresql license -->
          </dependency>
-
+         
          <dependency>
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections-testframework</artifactId>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/634fc1b4/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 2d62ce0..b0303c7 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -253,6 +253,7 @@
          <artifactId>postgresql</artifactId>
          <scope>test</scope>
       </dependency>
+
       <!--Vertx provided dependencies-->
       <dependency>
          <groupId>io.vertx</groupId>


Mime
View raw message