activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-852: Add PK and index to create journal table DDL script
Date Wed, 16 Nov 2016 14:21:24 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 530852b28 -> abdb9a7c4


ARTEMIS-852: Add PK and index to create journal table DDL script


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

Branch: refs/heads/master
Commit: 95e88dd22f68c27c57664cc5aec129f7f9175472
Parents: 530852b
Author: Benjamin Graf <benjamin.graf@gmx.net>
Authored: Wed Nov 16 10:08:10 2016 +0100
Committer: Benjamin Graf <benjamin.graf@gmx.net>
Committed: Wed Nov 16 10:08:10 2016 +0100

----------------------------------------------------------------------
 .../artemis/jdbc/store/drivers/AbstractJDBCDriver.java | 13 ++++++++-----
 .../jdbc/store/drivers/mysql/MySQLSQLProvider.java     | 10 ++++++----
 .../store/drivers/postgres/PostgresSQLProvider.java    |  9 ++++++---
 .../artemis/jdbc/store/sql/GenericSQLProvider.java     |  9 ++++++---
 .../activemq/artemis/jdbc/store/sql/SQLProvider.java   |  2 +-
 pom.xml                                                |  1 +
 6 files changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/95e88dd2/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
index 79cc1e5..7f8c58f 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
@@ -23,6 +23,7 @@ import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Arrays;
 import java.util.Properties;
 
 import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
@@ -76,8 +77,8 @@ public abstract class AbstractJDBCDriver {
 
    protected abstract void createSchema() throws SQLException;
 
-   protected void createTable(String schemaSql) throws SQLException {
-      createTableIfNotExists(connection, sqlProvider.getTableName(), schemaSql);
+   protected void createTable(String... schemaSqls) throws SQLException {
+      createTableIfNotExists(connection, sqlProvider.getTableName(), schemaSqls);
    }
 
    protected void connect() throws Exception {
@@ -107,15 +108,17 @@ public abstract class AbstractJDBCDriver {
       }
    }
 
-   private static void createTableIfNotExists(Connection connection, String tableName, String
sql) throws SQLException {
+   private static void createTableIfNotExists(Connection connection, String tableName, String...
sqls) throws SQLException {
       logger.tracef("Validating if table %s didn't exist before creating", tableName);
       try {
          connection.setAutoCommit(false);
          try (ResultSet rs = connection.getMetaData().getTables(null, null, tableName, null))
{
             if (rs != null && !rs.next()) {
-               logger.tracef("Table %s did not exist, creating it with SQL=%s", tableName,
sql);
+               logger.tracef("Table %s did not exist, creating it with SQL=%s", tableName,
Arrays.toString(sqls));
                try (Statement statement = connection.createStatement()) {
-                  statement.executeUpdate(sql);
+                  for (String sql : sqls) {
+                     statement.executeUpdate(sql);
+                  }
                }
             }
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/95e88dd2/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
index 7b2ab1f..9b0c4e6 100644
--- 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
@@ -25,7 +25,7 @@ public class MySQLSQLProvider extends GenericSQLProvider {
 
    private final String createFileTableSQL;
 
-   private final String createJournalTableSQL;
+   private final String[] createJournalTableSQL;
 
    private final String copyFileRecordByIdSQL;
 
@@ -36,8 +36,10 @@ public class MySQLSQLProvider extends GenericSQLProvider {
          "(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;";
+      createJournalTableSQL = new String[] {
+         "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;",
+         "CREATE INDEX " + tableName + "_IDX ON " + tableName + " (id)"
+      };
 
       copyFileRecordByIdSQL = " UPDATE " + tableName + ", (SELECT DATA AS FROM_DATA FROM
" + tableName +
          " WHERE id=?) SELECT_COPY SET DATA=FROM_DATA WHERE id=?;";
@@ -54,7 +56,7 @@ public class MySQLSQLProvider extends GenericSQLProvider {
    }
 
    @Override
-   public String getCreateJournalTableSQL() {
+   public String[] getCreateJournalTableSQL() {
       return createJournalTableSQL;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/95e88dd2/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
index 254fa86..fb0d34a 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
@@ -26,14 +26,17 @@ public class PostgresSQLProvider extends GenericSQLProvider {
 
    private final String createFileTableSQL;
 
-   private final String createJournalTableSQL;
+   private final String[] createJournalTableSQL;
 
    private PostgresSQLProvider(String tName) {
       super(tName.toLowerCase());
       createFileTableSQL = "CREATE TABLE " + tableName +
          "(ID SERIAL, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA OID, PRIMARY KEY(ID))";
 
-      createJournalTableSQL = "CREATE TABLE " + tableName + "(id BIGINT,recordType SMALLINT,compactCount
SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record BYTEA,txDataSize
INTEGER,txData BYTEA,txCheckNoRecords INTEGER,seq BIGINT)";
+      createJournalTableSQL = new String[] {
+         "CREATE TABLE " + tableName + "(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId
BIGINT,userRecordType SMALLINT,variableSize INTEGER,record BYTEA,txDataSize INTEGER,txData
BYTEA,txCheckNoRecords INTEGER,seq BIGINT)",
+         "CREATE INDEX " + tableName + "_IDX ON " + tableName + " (id)"
+      };
    }
 
    @Override
@@ -42,7 +45,7 @@ public class PostgresSQLProvider extends GenericSQLProvider {
    }
 
    @Override
-   public String getCreateJournalTableSQL() {
+   public String[] getCreateJournalTableSQL() {
       return createJournalTableSQL;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/95e88dd2/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/GenericSQLProvider.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/GenericSQLProvider.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/GenericSQLProvider.java
index f7b37f7..a7a4b47 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/GenericSQLProvider.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/GenericSQLProvider.java
@@ -45,7 +45,7 @@ public class GenericSQLProvider implements SQLProvider {
 
    private final String dropFileTableSQL;
 
-   private final String createJournalTableSQL;
+   private final String[] createJournalTableSQL;
 
    private final String insertJournalRecordsSQL;
 
@@ -84,7 +84,10 @@ public class GenericSQLProvider implements SQLProvider {
 
       dropFileTableSQL = "DROP TABLE " + tableName;
 
-      createJournalTableSQL = "CREATE TABLE " + tableName + "(id BIGINT,recordType SMALLINT,compactCount
SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record BLOB,txDataSize INTEGER,txData
BLOB,txCheckNoRecords INTEGER,seq BIGINT)";
+      createJournalTableSQL = new String[] {
+         "CREATE TABLE " + tableName + "(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId
BIGINT,userRecordType SMALLINT,variableSize INTEGER,record BLOB,txDataSize INTEGER,txData
BLOB,txCheckNoRecords INTEGER,seq BIGINT NOT NULL, PRIMARY KEY(seq))",
+         "CREATE INDEX " + tableName + "_IDX ON " + tableName + " (id)"
+      };
 
       insertJournalRecordsSQL = "INSERT INTO " + tableName + "(id,recordType,compactCount,txId,userRecordType,variableSize,record,txDataSize,txData,txCheckNoRecords,seq)
" + "VALUES (?,?,?,?,?,?,?,?,?,?,?)";
 
@@ -109,7 +112,7 @@ public class GenericSQLProvider implements SQLProvider {
 
    // Journal SQL Statements
    @Override
-   public String getCreateJournalTableSQL() {
+   public String[] getCreateJournalTableSQL() {
       return createJournalTableSQL;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/95e88dd2/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java
index 1fae83a..21561ff 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java
@@ -20,7 +20,7 @@ public interface SQLProvider {
 
    int getMaxBlobSize();
 
-   String getCreateJournalTableSQL();
+   String[] getCreateJournalTableSQL();
 
    String getInsertJournalRecordsSQL();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/95e88dd2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ff1cb40..3e7e525 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1266,6 +1266,7 @@
                   <exclude>**/.checkstyle</exclude>
                   <exclude>**/.factorypath</exclude>
                   <exclude>**/org.apache.activemq.artemis.cfg</exclude>
+                  <exclude>**/nb-configuration.xml</exclude>
                   <!-- activemq5 unit tests exclude -->
                   <exclude>**/*.data</exclude>
                   <exclude>**/*.bin</exclude>


Mime
View raw message