Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions donkey/donkeydbconf/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
VALUES (?, ?, ?, ?, ?, ?)
</query>

<query id="batchInsertMessageContent">
INSERT INTO D_MC${localChannelId} (METADATA_ID, MESSAGE_ID, CONTENT_TYPE, CONTENT, DATA_TYPE, IS_ENCRYPTED)
VALUES (?, ?, ?, ?, ?, ?)
</query>

<query id="storeMessageContent">
UPDATE D_MC${localChannelId} SET CONTENT = ?, DATA_TYPE = ?, IS_ENCRYPTED = ?
WHERE METADATA_ID = ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
import java.util.Properties;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.google.inject.Inject;
import com.mirth.connect.donkey.model.DatabaseConstants;
import com.mirth.connect.donkey.server.data.jdbc.ConnectionPool;
import com.mirth.connect.donkey.server.data.jdbc.DBCPConnectionPool;
import com.mirth.connect.donkey.server.data.jdbc.HikariConnectionPool;

public class DonkeyConnectionPools {

private static final Logger logger = LogManager.getLogger(DonkeyConnectionPools.class);

@Inject
private static volatile DonkeyConnectionPools instance = null;

Expand Down Expand Up @@ -59,7 +62,8 @@ public void init(Properties dbProperties) {
String url = dbProperties.getProperty(DatabaseConstants.DATABASE_URL);
String username = dbProperties.getProperty(DatabaseConstants.DATABASE_USERNAME);
String password = dbProperties.getProperty(DatabaseConstants.DATABASE_PASSWORD);
String pool = dbProperties.getProperty(DatabaseConstants.DATABASE_POOL);
warnIfPoolConfigured(dbProperties);

boolean jdbc4 = Boolean.parseBoolean(dbProperties.getProperty(DatabaseConstants.DATABASE_JDBC4));
String testQuery = dbProperties.getProperty(DatabaseConstants.DATABASE_TEST_QUERY);
int maxConnections;
Expand All @@ -70,7 +74,7 @@ public void init(Properties dbProperties) {
throw new Exception("Failed to read the " + DatabaseConstants.DATABASE_MAX_CONNECTIONS + " configuration property");
}

connectionPool = createConnectionPool(database, driver, url, username, password, pool, jdbc4, testQuery, maxConnections, false);
connectionPool = createConnectionPool(database, driver, url, username, password, jdbc4, testQuery, maxConnections, false);

boolean splitReadWrite = Boolean.parseBoolean(dbProperties.getProperty(DatabaseConstants.DATABASE_ENABLE_READ_WRITE_SPLIT));

Expand All @@ -80,7 +84,6 @@ public void init(Properties dbProperties) {
String readOnlyUrl = dbProperties.getProperty(DatabaseConstants.DATABASE_READONLY_URL, url);
String readOnlyUsername = dbProperties.getProperty(DatabaseConstants.DATABASE_READONLY_USERNAME, username);
String readOnlyPassword = dbProperties.getProperty(DatabaseConstants.DATABASE_READONLY_PASSWORD, password);
String readOnlyPool = dbProperties.getProperty(DatabaseConstants.DATABASE_READONLY_POOL, pool);
boolean readOnlyJdbc4 = Boolean.parseBoolean(dbProperties.getProperty(DatabaseConstants.DATABASE_READONLY_JDBC4, dbProperties.getProperty(DatabaseConstants.DATABASE_JDBC4)));
String readOnlyTestQuery = dbProperties.getProperty(DatabaseConstants.DATABASE_READONLY_TEST_QUERY, testQuery);
int readOnlyMaxConnections;
Expand All @@ -91,7 +94,7 @@ public void init(Properties dbProperties) {
throw new Exception("Failed to read the " + DatabaseConstants.DATABASE_READONLY_MAX_CONNECTIONS + " configuration property");
}

readOnlyConnectionPool = createConnectionPool(readOnlyDatabase, readOnlyDriver, readOnlyUrl, readOnlyUsername, readOnlyPassword, readOnlyPool, readOnlyJdbc4, readOnlyTestQuery, readOnlyMaxConnections, true);
readOnlyConnectionPool = createConnectionPool(readOnlyDatabase, readOnlyDriver, readOnlyUrl, readOnlyUsername, readOnlyPassword, readOnlyJdbc4, readOnlyTestQuery, readOnlyMaxConnections, true);
} else {
readOnlyConnectionPool = connectionPool;
}
Expand All @@ -100,15 +103,21 @@ public void init(Properties dbProperties) {
}
}

public ConnectionPool createConnectionPool(String database, String driver, String url, String username, String password, String pool, boolean jdbc4, String testQuery, int maxConnections, boolean readOnly) throws Exception {
public ConnectionPool createConnectionPool(String database, String driver, String url, String username, String password, boolean jdbc4, String testQuery, int maxConnections, boolean readOnly) throws Exception {
if (driver != null) {
Class.forName(driver);
}

if (StringUtils.equalsIgnoreCase(pool, "DBCP")) {
return new DBCPConnectionPool(url, username, password, maxConnections, readOnly);
} else {
return new HikariConnectionPool(driver, url, username, password, maxConnections, jdbc4, testQuery, readOnly);
return new HikariConnectionPool(driver, url, username, password, maxConnections, jdbc4, testQuery, readOnly);
}

private void warnIfPoolConfigured(Properties dbProperties) {
for (String property : new String[] { DatabaseConstants.DATABASE_POOL,
DatabaseConstants.DATABASE_READONLY_POOL }) {
// Only DBCP was defined. Anything but DBCP was taken to be Hikari.
if (StringUtils.equalsIgnoreCase(dbProperties.getProperty(property), "DBCP")) {
logger.warn("The {} setting is no longer supported and will be ignored; HikariCP is always used.", property);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1728,26 +1728,23 @@ protected Message process(ConnectorMessage sourceMessage, boolean markAsProcesse
}

// store the raw, transformed and encoded content
boolean insertedContent = false;
List<MessageContent> contentToInsert = new ArrayList<MessageContent>();
ThreadUtils.checkInterruptedStatus();

if (storageSettings.isStoreProcessedRaw() && sourceMessage.getProcessedRaw() != null) {
dao.batchInsertMessageContent(sourceMessage.getProcessedRaw());
insertedContent = true;
contentToInsert.add(sourceMessage.getProcessedRaw());
}

if (storageSettings.isStoreTransformed() && sourceMessage.getTransformed() != null) {
dao.batchInsertMessageContent(sourceMessage.getTransformed());
insertedContent = true;
contentToInsert.add(sourceMessage.getTransformed());
}

if (storageSettings.isStoreSourceEncoded() && sourceMessage.getEncoded() != null) {
dao.batchInsertMessageContent(sourceMessage.getEncoded());
insertedContent = true;
contentToInsert.add(sourceMessage.getEncoded());
}

if (insertedContent) {
dao.executeBatchInsertMessageContent(channelId);
if (!contentToInsert.isEmpty()) {
dao.insertMessageContentBatch(contentToInsert);
}

// create a message for each destination chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public interface DonkeyDao {

public void insertMessageContent(MessageContent messageContent);

public void batchInsertMessageContent(MessageContent messageContent);

public void executeBatchInsertMessageContent(String channelId);
public void insertMessageContentBatch(List<MessageContent> messageContents);

public void insertMessageAttachment(String channelId, long messageId, Attachment attachment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private DonkeyDao getDelegateDao() {
return dao;
}

@SuppressWarnings("unchecked")
private void executeTasks(Boolean durable) {
DonkeyDao dao = getDelegateDao();
boolean commitSuccess = false;
Expand All @@ -117,8 +118,7 @@ private void executeTasks(Boolean durable) {
case INSERT_MESSAGE: dao.insertMessage((Message) p[0]); break;
case INSERT_CONNECTOR_MESSAGE: dao.insertConnectorMessage((ConnectorMessage) p[0], (Boolean) p[1], (Boolean) p[2]); break;
case INSERT_MESSAGE_CONTENT: dao.insertMessageContent((MessageContent) p[0]); break;
case BATCH_INSERT_MESSAGE_CONTENT: dao.batchInsertMessageContent((MessageContent) p[0]); break;
case EXECUTE_BATCH_INSERT_MESSAGE_CONTENT: dao.executeBatchInsertMessageContent((String) p[0]); break;
case INSERT_MESSAGE_CONTENT_BATCH: dao.insertMessageContentBatch((List<MessageContent>) p[0]); break;
case INSERT_MESSAGE_ATTACHMENT: dao.insertMessageAttachment((String) p[0], (Long) p[1], (Attachment) p[2]); break;
case UPDATE_MESSAGE_ATTACHMENT: dao.updateMessageAttachment((String) p[0], (Long) p[1], (Attachment) p[2]); break;
case INSERT_META_DATA: dao.insertMetaData((ConnectorMessage) p[0], (List<MetaDataColumn>) p[1]); break;
Expand Down Expand Up @@ -203,15 +203,9 @@ public void insertMessageContent(MessageContent messageContent) {
}

@Override
public void batchInsertMessageContent(MessageContent messageContent) {
tasks.add(new DaoTask(DaoTaskType.BATCH_INSERT_MESSAGE_CONTENT, new Object[] {
messageContent }));
}

@Override
public void executeBatchInsertMessageContent(String channelId) {
tasks.add(new DaoTask(DaoTaskType.EXECUTE_BATCH_INSERT_MESSAGE_CONTENT, new Object[] {
channelId }));
public void insertMessageContentBatch(List<MessageContent> messageContents) {
tasks.add(new DaoTask(DaoTaskType.INSERT_MESSAGE_CONTENT_BATCH, new Object[] {
messageContents }));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
package com.mirth.connect.donkey.server.data.buffered;

public enum DaoTaskType {
INSERT_MESSAGE, INSERT_CONNECTOR_MESSAGE, INSERT_MESSAGE_CONTENT, BATCH_INSERT_MESSAGE_CONTENT, EXECUTE_BATCH_INSERT_MESSAGE_CONTENT, INSERT_MESSAGE_ATTACHMENT, UPDATE_MESSAGE_ATTACHMENT, INSERT_META_DATA, STORE_META_DATA, INSERT_EVENT, STORE_MESSAGE_CONTENT, STORE_CHANNEL_STATISTICS, UPDATE_SEND_ATTEMPTS, UPDATE_STATUS, UPDATE_ERRORS, UPDATE_MAPS, UPDATE_SOURCE_MAP, UPDATE_RESPONSE_MAP, MARK_AS_PROCESSED, RESET_MESSAGE, DELETE_MESSAGE, DELETE_CONNECTOR_MESSAGES, DELETE_MESSAGE_STATISTICS, DELETE_ALL_MESSAGES, DELETE_MESSAGE_CONTENT, DELETE_MESSAGE_CONTENT_BY_META_DATA_IDS, DELETE_MESSAGE_ATTACHMENTS, CREATE_CHANNEL, REMOVE_CHANNEL, CHECK_CHANNEL_TABLES, ADD_META_DATA_COLUMN, REMOVE_META_DATA_COLUMN, RESET_STATISTICS, RESET_ALL_STATISTICS, GET_PORTS_IN_USE;
INSERT_MESSAGE, INSERT_CONNECTOR_MESSAGE, INSERT_MESSAGE_CONTENT, INSERT_MESSAGE_CONTENT_BATCH, INSERT_MESSAGE_ATTACHMENT, UPDATE_MESSAGE_ATTACHMENT, INSERT_META_DATA, STORE_META_DATA, INSERT_EVENT, STORE_MESSAGE_CONTENT, STORE_CHANNEL_STATISTICS, UPDATE_SEND_ATTEMPTS, UPDATE_STATUS, UPDATE_ERRORS, UPDATE_MAPS, UPDATE_SOURCE_MAP, UPDATE_RESPONSE_MAP, MARK_AS_PROCESSED, RESET_MESSAGE, DELETE_MESSAGE, DELETE_CONNECTOR_MESSAGES, DELETE_MESSAGE_STATISTICS, DELETE_ALL_MESSAGES, DELETE_MESSAGE_CONTENT, DELETE_MESSAGE_CONTENT_BY_META_DATA_IDS, DELETE_MESSAGE_ATTACHMENTS, CREATE_CHANNEL, REMOVE_CHANNEL, CHECK_CHANNEL_TABLES, ADD_META_DATA_COLUMN, REMOVE_META_DATA_COLUMN, RESET_STATISTICS, RESET_ALL_STATISTICS, GET_PORTS_IN_USE;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@

package com.mirth.connect.donkey.server.data.jdbc;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

public interface ConnectionPool {
public PooledConnection getConnection() throws SQLException;

public Integer getMaxConnections();
public Connection getConnection() throws SQLException;

public DataSource getDataSource();
}

This file was deleted.

This file was deleted.

Loading
Loading