[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16442542#comment-16442542
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 closed the pull request at:

https://github.com/apache/activemq-artemis/pull/2028


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-18 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16442535#comment-16442535
 ] 

ASF subversion and git services commented on ARTEMIS-1653:
--

Commit af15fc43c663977be3cf2f82865936e3f5d02cda in activemq-artemis's branch 
refs/heads/1.x from [~nlippke]
[ https://git-wip-us.apache.org/repos/asf?p=activemq-artemis.git;h=af15fc4 ]

ARTEMIS-1653 Allow database tables to be created externally

(cherry picked from commit eab498456762c3df0f786b1f9ae4e372fdbbfa32)


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16442537#comment-16442537
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user clebertsuconic commented on the issue:

https://github.com/apache/activemq-artemis/pull/2028
  
merged.. close it


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-18 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16442536#comment-16442536
 ] 

ASF subversion and git services commented on ARTEMIS-1653:
--

Commit 0da630be500ff90db091f2014cba7e3ac97db38d in activemq-artemis's branch 
refs/heads/1.x from [~nigro@gmail.com]
[ https://git-wip-us.apache.org/repos/asf?p=activemq-artemis.git;h=0da630b ]

ARTEMIS-1653 Allow database tables to be created externally

(cherry picked from commit c7651853cdb291dfa3bd2906e1e082fd06cff612)


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16442389#comment-16442389
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

GitHub user franz1981 opened a pull request:

https://github.com/apache/activemq-artemis/pull/2028

 ARTEMIS-1653 Allow database tables to be created externally

https://issues.apache.org/jira/browse/ARTEMIS-1653

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/franz1981/activemq-artemis 1.x_ARTEMIS-1653

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/activemq-artemis/pull/2028.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2028


commit 24f7caba501c102fcc88d41926ab9d7aefc3e315
Author: Niels Lippke 
Date:   2018-01-28T16:53:35Z

ARTEMIS-1653 Allow database tables to be created externally

(cherry picked from commit eab498456762c3df0f786b1f9ae4e372fdbbfa32)

commit e10391dc885dd74b404d41f04c76d163f1c8227d
Author: Francesco Nigro 
Date:   2018-04-03T08:11:04Z

ARTEMIS-1653 Allow database tables to be created externally

(cherry picked from commit c7651853cdb291dfa3bd2906e1e082fd06cff612)




> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16440936#comment-16440936
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user asfgit closed the pull request at:

https://github.com/apache/activemq-artemis/pull/1997


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-17 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16440935#comment-16440935
 ] 

ASF subversion and git services commented on ARTEMIS-1653:
--

Commit c7651853cdb291dfa3bd2906e1e082fd06cff612 in activemq-artemis's branch 
refs/heads/master from [~nigro@gmail.com]
[ https://git-wip-us.apache.org/repos/asf?p=activemq-artemis.git;h=c765185 ]

ARTEMIS-1653 Allow database tables to be created externally

The previous commit about this feature wasn't using the row count query
ResultSet.
The mechanics has been changed to allow the row count query
to fail, because DROP and CREATE aren't transactional and immediate
in most DBMS.
It includes a test that stress its mechanics if used with DBMS like
DB2 10.5 and Oracle 12c.
Additional checks and logs have been added to trace each steps.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16440542#comment-16440542
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user mtaylor commented on the issue:

https://github.com/apache/activemq-artemis/pull/1997
  
+1 Franz.

On Tue, 17 Apr 2018, 07:27 nlippke,  wrote:

> @franz1981  I totally agree. Broker should
> not run any DDL-Statements if tables are managed by a DBA.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> 
,
> or mute the thread
> 

> .
>



> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16440469#comment-16440469
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on the issue:

https://github.com/apache/activemq-artemis/pull/1997
  
@franz1981 I totally agree. Broker should not run any DDL-Statements if 
tables are managed by a DBA.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16440464#comment-16440464
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on the issue:

https://github.com/apache/activemq-artemis/pull/1997
  
@nlippke @mtaylor I have updated this PR to avoid issues with concurrent 
creations of tables/indexes for the JDBC Journal with Oracle (there is a test 
attached): when a table seems to exists both CREATE TABLE and CREATE INDEX 
statements are no longer used to initialize it.
That is useful to allow a shared store to concurrently start 2 journals on 
the same database and while rebooting the broker with an empty journal (table 
already existent, but empty ie no need to create index twice).
That means that a DBA should take care to create table and indexes (if 
any), but if it will just create tables, the broker won't create any index on 
them, wdyt?


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16430303#comment-16430303
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on the issue:

https://github.com/apache/activemq-artemis/pull/1997
  
 


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16430196#comment-16430196
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1997#discussion_r180007702
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -179,32 +179,61 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
   logger.tracef("Validating if table %s didn't exist before creating", 
tableName);
   try {
  connection.setAutoCommit(false);
+ final boolean tableExists;
  try (ResultSet rs = connection.getMetaData().getTables(null, 
null, tableName, null)) {
-if (rs != null && !rs.next()) {
+if ((rs == null) || (rs != null && !rs.next())) {
+   tableExists = false;
if (logger.isTraceEnabled()) {
   logger.tracef("Table %s did not exist, creating it with 
SQL=%s", tableName, Arrays.toString(sqls));
}
-   final SQLWarning sqlWarning = rs.getWarnings();
-   if (sqlWarning != null) {
-  logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
+   if (rs != null) {
+  final SQLWarning sqlWarning = rs.getWarnings();
+  if (sqlWarning != null) {
+ logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
+  }
}
 } else {
-   try (Statement statement = connection.createStatement();
- ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
-  if (rs.next() && rs.getInt(1) > 0) {
- logger.tracef("Table %s did exist but is not empty. 
Skipping initialization.", tableName);
-  } else {
- sqls = Arrays.copyOfRange(sqls, 1, sqls.length);
+   tableExists = true;
+}
+ }
+ if (tableExists) {
+logger.tracef("Validating if the existing table %s is 
initialized or not", tableName);
+try (Statement statement = connection.createStatement();
+ ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
+   logger.tracef("Validation of the existing table %s 
initialization is started", tableName);
+   int rows;
+   if (cntRs.next() && (rows = cntRs.getInt(1)) > 0) {
+  logger.tracef("Table %s did exist but is not empty. 
Skipping initialization. Found %d rows.", tableName, rows);
+  if (logger.isDebugEnabled()) {
+ final long expectedRows = 
Stream.of(sqls).map(String::toUpperCase).filter(sql -> sql.contains("INSERT 
INTO")).count();
+ if (rows < expectedRows) {
+logger.debug("Table " + tableName + " was expected 
to contain " + expectedRows + " rows while it has " + rows + " rows.");
+ }
   }
+  connection.commit();
+  return;
+   } else {
+  assert sqls[0].toUpperCase().contains("CREATE TABLE") : 
"The first SQL statement must be a CREATE TABLE";
+  sqls = Arrays.copyOfRange(sqls, 1, sqls.length);
+  logger.tracef("Table %s did exist but is empty. Starting 
initialization.", tableName);
+   }
+} catch (SQLException e) {
+   logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder("Can't verify the initialization of table 
").append(tableName).append(" due to:"), e, 
sqlProvider.getCountJournalRecordsSQL()));
+   try {
+  connection.rollback();
+   } catch (SQLException rollbackEx) {
+  logger.debug("Rollback failed while validating 
initialization of a table", rollbackEx);
}
+   connection.setAutoCommit(false);
--- End diff --

it is driver dependents what to do after a rollback :(


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels 

[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16430194#comment-16430194
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1997#discussion_r180007558
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -179,32 +179,61 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
   logger.tracef("Validating if table %s didn't exist before creating", 
tableName);
   try {
  connection.setAutoCommit(false);
+ final boolean tableExists;
  try (ResultSet rs = connection.getMetaData().getTables(null, 
null, tableName, null)) {
-if (rs != null && !rs.next()) {
+if ((rs == null) || (rs != null && !rs.next())) {
--- End diff --

Nice feature on some DB2 drivers :)


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16430183#comment-16430183
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1997#discussion_r180006216
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -179,32 +179,61 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
   logger.tracef("Validating if table %s didn't exist before creating", 
tableName);
   try {
  connection.setAutoCommit(false);
+ final boolean tableExists;
  try (ResultSet rs = connection.getMetaData().getTables(null, 
null, tableName, null)) {
-if (rs != null && !rs.next()) {
+if ((rs == null) || (rs != null && !rs.next())) {
+   tableExists = false;
if (logger.isTraceEnabled()) {
   logger.tracef("Table %s did not exist, creating it with 
SQL=%s", tableName, Arrays.toString(sqls));
}
-   final SQLWarning sqlWarning = rs.getWarnings();
-   if (sqlWarning != null) {
-  logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
+   if (rs != null) {
+  final SQLWarning sqlWarning = rs.getWarnings();
+  if (sqlWarning != null) {
+ logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
+  }
}
 } else {
-   try (Statement statement = connection.createStatement();
- ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
-  if (rs.next() && rs.getInt(1) > 0) {
- logger.tracef("Table %s did exist but is not empty. 
Skipping initialization.", tableName);
-  } else {
- sqls = Arrays.copyOfRange(sqls, 1, sqls.length);
+   tableExists = true;
+}
+ }
+ if (tableExists) {
+logger.tracef("Validating if the existing table %s is 
initialized or not", tableName);
+try (Statement statement = connection.createStatement();
+ ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
+   logger.tracef("Validation of the existing table %s 
initialization is started", tableName);
+   int rows;
+   if (cntRs.next() && (rows = cntRs.getInt(1)) > 0) {
+  logger.tracef("Table %s did exist but is not empty. 
Skipping initialization. Found %d rows.", tableName, rows);
+  if (logger.isDebugEnabled()) {
+ final long expectedRows = 
Stream.of(sqls).map(String::toUpperCase).filter(sql -> sql.contains("INSERT 
INTO")).count();
+ if (rows < expectedRows) {
+logger.debug("Table " + tableName + " was expected 
to contain " + expectedRows + " rows while it has " + rows + " rows.");
+ }
   }
+  connection.commit();
+  return;
+   } else {
+  assert sqls[0].toUpperCase().contains("CREATE TABLE") : 
"The first SQL statement must be a CREATE TABLE";
+  sqls = Arrays.copyOfRange(sqls, 1, sqls.length);
+  logger.tracef("Table %s did exist but is empty. Starting 
initialization.", tableName);
+   }
+} catch (SQLException e) {
+   logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder("Can't verify the initialization of table 
").append(tableName).append(" due to:"), e, 
sqlProvider.getCountJournalRecordsSQL()));
+   try {
+  connection.rollback();
+   } catch (SQLException rollbackEx) {
+  logger.debug("Rollback failed while validating 
initialization of a table", rollbackEx);
}
+   connection.setAutoCommit(false);
--- End diff --

Isn't `connetion` already configured as such?


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
> 

[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16430179#comment-16430179
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1997#discussion_r180005903
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -179,32 +179,61 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
   logger.tracef("Validating if table %s didn't exist before creating", 
tableName);
   try {
  connection.setAutoCommit(false);
+ final boolean tableExists;
  try (ResultSet rs = connection.getMetaData().getTables(null, 
null, tableName, null)) {
-if (rs != null && !rs.next()) {
+if ((rs == null) || (rs != null && !rs.next())) {
--- End diff --

`connection.getMetaData().getTables()` can return _null_?


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16428390#comment-16428390
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on the issue:

https://github.com/apache/activemq-artemis/pull/1997
  
@clebertsuconic @nlippke I know that the failing COUNT sounds weird, but it 
is quite simple to be reproduced with DB2 through the test attached :+1: 


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16428388#comment-16428388
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

GitHub user franz1981 opened a pull request:

https://github.com/apache/activemq-artemis/pull/1997

ARTEMIS-1653 Allow database tables to be created externally

The previous commit about this feature wasn't using the row count query
ResultSet.
The mechanics has been changed to allow the row count query
to fail, because DROP and CREATE aren't transactional and immediate
in most DBMS.
It includes a test that stress its mechanics if used with DBMS like
DB2 10.5 and Oracle 12c.
Additional checks and logs have been added to trace each steps.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/franz1981/activemq-artemis ARTEMIS-1653

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/activemq-artemis/pull/1997.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1997


commit 1e2b5270854ba19a87a3ba0fa308751ce9cc5122
Author: Francesco Nigro 
Date:   2018-04-03T08:11:04Z

ARTEMIS-1653 Allow database tables to be created externally

The previous commit about this feature wasn't using the row count query
ResultSet.
The mechanics has been changed to allow the row count query
to fail, because DROP and CREATE aren't transactional and immediate
in most DBMS.
It includes a test that stress its mechanics if used with DBMS like
DB2 10.5 and Oracle 12c.
Additional checks and logs have been added to trace each steps.




> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
> Fix For: 2.5.1
>
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16426839#comment-16426839
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 closed the pull request at:

https://github.com/apache/activemq-artemis/pull/1986


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16426811#comment-16426811
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1986#discussion_r179441774
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -191,9 +191,18 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
 } else {
try (Statement statement = connection.createStatement();
  ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
-  if (rs.next() && rs.getInt(1) > 0) {
+  int rows;
+  if (cntRs.next() && (rows = cntRs.getInt(1)) > 0) {
  logger.tracef("Table %s did exist but is not empty. 
Skipping initialization.", tableName);
+ if (logger.isDebugEnabled()) {
+final long expectedRows = 
Stream.of(sqls).map(String::toUpperCase).filter(sql -> sql.contains("INSERT 
INTO")).count();
--- End diff --

@clebertsuconic PLease do not merge it yet...because on DB2 it is creating 
some problems


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16425444#comment-16425444
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1986#discussion_r179124397
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -191,9 +191,18 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
 } else {
try (Statement statement = connection.createStatement();
  ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
-  if (rs.next() && rs.getInt(1) > 0) {
+  int rows;
+  if (cntRs.next() && (rows = cntRs.getInt(1)) > 0) {
  logger.tracef("Table %s did exist but is not empty. 
Skipping initialization.", tableName);
+ if (logger.isDebugEnabled()) {
+final long expectedRows = 
Stream.of(sqls).map(String::toUpperCase).filter(sql -> sql.contains("INSERT 
INTO")).count();
--- End diff --

Nope, I meant that the check should be performed only with debug log level 
to help spotting weird behavious.
It is not the most robust check ever, but it is pretty helpfull for HA (for 
example).


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16423943#comment-16423943
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1986#discussion_r178806417
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -191,9 +191,18 @@ private void createTableIfNotExists(String tableName, 
String... sqls) throws SQL
 } else {
try (Statement statement = connection.createStatement();
  ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
-  if (rs.next() && rs.getInt(1) > 0) {
+  int rows;
+  if (cntRs.next() && (rows = cntRs.getInt(1)) > 0) {
  logger.tracef("Table %s did exist but is not empty. 
Skipping initialization.", tableName);
+ if (logger.isDebugEnabled()) {
+final long expectedRows = 
Stream.of(sqls).map(String::toUpperCase).filter(sql -> sql.contains("INSERT 
INTO")).count();
--- End diff --

Are you sure you meant this INSERT to only happen if debug?


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16423914#comment-16423914
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on the issue:

https://github.com/apache/activemq-artemis/pull/1986
  
@franz1981 :+1:


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16423898#comment-16423898
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on the issue:

https://github.com/apache/activemq-artemis/pull/1986
  
@nlippke 

> Statement-checks are all uppercase. Implementors using this method need 
to be aware of it

Thanks for the note :+1: I have added a `String::toUpperCase` while 
performing the checks as well.
Are not perfect/safe enough to be used as proper checks (throwing 
anything), but at least could help to spot regressions on tests due to some 
changes/configurations.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16423641#comment-16423641
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on the issue:

https://github.com/apache/activemq-artemis/pull/1986
  
@clebertsuconic I haven't reverted tha change made by 
https://github.com/apache/activemq-artemis/commit/ef74221684e8bf7f5ad0992f2c4ef81aa2ff986e
 but isn't necessary anymore, because with this fix it works without the change 
too.
@nlippke how it seems now? I have added a couple of checks to simplify 
spotting weird initialisation errors on tests too.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16423630#comment-16423630
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

GitHub user franz1981 opened a pull request:

https://github.com/apache/activemq-artemis/pull/1986

ARTEMIS-1653 Allow database tables to be created externally

The previous commit about this feature wasn't using the right ResultSet
to count the rows in a table.
Additional checks have been added to:
- verify that the first SQL statement is a CREATE TABLE
- log if the existing rows are less than the expected ones

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/franz1981/activemq-artemis ARTEMIS-1653

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/activemq-artemis/pull/1986.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1986


commit 66c442dd6a4eae02f7ac0d84eb0bffd6df9a01b3
Author: Francesco Nigro 
Date:   2018-04-03T08:11:04Z

ARTEMIS-1653 Allow database tables to be created externally

The previous commit about this feature wasn't using the right ResultSet
to count the rows in a table.
Additional checks have been added to:
- verify that the first SQL statement is a CREATE TABLE
- log if the existing rows are less than the expected ones




> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Assignee: Francesco Nigro
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-04-01 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16421681#comment-16421681
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r178460259
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -189,17 +187,27 @@ private static void createTableIfNotExists(Connection 
connection,
if (sqlWarning != null) {
   logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
}
-   try (Statement statement = connection.createStatement()) {
-  for (String sql : sqls) {
- statement.executeUpdate(sql);
- final SQLWarning statementSqlWarning = 
statement.getWarnings();
- if (statementSqlWarning != null) {
-
logger.warn(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), 
statementSqlWarning, sql));
- }
+} else {
+   try (Statement statement = connection.createStatement();
+ ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
+  if (rs.next() && rs.getInt(1) > 0) {
--- End diff --

@franz1981, @clebertsuconic: Indeed, the branch was broken. I've fixed it 
with the following patch:
~~~
--- 
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
@@ -190,8 +190,9 @@ public abstract class AbstractJDBCDriver {
 } else {
try (Statement statement = connection.createStatement();
  ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
-  if (rs.next() && rs.getInt(1) > 0) {
+  if (cntRs.next() && cntRs.getInt(1) > 0) {
  logger.tracef("Table %s did exist but is not empty. 
Skipping initialization.", tableName);
+ return;
   } else {
  sqls = Arrays.copyOfRange(sqls, 1, sqls.length);
   }
~~~
With this patch the tests run fine and I do not get those PK violations 
anymore. Please have look.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16419223#comment-16419223
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r178098492
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -189,17 +187,27 @@ private static void createTableIfNotExists(Connection 
connection,
if (sqlWarning != null) {
   logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
}
-   try (Statement statement = connection.createStatement()) {
-  for (String sql : sqls) {
- statement.executeUpdate(sql);
- final SQLWarning statementSqlWarning = 
statement.getWarnings();
- if (statementSqlWarning != null) {
-
logger.warn(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), 
statementSqlWarning, sql));
- }
+} else {
+   try (Statement statement = connection.createStatement();
+ ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
+  if (rs.next() && rs.getInt(1) > 0) {
--- End diff --

@nlippke @clebertsuconic has fixed the failed test by changing it but there 
are now new ERROR logs on each test, like:
```
[main] 17:39:46,342 ERROR 
[org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver] 
SQL STATEMENTS: 
INSERT INTO NODE_MANAGER_STORE (ID) VALUES (3)
INSERT INTO NODE_MANAGER_STORE (ID) VALUES (0)
INSERT INTO NODE_MANAGER_STORE (ID) VALUES (1)
INSERT INTO NODE_MANAGER_STORE (ID) VALUES (2)
SQL EXCEPTIONS: 
SQLState: 23505 ErrorCode: 2 Message: The statement was aborted because 
it would have caused a duplicate key value in a unique or primary key 
constraint or unique index identified by 'SQL180329173946240' defined on 
'NODE_MANAGER_STORE'.
```
I will be able to return on it from 3 April, but feel free to give it a 
look, because it seems related to this PR.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16418600#comment-16418600
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r177985094
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -189,17 +187,27 @@ private static void createTableIfNotExists(Connection 
connection,
if (sqlWarning != null) {
   logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
}
-   try (Statement statement = connection.createStatement()) {
-  for (String sql : sqls) {
- statement.executeUpdate(sql);
- final SQLWarning statementSqlWarning = 
statement.getWarnings();
- if (statementSqlWarning != null) {
-
logger.warn(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), 
statementSqlWarning, sql));
- }
+} else {
+   try (Statement statement = connection.createStatement();
+ ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
+  if (rs.next() && rs.getInt(1) > 0) {
--- End diff --

@nlippke @clebertsuconic This PR is causing a failure on CI for 
`NettyFailoverTest::testFailBack`, please check it to see what is happening 
:+1: 


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-27 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16415726#comment-16415726
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user asfgit closed the pull request at:

https://github.com/apache/activemq-artemis/pull/1822


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-27 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16415715#comment-16415715
 ] 

ASF subversion and git services commented on ARTEMIS-1653:
--

Commit b95afbf9363ad57a5c4a0a744220514d2d753908 in activemq-artemis's branch 
refs/heads/master from [~nlippke]
[ https://git-wip-us.apache.org/repos/asf?p=activemq-artemis.git;h=b95afbf ]

ARTEMIS-1653 Allow database tables to be created externally

In some environments it is not allowed to create a schema
by the application itself. With this change the AbstractJDBCDriver
now tests if an existing table is empty and executes further
statements in the same way as if the table does not exist.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-27 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16415700#comment-16415700
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r177442175
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -189,17 +187,27 @@ private static void createTableIfNotExists(Connection 
connection,
if (sqlWarning != null) {
   logger.warn(JDBCUtils.appendSQLExceptionDetails(new 
StringBuilder(), sqlWarning));
}
-   try (Statement statement = connection.createStatement()) {
-  for (String sql : sqls) {
- statement.executeUpdate(sql);
- final SQLWarning statementSqlWarning = 
statement.getWarnings();
- if (statementSqlWarning != null) {
-
logger.warn(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), 
statementSqlWarning, sql));
- }
+} else {
+   try (Statement statement = connection.createStatement();
+ ResultSet cntRs = 
statement.executeQuery(sqlProvider.getCountJournalRecordsSQL())) {
+  if (rs.next() && rs.getInt(1) > 0) {
--- End diff --

I will merge it this.. but I'm a bit concerned with the select count taking 
forever in big tables.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-07 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16389420#comment-16389420
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r172812406
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -109,7 +109,7 @@ public void stop() throws SQLException {
protected abstract void createSchema() throws SQLException;
 
protected final void createTable(String... schemaSqls) throws 
SQLException {
-  createTableIfNotExists(connection, sqlProvider.getTableName(), 
schemaSqls);
+  createTableIfNotExists(sqlProvider.getTableName(), schemaSqls);
--- End diff --

`createTableIfNotExists` was `private static` before. I needed to change it 
to non-static in order for `TestJDBCDriver` to be able to access the underlying 
connection to create the empty table for the test.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16388741#comment-16388741
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r172699944
  
--- Diff: 
artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
 ---
@@ -109,7 +109,7 @@ public void stop() throws SQLException {
protected abstract void createSchema() throws SQLException;
 
protected final void createTable(String... schemaSqls) throws 
SQLException {
-  createTableIfNotExists(connection, sqlProvider.getTableName(), 
schemaSqls);
+  createTableIfNotExists(sqlProvider.getTableName(), schemaSqls);
--- End diff --

easier to ask than reading the code :)


Why removing this parameter here?


(sorry if I'm lazy.. I have a bunch of other PRs to check.. so it was 
easier to ask).


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-03-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16388740#comment-16388740
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user clebertsuconic commented on the issue:

https://github.com/apache/activemq-artemis/pull/1822
  
@franz1981 ok to merge this?


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-02-16 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16366765#comment-16366765
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r168707901
  
--- Diff: 
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/jdbc/JdbcLeaseLockTest.java
 ---
@@ -33,13 +35,31 @@
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
 
+@RunWith(Parameterized.class)
 public class JdbcLeaseLockTest extends ActiveMQTestBase {
 
private JdbcSharedStateManager jdbcSharedStateManager;
private DatabaseStorageConfiguration dbConf;
private SQLProvider sqlProvider;
 
+   @Parameterized.Parameters(name = "create_tables_prior_test")
+   public static List data() {
+  return Arrays.asList(new Object[][] {
+ {true, null},
+ {false, null}
+  });
+   }
+
+   @Parameter(0)
+   public boolean withExistingTable;
+   @Parameter(1)
+   public Object result;
--- End diff --

Your version of Junit requires to work with tuples (input, expecte result). 
Newer versions allow input only. If you don't have this annotation JUnit will 
complain.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-02-16 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16366759#comment-16366759
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/1822#discussion_r168704701
  
--- Diff: 
artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/jdbc/JdbcLeaseLockTest.java
 ---
@@ -33,13 +35,31 @@
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
 
+@RunWith(Parameterized.class)
 public class JdbcLeaseLockTest extends ActiveMQTestBase {
 
private JdbcSharedStateManager jdbcSharedStateManager;
private DatabaseStorageConfiguration dbConf;
private SQLProvider sqlProvider;
 
+   @Parameterized.Parameters(name = "create_tables_prior_test")
+   public static List data() {
+  return Arrays.asList(new Object[][] {
+ {true, null},
+ {false, null}
+  });
+   }
+
+   @Parameter(0)
+   public boolean withExistingTable;
+   @Parameter(1)
+   public Object result;
--- End diff --

'result` isn't used, it is needed?


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARTEMIS-1653) Allow database tables to be created externally

2018-02-15 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARTEMIS-1653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16365398#comment-16365398
 ] 

ASF GitHub Bot commented on ARTEMIS-1653:
-

Github user nlippke commented on the issue:

https://github.com/apache/activemq-artemis/pull/1822
  
@franz1981 Done.


> Allow database tables to be created externally
> --
>
> Key: ARTEMIS-1653
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1653
> Project: ActiveMQ Artemis
>  Issue Type: Improvement
>  Components: Broker
>Affects Versions: 2.4.0
>Reporter: Niels Lippke
>Priority: Major
>
> In some environments (e.g. production) it is not allowed that applications 
> create their own schema. It's common practice to pass DDL-Statetements to 
> DBAs instead prior to rollout.
> Currently the broker does not support this scenario. If the required tables 
> already exist the broker fails to start.
> A better approach is that if the broker detects empy tables and initializes 
> them in the very same way it does if the tables dont't exist.
> See also discussion in 
> [forum|http://activemq.2283324.n4.nabble.com/ARTEMIS-Server-doesn-t-start-if-JDBC-store-is-used-and-table-NODE-MANAGER-STORE-is-empty-td4735779.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)