teiid SVN: r699 - in trunk/server/src: test/java/com/metamatrix/common and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-02 21:38:21 -0400 (Thu, 02 Apr 2009)
New Revision: 699
Removed:
trunk/server/src/main/java/com/metamatrix/common/jdbc/db/
trunk/server/src/main/java/com/metamatrix/common/jdbc/metadata/
trunk/server/src/main/java/com/metamatrix/common/jdbc/syntax/
trunk/server/src/test/java/com/metamatrix/common/jdbc/
Log:
TEIID-456 removing db platform code
15 years, 8 months
teiid SVN: r698 - in trunk/server/src/main/java/com/metamatrix: common/extensionmodule/spi/jdbc and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-02 21:38:17 -0400 (Thu, 02 Apr 2009)
New Revision: 698
Removed:
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java
trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java
Log:
TEIID-456 removing db platform code
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -815,7 +815,7 @@
/**
* Retrieves a checksum value for the contents of an extension module
*/
- private long getChecksum(byte[] data){
+ public static long getChecksum(byte[] data){
Checksum algorithm = new CRC32();
algorithm.update(data, 0, data.length);
return algorithm.getValue();
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -37,7 +37,6 @@
import com.metamatrix.common.extensionmodule.ExtensionModuleDescriptor;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.CommonPropertyNames;
import com.metamatrix.common.util.ErrorMessageKeys;
@@ -125,65 +124,9 @@
public static byte[] getSource(String sourceName, Connection jdbcConnection)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException, SQLException {
- //NOTE: DO NOT PUT LOGGING IN THIS METHOD
- // Because configuration initializes by getting the source
- // from the database prior to configuration properties being
- // available
-
- if (JDBCExtensionModuleUtil.isConfigurationModel(sourceName)) {
- return getConfigContent(sourceName, jdbcConnection);
- }
return getFileContent(sourceName, jdbcConnection);
}
-
-
- private static byte[] getConfigContent(String sourceName, Connection jdbcConnection)
- throws MetaMatrixComponentException, SQLException {
-
- String sql = null;
- PreparedStatement statement = null;
- ResultSet results = null;
- sql = JDBCExtensionModuleTranslator.SELECT_CONFIG_FILE_DATA_BY_NAME;
- JDBCPlatform platform = getPlatform(jdbcConnection);
-
- byte[] data = null;
-
- try{
-
-
- statement = jdbcConnection.prepareStatement(sql);
- statement.setString(1, sourceName);
-
- if ( ! statement.execute() ) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0046, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0046, sql));
- }
- results = statement.getResultSet();
- try {
- if (results.next()) {
- data = platform.convertClobToByteArray(results, JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS);
- } else {
- throw new ExtensionModuleNotFoundException(sourceName);
- }
- } catch( Throwable e) {
- throw new MetaMatrixComponentException(e.getMessage());
- }
-
- } catch (SQLException se){
- throw se;
- } catch ( MetaMatrixComponentException e ) {
- throw e;
- } catch (Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0047, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0047, sql));
- } finally {
- close(results);
- close(statement);
- }
-
- return data;
- }
-
-
/**
* Get file resource. Caches files in memory. Checks memory cache by checksum.
* If it's not in the cache or the checksum has changed, load from the DB.
@@ -203,16 +146,20 @@
CheckSumAndType csat = loadChecksumAndType(sourceName, jdbcConnection);
long checksum = csat.getChecksum();
String type = csat.getType();
- long cachedChecksum = fileCache.getChecksum(sourceName);
-
byte[] bytes = null;
- if (cachedChecksum == checksum) {
- bytes = fileCache.getBytes(sourceName);
- }
+ if (fileCache != null) {
+ long cachedChecksum = fileCache.getChecksum(sourceName);
+
+ if (cachedChecksum == checksum) {
+ bytes = fileCache.getBytes(sourceName);
+ }
+ }
if (bytes == null) {
bytes = loadBytes(sourceName, jdbcConnection);
- fileCache.put(sourceName, checksum, bytes, type);
+ if (fileCache != null) {
+ fileCache.put(sourceName, checksum, bytes, type);
+ }
}
return bytes;
@@ -304,9 +251,7 @@
byte[] data = null;
try{
- JDBCPlatform platform = JDBCPlatformFactory.getPlatform(jdbcConnection);
-
- data = platform.convertToByteArray(dataObj);
+ data = JDBCPlatform.convertToByteArray(dataObj);
} catch (Exception e) {
throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0049, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0049));
@@ -528,22 +473,6 @@
}
}
- /**
- * Get the Platform for JDBC that is representive of the type of
- * connection.
- *
- * @since 4.2
- */
- private static JDBCPlatform getPlatform(Connection jdbcConnection) throws MetaMatrixComponentException {
- try {
- return JDBCPlatformFactory.getPlatform(jdbcConnection);
-
- } catch(Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0067, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0067));
- }
- }
-
-
public static ExtensionModuleDescriptor buildExtensionDescriptor (ResultSet resultSet) throws MetaMatrixComponentException {
try{
ExtensionModuleDescriptor module = new ExtensionModuleDescriptor(
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -108,16 +108,6 @@
+ JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + PARAM
;
- public static final String SELECT_CONFIG_FILE_DATA_BY_NAME
- = SELECT
- + JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS
- + FROM
- + JDBCNames.ExtensionFilesTable.TABLE_NAME
- + WHERE
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + PARAM
- ;
-
-
public static final String SELECT_MAX_SEARCH_POSITION
= SELECT
+ MAX + OPEN_PAREN
@@ -231,23 +221,6 @@
+ VALUES
;
-
- public static final String ADD_CONFIG_FILE_DATA
- = INSERT + INTO + JDBCNames.ExtensionFilesTable.TABLE_NAME + OPEN_PAREN
- + JDBCNames.ExtensionFilesTable.ColumnName.UID + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.SEARCH_POSITION + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.IS_ENABLED + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_DESCRIPTION + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CREATED_BY + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CREATION_DATE + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED + "," //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_TYPE + CLOSED_PAREN
- //+ JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS + CLOSED_PAREN
- + VALUES
- ;
public static final String ADD_SOURCE_FILE_DATA_PARAMS
= "(?,?,?,?,?,?,?,?,?,?,?)"; //$NON-NLS-1$
public static final String ADD_SOURCE_FILE_DATA_ORACLE_PARAMS
@@ -264,42 +237,17 @@
+ WHERE
+ JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
- public static final String UPDATE_SOURCE_CONFIG_DATA_DEFAULT
+ public static final String UPDATE_SOURCE_FILE_DATA_ORACLE
= UPDATE
+ JDBCNames.ExtensionFilesTable.TABLE_NAME + " " //$NON-NLS-1$
+ SET
+ JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "= ?, " //$NON-NLS-1$
+ JDBCNames.ExtensionFilesTable.ColumnName.UPDATED + "= ?, " //$NON-NLS-1$
+ JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS + "= ? " //$NON-NLS-1$
- + WHERE
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
-
-
- public static final String UPDATE_SOURCE_CONFIG_DATA_ORACLE
- = UPDATE
- + JDBCNames.ExtensionFilesTable.TABLE_NAME + " " //$NON-NLS-1$
- + SET
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS + "= empty_clob() " //$NON-NLS-1$
- + WHERE
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
-
-
-
- public static final String UPDATE_SOURCE_FILE_DATA_ORACLE
- = UPDATE
- + JDBCNames.ExtensionFilesTable.TABLE_NAME + " " //$NON-NLS-1$
- + SET
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM + "= ?, " //$NON-NLS-1$
+ JDBCNames.ExtensionFilesTable.ColumnName.FILE_CONTENTS + "= empty_blob() " //$NON-NLS-1$
+ WHERE
+ JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
-
+
public static final String UPDATE_SOURCE_NAME
= UPDATE
+ JDBCNames.ExtensionFilesTable.TABLE_NAME + " " //$NON-NLS-1$
@@ -347,19 +295,5 @@
-//*******************************
-//
-// I N S E R T S Q L
-//
-//*******************************
-
-
-
- // ---------------------------------------------------------------------------------
- // TRANSLATE RESULT SETS
- // ---------------------------------------------------------------------------------
-
-
-
}
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -33,19 +33,15 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Properties;
-import java.util.Set;
-import java.util.zip.CRC32;
-import java.util.zip.Checksum;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
-import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.extensionmodule.ExtensionModuleDescriptor;
+import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.common.extensionmodule.exception.DuplicateExtensionModuleException;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.util.ByteArrayHelper;
@@ -56,14 +52,6 @@
private static final String PRINCIPAL = "JDBCExtensionUtil"; //$NON-NLS-1$
- private static Set configurationNames;
-
- static {
- configurationNames = new HashSet();
- configurationNames.add(Configuration.NEXT_STARTUP);
- }
-
-
private Properties properties;
/**
* Instantiates this class with any Properties that need to override
@@ -221,9 +209,9 @@
}
if (inuse) {
- JDBCExtensionModuleWriter.setSource(PRINCIPAL, extName, data, getChecksum(data), connection);
+ JDBCExtensionModuleWriter.setSource(PRINCIPAL, extName, data, ExtensionModuleManager.getChecksum(data), connection);
} else {
- JDBCExtensionModuleWriter.addSource(PRINCIPAL, extType, extName, data, getChecksum(data), extDesc, true, connection);
+ JDBCExtensionModuleWriter.addSource(PRINCIPAL, extType, extName, data, ExtensionModuleManager.getChecksum(data), extDesc, true, connection);
}
} catch (MetaMatrixComponentException mce) {
@@ -251,32 +239,6 @@
}
- public static boolean isConfigurationModel(String sourceName) {
- return configurationNames.contains(sourceName);
- }
-
- /**
- * Adds an element to the list of filenames considered to be configuration models
- * (and therefore stored as clobs).
- *
- * @since 4.2
- */
- static void addConfigurationModelName(String sourceName) {
- configurationNames.add(sourceName);
- }
-
- /**
- * Removes an element from the list of filenames considered to be configuration models
- * (and therefore stored as clobs).
- *
- * @since 4.2
- */
- static void removeConfigurationModelName(String sourceName) {
- configurationNames.remove(sourceName);
- }
-
-
-
public void importExtensionModule(String importFileName, String extName, String extType, String extDesc, String position)
throws ExtensionModuleNotFoundException, DuplicateExtensionModuleException, MetaMatrixComponentException{
importExtensionModule(importFileName, extName, extType, extDesc);
@@ -388,22 +350,4 @@
}
-
-
-
- /**
- * this checksum method is the same as the one in ExtensionMangaer
- *
- * @param data
- * @return
- */
- private long getChecksum(byte[] data){
- Checksum algorithm = new CRC32();
- algorithm.update(data, 0, data.length);
- return algorithm.getValue();
- }
-
-
-
-
}
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -22,7 +22,7 @@
package com.metamatrix.common.extensionmodule.spi.jdbc;
-import java.io.IOException;
+import java.io.ByteArrayInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -39,8 +39,6 @@
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleOrderingException;
import com.metamatrix.common.id.dbid.DBIDGenerator;
-import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
@@ -134,23 +132,16 @@
PreparedStatement statement = null;
- String sql = null;
+ String sql = JDBCExtensionModuleTranslator.ADD_SOURCE_FILE_DATA;
ExtensionModuleDescriptor descriptor = null;
description = StringUtil.truncString(description, MAX_DESC_LEN);
int position = getNextPosition(jdbcConnection);
- boolean isConfigModel = JDBCExtensionModuleUtil.isConfigurationModel(sourceName);
boolean orignalAutocommit=true;
boolean firstException = false;
try{
- if (isConfigModel) {
- sql = JDBCExtensionModuleTranslator.ADD_CONFIG_FILE_DATA;
- } else {
- sql = JDBCExtensionModuleTranslator.ADD_SOURCE_FILE_DATA;
- }
-
long longUID = DBIDGenerator.getInstance().getID(JDBCNames.ExtensionFilesTable.TABLE_NAME);
orignalAutocommit=jdbcConnection.getAutoCommit();
@@ -185,13 +176,8 @@
throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0054, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0054, sourceName,sql));
}
- if (isConfigModel) {
- updateConfig(updatedBy, sourceName, data, checksum, jdbcConnection, JDBCExtensionModuleTranslator.UPDATE_SOURCE_CONFIG_DATA_DEFAULT);
- } else {
- updateFile(updatedBy, sourceName, data, checksum, jdbcConnection, JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
- }
+ updateFile(updatedBy, sourceName, data, checksum, jdbcConnection, JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
-
jdbcConnection.commit();
} catch (SQLException se){
@@ -246,243 +232,36 @@
public static void setSource(String principalName, String sourceName, byte[] data, long checksum, Connection jdbcConnection)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
-
- if (JDBCExtensionModuleUtil.isConfigurationModel(sourceName)) {
- updateConfig(principalName, sourceName, data, checksum, jdbcConnection, JDBCExtensionModuleTranslator.UPDATE_SOURCE_CONFIG_DATA_DEFAULT);
- } else {
- updateFile(principalName, sourceName, data, checksum, jdbcConnection, JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
- }
-
+ updateFile(principalName, sourceName, data, checksum, jdbcConnection, JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
}
- private static void updateConfig(String principalName, String sourceName, byte[] data, long checksum, Connection jdbcConnection, String sql)
- throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
-
-
- LogManager.logTrace(CONTEXT, "setting extension module file " + sourceName + " containing # bytes: " + data.length); //$NON-NLS-1$ //$NON-NLS-2$
- JDBCPlatform platform = getPlatform(jdbcConnection);
-
- PreparedStatement statement = null;
- boolean original_autocommit = true;
- try{
- original_autocommit = jdbcConnection.getAutoCommit();
- // Oracle specific handling
- if(platform.usesStreamsForClobBinding()) {
-
- jdbcConnection.setAutoCommit(false);
-
-
- sql = JDBCExtensionModuleTranslator.UPDATE_SOURCE_CONFIG_DATA_ORACLE;
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
- statement.setString(4, sourceName);
-
-
- if (statement.executeUpdate() != 1){
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
- throw new ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059, sourceName));
- }
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- }
-
- statement.close();
-
- sql = JDBCExtensionModuleTranslator.SELECT_CONFIG_FILE_DATA_BY_NAME;
- sql = sql + " FOR UPDATE"; //$NON-NLS-1$
-
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, sourceName);
-
- if ( ! statement.execute() ) {
- //already checked if name wasn't in use above, shouldn't be a problem here
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0072, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0072, sourceName,sql));
- }
-
- ResultSet results = statement.getResultSet();
- try {
- if ( results.next() ) {
- // the inputstream is closed in the oracle implementation
- platform.setClob(results, data, JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS);
-
- jdbcConnection.commit();
- } else {
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0064, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0064,sourceName));
- }
- } catch (SQLException se){
- try {
- jdbcConnection.rollback();
- } catch (SQLException sr) {
- // do nothing
- }
- throw se;
- } finally {
- if( results != null) {
- try {
- results.close();
- } catch(SQLException e) {
- LogManager.logWarning(CONTEXT, e, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0073));
- }
- }
-
- try {
- jdbcConnection.setAutoCommit(original_autocommit);
- } catch (SQLException sr) {
- // do nothing
- }
-
- }
-
-
-
- } else {
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
-
- platform.setClob(statement, data, 4);
-
- statement.setString(5, sourceName);
- int r = statement.executeUpdate();
-
- if (r != 1){
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
- throw new ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059, sourceName));
- }
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- }
-
- }
- } catch (SQLException se){
-
- //check if name is in use
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
- throw new ExtensionModuleNotFoundException(sourceName);
- }
- throw new MetaMatrixComponentException(se, ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
-
- } catch (IOException e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- } finally {
- if ( statement != null ) {
- try {
- statement.close();
- statement = null;
- } catch ( SQLException e ) {
- LogManager.logWarning(CONTEXT, e, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0048));
- }
- }
-
- }
-
- }
-
private static void updateFile(String principalName, String sourceName, byte[] data, long checksum, Connection jdbcConnection, String sql)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
LogManager.logTrace(CONTEXT, "setting extension module file " + sourceName + " containing # bytes: " + data.length); //$NON-NLS-1$ //$NON-NLS-2$
- JDBCPlatform platform = getPlatform(jdbcConnection);
PreparedStatement statement = null;
ResultSet results = null;
- boolean original_autocommit = true;
try{
- original_autocommit = jdbcConnection.getAutoCommit();
- // Oracle specific handling
- if(platform.usesStreamsForClobBinding()) {
-
- jdbcConnection.setAutoCommit(false);
-
- statement = jdbcConnection.prepareStatement(sql);
+ sql = JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_DEFAULT;
+ statement = jdbcConnection.prepareStatement(sql);
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
- statement.setString(4, sourceName);
-
- if (statement.executeUpdate() != 1) {
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
- throw new ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059, sourceName));
- }
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0060, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0060, sourceName,sql));
- }
- LogManager.logTrace(CONTEXT, "SUCCESS-reset Blob: " + sql); //$NON-NLS-1$
+ statement.setString(1, principalName);
+ statement.setString(2, DateUtil.getCurrentDateAsString());
+ statement.setLong(3, checksum);
+
+ statement.setBinaryStream(4, new ByteArrayInputStream(data), data.length);
+
+ // DBstatement.setBytes(4, data);
+ statement.setString(5, sourceName);
- statement.close();
-
- sql = JDBCExtensionModuleTranslator.SELECT_SOURCE_FILE_DATA_BY_NAME;
- sql = sql + " FOR UPDATE"; //$NON-NLS-1$
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, sourceName);
-
- if ( ! statement.execute() ) {
- //already checked if name wasn't in use above, shouldn't be a problem here
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0062, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0062, sourceName,sql));
+ if (statement.executeUpdate() != 1){
+ if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
+ throw new ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059, sourceName));
}
-
- try {
-
- results = statement.getResultSet();
- if ( results.next() ) {
-
- platform.setBlob(results, data, JDBCNames.ExtensionFilesTable.ColumnName.FILE_CONTENTS);
- jdbcConnection.commit();
-
- } else {
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0064, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0064,sourceName));
- }
- } catch (SQLException se){
- try {
- jdbcConnection.rollback();
- } catch (SQLException sr) {
- // do nothing
- }
- throw se;
- } finally {
- if( results != null) {
- try {
- results.close();
- } catch(SQLException e) {
- LogManager.logWarning(CONTEXT, e, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0073));
- }
- }
-
- try {
- jdbcConnection.setAutoCommit(original_autocommit);
- } catch (SQLException sr) {
- // do nothing
- }
-
- }
-
-
- } else {
- sql = JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_DEFAULT;
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
-
- platform.setBlob(statement, data, 4);
-
- // DBstatement.setBytes(4, data);
- statement.setString(5, sourceName);
-
- if (statement.executeUpdate() != 1){
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
- throw new ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059, sourceName));
- }
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- }
- }
+ throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
+ }
} catch (SQLException se){
//check if name is in use
@@ -491,8 +270,6 @@
}
throw new MetaMatrixComponentException(se, ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- } catch (IOException e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0065, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
} finally {
if ( statement != null ) {
try {
@@ -716,19 +493,6 @@
}
-
-
-
- private static JDBCPlatform getPlatform(Connection jdbcConnection) throws MetaMatrixComponentException {
- try {
- return JDBCPlatformFactory.getPlatform(jdbcConnection);
-
- } catch(Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0067, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0067));
- }
- }
-
-
/**
* Deletes a module from the list of modules
* @param principalName name of principal requesting this addition
Modified: trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -36,7 +36,6 @@
import com.metamatrix.common.id.dbid.ReservedIDBlock;
import com.metamatrix.common.id.dbid.spi.DBIDSourceTransaction;
import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
@@ -47,8 +46,6 @@
public class DBIDResourceTransaction extends BaseTransaction implements DBIDSourceTransaction {
private Connection jdbcConnection;
- private JDBCPlatform platform=null;
-
// private static long columnMax=-1;
private static long columnMax=999999999;
@@ -74,8 +71,6 @@
JDBCMgdResourceConnection jdbcManagedConnection = (JDBCMgdResourceConnection) connection;
jdbcConnection = jdbcManagedConnection.getConnection();
- platform = JDBCPlatformFactory.getPlatform(jdbcConnection);
-
} catch ( Exception e ) {
throw new ManagedConnectionException(e,ErrorMessageKeys.ID_ERR_0016, CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0016));
}
@@ -261,7 +256,7 @@
if (columnMax > -1) return;
- int s = platform.getDatabaseColumnSize(JDBCNames.IDTable.TABLE_NAME,
+ int s = JDBCPlatform.getDatabaseColumnSize(JDBCNames.IDTable.TABLE_NAME,
JDBCNames.IDTable.ColumnName.NEXT_ID,
jdbcConnection);
// Map columns = platform.getDatabaseColumns(JDBCNames.IDTable.TABLE_NAME, jdbcConnection);
Modified: trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -22,1072 +22,220 @@
package com.metamatrix.common.jdbc;
-import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.sql.Blob;
-import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.jdbc.metadata.Column;
-import com.metamatrix.common.jdbc.metadata.Table;
-import com.metamatrix.common.jdbc.metadata.UniqueKey;
-import com.metamatrix.common.jdbc.syntax.ExpressionOperator;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.core.util.ReflectionHelper;
-/**
-* The JDBCPlatform represents a single datasource connection. The
-* default platform is that of MetaMatrix. Use the JDBCPlatformFactory
-* to create a JDBCPlatform that is representive of the type of
-* connection.
-*/
+public class JDBCPlatform {
-public class JDBCPlatform implements Serializable, Cloneable {
-
- // temporarily stored so that other methods can be initialized
- private DatabaseMetaData metadata;
-
- /** Indicates that streams will be used to store BLOB data. NOTE: does not work with ODBC */
- protected boolean usesStreamsForBlobBinding;
- protected boolean usesStreamsForClobBinding;
- protected boolean isSecure=false;
-
- // this is the product name from the metedata, if it can be determined;
- private String platformName;
-
- /** Holds a hashtable of values used to map JAVA types to database types for table creation */
- protected transient Map fieldTypes;
-
- protected transient String[] tableTypes;
-
- /** Operators specific to this platform */
- protected transient Map platformOperators;
- protected transient Map classTypes;
- protected transient Map minimumValues;
- protected transient Map maximumValues;
-
- protected static final String SPACE = " "; //$NON-NLS-1$
- protected static final String COMMA = ", "; //$NON-NLS-1$
- protected static final String PARAM = "?"; //$NON-NLS-1$
- protected static final String PERIOD = "."; //$NON-NLS-1$
-
- protected static final String INSERT_INTO = JDBCReservedWords.INSERT + SPACE + JDBCReservedWords.INTO + SPACE;
- protected static final String DELETE_FROM = JDBCReservedWords.DELETE + SPACE + JDBCReservedWords.FROM + SPACE;
- protected static final String UPDATE = JDBCReservedWords.UPDATE + SPACE;
- protected static final String SELECT = JDBCReservedWords.SELECT + SPACE;
- protected static final String EQUAL = " = "; //$NON-NLS-1$
- protected static final String FROM = SPACE + JDBCReservedWords.FROM + SPACE;
- protected static final String WHERE = SPACE + JDBCReservedWords.WHERE + SPACE;
- protected static final String ORDER_BY = SPACE + JDBCReservedWords.ORDER_BY + SPACE;
- protected static final String GROUP_BY = SPACE + "GROUP BY" + SPACE; //$NON-NLS-1$
- protected static final String SET = SPACE + JDBCReservedWords.SET + SPACE;
- protected static final String ON = SPACE + JDBCReservedWords.ON + SPACE;
- protected static final String INTO = SPACE + JDBCReservedWords.INTO + SPACE;
- protected static final String IN = SPACE + JDBCReservedWords.IN + SPACE;
-// protected static final String INNER_JOIN = SPACE + JDBCReservedWords.INNER_JOIN + SPACE;
- protected static final String DISTINCT = SPACE + JDBCReservedWords.DISTINCT + SPACE;
- protected static final String VALUES = SPACE + JDBCReservedWords.VALUES + SPACE;
- protected static final String AND = SPACE + JDBCReservedWords.AND + SPACE;
- protected static final String LENGTH = SPACE + "LEN"; //$NON-NLS-1$
-
- public interface TableTypes {
- public static final String TABLE = "TABLE"; //$NON-NLS-1$
- public static final String VIEW = "VIEW"; //$NON-NLS-1$
- public static final String SYSTEM_TABLE = "SYSTEM TABLE"; //$NON-NLS-1$
- public static final String GLOBAL_TEMPORARY = "GLOBAL TEMPORARY"; //$NON-NLS-1$
- public static final String LOCAL_TEMPORARY = "LOCAL TEMPORARY"; //$NON-NLS-1$
- public static final String ALIAS = "ALIAS"; //$NON-NLS-1$
- public static final String SYNONYM = "SYNONYM"; //$NON-NLS-1$
- }
-
- protected JDBCPlatform () {
- usesStreamsForBlobBinding = false;
- tableTypes = null;
- }
-
- public void setConnection(Connection conn) throws MetaMatrixException {
-
- try {
- metadata = conn.getMetaData();
- getTableTypes();
- metadata = null;
- } catch (SQLException sqle){
- throw new MetaMatrixException(sqle);
- }
- }
-
- public boolean isClosed(Connection connection) {
- try {
- return connection.isClosed();
- } catch(SQLException e) {
- return true;
- }
- }
-
- public void setIsSecure(boolean secure) {
- this.isSecure = secure;
- }
-
- public void setPlatformName(String platformName) {
- this.platformName = platformName;
- }
-
- public String getPlatformName() {
- return platformName;
- }
-
- public boolean isOracle() {
- return false;
- }
-
- public boolean isDefault() {
- return true;
- }
-
- public boolean isMetaMatrix() {
- return false;
- }
-
- public boolean isDB2() {
- return false;
- }
-
- public boolean isSybase() {
- return false;
- }
-
- public boolean isMSSQL() {
- return false;
- }
-
- public boolean isMYSQL() {
- return false;
- }
-
- public boolean isInformix() {
- return false;
- }
-
- public boolean isDerby() {
- return false;
- }
-
- public boolean isPostgres() {
- return false;
- }
-
- public boolean isSecure() {
- return isSecure;
- }
-
- public boolean usesStreamsForBlobBinding() {
- return usesStreamsForBlobBinding;
- }
-
- public boolean usesStreamsForClobBinding() {
- return usesStreamsForClobBinding;
- }
-
- public int setBlob(ResultSet results, byte[] data, String columnName) throws SQLException, IOException {
- Blob blob = results.getBlob(columnName);
- OutputStream l_blobOutputStream = null;
-
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- InputStream is = new BufferedInputStream(bais);
-
- try {
- ReflectionHelper helper = new ReflectionHelper(blob.getClass());
- final Object[] args = new Object[]{};
- final Method m = helper.findBestMethodOnTarget("getBinaryOutputStream",args); //$NON-NLS-1$
-
- l_blobOutputStream = (OutputStream) m.invoke(blob,args);
- byte[] l_buffer = new byte[10* 1024];
-
- int cnt = is.available();
-
- int l_nread = 0; // Number of bytes read
- while ((l_nread= is.read(l_buffer)) != -1) { // Read from file
- l_blobOutputStream.write(l_buffer,0,l_nread); // Write to BLOB
- }
-
- return cnt;
- } catch (Exception nsme) {
- throw new IOException(nsme.getMessage());
- } finally {
- // Close both streams
- if( is != null) {
- is.close();
- is = null;
- }
- if( l_blobOutputStream != null) {
- l_blobOutputStream.close();
- l_blobOutputStream = null;
- }
- }
- }
-
- public void setBlob(PreparedStatement statement, byte[] data, int column) throws SQLException, IOException {
-
- statement.setBytes(column, data);
- }
-
- public void setClob(ResultSet results, byte[] data, String columnName) throws SQLException, IOException {
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- BufferedInputStream is = new BufferedInputStream(bais);
-
- setClob(results, is, columnName);
- }
-
- public void setClob(ResultSet results, InputStream is, String columnName) throws SQLException, IOException {
-
- OutputStream l_clobOutputStream = null;
-
- Clob clob = results.getClob(columnName);
- try {
- ReflectionHelper helper = new ReflectionHelper(clob.getClass());
- final Object[] args = new Object[]{};
- final Method m = helper.findBestMethodOnTarget("getAsciiOutputStream",args); //$NON-NLS-1$
-
- l_clobOutputStream = (OutputStream) m.invoke(clob,args);
-
- byte[] l_buffer = new byte[10* 1024];
-
-// int cnt = is.available();
-
- int l_nread = 0; // Number of bytes read
- while ((l_nread= is.read(l_buffer)) != -1) { // Read from file
- l_clobOutputStream.write(l_buffer,0,l_nread); // Write to BLOB
-
- }
- return;
-// return cnt;
- } catch (Exception nsme) {
- nsme.printStackTrace();
- throw new IOException(nsme.getMessage());
- } finally {
- // Close both streams
- if( is != null) {
- is.close();
- is = null;
- }
- if( l_clobOutputStream != null) {
- l_clobOutputStream.close();
- l_clobOutputStream = null;
- }
- }
- }
-
-
-
- public void setClob(PreparedStatement statement, byte[] data, int column) throws SQLException, IOException {
-
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- BufferedInputStream is = new BufferedInputStream(bais);
-
- statement.setAsciiStream(column, is, is.available());
- }
-
-
-
- /**
- * This will create an select statement that can be used
- * to select rows.
- * @param tableMetadata the definition of the table in which
- * columns will be used to create the select statement.
- */
-
- public String createSelectStatement( Table tableMetadata) {
- return createSelectStatement(tableMetadata, null);
-
- }
-
- public String createSelectStatement( Table tableMetadata, String tablePrefix) {
- return createSelectStatement(tableMetadata, tablePrefix, null);
- }
-
- /**
- * Create the select SQL string based on the table metadata. If the
- * table prefix is passed, then prefix the table with this value.
- * Also, if the where columns are passed the sql will build a
- * WHERE clause containing parameters for each column
- * @param tabelMetadata is the table that drives the sql statement
- * @param tablePrefix is a prefix to add to the table; optional and nullable
- * @param whereColumns are columns to use in the where clause; optional and nullable
- */
- public String createSelectStatement(Table tableMetadata, String tablePrefix, Column[] whereColumns) {
- StringBuffer sql = new StringBuffer();
- sql.append(SELECT);
-
- Collection columns = tableMetadata.getColumns();
-
- String columnString = buildCommaSeperatedColumns(columns);
- sql.append(columnString);
- sql.append(FROM);
-
- if (tablePrefix != null && tablePrefix.length() > 0) {
- sql.append(tablePrefix);
- sql.append("."); //$NON-NLS-1$
- } else {
- sql.append(" "); //$NON-NLS-1$
- }
-
- sql.append(tableMetadata.getFullName());
-
- if (whereColumns != null) {
- String whereClause = buildWhereParameterClause(whereColumns);
- sql.append(SPACE);
- sql.append(whereClause);
- }
-
- return sql.toString();
- }
-
- /**
- * This will create an insert statement that can be used
- * to insert rows using a PreparedStatement.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
- */
- public String createInsertStatement( Table tableMetadata ) {
- return createInsertStatement(tableMetadata, ""); //$NON-NLS-1$
- }
-
- public String createInsertStatement( Table tableMetadata, String tablePrefix) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(INSERT_INTO);
-
- if (tablePrefix != null && tablePrefix.length() > 0) {
- sql.append(tablePrefix);
- sql.append("."); //$NON-NLS-1$
- }
- sql.append(tableMetadata.getFullName());
- sql.append(" " + JDBCReservedWords.LEFT_PAREN); //$NON-NLS-1$
- Collection columns = tableMetadata.getColumns();
-
- String columnString = buildCommaSeperatedColumns(columns);
-/*
- for (Iterator cit=columns.iterator(); cit.hasNext(); i++) {
- Column column = (Column) cit.next();
- sql.append(column.getFullName());
- if (i < size) {
- sql.append(COMMA);
- }
- }
-*/
- sql.append(columnString);
- int size = columns.size();
- sql.append(JDBCReservedWords.RIGHT_PAREN);
- sql.append(VALUES);
- sql.append(JDBCReservedWords.LEFT_PAREN);
- for(int k=1;k<=size;k++){
- sql.append(PARAM);
- if(k < size){
- sql.append(COMMA);
- }
- }
- sql.append(JDBCReservedWords.RIGHT_PAREN);
- return sql.toString();
- }
-
- /**
- * This will create an insert statement that will contain the actual values to
- * be inserted into the table.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
- * @param values to be inserted
- */
- public String createInsertStatement( Table tableMetadata, String[] values ) {
- return ""; //$NON-NLS-1$
- }
-
/**
- * Obtain the statement that can be used to update records
- * in a table using a PreparedStatement.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
+ * These are the platforms supported
*/
- public String createUpdateStatement( Table tableMetadata ) {
- return createUpdateStatement(tableMetadata, null);
- }
+ public enum Supported {
+ ORACLE,
+ SYBASE,
+ DB2,
+ MSSQL,
+ INFORMIX,
+ METAMATRIX,
+ MM_ORACLE,
+ MYSQL,
+ POSTGRES,
+ DEFAULT,
+ DERBY
+ }
- /**
- * Obtain the statement which will contain the actual data values
- * to update records in a table.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
- * @param values to be inserted
- */
- public String createUpdateStatement( Table tableMetadata, String[] values ) {
- StringBuffer sql = new StringBuffer();
- sql.append(UPDATE);
-
- sql.append(tableMetadata.getFullName());
-
- if (values == null) {
- String setClause = buildSetParmClause(tableMetadata.getColumns().toArray());
- sql.append(setClause);
- } else {
- //TODO Not coded yet to build the set clause with the
- // values.
- return "NEED TO UPDATE method createUpdateStatement"; //$NON-NLS-1$
- }
-
- if (!tableMetadata.getUniqueKeys().isEmpty()) {
- String whereClause = buildWhereUsingUiqueKeys(tableMetadata.getUniqueKeys());
- sql.append(SPACE);
- sql.append(whereClause);
-
- }
-
- return sql.toString();
-
- }
-
-
- protected String buildSetParmClause(Object[] setColumns) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(SET);
-
- int size = setColumns.length;
-
- for(int k=0;k<size;k++){
- Column col = (Column) setColumns[k];
- sql.append(col.getName());
- sql.append(EQUAL);
- sql.append(PARAM);
- if(k < size - 1){
- sql.append(COMMA);
- }
- }
-
- return sql.toString();
-
- }
-
-
- protected String buildWhereUsingUiqueKeys(Collection uniqueKeys) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(WHERE);
-
- int size = uniqueKeys.size();
- int k=0;
- for (Iterator it=uniqueKeys.iterator(); it.hasNext(); k++) {
- UniqueKey key = (UniqueKey) it.next();
- sql.append(key.getName());
- sql.append(EQUAL);
- sql.append(PARAM);
- if(k < size - 1){
- sql.append(AND);
- }
- }
-
- return sql.toString();
-
- }
-
/**
- * Obtain the statement that may be used to delete records
- * from a table with the specified metadata.
- * @param tableMetadata the definition of the table from which
- * records are to be deleted; may not be null;
+ * The use of platforms is a secondary search option in case the supported
+ * platforms don't match to the product name
*/
- public String createDeleteStatement( Table table ) {
- return createDeleteStatement(table, null);
- }
+ protected interface Protocol {
+ public static final String MSSQL = "mssql"; //$NON-NLS-1$
+ public static final String SQLSERVER = "sqlserver"; //$NON-NLS-1$
+ public static final String ORACLE = "oracle"; //$NON-NLS-1$
+ public static final String DB2 = "db2"; //$NON-NLS-1$
+ public static final String SYBASE = "sybase"; //$NON-NLS-1$
+ public static final String INFORMIX = "informix-sqli"; //$NON-NLS-1$
+ public static final String METAMATRIX = "metamatrix"; //$NON-NLS-1$
+ public static final String MM_ORACLE = "mmx:oracle"; //$NON-NLS-1$
+ public static final String DERBY = "derby"; //$NON-NLS-1$
+ public static final String MYSQL = "mysql"; //$NON-NLS-1$
+ public static final String POSTGRES = "postgres"; //$NON-NLS-1$
- public String createDeleteStatement( Table table, String tablePrefix) {
- if (tablePrefix != null && tablePrefix.length() > 0) {
- return DELETE_FROM + tablePrefix + "." + table.getName(); //$NON-NLS-1$
- }
- return DELETE_FROM+ table.getName();
- }
+ }
- public String createDeleteStatement( Table table, Column[] whereColumns, String tablePrefix) {
- String prefix;
- if (tablePrefix != null && tablePrefix.length() > 0) {
- prefix = DELETE_FROM + tablePrefix + "." + table.getName(); //$NON-NLS-1$
- } else {
- prefix = DELETE_FROM+ table.getName();
- }
+ public static Supported getSupportedByProtocol(String value) {
+ // System.out.println("==== Look for platform by product " + value);
+ String lower = value.toLowerCase();
- StringBuffer sql = new StringBuffer(prefix);
+ if (lower.indexOf(Protocol.METAMATRIX) >= 0) {
+ return Supported.METAMATRIX;
+ } else if (lower.indexOf(Protocol.MM_ORACLE) >= 0) {
+ return Supported.MM_ORACLE;
+ } else if (lower.indexOf(Protocol.MSSQL) >= 0
+ || lower.indexOf(Protocol.SQLSERVER) >= 0) {
+ return Supported.MSSQL;
+ } else if (lower.indexOf(Protocol.DB2) >= 0) {
+ return Supported.DB2;
+ } else if (lower.indexOf(Protocol.ORACLE) >= 0) {
+ return Supported.ORACLE;
+ } else if (lower.indexOf(Protocol.SYBASE) >= 0) {
+ return Supported.SYBASE;
+ } else if (lower.indexOf(Protocol.INFORMIX) >= 0) {
+ return Supported.INFORMIX;
+ } else if (lower.indexOf(Protocol.DERBY) >= 0) {
+ return Supported.DERBY;
+ } else if (lower.indexOf(Protocol.MYSQL) >= 0) {
+ return Supported.MYSQL;
+ } else if (lower.indexOf(Protocol.POSTGRES) >= 0) {
+ return Supported.POSTGRES;
+ }
- if (whereColumns != null) {
- String whereClause = buildWhereParameterClause(whereColumns);
- sql.append(SPACE);
- sql.append(whereClause);
- }
+ return null;
+ }
- return sql.toString();
- }
+ public static byte[] convertToByteArray(Object sourceObject)
+ throws TransformationException {
+ if (sourceObject instanceof byte[]) {
+ return (byte[]) sourceObject;
+ } else if (sourceObject instanceof java.sql.Clob) {
+ return convertToByteArray((java.sql.Clob) sourceObject);
+ } else if (sourceObject instanceof java.sql.Blob) {
+ return convertToByteArray((java.sql.Blob) sourceObject);
+ } else {
+ throw new TransformationException(ErrorMessageKeys.JDBC_ERR_0001,
+ CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0001,
+ sourceObject.getClass().getName()));
+ }
+ }
+ protected static byte[] convertToByteArray(java.sql.Blob sourceObject)
+ throws TransformationException {
- public String createTruncateStatement( String tablename ) {
- return createTruncateStatement(tablename, null);
- }
+ try {
- public String createTruncateStatement( String tablename , String tablePrefix) {
- if (tablePrefix != null && tablePrefix.length() > 0) {
- return DELETE_FROM + tablePrefix + "." + tablename; //$NON-NLS-1$
- }
+ // long size = sourceObject.length();
+ // System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
- return DELETE_FROM + tablename;
- }
+ // Open a stream to read the BLOB data
+ InputStream l_blobStream = sourceObject.getBinaryStream();
- public int getMaxFieldNameSize() {
- return 50;
- }
+ // Open a file stream to save the BLOB data
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(out);
- public String[] getTableTypes() throws MetaMatrixException {
- if (tableTypes != null) {
- return tableTypes;
- }
+ // Read from the BLOB data input stream, and write to the file
+ // output
+ // stream
+ byte[] l_buffer = new byte[1024]; // buffer holding bytes to be
+ // transferred
+ int l_nbytes = 0; // Number of bytes read
+ while ((l_nbytes = l_blobStream.read(l_buffer)) != -1)
+ // Read from BLOB stream
+ bos.write(l_buffer, 0, l_nbytes); // Write to file stream
- Set tableTypesSet = new HashSet();
- try {
- ResultSet tableTypesResults = metadata.getTableTypes();
- while ( tableTypesResults.next() ) {
- tableTypesSet.add(tableTypesResults.getString(1).trim());
- }
- } catch ( SQLException e ){
- throw new MetaMatrixException(e);
-// errorMessages.add("Error using 'getTableTypes': " + e.getMessage());
- }
+ // Flush and close the streams
+ bos.flush();
+ bos.close();
+ l_blobStream.close();
- tableTypes = new String[tableTypesSet.size()];
- int index = -1;
- Iterator iter = tableTypesSet.iterator();
- while ( iter.hasNext() ) {
- tableTypes[++index] = iter.next().toString();
- }
+ return out.toByteArray();
- return tableTypes;
- }
+ } catch (IOException ioe) {
+ throw new TransformationException(ioe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ } catch (SQLException sqe) {
+ throw new TransformationException(sqe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ }
- public Map getClassTypes()
- {
- if (classTypes == null)
- classTypes = buildClassTypes();
- return classTypes;
- }
+ }
- public Map getFieldTypes() {
- if (fieldTypes == null)
- fieldTypes = buildFieldTypes();
- return fieldTypes;
- }
+ protected static byte[] convertToByteArray(java.sql.Clob sourceObject)
+ throws TransformationException {
- /**
- * Call to determine what is the maximum value allowed for the
- * current database platform.
- * @param clazz is the java object data type that is of type Number
- * @return Number that represents the maximum value allowed on the
- * current database platform.
- */
- public synchronized Number getMaximumValue(Class clazz) {
- if (clazz == null) return null;
+ try {
- if (maximumValues == null) {
- maximumValues = maximumNumericValues();
- }
+ // long size = sourceObject.length();
+ // System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
- Object obj = maximumValues.get(clazz);
- if (obj != null) {
- return (Number) obj;
- }
- return null;
- }
+ // Open a stream to read the BLOB data
+ InputStream l_clobStream = sourceObject.getAsciiStream();
- /**
- * Call to determine what is the minimum value allowed for the
- * current database platform.
- * @param clazz is the java object data type that is of type Number
- * @return Number that represents the minimum value allowed on the
- * current database platform.
- */
- public synchronized Number getMinimumValue(Class clazz) {
- if (clazz == null) return null;
+ // Open a file stream to save the BLOB data
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(out);
- if (minimumValues == null) {
- minimumValues = minimumNumericValues();
- }
+ // Read from the BLOB data input stream, and write to the file
+ // output
+ // stream
+ byte[] l_buffer = new byte[1024]; // buffer holding bytes to be
+ // transferred
+ int l_nbytes = 0; // Number of bytes read
+ while ((l_nbytes = l_clobStream.read(l_buffer)) != -1)
+ // Read from BLOB stream
+ bos.write(l_buffer, 0, l_nbytes); // Write to file stream
- Object obj = minimumValues.get(clazz);
- if (obj != null) {
- return (Number) obj;
- }
- return null;
- }
+ // Flush and close the streams
+ bos.flush();
+ bos.close();
+ l_clobStream.close();
+ return out.toByteArray();
- public ExpressionOperator getOperator(String name) {
- return (ExpressionOperator) getPlatformOperators().get(name);
- }
+ } catch (IOException ioe) {
+ throw new TransformationException(ioe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ } catch (SQLException sqe) {
+ throw new TransformationException(sqe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ }
+ }
-/**
- * Return any platform-specific operators
- */
- public synchronized Map getPlatformOperators() {
- if (platformOperators == null)
- platformOperators = buildPlatformOperators();
- return platformOperators;
- }
+ public static int getDatabaseColumnSize(String tableName,
+ String columnName, Connection jdbcConnection) throws SQLException {
+ DatabaseMetaData dbMetadata = jdbcConnection.getMetaData();
+ String catalogName = jdbcConnection.getCatalog();
+ ResultSet columns = dbMetadata.getColumns(catalogName, null, tableName,
+ "%"); //$NON-NLS-1$
+ int s = -1;
+ while (columns.next()) {
+ String nis = columns.getString(4);
+ if (columnName.equals(nis)) {
+ s = columns.getInt(7);
+ }
- void initializePlatform() {
- }
-
- protected Map buildClassTypes() {
- HashMap types = new HashMap();
- return types;
- }
-
- protected Map buildFieldTypes() {
- HashMap types = new HashMap();
- return types;
- }
-
- protected void addOperator(ExpressionOperator op)
- {
- for (Iterator it=op.getSelectors().iterator(); it.hasNext(); ) {
- platformOperators.put(it.next(), op);
- }
- }
-
- protected Map buildPlatformOperators() {
-
- this.platformOperators = new Hashtable();
-
- // Ordering
- addOperator(ExpressionOperator.ascending());
- addOperator(ExpressionOperator.descending());
-
- // String
- addOperator(ExpressionOperator.toUpperCase());
- addOperator(ExpressionOperator.toLowerCase());
- addOperator(ExpressionOperator.maximum());
- addOperator(ExpressionOperator.minimum());
-
-// addOperator(ExpressionOperator.chr());
-// addOperator(ExpressionOperator.concat());
-// addOperator(ExpressionOperator.hexToRaw());
-// addOperator(ExpressionOperator.initcap());
-// addOperator(ExpressionOperator.instring());
-// addOperator(ExpressionOperator.leftPad());
-// addOperator(ExpressionOperator.leftTrim());
-// addOperator(ExpressionOperator.replace());
-// addOperator(ExpressionOperator.rightPad());
-// addOperator(ExpressionOperator.rightTrim());
-// addOperator(ExpressionOperator.substring());
-// addOperator(ExpressionOperator.toNumber());
-// addOperator(ExpressionOperator.translate());
-// addOperator(ExpressionOperator.trim());
-// addOperator(ExpressionOperator.ascii());
-
- // Date
-// addOperator(ExpressionOperator.addMonths());
-// addOperator(ExpressionOperator.dateToString());
-// addOperator(ExpressionOperator.lastDay());
-// addOperator(ExpressionOperator.monthsBetween());
-// addOperator(ExpressionOperator.nextDay());
-// addOperator(ExpressionOperator.roundDate());
-// addOperator(ExpressionOperator.toDate());
-
- // Math
- addOperator(ExpressionOperator.sum());
- addOperator(ExpressionOperator.count());
- addOperator(ExpressionOperator.average());
-
-// addOperator(ExpressionOperator.ceil());
-// addOperator(ExpressionOperator.cos());
-// addOperator(ExpressionOperator.cosh());
-// addOperator(ExpressionOperator.abs());
-// addOperator(ExpressionOperator.acos());
-// addOperator(ExpressionOperator.asin());
-// addOperator(ExpressionOperator.atan());
-// addOperator(ExpressionOperator.exp());
-// addOperator(ExpressionOperator.floor());
-// addOperator(ExpressionOperator.ln());
-// addOperator(ExpressionOperator.log());
-// addOperator(ExpressionOperator.mod());
-// addOperator(ExpressionOperator.power());
-// addOperator(ExpressionOperator.round());
-// addOperator(ExpressionOperator.sign());
-// addOperator(ExpressionOperator.sin());
-// addOperator(ExpressionOperator.sinh());
-// addOperator(ExpressionOperator.tan());
-// addOperator(ExpressionOperator.tanh());
-// addOperator(ExpressionOperator.trunc());
-
- // Object-relational
-// addOperator(ExpressionOperator.deref());
-// addOperator(ExpressionOperator.ref());
-// addOperator(ExpressionOperator.refToHex());
-// addOperator(ExpressionOperator.refToValue());
-
- // Other
-// addOperator(ExpressionOperator.greatest());
-// addOperator(ExpressionOperator.least());
-
- // ?
- addOperator(ExpressionOperator.today());
-
- return platformOperators;
-
-
- }
-
- /**
- * Builds a table of maximum numeric values keyed on java class. This is used for type testing but
- * might also be useful to end users attempting to sanitize values.
- * <p><b>NOTE</b>: BigInteger & BigDecimal maximums are dependent upon their precision & Scale
- */
- public Map maximumNumericValues()
- {
- Map values = new HashMap(1);
-/*
- values.put(Integer.class, new Integer(Integer.MAX_VALUE));
- values.put(Long.class, new Long(Long.MAX_VALUE));
- values.put(Double.class, new Double(Double.MAX_VALUE));
- values.put(Short.class, new Short(Short.MAX_VALUE));
- values.put(Byte.class, new Byte(Byte.MAX_VALUE));
- values.put(Float.class, new Float(Float.MAX_VALUE));
- values.put(java.math.BigInteger.class, new java.math.BigInteger("999999999999999999999999999999999999999")); //$NON-NLS-1$
- values.put(java.math.BigDecimal.class, new java.math.BigDecimal("99999999999999999999.9999999999999999999")); //$NON-NLS-1$
-*/
- return values;
+ }
+ return s;
}
- /**
- * Builds a table of minimum numeric values keyed on java class. This is used for type testing but
- * might also be useful to end users attempting to sanitize values.
- * <p><b>NOTE</b>: BigInteger & BigDecimal minimums are dependent upon their precision & Scale
- */
- public Map minimumNumericValues()
- {
- Map values = new HashMap(1);
-/*
- values.put(Integer.class, new Integer(Integer.MIN_VALUE));
- values.put(Long.class, new Long(Long.MIN_VALUE));
- values.put(Double.class, new Double(Double.MIN_VALUE));
- values.put(Short.class, new Short(Short.MIN_VALUE));
- values.put(Byte.class, new Byte(Byte.MIN_VALUE));
- values.put(Float.class, new Float(Float.MIN_VALUE));
- values.put(java.math.BigInteger.class, new java.math.BigInteger("-99999999999999999999999999999999999999")); //$NON-NLS-1$
- values.put(java.math.BigDecimal.class, new java.math.BigDecimal("-9999999999999999999.9999999999999999999")); //$NON-NLS-1$
-*/
- return values;
+ public static String getIdentifierQuoteString(Connection connection)
+ throws SQLException {
+ String quote = connection.getMetaData().getIdentifierQuoteString();
+ if (quote == null || quote.equals(" ")) { //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ return quote;
}
- public byte[] convertToByteArray(Object sourceObject) throws TransformationException{
- if (sourceObject instanceof byte[]) {
- return (byte[]) sourceObject;
- } else if(sourceObject instanceof java.sql.Clob) {
- return convertToByteArray( (java.sql.Clob) sourceObject);
- } else if (sourceObject instanceof java.sql.Blob) {
- return convertToByteArray( (java.sql.Blob) sourceObject);
- } else {
- throw new TransformationException(ErrorMessageKeys.JDBC_ERR_0001, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0001, sourceObject.getClass().getName()));
- }
- }
-
- protected byte[] convertToByteArray(java.sql.Blob sourceObject) throws TransformationException{
-
- try {
-
-// long size = sourceObject.length();
-// System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
-
- // Open a stream to read the BLOB data
- InputStream l_blobStream = sourceObject.getBinaryStream();
-
- // Open a file stream to save the BLOB data
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- BufferedOutputStream bos = new BufferedOutputStream(out);
-
- // Read from the BLOB data input stream, and write to the file output
- // stream
- byte[] l_buffer = new byte[1024]; // buffer holding bytes to be transferred
- int l_nbytes = 0; // Number of bytes read
- while ((l_nbytes = l_blobStream.read(l_buffer)) != -1) // Read from BLOB stream
- bos.write(l_buffer,0,l_nbytes); // Write to file stream
-
- // Flush and close the streams
- bos.flush();
- bos.close();
- l_blobStream.close();
-
- return out.toByteArray();
-
- } catch (IOException ioe) {
- throw new TransformationException(ioe, ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, sourceObject.getClass().getName()));
- } catch (SQLException sqe) {
- throw new TransformationException(sqe, ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, sourceObject.getClass().getName()));
-
- }
-
- }
-
-
-
- public byte[] convertClobToByteArray(ResultSet results, String columName) throws TransformationException{
- byte[] data = null;
- Clob clobResults = null;
- try {
- if(usesStreamsForClobBinding()) {
- clobResults = results.getClob(columName);
- if (clobResults != null) {
- data = convertToByteArray(clobResults);
- }
- } else {
- String s = results.getString(columName);
- data = s.getBytes();
-
- }
-// } catch (IOException ioe) {
-// throw new TransformationException(ioe, ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, columName));
- } catch (SQLException sqe) {
- throw new TransformationException(sqe, ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, columName));
-
- }
-
- return data;
-
-
- }
-
- protected byte[] convertToByteArray(java.sql.Clob sourceObject) throws TransformationException{
-
- try {
-
-// long size = sourceObject.length();
-// System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
-
- // Open a stream to read the BLOB data
- InputStream l_clobStream = sourceObject.getAsciiStream();
-
- // Open a file stream to save the BLOB data
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- BufferedOutputStream bos = new BufferedOutputStream(out);
-
- // Read from the BLOB data input stream, and write to the file output
- // stream
- byte[] l_buffer = new byte[1024]; // buffer holding bytes to be transferred
- int l_nbytes = 0; // Number of bytes read
- while ((l_nbytes = l_clobStream.read(l_buffer)) != -1) // Read from BLOB stream
- bos.write(l_buffer,0,l_nbytes); // Write to file stream
-
- // Flush and close the streams
- bos.flush();
- bos.close();
- l_clobStream.close();
-
- return out.toByteArray();
-
- } catch (IOException ioe) {
- throw new TransformationException(ioe, ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, sourceObject.getClass().getName()));
- } catch (SQLException sqe) {
- throw new TransformationException(sqe, ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, sourceObject.getClass().getName()));
-
- }
- }
-
- /**
- * Takes a columns of Columns and returns a comma seperated string
- */
- protected String buildCommaSeperatedColumns(Collection columns) {
- StringBuffer sql = new StringBuffer();
- int i=1;
- int size = columns.size();
- for (Iterator cit=columns.iterator(); cit.hasNext(); i++) {
- Column column = (Column) cit.next();
- sql.append(column.getName());
- if (i < size) {
- sql.append(COMMA);
- }
- }
-
- return sql.toString();
-
- }
-
- protected String buildWhereParameterClause(Column[] whereColumns) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(WHERE);
-
- int size = whereColumns.length;
-
- for(int k=0;k<size;k++){
- Column col = whereColumns[k];
- sql.append(col.getName());
- sql.append(EQUAL);
- sql.append(PARAM);
- if(k < size - 1){
- sql.append(AND);
- }
- }
-
- return sql.toString();
-
- }
-
- public int getDatabaseColumnSize(String tableName, String columnName, Connection jdbcConnection) throws SQLException {
- DatabaseMetaData dbMetadata = jdbcConnection.getMetaData();
- String catalogName = jdbcConnection.getCatalog();
-
- ResultSet columns = dbMetadata.getColumns(catalogName, null, tableName, "%"); //$NON-NLS-1$
- int s = -1;
- while ( columns.next() ) {
- String nis = columns.getString(4);
- if (columnName.equals(nis) ) {
- s = columns.getInt(7);
- }
-
- }
- return s;
- }
-
-// public Map getDatabaseColumns(String tableName, Connection jdbcConnection) throws SQLException {
-// Map table = new HashMap();
-//
-// DatabaseMetaData dbMetadata = jdbcConnection.getMetaData();
-// String catalogName = jdbcConnection.getCatalog();
-//// String schemaName = jdbcConnection.getMetaData().getSchemaTerm();
-//
-// ResultSet columns = dbMetadata.getColumns(catalogName, null, tableName, "%"); //$NON-NLS-1$
-//
-// while ( columns.next() ) {
-//
-// // Assume that the catalog, schema and table name all match ...
-// DatabaseColumn column = new DatabaseColumn( columns.getString(4) );
-// column.setDataType( columns.getShort(5) );
-// column.setDataTypeName( columns.getString(6) );
-// column.setSize( columns.getInt(7) );
-// //column.( columns.getShort(8) ); // buffer length is not used
-// column.setDecimalDigits( columns.getInt(9) );
-// column.setRadix( columns.getInt(10) );
-//// column.setNullability( Nullability.getInstance( columns.getInt(11) ) );
-// column.setRemarks( columns.getString(12) );
-// column.setDefaultValue( columns.getString(13) );
-// //column.( columns.getInt(14) ); // current unused
-// //column.( columns.getInt(15) ); // current unused
-// column.setCharOctetLength( columns.getInt(16) );
-// column.setPosition( columns.getInt(17) );
-// //column.( columns.getString(18) ); // nullability string
-//
-// table.put(column.getNameInSource(), column);
-// }
-//
-// return table;
-// }
-
-
- public List parseToExecutableStatements(BufferedReader reader, String delimiter) throws SQLException {
-
- StringBuffer buffer = new StringBuffer();
- LinkedList listOfStatements = new LinkedList();
-
- try {
- List remove = getNonExecutableDelimiters();
- while (reader.ready()) {
- String line = reader.readLine();
- if(line == null) {
- // End of stream
- break;
- }
-
- line = line.trim();
- boolean doNotRemove=true;
- // check if the line starts with a nonexecutable delimiter
- // if so, then the line is not included
- if (line == null || line.length() == 0) {
- continue;
- }
- String UCASELINE = line.toUpperCase();
- for (Iterator it=remove.iterator(); it.hasNext();) {
- String removeItem = (String) it.next();
- if (UCASELINE.startsWith(removeItem)) {
- // line is to not be included in the statement list
- // i.e., it may be a comment
- doNotRemove=false;
- break;
- }
- }
-
- if (doNotRemove) {
- if (line.endsWith(delimiter)) {
- int x = line.lastIndexOf(delimiter);
- buffer.append(line.substring(0, x ));
- listOfStatements.add(buffer);
- buffer = new StringBuffer();
- } else {
- buffer.append(line + SPACE);
-
- }
-
- }
-
-
- }
-
- } catch(Exception e) {
- throw new SQLException(e.getMessage());
- }
-
- return listOfStatements;
-
- }
-
- /**
- * These nonexecutable delimiters are words or symbols that
- * cannot be excuted via an execute statement. These generally
- * are platform specific or are required to be handled
- * by the processing logic (i.e., commit, set spool off, etc.)
- *
- * the extending class should copy this forward and then
- * add to it. Also, make an alpha characters upper case.
- * @return
- */
- protected List getNonExecutableDelimiters() {
-
- List re = new ArrayList(1);
- re.add("--"); //$NON-NLS-1$
- re.add("SET");//$NON-NLS-1$
- re.add("COMMIT");//$NON-NLS-1$
- re.add("SPOOL");//$NON-NLS-1$
- return re;
-
- }
-
}
Deleted: trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -1,323 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.jdbc;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.ErrorMessageKeys;
-
-/**
- * DO NOT USE LogManager in this class
- *
- * Here's the matrix for determining which platform to use:
- * PN = Product Name, which means the product name from the metadata will help determine the platform
- * Protocol = means the Protocol (mmx:oracle, oracle, sequelink) will help determine the platform
- *
- *
- * Driver | Oracle DB2 SQLServer Sybase Informix
- * ------------------------------------------------------------------------------
- * Native PN PN PN PN PN
- *
- * MMX (DD) Protocol PN PN PN PN
- * (mmx:oracle)
- *
- * MetaMatrix JDBC Protocol -->(SAME) -->(SAME) ----->(SAME) --> (SAME)
- *
- * ------------------------------------------------------------------------------
- *
- * The process will look 1st at the protocol and then the product name to further
- * deliniate the type of platform that should be used.
- *
- */
-public class JDBCPlatformFactory {
-
- /**
- * These are the platforms supported
- */
- public interface Supported {
- public static final String ORACLE = "oracle"; //$NON-NLS-1$
- public static final String SYBASE = "sybase"; //$NON-NLS-1$
- public static final String DB2 = "db2"; //$NON-NLS-1$
- public static final String MSSQL = "microsoft"; //$NON-NLS-1$
- public static final String INFORMIX = "informix"; //$NON-NLS-1$
- public static final String METAMATRIX = "metamatrix"; //$NON-NLS-1$
- public static final String MM_ORACLE = "mmx:oracle"; //$NON-NLS-1$
- public static final String MYSQL = "mysql"; //$NON-NLS-1$
- public static final String POSTGRES = "postgres"; //$NON-NLS-1$
-
- // default
- public static final String DEFAULT = "default"; //$NON-NLS-1$
- public static final String DERBY = "derby"; //$NON-NLS-1$
- }
-
-
- /**
- * The use of platforms is a secondary search option
- * in case the supported platforms don't match
- * to the product name
- */
- protected interface Protocol {
- public static final String MSSQL = "mssql"; //$NON-NLS-1$
- public static final String SQLSERVER = "sqlserver"; //$NON-NLS-1$
- public static final String ORACLE = "oracle"; //$NON-NLS-1$
- public static final String DB2 = "db2"; //$NON-NLS-1$
- public static final String SYBASE = "sybase"; //$NON-NLS-1$
- public static final String INFORMIX = "informix-sqli"; //$NON-NLS-1$
- public static final String METAMATRIX = "metamatrix"; //$NON-NLS-1$
- public static final String MM_ORACLE = "mmx:oracle"; //$NON-NLS-1$
- public static final String DERBY = "derby"; //$NON-NLS-1$
- public static final String MYSQL = "mysql"; //$NON-NLS-1$
- public static final String POSTGRES = "postgres"; //$NON-NLS-1$
-
- }
-
- protected interface PlatformClass {
- public static final String MSSQL = "com.metamatrix.common.jdbc.db.MSSQLPlatform"; //$NON-NLS-1$
- public static final String DB2 = "com.metamatrix.common.jdbc.db.DB2Platform"; //$NON-NLS-1$
- public static final String ORACLE = "com.metamatrix.common.jdbc.db.OraclePlatform"; //$NON-NLS-1$
- public static final String SYBASE = "com.metamatrix.common.jdbc.db.SybasePlatform"; //$NON-NLS-1$
- public static final String INFORMIX = "com.metamatrix.common.jdbc.db.InformixPlatform"; //$NON-NLS-1$
- public static final String METAMATRIX = "com.metamatrix.common.jdbc.db.MetaMatrixPlatform"; //$NON-NLS-1$
- public static final String DEFAULT = "com.metamatrix.common.jdbc.JDBCPlatform"; //$NON-NLS-1$
-
- public static final String MMORACLE = "com.metamatrix.common.jdbc.db.MMOraclePlatform"; //$NON-NLS-1$
- public static final String DERBY = "com.metamatrix.common.jdbc.db.DerbyPlatform"; //$NON-NLS-1$
- public static final String MYSQL = "com.metamatrix.common.jdbc.db.MySQLPlatform"; //$NON-NLS-1$
- public static final String POSTGRES = "com.metamatrix.common.jdbc.db.PostgresPlatform"; //$NON-NLS-1$
-
- }
-
- private static final String DEFAULT_PLATFORM = "default"; //$NON-NLS-1$
- private static Map classMap;
-
- private static Map platformCache;
-
-
- static {
- platformCache = new HashMap(10);
-
- classMap = new HashMap(10);
- classMap.put(Supported.DB2, PlatformClass.DB2);
- classMap.put(Supported.MSSQL, PlatformClass.MSSQL);
- classMap.put(Supported.ORACLE, PlatformClass.ORACLE);
- classMap.put(Supported.SYBASE, PlatformClass.SYBASE);
- classMap.put(Supported.INFORMIX, PlatformClass.INFORMIX);
- classMap.put(Supported.METAMATRIX, PlatformClass.METAMATRIX);
- classMap.put(Supported.MM_ORACLE, PlatformClass.MMORACLE);
- classMap.put(Supported.MYSQL, PlatformClass.MYSQL);
- classMap.put(Supported.POSTGRES, PlatformClass.POSTGRES);
-
-
- classMap.put(DEFAULT_PLATFORM, PlatformClass.DEFAULT);
- classMap.put(Supported.DERBY, PlatformClass.DERBY);
-
-
- }
-
- public static JDBCPlatform getPlatform(Connection jdbcConnection) throws MetaMatrixException {
- try {
- DatabaseMetaData metadata = jdbcConnection.getMetaData();
- String productName = metadata.getDatabaseProductName();
- String driverName = metadata.getDriverName();
-
- JDBCPlatform p = getPlatform(metadata.getURL(), driverName, productName);
- if (p != null) {
- p.setConnection(jdbcConnection);
- }
- return p;
- } catch (Exception sqle) {
- throw new MetaMatrixException(sqle, ErrorMessageKeys.JDBC_ERR_0003, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0003));
- }
-
- }
-
- public static JDBCPlatform getPlatform(String url, String driverName) throws MetaMatrixException {
-
- String productName = getSupportedByProtocol(url);
- if (productName == null) {
- return null;
- }
- return getPlatform(url, driverName, productName );
- }
-
-
-
- static JDBCPlatform getPlatform(String url, String driverName, String productName) throws MetaMatrixException {
- try {
- boolean isSecure = false;
-
- JDBCURL jdbcurl = new JDBCURL(url);
-
- String dbplatform = getSupportedByProductName(productName);
-
- String supported = getSupportedByProtocol(jdbcurl.getProtocol());
-
-
- if (supported == null) {
- supported = dbplatform;
- }
-
- if (supported == null) {
- supported = Supported.DEFAULT;
- }
-
- String platformClass = getPlatformClass(supported);
-
-
-
- String key = driverName + " - " + jdbcurl.getProtocol(); //$NON-NLS-1$
-
- JDBCPlatform p = createPlatform(dbplatform, platformClass, key, isSecure);
-
- return p;
- } catch (Exception sqle) {
- throw new MetaMatrixException(sqle, ErrorMessageKeys.JDBC_ERR_0003, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0003));
- }
- }
-
-
- private static JDBCPlatform createPlatform(String productName, String platformClass, String key, boolean isSecure) throws MetaMatrixException {
- try {
-
- JDBCPlatform p = getAvailablePlatform(platformClass, key);
-
- if (p != null) {
- return p;
- }
- Object o = Class.forName(platformClass).newInstance();
- if (o instanceof JDBCPlatform) {
- p = (JDBCPlatform) o;
- } else {
- throw new MetaMatrixException(ErrorMessageKeys.JDBC_ERR_0005, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0005));
- }
-
- if (isSecure) {
- p.setIsSecure(isSecure);
- }
-
- p.setPlatformName(productName);
- p.initializePlatform();
-
- addAvailablePlatform(platformClass, key, p);
-
- return p;
-
- } catch (Exception cnfe) {
- throw new MetaMatrixException(cnfe, ErrorMessageKeys.JDBC_ERR_0003, CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0003));
- }
- }
-
- private static JDBCPlatform getAvailablePlatform(String platform, String key) {
-
- JDBCPlatform p =null;
- Map platformInstances = null;
- if (platformCache.containsKey(platform)) {
- platformInstances = (Map) platformCache.get(platform);
- if (platformInstances.containsKey(key)) {
- p = (JDBCPlatform) platformInstances.get(key);
- }
- } else {
- platformInstances = new HashMap(10);
- platformCache.put(platform, platformInstances);
- }
-
- return p;
- }
-
- private static void addAvailablePlatform(String platform, String key, JDBCPlatform jdbc) {
-
- Map platformInstances = (Map) platformCache.get(platform);
- platformInstances.put(key, jdbc);
- }
-
- static String getSupportedByProtocol(String value) {
-// System.out.println("==== Look for platform by product " + value);
- String lower = value.toLowerCase();
-
- if (lower.indexOf(Protocol.METAMATRIX) >= 0) {
- return Supported.METAMATRIX;
- } else if (lower.indexOf(Protocol.MM_ORACLE) >= 0) {
- return Supported.MM_ORACLE;
- } else if (lower.indexOf(Protocol.MSSQL) >= 0 || lower.indexOf(Protocol.SQLSERVER) >= 0) {
- return Supported.MSSQL;
- } else if (lower.indexOf(Protocol.DB2) >= 0) {
- return Supported.DB2;
- } else if (lower.indexOf(Protocol.ORACLE) >= 0) {
- return Supported.ORACLE;
- } else if (lower.indexOf(Protocol.SYBASE) >= 0) {
- return Supported.SYBASE;
- } else if (lower.indexOf(Protocol.INFORMIX) >= 0) {
- return Supported.INFORMIX;
- } else if (lower.indexOf(Protocol.DERBY) >= 0) {
- return Supported.DERBY;
- } else if (lower.indexOf(Protocol.MYSQL) >= 0) {
- return Supported.MYSQL;
- } else if (lower.indexOf(Protocol.POSTGRES) >= 0) {
- return Supported.POSTGRES;
- }
-
- return null;
- }
-
- static String getSupportedByProductName(String value) {
-// System.out.println("==== Look for platform by product " + value);
- String lower = value.toLowerCase();
-
- if (lower.indexOf(Supported.MSSQL) >= 0) {
- return Supported.MSSQL;
- } else if (lower.indexOf(Supported.DB2) >= 0) {
- return Supported.DB2;
- } else if (lower.indexOf(Supported.ORACLE) >= 0) {
- return Supported.ORACLE;
- } else if (lower.indexOf(Supported.SYBASE) >= 0) {
- return Supported.SYBASE;
- } else if (lower.indexOf(Supported.INFORMIX) >= 0) {
- return Supported.INFORMIX;
- } else if (lower.indexOf(Supported.METAMATRIX) >= 0) {
- return Supported.METAMATRIX;
- } else if (lower.indexOf(Supported.DERBY) >= 0) {
- return Supported.DERBY;
- } else if (lower.indexOf(Supported.POSTGRES) >= 0) {
- return Supported.POSTGRES;
- } else if (lower.indexOf(Supported.MYSQL) >= 0) {
- return Supported.MYSQL;
- }
-
- return Supported.DEFAULT;
-
- }
-
- static String getPlatformClass(String supported) {
- String platformClass = (String) classMap.get(supported);
- if (platformClass == null) {
- platformClass = (String) classMap.get(Supported.DEFAULT);
- }
- return platformClass;
-
- }
-}
Deleted: trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.jdbc;
-
-import java.util.List;
-
-import com.metamatrix.core.util.StringUtil;
-
-
-/**
- * @since 4.3
- */
-public class JDBCURL {
-
- private static final String DELIMITER_AT = "@";//$NON-NLS-1$
- private static final String DELIMITER_FORWARDSLASH = "//"; //$NON-NLS-1$
- private static final String JDBC_PROTOCOL = "jdbc:"; //$NON-NLS-1$
-
- private String connectionURL;
- private String protocol;
- private String databaseInfo;
-
- public JDBCURL(String jdbcURL) {
- parseURL(jdbcURL);
- connectionURL = jdbcURL;
- }
-
-
- public String getConnectionURL() {
- return connectionURL;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public String getDataConnectionInfo() {
- return databaseInfo;
- }
-
-
- private void parseURL(String jdbcURL) {
- if (jdbcURL == null) {
- throw new IllegalArgumentException();
- }
- // Trim extra spaces
- jdbcURL = jdbcURL.trim();
- if (jdbcURL.length() == 0) {
- throw new IllegalArgumentException();
- }
-
- int delimiter = jdbcURL.indexOf(DELIMITER_AT);
- if (delimiter > 0) {
- parseWithAt(jdbcURL);
- } else {
- parseForSlash(jdbcURL);
- }
-
-
- }
-
- private void parseForSlash(String jdbcURL) {
-
- parseOnDelimiter(jdbcURL, DELIMITER_FORWARDSLASH);
- }
- private void parseOnDelimiter(String jdbcURL, String delim) {
- List urlParts = StringUtil.splitOnEntireString(jdbcURL, delim);
- // String[] urlParts = split(jdbcURL, DELIMITER_FORWARDSLASH);
- if (urlParts.size() != 2) {
- throw new IllegalArgumentException();
- }
- parseJDBCProtocol((String) urlParts.get(0));
- parseConnectionPart((String)urlParts.get(1));
- }
-
- private void parseWithAt(String jdbcURL) {
- parseOnDelimiter(jdbcURL, DELIMITER_AT);
- }
-
- private void parseJDBCProtocol(String protocolurl) {
- if (!protocolurl.startsWith(JDBC_PROTOCOL)) {
- throw new IllegalArgumentException();
- }
- if (protocolurl.length() == JDBC_PROTOCOL.length()) {
- throw new IllegalArgumentException();
- }
- protocol = protocolurl.substring(JDBC_PROTOCOL.length());
- }
-
- private void parseConnectionPart(String connectionInfo) {
- databaseInfo = connectionInfo;
-
- }
-
- public String getJDBCURL() {
- return connectionURL;
- }
-
- public String toString() {
- return getJDBCURL();
- }
-
-
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -32,6 +32,7 @@
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
+import com.metamatrix.common.jdbc.JDBCPlatform;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.util.DateUtil;
@@ -160,7 +161,7 @@
private int maxExceptionLength = DEFAULT_MAX_EXCEPTION_LENGTH;
private Properties connProps;
- private StringBuffer insertStr;
+ private String insert;
private boolean shutdown = false;
@@ -223,30 +224,7 @@
// ignore and use default
}
- // construct the insert string
- insertStr = new StringBuffer(INSERT_INTO);
- insertStr.append(getTableName(connProps));
- insertStr.append(LEFT_PAREN);
- insertStr.append( ColumnName.TIMESTAMP );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.SEQUENCE_NUMBER );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.CONTEXT );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.LEVEL );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.MESSAGE );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.HOST );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.VM );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.THREAD );
- insertStr.append(COMMA);
- insertStr.append( '"'+ ColumnName.EXCEPTION +'"' );
- insertStr.append(VALUES);
}
-
public synchronized void logMessage(LogMessage msg) {
write(msg);
@@ -275,6 +253,36 @@
}
}
+ private String getInsertStr(Connection c) throws SQLException {
+ if (this.insert == null) {
+ // construct the insert string
+ StringBuffer insertStr = new StringBuffer(INSERT_INTO);
+ insertStr.append(getTableName(connProps));
+ insertStr.append(LEFT_PAREN);
+ insertStr.append( ColumnName.TIMESTAMP );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.SEQUENCE_NUMBER );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.CONTEXT );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.LEVEL );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.MESSAGE );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.HOST );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.VM );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.THREAD );
+ insertStr.append(COMMA);
+ String quote = JDBCPlatform.getIdentifierQuoteString(c);
+ insertStr.append( quote+ ColumnName.EXCEPTION +quote );
+ insertStr.append(VALUES);
+ this.insert = insertStr.toString();
+ }
+ return this.insert;
+ }
+
private void printMsg(LogMessage message) throws SQLException {
if (this.shutdown) {
return;
@@ -289,7 +297,7 @@
PreparedStatement stmt = null;
try {
connection = JDBCConnectionPoolHelper.getInstance().getConnection();
- stmt = connection.prepareStatement(insertStr.toString());
+ stmt = connection.prepareStatement(getInsertStr(connection));
// Add values to Prepared statement
Modified: trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -33,8 +33,6 @@
import com.metamatrix.common.connection.ManagedConnection;
import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.connection.jdbc.JDBCMgdResourceConnection;
-import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.DateUtil;
@@ -56,10 +54,9 @@
public class JDBCConnector extends BaseTransaction implements MetaBaseConnector {
- private static String IS_TRUE = "1";
- private static String IS_FALSE = "0";
+ private static String IS_TRUE = "1"; //$NON-NLS-1$
+ private static String IS_FALSE = "0"; //$NON-NLS-1$
private Connection jdbcConnection;
- private JDBCPlatform platform;
/**
* Create a new instance of a transaction for a managed connection.
* @param connection the connection that should be used and that was created using this
@@ -74,12 +71,10 @@
JDBCMgdResourceConnection jdbcManagedConnection = (JDBCMgdResourceConnection) connection;
this.jdbcConnection = jdbcManagedConnection.getConnection();
- platform = JDBCPlatformFactory.getPlatform(jdbcConnection);
} catch ( Exception e ) {
throw new ManagedConnectionException(ErrorMessageKeys.JDBCC_0002, RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0002, JDBCMgdResourceConnection.class.getName() ) );
}
- JDBCRuntimeMetadataReader.setJDBCPlatform(this.platform);
}
/**
@@ -192,7 +187,7 @@
if (statement.executeUpdate() != 1) {
throw new VirtualDatabaseException(ErrorMessageKeys.JDBCC_0009, RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0009) );
}
- LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new Object[]{"Inserted Model with DBID ",new Long(modelID.getUID())});
+ LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new Object[]{"Inserted Model with DBID ",new Long(modelID.getUID())}); //$NON-NLS-1$
// Properties prop;
@@ -203,16 +198,16 @@
}catch (SQLException se){
BasicModelID modelID = (BasicModelID)model.getID();
- sql = StringUtil.replace(sql, "?", Long.toString(modelID.getUID()) );
- sql = StringUtil.replace(sql, "?", model.getName());
- sql = StringUtil.replace(sql, "?", ((ModelID)model.getID()).getVersion());
- sql = StringUtil.replace(sql, "?", (adjustLengthToFit(model.getDescription())==null?"NULL" : adjustLengthToFit(model.getDescription())));
- sql = StringUtil.replace(sql, "?", (model.isPhysical()? IS_TRUE : IS_FALSE));
- sql = StringUtil.replace(sql, "?", (model.isMultiSourceBindingEnabled()? IS_TRUE : IS_FALSE));
- sql = StringUtil.replace(sql, "?", (model.isVisible()? IS_TRUE : IS_FALSE));
- sql = StringUtil.replace(sql, "?", ((BasicModelID)model.getID()).getUuid());
- sql = StringUtil.replace(sql, "?", Integer.toString(model.getModelType()));
- sql = StringUtil.replace(sql, "?", model.getModelURI());
+ sql = StringUtil.replace(sql, "?", Long.toString(modelID.getUID()) ); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", model.getName()); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", ((ModelID)model.getID()).getVersion()); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", (adjustLengthToFit(model.getDescription())==null?"NULL" : adjustLengthToFit(model.getDescription()))); //$NON-NLS-1$ //$NON-NLS-2$
+ sql = StringUtil.replace(sql, "?", (model.isPhysical()? IS_TRUE : IS_FALSE)); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", (model.isMultiSourceBindingEnabled()? IS_TRUE : IS_FALSE)); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", (model.isVisible()? IS_TRUE : IS_FALSE)); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", ((BasicModelID)model.getID()).getUuid()); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", Integer.toString(model.getModelType())); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", model.getModelURI()); //$NON-NLS-1$
throw new VirtualDatabaseException(se, ErrorMessageKeys.JDBCC_0003, RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0003, sql) );
}finally {
@@ -255,7 +250,7 @@
if (statement.executeUpdate() != 1) {
throw new VirtualDatabaseException(ErrorMessageKeys.JDBCC_0023, RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0023, vdb.getName() ) );
}
- LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new Object[]{"Inserted VirtualDatabase with DBID ",new Long(((BasicVirtualDatabaseID)vdb.getID()).getUID())});
+ LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new Object[]{"Inserted VirtualDatabase with DBID ",new Long(((BasicVirtualDatabaseID)vdb.getID()).getUID())}); //$NON-NLS-1$
}catch (SQLException se){
throw new VirtualDatabaseException(se, ErrorMessageKeys.JDBCC_0003, RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0003, sql) );
@@ -365,7 +360,7 @@
I18nLogManager.logError(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA, ErrorMessageKeys.GEN_0008, e);
}
- LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA, "" + lines + " rows deleted.");
+ LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA, "" + lines + " rows deleted."); //$NON-NLS-1$ //$NON-NLS-2$
}
private String adjustLengthToFit(String oriString){
Modified: trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -35,8 +35,6 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.syntax.ExpressionOperator;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.CorePlugin;
@@ -62,12 +60,6 @@
// private static String IS_FALSE = "0";
// private static int MAX_COLUMN_WIDTH = 255;
- private static JDBCPlatform platform;
-
- public static void setJDBCPlatform(JDBCPlatform jdbcPlatform) {
- platform = jdbcPlatform;
- }
-
/**
* returns the <code>VirtualDatabase</code> based on the virtual database id.
* @param virtualDatabaseID is the VirtualDatabase to be returned.
@@ -342,31 +334,26 @@
return result;
}
-
protected static VirtualDatabaseID getVirtualDatabaseID(String fullName, String version, boolean isActive, Connection jdbcConnection) throws VirtualDatabaseDoesNotExistException, VirtualDatabaseException {
PreparedStatement statement = null;
String sql = null;
VirtualDatabaseID result = null;
- String uVdbName = platform.getOperator(ExpressionOperator.ToUpperCase).buildExpression(JDBCNames.VirtualDatabases.ColumnName.VDB_NM);
int nParms = 2;
try{
if(isActive){
if(version == null){
- sql = replace(JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID_LV, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
- sql = replace(sql, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
- sql = replace(sql, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
+ sql = JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID_LV;
nParms = 3;
}else{
- sql = replace(JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
+ sql = JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID;
}
}else{
if(version == null){
- sql = replace(JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID_LV, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
- sql = replace(sql, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
+ sql = JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID_LV;
}else
- sql = replace(JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID, JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
+ sql = JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID;
}
statement = jdbcConnection.prepareStatement(sql);
statement.setString(1, fullName.toUpperCase());
Modified: trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -52,32 +52,30 @@
public static long NA_LONG = 0;
public static int NA_INT = 0;
public static short NA_SHORT = 0;
- public static String PLATFORM_DEPENDENT_MARK = "??";
+ private static String IS_TRUE = "1"; //$NON-NLS-1$
- private static String IS_TRUE = "1";
-
// private static final String DELIMITER = ".";
// private static final String BLANK = MetadataConstants.BLANK;
- private static final String MAX = "MAX";
- private static final String INSERT = JDBCReservedWords.INSERT + " ";
- private static final String UPDATE = JDBCReservedWords.UPDATE + " ";
- private static final String DELETE = JDBCReservedWords.DELETE + " ";
- private static final String SELECT = JDBCReservedWords.SELECT + " ";
- private static final String FROM = " " + JDBCReservedWords.FROM + " ";
- private static final String WHERE = " " + JDBCReservedWords.WHERE + " ";
+ private static final String MAX = "MAX"; //$NON-NLS-1$
+ private static final String INSERT = JDBCReservedWords.INSERT + " "; //$NON-NLS-1$
+ private static final String UPDATE = JDBCReservedWords.UPDATE + " "; //$NON-NLS-1$
+ private static final String DELETE = JDBCReservedWords.DELETE + " "; //$NON-NLS-1$
+ private static final String SELECT = JDBCReservedWords.SELECT + " "; //$NON-NLS-1$
+ private static final String FROM = " " + JDBCReservedWords.FROM + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String WHERE = " " + JDBCReservedWords.WHERE + " "; //$NON-NLS-1$ //$NON-NLS-2$
// private static final String LIKE = " " + JDBCReservedWords.LIKE + " ";
- private static final String ORDER_BY = " " + JDBCReservedWords.ORDER_BY + " ";
- private static final String SET = " " + JDBCReservedWords.SET + " ";
+ private static final String ORDER_BY = " " + JDBCReservedWords.ORDER_BY + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String SET = " " + JDBCReservedWords.SET + " "; //$NON-NLS-1$ //$NON-NLS-2$
// private static final String ON = " " + JDBCReservedWords.ON + " ";
- private static final String INTO = " " + JDBCReservedWords.INTO + " ";
- private static final String DISTINCT = " " + JDBCReservedWords.DISTINCT + " ";
- private static final String VALUES = " " + JDBCReservedWords.VALUES + " ";
- private static final String AND = " " + JDBCReservedWords.AND + " ";
- private static final String IN = " " + JDBCReservedWords.IN + " ";
- private static final String NOT_IN = " " + JDBCReservedWords.NOT + " " + JDBCReservedWords.IN + " ";
- private static final String OR = " " + JDBCReservedWords.OR + " ";
+ private static final String INTO = " " + JDBCReservedWords.INTO + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String DISTINCT = " " + JDBCReservedWords.DISTINCT + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String VALUES = " " + JDBCReservedWords.VALUES + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String AND = " " + JDBCReservedWords.AND + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String IN = " " + JDBCReservedWords.IN + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String NOT_IN = " " + JDBCReservedWords.NOT + " " + JDBCReservedWords.IN + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String OR = " " + JDBCReservedWords.OR + " "; //$NON-NLS-1$ //$NON-NLS-2$
// private static final String IS = " " + JDBCReservedWords.IS + " ";
// private static final String IS_NOT_NULL = IS + " " + JDBCReservedWords.NOT + " " + JDBCReservedWords.NULL;
@@ -89,87 +87,87 @@
// ---------------------------------------------------------------------------------
//select IDs
public static final String SELECT_ACTIVE_VIRTUAL_DATABASE_ID
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$ //$NON-NLS-2$
+ AND
- + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?"
- + AND + "(" + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE
- + OR + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE_DEFAULT
- + ")";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?" //$NON-NLS-1$
+ + AND + "(" + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE //$NON-NLS-1$ //$NON-NLS-2$
+ + OR + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE_DEFAULT //$NON-NLS-1$
+ + ")"; //$NON-NLS-1$
public static final String SELECT_VIRTUAL_DATABASE_ID
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$ //$NON-NLS-2$
+ AND
- + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?"; //$NON-NLS-1$
public static final String SELECT_ACTIVE_VIRTUAL_DATABASE_ID_LV
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
- + AND + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=("
- + SELECT + MAX + "("
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")"
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$ //$NON-NLS-2$
+ + AND + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=(" //$NON-NLS-1$
+ + SELECT + MAX + "(" //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")" //$NON-NLS-1$
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$ //$NON-NLS-2$
+ AND
- + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "="
- + "(" + SELECT + MAX + "(" + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + ")"
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" //$NON-NLS-1$
+ + "(" + SELECT + MAX + "(" + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + ")" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
- + AND + "(" + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE
- + OR + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE_DEFAULT
- +")))";
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$ //$NON-NLS-2$
+ + AND + "(" + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE //$NON-NLS-1$ //$NON-NLS-2$
+ + OR + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE_DEFAULT //$NON-NLS-1$
+ +")))"; //$NON-NLS-1$
public static final String SELECT_VIRTUAL_DATABASE_ID_LV
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
- + AND + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=("
- + SELECT + MAX + "("
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")"
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$ //$NON-NLS-2$
+ + AND + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=(" //$NON-NLS-1$
+ + SELECT + MAX + "(" //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")" //$NON-NLS-1$
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?)";
+ + "{fn ucase(" +JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?"; //$NON-NLS-1$ //$NON-NLS-2$
//select objects
public static final String SELECT_VIRTUAL_DATABASES
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + ","
- + JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +","
- + JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +","
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +","
- + JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +","
- + JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+","
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+","
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+"," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME;
@@ -181,189 +179,189 @@
+ FROM
+ JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
public static final String SELECT_DELETED_VIRTUAL_DATABASES
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + ","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_UID
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=4";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=4"; //$NON-NLS-1$
public static final String SELECT_VIRTUAL_DATABASE
- = SELECT + JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + ","
- + JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +","
- + JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +","
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +","
- + JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +","
- + JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+","
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+","
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + ","
+ = SELECT + JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
public static final String SELECT_MODELS
- = SELECT + JDBCNames.VDBModels.TABLE_NAME + "."
- + JDBCNames.Models.ColumnName.MDL_UID +","
- + JDBCNames.Models.ColumnName.MDL_NM +","
- + JDBCNames.Models.ColumnName.MDL_VERSION +","
- + JDBCNames.Models.ColumnName.MDL_UUID +","
- + JDBCNames.Models.ColumnName.MDL_TYPE +","
- + JDBCNames.Models.ColumnName.MDL_URI +","
- + JDBCNames.Models.ColumnName.DESCRIPTION +","
- + JDBCNames.Models.ColumnName.IS_PHYSICAL +","
- + JDBCNames.Models.ColumnName.MULTI_SOURCED +","
- + JDBCNames.Models.ColumnName.VISIBILITY +","
+ = SELECT + JDBCNames.VDBModels.TABLE_NAME + "." //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UID +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UUID +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_TYPE +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_URI +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.DESCRIPTION +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.IS_PHYSICAL +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MULTI_SOURCED +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.VISIBILITY +"," //$NON-NLS-1$
+ JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM
- + FROM + JDBCNames.Models.TABLE_NAME + ","
+ + FROM + JDBCNames.Models.TABLE_NAME + "," //$NON-NLS-1$
+ JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.TABLE_NAME + "."
- + JDBCNames.VDBModels.ColumnName.MDL_UID + "="
- + JDBCNames.Models.TABLE_NAME + "."
+ + JDBCNames.VDBModels.TABLE_NAME + "." //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "=" //$NON-NLS-1$
+ + JDBCNames.Models.TABLE_NAME + "." //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UID
+ AND
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?" //$NON-NLS-1$
+ ORDER_BY
+ JDBCNames.Models.ColumnName.MDL_NM
;
public static final String SELECT_MODEL_IDS
- = SELECT + JDBCNames.Models.ColumnName.MDL_UID +","
- + JDBCNames.Models.ColumnName.MDL_VERSION +","
- + JDBCNames.Models.ColumnName.MDL_NM +","
+ = SELECT + JDBCNames.Models.ColumnName.MDL_UID +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM +"," //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UUID
+ FROM + JDBCNames.Models.TABLE_NAME;
public static final String SELECT_MODEL_IDS_ONLY_IN_VDB
- = SELECT + JDBCNames.Models.TABLE_NAME + "."
- + JDBCNames.Models.ColumnName.MDL_UID +","
- + JDBCNames.Models.ColumnName.MDL_VERSION +","
- + JDBCNames.Models.ColumnName.MDL_NM +","
+ = SELECT + JDBCNames.Models.TABLE_NAME + "." //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UID +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM +"," //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UUID
+ FROM + JDBCNames.Models.TABLE_NAME
+ WHERE
+ JDBCNames.Models.ColumnName.MDL_UID
- + NOT_IN +"("
- + SELECT + JDBCNames.Models.TABLE_NAME + "."
+ + NOT_IN +"(" //$NON-NLS-1$
+ + SELECT + JDBCNames.Models.TABLE_NAME + "." //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UID
- + FROM + JDBCNames.Models.TABLE_NAME + ","
+ + FROM + JDBCNames.Models.TABLE_NAME + "," //$NON-NLS-1$
+ JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.TABLE_NAME + "."
- + JDBCNames.VDBModels.ColumnName.MDL_UID + "="
- + JDBCNames.Models.TABLE_NAME + "."
+ + JDBCNames.VDBModels.TABLE_NAME + "." //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "=" //$NON-NLS-1$
+ + JDBCNames.Models.TABLE_NAME + "." //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UID
+ AND
- + JDBCNames.VDBModels.ColumnName.VDB_UID + " !=?)";
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + " !=?)"; //$NON-NLS-1$
//a special one
public static final String SELECT_PROPERTIES
- = SELECT + JDBCNames.VCommonProperties.ColumnName.PRP_NM + ","
+ = SELECT + JDBCNames.VCommonProperties.ColumnName.PRP_NM + "," //$NON-NLS-1$
+ JDBCNames.VCommonProperties.ColumnName.PRP_VL
- + FROM + "?"
+ + FROM + "?" //$NON-NLS-1$
+ WHERE
- + "="
+ + "=" //$NON-NLS-1$
+ AND
- + "?=?"
+ + "?=?" //$NON-NLS-1$
+ ORDER_BY
- + JDBCNames.VCommonProperties.ColumnName.PRP_NM + ","
+ + JDBCNames.VCommonProperties.ColumnName.PRP_NM + "," //$NON-NLS-1$
+ JDBCNames.VCommonProperties.ColumnName.PART_ID;
//insert statement
public static final String INSERT_VIRTUAL_DATABASE
- = INSERT + INTO + JDBCNames.VirtualDatabases.TABLE_NAME + "("
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
- + JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + ","
- + JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +","
- + JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +","
- + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +","
- + JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +","
- + JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+","
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+","
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME + ")"
+ = INSERT + INTO + JDBCNames.VirtualDatabases.TABLE_NAME + "(" //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+"," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; //$NON-NLS-1$
public static final String INSERT_MODELS
- = INSERT + INTO + JDBCNames.Models.TABLE_NAME + "("
- + JDBCNames.Models.ColumnName.MDL_UID +","
- + JDBCNames.Models.ColumnName.MDL_NM +","
- + JDBCNames.Models.ColumnName.MDL_VERSION +","
- + JDBCNames.Models.ColumnName.DESCRIPTION +","
- + JDBCNames.Models.ColumnName.IS_PHYSICAL +","
- + JDBCNames.Models.ColumnName.MULTI_SOURCED +","
- + JDBCNames.Models.ColumnName.VISIBILITY +","
- + JDBCNames.Models.ColumnName.MDL_UUID +","
- + JDBCNames.Models.ColumnName.MDL_TYPE +","
- + JDBCNames.Models.ColumnName.MDL_URI + ")"
+ = INSERT + INTO + JDBCNames.Models.TABLE_NAME + "(" //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UID +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.DESCRIPTION +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.IS_PHYSICAL +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MULTI_SOURCED +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.VISIBILITY +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UUID +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_TYPE +"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_URI + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?,?,?,?,?,?,?,?)";
+ + "(?,?,?,?,?,?,?,?,?,?)"; //$NON-NLS-1$
public static final String INSERT_VDB_MODELS
- = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME + "("
- + JDBCNames.VDBModels.ColumnName.VDB_UID + ","
- + JDBCNames.VDBModels.ColumnName.MDL_UID + ")"
+ = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME + "(" //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?)";
+ + "(?,?)"; //$NON-NLS-1$
public static final String INSERT_VDB_MODELS_WITH_BINDING
- = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME + "("
- + JDBCNames.VDBModels.ColumnName.VDB_UID + ","
- + JDBCNames.VDBModels.ColumnName.MDL_UID + ","
- + JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM + ")"
+ = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME + "(" //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "," //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?)";
+ + "(?,?,?)"; //$NON-NLS-1$
public static final String INSERT_PROP_NAMES
- = INSERT + INTO + "?" + "("
- + JDBCNames.VCommonProperties.ColumnName.PRP_UID + ","
- + "?," + JDBCNames.VCommonProperties.ColumnName.PRP_NM + ")"
+ = INSERT + INTO + "?" + "(" //$NON-NLS-1$ //$NON-NLS-2$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_UID + "," //$NON-NLS-1$
+ + "?," + JDBCNames.VCommonProperties.ColumnName.PRP_NM + ")" //$NON-NLS-1$ //$NON-NLS-2$
+ VALUES
- + "(?,?,?)";
+ + "(?,?,?)"; //$NON-NLS-1$
public static final String INSERT_PROP_VALUES
- = INSERT + INTO + "?" + "("
- + JDBCNames.VCommonProperties.ColumnName.PRP_UID + ","
- + JDBCNames.VCommonProperties.ColumnName.PART_ID + ","
- + JDBCNames.VCommonProperties.ColumnName.PRP_VL + ")"
+ = INSERT + INTO + "?" + "(" //$NON-NLS-1$ //$NON-NLS-2$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_UID + "," //$NON-NLS-1$
+ + JDBCNames.VCommonProperties.ColumnName.PART_ID + "," //$NON-NLS-1$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_VL + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?)";
+ + "(?,?,?)"; //$NON-NLS-1$
//update statement
public static final String UPDATE_SET_STATUS
= UPDATE + JDBCNames.VirtualDatabases.TABLE_NAME
+ SET
- + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=?,"
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?,"
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?"
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=?," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
public static final String UPDATE_CONNECTOR_BINGING_NAME
= UPDATE + JDBCNames.VDBModels.TABLE_NAME
+ SET
- + JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM + "=?"
+ + JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?" //$NON-NLS-1$
+ AND
- + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?";
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?"; //$NON-NLS-1$
// public static final String UPDATE_VISIBILITY_LEVELS
// = UPDATE + JDBCNames.VDBModels.TABLE_NAME
@@ -377,33 +375,33 @@
public static final String UPDATE_VDB
= UPDATE + JDBCNames.VirtualDatabases.TABLE_NAME
+ SET
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?,"
- + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?"
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
public static final String UPDATE_VDB_VERSION
= UPDATE + JDBCNames.VirtualDatabases.TABLE_NAME
+ SET
- + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?"
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
public static final String UPDATE_VDB_MODELS
= UPDATE + JDBCNames.VDBModels.TABLE_NAME
+ SET
- + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?"
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?" //$NON-NLS-1$
+ AND
- + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?";
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?"; //$NON-NLS-1$
public static final String UPDATE_MODEL_NAME
= UPDATE + JDBCNames.Models.TABLE_NAME
+ SET
- + JDBCNames.Models.ColumnName.MDL_NM + "=?"
+ + JDBCNames.Models.ColumnName.MDL_NM + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.Models.ColumnName.MDL_UID + "=?";
+ + JDBCNames.Models.ColumnName.MDL_UID + "=?"; //$NON-NLS-1$
@@ -411,41 +409,41 @@
= DELETE + FROM + JDBCNames.ModelPropValues.TABLE_NAME
+ WHERE
+ JDBCNames.ModelPropValues.ColumnName.PRP_UID
- + IN + "("
+ + IN + "(" //$NON-NLS-1$
+ SELECT
+ JDBCNames.ModelPropValues.ColumnName.PRP_UID
+ FROM
+ JDBCNames.ModelPropNames.TABLE_NAME
+ WHERE
- + JDBCNames.ModelPropNames.ColumnName.MDL_UID +"=?)";
+ + JDBCNames.ModelPropNames.ColumnName.MDL_UID +"=?)"; //$NON-NLS-1$
public static final String DELETE_MODEL_PROP_NMS
= DELETE + FROM + JDBCNames.ModelPropNames.TABLE_NAME
+ WHERE
- + JDBCNames.ModelPropNames.ColumnName.MDL_UID + "=?";
+ + JDBCNames.ModelPropNames.ColumnName.MDL_UID + "=?"; //$NON-NLS-1$
public static final String DELETE_VDB_MODELS
= DELETE + FROM + JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
public static final String DELETE_VDB_MODEL
= DELETE + FROM + JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "=?" //$NON-NLS-1$
+ AND
- + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?";
+ + JDBCNames.VDBModels.ColumnName.MDL_UID + "=?"; //$NON-NLS-1$
public static final String DELETE_MODEL
= DELETE + FROM + JDBCNames.Models.TABLE_NAME
+ WHERE
- + JDBCNames.Models.ColumnName.MDL_UID + "=?";
+ + JDBCNames.Models.ColumnName.MDL_UID + "=?"; //$NON-NLS-1$
public static final String DELETE_VDB
= DELETE + FROM + JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "=?"; //$NON-NLS-1$
@@ -639,20 +637,20 @@
int i;
if(id instanceof ModelID){
- i = sql.indexOf("?");
+ i = sql.indexOf("?"); //$NON-NLS-1$
if(queryID == 1){
sql = sql.substring(0,i) + JDBCNames.VModelProperties.TABLE_NAME + sql.substring(i+1);
- int j = sql.indexOf("=");
- sql = sql.substring(0,j) + JDBCNames.ModelPropNames.TABLE_NAME + "."
- + JDBCNames.VCommonProperties.ColumnName.PRP_UID + "="
- + JDBCNames.ModelPropValues.TABLE_NAME + "."
+ int j = sql.indexOf("="); //$NON-NLS-1$
+ sql = sql.substring(0,j) + JDBCNames.ModelPropNames.TABLE_NAME + "." //$NON-NLS-1$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_UID + "=" //$NON-NLS-1$
+ + JDBCNames.ModelPropValues.TABLE_NAME + "." //$NON-NLS-1$
+ JDBCNames.VCommonProperties.ColumnName.PRP_UID + sql.substring(j+1);
}else if(queryID ==2)
sql = sql.substring(0,i) + JDBCNames.ModelPropNames.TABLE_NAME + sql.substring(i+1);
else
sql = sql.substring(0,i) + JDBCNames.ModelPropValues.TABLE_NAME + sql.substring(i+1);
if(queryID != 3){
- i = sql.indexOf("?");
+ i = sql.indexOf("?"); //$NON-NLS-1$
sql = sql.substring(0,i) + JDBCNames.VModelProperties.ColumnName.MDL_UID + sql.substring(i+1);
}
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -11,6 +11,7 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
import com.metamatrix.common.connection.ManagedConnectionException;
+import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.common.extensionmodule.ExtensionModuleTypes;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.extensionmodule.spi.ExtensionModuleTransaction;
@@ -113,12 +114,12 @@
boolean inUse = trans.isNameInUse(model.getConfigurationID().getFullName());
if (inUse) {
- trans.setSource(principal, model.getConfigurationID().getFullName(), data, data.length);
+ trans.setSource(principal, model.getConfigurationID().getFullName(), data, ExtensionModuleManager.getChecksum(data));
} else {
trans.addSource(principal, ExtensionModuleTypes.CONFIGURATION_MODEL_TYPE,
model.getConfigurationID().getFullName(),
data,
- data.length,
+ ExtensionModuleManager.getChecksum(data),
model.getConfigurationID().getFullName() + " Configuration Model", //$NON-NLS-1$
true);
Modified: trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java 2009-04-03 01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java 2009-04-03 01:38:17 UTC (rev 698)
@@ -36,10 +36,9 @@
import com.metamatrix.admin.api.objects.AdminOptions;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
+import com.metamatrix.common.jdbc.JDBCPlatform.Supported;
import com.metamatrix.common.tree.basic.BasicTreeNode;
import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -836,26 +835,23 @@
// Example: jdbc:mmx:oracle://host:port;SID=sid
if ( url != null ) {
- try {
- JDBCPlatform platform = JDBCPlatformFactory.getPlatform(url, driver);
- if (platform != null) {
- if (platform.isDB2()) {
- return DatabaseDialect.DB2.getType().toLowerCase();
- } else if (platform.isOracle()) {
- return DatabaseDialect.ORACLE.getType().toLowerCase();
- } else if (platform.isSybase()) {
- return DatabaseDialect.SYBASE.getType().toLowerCase();
- } else if (platform.isMSSQL()) {
- return DatabaseDialect.SQL_SERVER.getType().toLowerCase();
- } else if (platform.isMYSQL()) {
- return DatabaseDialect.MYSQL.getType().toLowerCase();
- }
- }
- } catch (MetaMatrixException err) {
- err.printStackTrace();
+ Supported supported = JDBCPlatform.getSupportedByProtocol(url);
+ if (supported != null) {
+ switch (supported) {
+ case DB2:
+ return DatabaseDialect.DB2.getType().toLowerCase();
+ case MM_ORACLE:
+ case ORACLE:
+ return DatabaseDialect.ORACLE.getType().toLowerCase();
+ case SYBASE:
+ return DatabaseDialect.SYBASE.getType().toLowerCase();
+ case MSSQL:
+ return DatabaseDialect.SQL_SERVER.getType().toLowerCase();
+ case MYSQL:
+ return DatabaseDialect.MYSQL.getType().toLowerCase();
+ }
}
-
Object[] urlParts = StringUtil.split(url, ":").toArray(); //$NON-NLS-1$
if (urlParts.length >= 3) {
15 years, 8 months
teiid SVN: r697 - in trunk: client/src/main/java/com/metamatrix/common/comm/platform/socket and 12 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-02 21:31:23 -0400 (Thu, 02 Apr 2009)
New Revision: 697
Added:
trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java
trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectInputStreamWithClassloader.java
trunk/common-core/src/test/java/com/metamatrix/api/exception/TestExceptionHolder.java
trunk/common-core/src/test/resources/test.jar
Removed:
trunk/client/src/main/java/com/metamatrix/common/comm/exception/ExceptionHolder.java
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectInputStreamWithClassloader.java
trunk/client/src/test/java/com/metamatrix/common/comm/exception/TestExceptionHolder.java
trunk/client/src/test/resources/test.jar
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
trunk/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java
trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties
trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java
trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java
Log:
TEIID-297: making changes to exception holder to be resilient to unknown classes in the class loader. This will send cause of exception along with original exception, and in case exception is was not able to construct in original form then the cause will be bubbled up, otherwise it will create one of exceptions in chain of its hierarchy. Reviewed by SH.
Deleted: trunk/client/src/main/java/com/metamatrix/common/comm/exception/ExceptionHolder.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/exception/ExceptionHolder.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/exception/ExceptionHolder.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -1,111 +0,0 @@
-package com.metamatrix.common.comm.exception;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import com.metamatrix.common.comm.platform.CommPlatformPlugin;
-import com.metamatrix.common.comm.platform.socket.ObjectInputStreamWithClassloader;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.ReflectionHelper;
-
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-public class ExceptionHolder implements Externalizable {
-
- private Throwable exception;
-
- public ExceptionHolder() {
- }
-
- public ExceptionHolder(Throwable exception) {
- this.exception = exception;
- }
-
- @Override
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- List<String> classNames = (List<String>)in.readObject();
- String message = (String)in.readObject();
- StackTraceElement[] stackTrace = (StackTraceElement[])in.readObject();
- byte[] serializedException = (byte[])in.readObject();
- ByteArrayInputStream bais = new ByteArrayInputStream(serializedException);
- ObjectInputStream ois = new ObjectInputStreamWithClassloader(bais, Thread.currentThread().getContextClassLoader());
- try {
- this.exception = (Throwable)ois.readObject();
- } catch (ClassNotFoundException e) {
- List<String> args = Arrays.asList(CommPlatformPlugin.Util.getString("ExceptionHolder.converted_exception", message, classNames)); //$NON-NLS-1$
-
- for (String className : classNames) {
- try {
- Throwable result = (Throwable)ReflectionHelper.create(className, args, Thread.currentThread().getContextClassLoader());
- result.initCause(e);
- result.setStackTrace(stackTrace);
- this.exception = result;
- break;
- } catch (MetaMatrixCoreException e1) {
- //
- }
- }
- if (this.exception == null) {
- throw new MetaMatrixRuntimeException(exception, args.get(0));
- }
- }
- }
-
- @Override
- public void writeExternal(ObjectOutput out) throws IOException {
- List<String> classNames = new ArrayList<String>();
- Class<?> clazz = exception.getClass();
- while (clazz != null) {
- if (clazz == Throwable.class || clazz == Exception.class) {
- break;
- }
- classNames.add(clazz.getName());
- clazz = clazz.getSuperclass();
- }
- out.writeObject(classNames);
- out.writeObject(exception.getMessage());
- out.writeObject(exception.getStackTrace());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(this.exception);
- oos.flush();
- oos.close();
- out.writeObject(baos.toByteArray());
- }
-
- public Throwable getException() {
- return exception;
- }
-
-}
Deleted: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectInputStreamWithClassloader.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectInputStreamWithClassloader.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectInputStreamWithClassloader.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.comm.platform.socket;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectStreamClass;
-
-public final class ObjectInputStreamWithClassloader extends
- ObjectInputStream {
- private final ClassLoader cl;
-
- public ObjectInputStreamWithClassloader(InputStream in,
- ClassLoader cl) throws IOException {
- super(in);
- this.cl = cl;
- }
-
- @Override
- protected Class<?> resolveClass(ObjectStreamClass desc)
- throws IOException, ClassNotFoundException {
- //see java bug id 6434149
- try {
- return Class.forName(desc.getName(), false, cl);
- } catch (ClassNotFoundException e) {
- return super.resolveClass(desc);
- }
- }
-}
\ No newline at end of file
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -44,12 +44,12 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.metamatrix.api.exception.ExceptionHolder;
import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.api.HostInfo;
import com.metamatrix.common.comm.api.Message;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.comm.exception.ExceptionHolder;
import com.metamatrix.common.comm.exception.SingleInstanceCommunicationException;
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
import com.metamatrix.common.comm.platform.socket.Handshake;
Modified: trunk/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -32,9 +32,9 @@
import java.util.List;
import java.util.Map;
+import com.metamatrix.api.exception.ExceptionHolder;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.batch.BatchSerializer;
-import com.metamatrix.common.comm.exception.ExceptionHolder;
import com.metamatrix.core.util.ExternalizeUtil;
/**
@@ -55,7 +55,7 @@
private MetaMatrixException exception;
/** Warning could be schema validation errors or partial results warnings */
- private List<Exception> warnings;
+ private List<Throwable> warnings;
/** Schemas associated with xml results. */
private Collection schemas;
@@ -262,7 +262,7 @@
/**
* @param list
*/
- public void setWarnings(List<Exception> list) {
+ public void setWarnings(List<Throwable> list) {
warnings = list;
}
@@ -346,10 +346,7 @@
}
List<ExceptionHolder> holderList = (List<ExceptionHolder>)in.readObject();
if (holderList != null) {
- this.warnings = new ArrayList<Exception>(holderList.size());
- for (ExceptionHolder exceptionHolder : holderList) {
- this.warnings.add((Exception)exceptionHolder.getException());
- }
+ this.warnings = ExceptionHolder.toThrowables(holderList);
}
//Schemas
@@ -389,11 +386,7 @@
out.writeObject(exception);
}
if (this.warnings != null) {
- List<ExceptionHolder> replcement = new ArrayList<ExceptionHolder>(this.warnings.size());
- for (Exception warning : warnings) {
- replcement.add(new ExceptionHolder(warning));
- }
- out.writeObject(replcement);
+ out.writeObject(ExceptionHolder.toExceptionHolders(this.warnings));
} else {
out.writeObject(this.warnings);
}
Modified: trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties
===================================================================
--- trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties 2009-04-03 01:31:23 UTC (rev 697)
@@ -115,8 +115,6 @@
SocketServerConnection.closed=Server connection is closed
-ExceptionHolder.converted_exception=Remote exception: {0} ... Original type hierarchy {1}.
-
SocketHelper.keystore_not_found=Key store ''{0}'' was not found.
MMURL.INVALID_FORMAT=The required url format is {0}
\ No newline at end of file
Deleted: trunk/client/src/test/java/com/metamatrix/common/comm/exception/TestExceptionHolder.java
===================================================================
--- trunk/client/src/test/java/com/metamatrix/common/comm/exception/TestExceptionHolder.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/client/src/test/java/com/metamatrix/common/comm/exception/TestExceptionHolder.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -1,43 +0,0 @@
-package com.metamatrix.common.comm.exception;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.URL;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.classloader.NonDelegatingClassLoader;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.core.util.UnitTestUtil;
-
-public class TestExceptionHolder {
-
- @SuppressWarnings("all")
- public static class BadException extends MetaMatrixProcessingException {
- private Object obj;
- public BadException(Object obj) {
- this.obj = obj;
- }
- }
-
- @Test public void testDeserializationUnknownException() throws Exception {
- ClassLoader cl = new NonDelegatingClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
- Object obj = ReflectionHelper.create("Test", null, cl); //$NON-NLS-1$
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(new ExceptionHolder(new BadException(obj)));
- oos.flush();
-
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
- ExceptionHolder holder = (ExceptionHolder)ois.readObject();
- assertTrue(holder.getException() instanceof MetaMatrixProcessingException);
- assertEquals("Remote exception: null ... Original type hierarchy [com.metamatrix.common.comm.exception.TestExceptionHolder$BadException, com.metamatrix.api.exception.MetaMatrixProcessingException, com.metamatrix.api.exception.MetaMatrixException, com.metamatrix.core.MetaMatrixCoreException].", holder.getException().getMessage()); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/client/src/test/resources/test.jar
===================================================================
(Binary files differ)
Copied: trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java (from rev 682, trunk/client/src/main/java/com/metamatrix/common/comm/exception/ExceptionHolder.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -0,0 +1,184 @@
+package com.metamatrix.api.exception;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import com.metamatrix.core.CorePlugin;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.ObjectInputStreamWithClassloader;
+import com.metamatrix.core.util.ReflectionHelper;
+
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+public class ExceptionHolder implements Externalizable {
+
+ private Throwable exception;
+ private boolean nested = false;
+
+ public ExceptionHolder() {
+ }
+
+ public ExceptionHolder(Throwable exception) {
+ this.exception = exception;
+ }
+
+ public ExceptionHolder(Throwable exception, boolean nested) {
+ this.exception = exception;
+ this.nested = nested;
+ }
+
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ List<String> classNames = (List<String>)in.readObject();;
+ String message = (String)in.readObject();
+ StackTraceElement[] stackTrace = (StackTraceElement[])in.readObject();
+ ExceptionHolder causeHolder = (ExceptionHolder)in.readObject();
+ byte[] serializedException = (byte[])in.readObject();
+
+ this.exception = readFromByteArray(serializedException);
+
+ if (this.exception == null) {
+ Throwable t = buildException(classNames, message, stackTrace);
+ if (t == null) {
+ if (causeHolder != null) {
+ this.exception = causeHolder.exception;
+ }
+ }
+ else {
+ if (causeHolder != null) {
+ t.initCause(causeHolder.exception);
+ }
+ this.exception = t;
+ }
+ }
+
+ if (this.exception == null) {
+ this.exception = new MetaMatrixRuntimeException(message);
+ this.exception.setStackTrace(stackTrace);
+ }
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ List<String> classNames = new ArrayList<String>();
+ Class<?> clazz = exception.getClass();
+ while (clazz != null) {
+ if (clazz == Throwable.class || clazz == Exception.class) {
+ break;
+ }
+ classNames.add(clazz.getName());
+ clazz = clazz.getSuperclass();
+ }
+ out.writeObject(classNames);
+ out.writeObject(exception.getMessage());
+ out.writeObject(exception.getStackTrace());
+
+ // specify that this cause is nested exception; not top level
+ if (this.exception.getCause() != null) {
+ out.writeObject(new ExceptionHolder(this.exception.getCause(), true));
+ }
+ else {
+ out.writeObject(null);
+ }
+
+ // only for the top level exception write the serialized block for the object
+ if (!nested) {
+ out.writeObject(writeAsByteArray(this.exception));
+ }
+ else {
+ out.writeObject(null);
+ }
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ private Throwable buildException(List<String> classNames, String message, StackTraceElement[] stackTrace) {
+ List<String> args = Arrays.asList(CorePlugin.Util.getString("ExceptionHolder.converted_exception", message, classNames)); //$NON-NLS-1$
+
+ Throwable result = null;
+ for (String className : classNames) {
+ try {
+ result = (Throwable)ReflectionHelper.create(className, args, Thread.currentThread().getContextClassLoader());
+ result.setStackTrace(stackTrace);
+ break;
+ } catch (MetaMatrixCoreException e1) {
+ //
+ }
+ }
+ return result;
+ }
+
+ private byte[] writeAsByteArray(Throwable t) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(t);
+ oos.flush();
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ private Throwable readFromByteArray(byte[] contents) throws IOException {
+ // only for top level we would have the contents as not null.
+ if (contents != null) {
+ ByteArrayInputStream bais = new ByteArrayInputStream(contents);
+ ObjectInputStream ois = new ObjectInputStreamWithClassloader(bais, Thread.currentThread().getContextClassLoader());
+ try {
+ return (Throwable)ois.readObject();
+ } catch (ClassNotFoundException e) {
+ //
+ }
+ }
+ return null;
+ }
+
+ public static List<ExceptionHolder> toExceptionHolders(List<? extends Throwable> throwables){
+ List<ExceptionHolder> list = new ArrayList();
+ for (Throwable t: throwables) {
+ list.add(new ExceptionHolder(t));
+ }
+ return list;
+ }
+
+ public static List<Throwable> toThrowables(List<ExceptionHolder> exceptionHolders) {
+ List<Throwable> list = new ArrayList();
+ for(ExceptionHolder e: exceptionHolders) {
+ list.add(e.getException());
+ }
+ return list;
+ }
+
+}
Modified: trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -22,27 +22,28 @@
package com.metamatrix.api.exception;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.*;
/**
* Exception that represents the occurrence of multiple exceptions.
*/
-public class MultipleException extends Exception {
- // =========================================================================
- // C O N S T R U C T O R S
- // =========================================================================
+public class MultipleException extends Exception implements Externalizable {
-// private int attribute1;
- /**
+ /**
*The set of Throwable instances that make up this exception
* @link aggregation
* @associates <b>java.lang.Throwable</b>
* @supplierCardinality 1..*
*/
- private List throwablesList = new ArrayList();
+ private List throwablesList = null;
/** An error code. */
private String code;
+
/** Construct a default instance of this class. */
public MultipleException() {
super();
@@ -139,5 +140,17 @@
public void setExceptions( Collection throwables ){
this.throwablesList = new ArrayList(throwables);
}
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
+ this.code = (String)in.readObject();
+ this.throwablesList = ExceptionHolder.toThrowables((List<ExceptionHolder>)in.readObject());
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(code);
+ out.writeObject(ExceptionHolder.toExceptionHolders(throwablesList));
+ }
}
Copied: trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectInputStreamWithClassloader.java (from rev 682, trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectInputStreamWithClassloader.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectInputStreamWithClassloader.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectInputStreamWithClassloader.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.core.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+
+public final class ObjectInputStreamWithClassloader extends
+ ObjectInputStream {
+ private final ClassLoader cl;
+
+ public ObjectInputStreamWithClassloader(InputStream in,
+ ClassLoader cl) throws IOException {
+ super(in);
+ this.cl = cl;
+ }
+
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc)
+ throws IOException, ClassNotFoundException {
+ //see java bug id 6434149
+ try {
+ return Class.forName(desc.getName(), false, cl);
+ } catch (ClassNotFoundException e) {
+ return super.resolveClass(desc);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectInputStreamWithClassloader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-04-03 01:31:23 UTC (rev 697)
@@ -406,3 +406,5 @@
ERR.003.030.0179=Unable to load the JDBC driver class {0}
ERR.003.030.0180=Driver {0} can not load {1}
ERR.003.030.0181=Failed to connect to the Database at {0} check connection properties.
+
+ExceptionHolder.converted_exception=Remote exception: {0} ... Original type hierarchy {1}.
Copied: trunk/common-core/src/test/java/com/metamatrix/api/exception/TestExceptionHolder.java (from rev 682, trunk/client/src/test/java/com/metamatrix/common/comm/exception/TestExceptionHolder.java)
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/api/exception/TestExceptionHolder.java (rev 0)
+++ trunk/common-core/src/test/java/com/metamatrix/api/exception/TestExceptionHolder.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -0,0 +1,98 @@
+package com.metamatrix.api.exception;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.ExceptionHolder;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.classloader.NonDelegatingClassLoader;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.ReflectionHelper;
+import com.metamatrix.core.util.UnitTestUtil;
+
+public class TestExceptionHolder {
+
+ @SuppressWarnings("all")
+ public static class BadException extends MetaMatrixProcessingException {
+ private Object obj;
+ public BadException(String msg) {super(msg);}
+ public BadException(Object obj) {
+ this.obj = obj;
+ }
+ }
+
+ @Test public void testDeserializationUnknownException() throws Exception {
+ ClassLoader cl = new NonDelegatingClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
+ Object obj = ReflectionHelper.create("test.Test", null, cl); //$NON-NLS-1$
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(new ExceptionHolder(new BadException(obj)));
+ oos.flush();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ ExceptionHolder holder = (ExceptionHolder)ois.readObject();
+ assertTrue(holder.getException() instanceof BadException);
+ assertEquals("Remote exception: null ... Original type hierarchy [com.metamatrix.api.exception.TestExceptionHolder$BadException, com.metamatrix.api.exception.MetaMatrixProcessingException, com.metamatrix.api.exception.MetaMatrixException, com.metamatrix.core.MetaMatrixCoreException].", holder.getException().getMessage()); //$NON-NLS-1$
+ }
+
+
+ @SuppressWarnings("all")
+ public static class BadException2 extends MetaMatrixProcessingException {
+ public BadException2(String msg) {
+ super(msg);
+ }
+ public BadException2(Throwable e, String msg) {
+ super(e, msg);
+ }
+ }
+
+ @Test public void testDeserializationUnknownChildException() throws Exception {
+ ClassLoader cl = new NonDelegatingClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
+ Exception obj = (Exception)ReflectionHelper.create("test.UnknownException", null, cl); //$NON-NLS-1$
+ obj.initCause(new SQLException("something bad happended")); //$NON-NLS-1$
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(new ExceptionHolder(new BadException2(obj, "I have foreign exception embedded in me"))); //$NON-NLS-1$
+ oos.flush();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ ExceptionHolder holder = (ExceptionHolder)ois.readObject();
+ Throwable e = holder.getException();
+ assertTrue(e instanceof BadException2);
+ assertEquals("Remote exception: I have foreign exception embedded in me ... Original type hierarchy [com.metamatrix.api.exception.TestExceptionHolder$BadException2, com.metamatrix.api.exception.MetaMatrixProcessingException, com.metamatrix.api.exception.MetaMatrixException, com.metamatrix.core.MetaMatrixCoreException].", e.getMessage()); //$NON-NLS-1$
+
+ // now unknown exception is not found, so promote known SQL exception up
+ e = e.getCause();
+ assertTrue(e instanceof SQLException);
+ assertEquals("Remote exception: something bad happended ... Original type hierarchy [java.sql.SQLException].", e.getMessage()); //$NON-NLS-1$
+ }
+
+ @Test public void testDeserializationUnknownChildException2() throws Exception {
+ ClassLoader cl = new NonDelegatingClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
+ ArrayList<String> args = new ArrayList<String>();
+ args.add("Unknown Exception"); //$NON-NLS-1$
+ Exception obj = (Exception)ReflectionHelper.create("test.UnknownException", args, cl); //$NON-NLS-1$
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(new ExceptionHolder(obj));
+ oos.flush();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ ExceptionHolder holder = (ExceptionHolder)ois.readObject();
+ Throwable e = holder.getException();
+ assertTrue(e instanceof MetaMatrixRuntimeException);
+ assertEquals("Unknown Exception", e.getMessage()); //$NON-NLS-1$
+ }
+}
Property changes on: trunk/common-core/src/test/java/com/metamatrix/api/exception/TestExceptionHolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/common-core/src/test/resources/test.jar (from rev 682, trunk/client/src/test/resources/test.jar)
===================================================================
(Binary files differ)
Property changes on: trunk/common-core/src/test/resources/test.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -453,7 +453,7 @@
response.setSchemas(this.schemas);
// send any warnings with the response object
- List<Exception> responseWarnings = new ArrayList<Exception>();
+ List<Throwable> responseWarnings = new ArrayList<Throwable>();
List<Exception> currentWarnings = processor.getAndClearWarnings();
if (currentWarnings != null) {
responseWarnings.addAll(currentWarnings);
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java 2009-04-02 16:09:56 UTC (rev 696)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java 2009-04-03 01:31:23 UTC (rev 697)
@@ -36,10 +36,10 @@
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.api.exception.ExceptionHolder;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.ClientServiceRegistry;
import com.metamatrix.common.comm.api.Message;
-import com.metamatrix.common.comm.exception.ExceptionHolder;
import com.metamatrix.common.comm.platform.socket.SocketVMController;
import com.metamatrix.common.comm.platform.socket.client.ServiceInvocationStruct;
import com.metamatrix.common.log.LogManager;
15 years, 8 months
teiid SVN: r696 - in trunk: client/src/main/java/com/metamatrix/admin/objects and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-02 12:09:56 -0400 (Thu, 02 Apr 2009)
New Revision: 696
Added:
trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/AbstractStatisticsPanel.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
Removed:
trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatistics.java
Modified:
trunk/client/src/main/java/com/metamatrix/admin/api/objects/QueueWorkerPool.java
trunk/client/src/main/java/com/metamatrix/admin/objects/MMQueueWorkerPool.java
trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties
trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java
trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java
trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolStats.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsDisplayHandler.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsRefreshRequestHandlerImp.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/VMStatisticsPanel.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java
Log:
TEIID-454 fixing stats displays
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/objects/QueueWorkerPool.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/objects/QueueWorkerPool.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/objects/QueueWorkerPool.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -24,7 +24,7 @@
/**
- * All the metamatrix server modules use queue based processing inside them. This
+ * All server modules use queue based processing inside them. This
* object holds the statisics of those queues, as per how many of them queued, dequeued,
* processed etc.
* <p>An identifier for QueueWorkerPool, is nothing but the modules it self, like "DQP",
@@ -34,21 +34,6 @@
*/
public interface QueueWorkerPool extends AdminObject {
/**
- * @return Returns the number of dequeues.
- * @since 4.3
- */
- public int getDequeues();
- /**
- * @return Returns the number of enqueues.
- * @since 4.3
- */
- public int getEnqueues();
- /**
- * @return Returns the highwaterMark.
- * @since 4.3
- */
- public int getHighwaterMark();
- /**
* @return Returns the number of requests queued.
* @since 4.3
*/
@@ -61,20 +46,43 @@
public int getThreads();
/**
+ * @return Returns the highest number of active threads
+ */
+ public int getHighestThreads();
+
+ /**
* @return Returns the number of totalDequeues.
* @since 4.3
+ * @deprecated see {@link #getTotalCompleted()}
*/
public long getTotalDequeues();
+ /**
+ * @return The number of completed tasks
+ */
+ long getTotalCompleted();
+
/**
* @return Returns the number of totalEnqueues.
* @since 4.3
+ * @deprecated see {@link #getTotalSubmitted()}
*/
public long getTotalEnqueues();
+ /**
+ * @return The number of submitted tasks
+ */
+ long getTotalSubmitted();
+
/**
* @return Returns the totalHighwaterMark.
* @since 4.3
+ * @deprecated see {@link #getHighestQueued()}
*/
public int getTotalHighwaterMark();
+
+ /**
+ * @return Returns the highest queue size
+ */
+ public int getHighestQueued();
}
Modified: trunk/client/src/main/java/com/metamatrix/admin/objects/MMQueueWorkerPool.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/objects/MMQueueWorkerPool.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/client/src/main/java/com/metamatrix/admin/objects/MMQueueWorkerPool.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -34,19 +34,12 @@
private int queued = 0;
private int threads = 0;
- // Counts since last stats retrieval
- private int enqueues = 0;
- private int dequeues = 0;
- private int highwaterMark = 0;
-
// Total counts, never reset
- private int totalHighwaterMark = 0;
- private long totalEnqueues = 0;
- private long totalDequeues = 0;
+ private int highestThreads;
+ private int highestQueued = 0;
+ private long totalSubmitted = 0;
+ private long totalCompleted = 0;
-
-
-
/**
* Construct a new MMQueueWorkerPool
* @param identifierParts
@@ -55,8 +48,6 @@
public MMQueueWorkerPool(String[] identifierParts) {
super(identifierParts);
}
-
-
/**
* Get string for display purposes
@@ -68,64 +59,16 @@
str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.MMQueueWorkerPool") + getIdentifier()); //$NON-NLS-1$
str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.queued") + queued); //$NON-NLS-1$
- str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.enqueues") + enqueues); //$NON-NLS-1$
- str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.dequeues") + dequeues); //$NON-NLS-1$
- str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.highwaterMark") + highwaterMark); //$NON-NLS-1$
- str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.totalEnqueues") + totalEnqueues); //$NON-NLS-1$
- str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.totalDequeues") + totalDequeues); //$NON-NLS-1$
- str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.totalHighwaterMark") + totalHighwaterMark); //$NON-NLS-1$
+ str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.highestQueued") + highestQueued); //$NON-NLS-1$
+ str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.totalSubmitted") + totalSubmitted); //$NON-NLS-1$
+ str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.totalCompleted") + totalCompleted); //$NON-NLS-1$
str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.threads") + threads); //$NON-NLS-1$
+ str.append(AdminPlugin.Util.getString("MMQueueWorkerPool.highestThreads") + highestThreads); //$NON-NLS-1$
return str.toString();
}
-
-
-
-
/**
- * @return Returns the dequeues.
- * @since 4.3
- */
- public int getDequeues() {
- return this.dequeues;
- }
- /**
- * @param dequeues The dequeues to set.
- * @since 4.3
- */
- public void setDequeues(int dequeues) {
- this.dequeues = dequeues;
- }
- /**
- * @return Returns the enqueues.
- * @since 4.3
- */
- public int getEnqueues() {
- return this.enqueues;
- }
- /**
- * @param enqueues The enqueues to set.
- * @since 4.3
- */
- public void setEnqueues(int enqueues) {
- this.enqueues = enqueues;
- }
- /**
- * @return Returns the highwaterMark.
- * @since 4.3
- */
- public int getHighwaterMark() {
- return this.highwaterMark;
- }
- /**
- * @param highwaterMark The highwaterMark to set.
- * @since 4.3
- */
- public void setHighwaterMark(int highwaterMark) {
- this.highwaterMark = highwaterMark;
- }
- /**
* @return Returns the number of requests queued.
* @since 4.3
*/
@@ -158,42 +101,54 @@
* @since 4.3
*/
public long getTotalDequeues() {
- return this.totalDequeues;
+ return getTotalCompleted();
}
/**
- * @param totalDequeues The number of totalDequeues to set.
- * @since 4.3
- */
- public void setTotalDequeues(long totalDequeues) {
- this.totalDequeues = totalDequeues;
- }
- /**
* @return Returns the number of totalEnqueues.
* @since 4.3
*/
public long getTotalEnqueues() {
- return this.totalEnqueues;
+ return getTotalSubmitted();
}
/**
- * @param totalEnqueues The number of totalEnqueues to set.
- * @since 4.3
- */
- public void setTotalEnqueues(long totalEnqueues) {
- this.totalEnqueues = totalEnqueues;
- }
- /**
* @return Returns the totalHighwaterMark.
* @since 4.3
*/
public int getTotalHighwaterMark() {
- return this.totalHighwaterMark;
+ return getHighestQueued();
}
- /**
- * @param totalHighwaterMark The totalHighwaterMark to set.
- * @since 4.3
- */
- public void setTotalHighwaterMark(int totalHighwaterMark) {
- this.totalHighwaterMark = totalHighwaterMark;
- }
+
+ public int getHighestThreads() {
+ return highestThreads;
+ }
+
+ public void setHighestThreads(int highestThreads) {
+ this.highestThreads = highestThreads;
+ }
+
+ public int getHighestQueued() {
+ return highestQueued;
+ }
+
+ public void setHighestQueued(int highestQueued) {
+ this.highestQueued = highestQueued;
+ }
+
+ public long getTotalSubmitted() {
+ return totalSubmitted;
+ }
+
+ public void setTotalSubmitted(long totalSubmitted) {
+ this.totalSubmitted = totalSubmitted;
+ }
+
+ public void setTotalCompleted(long totalCompleted) {
+ this.totalCompleted = totalCompleted;
+ }
+
+ public long getTotalCompleted() {
+ return totalCompleted;
+ }
+
}
Modified: trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties
===================================================================
--- trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties 2009-04-02 16:09:56 UTC (rev 696)
@@ -177,18 +177,15 @@
-MMQueueWorkerPool.MMQueueWorkerPool=MMQueueWorkerPool:\n Identifier:\
+MMQueueWorkerPool.MMQueueWorkerPool=QueueWorkerPool:\n Identifier:\
MMQueueWorkerPool.queued=\n queued:\
-MMQueueWorkerPool.enqueues=\n enqueues:\
-MMQueueWorkerPool.dequeues=\n dequeues:\
-MMQueueWorkerPool.highwaterMark=\n highwaterMark:\
-MMQueueWorkerPool.totalEnqueues=\n totalEnqueues:\
-MMQueueWorkerPool.totalDequeues=\n totalDequeues:\
-MMQueueWorkerPool.totalHighwaterMark=\n totalHighwaterMark:\
+MMQueueWorkerPool.highestQueued=\n highestQueued:\
+MMQueueWorkerPool.totalSubmitted=\n totalSubmitted:\
+MMQueueWorkerPool.totalCompleted=\n totalCompleted:\
MMQueueWorkerPool.threads=\n threads:\
+MMQueueWorkerPool.highestThreads=\n highestThreads:\
-
MMRequest.MMRequest=MMRequest:\n Identifier:\
MMRequest.requestID=\n requestID:\
MMRequest.userName=\n userName:\
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -42,8 +42,6 @@
boolean hasWork();
- int getPoolSize();
-
ScheduledFuture<?> schedule(Runnable command,
long delay,
TimeUnit unit);
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -149,8 +149,8 @@
}
private volatile int activeCount;
- private volatile int maxActiveCount;
- private volatile int maxQueueSize;
+ private volatile int highestActiveCount;
+ private volatile int highestQueueSize;
private volatile boolean terminated;
private volatile int submittedCount;
private volatile int completedCount;
@@ -179,18 +179,18 @@
if (atMaxThreads) {
queue.add(command);
int queueSize = queue.size();
- if (queueSize > maxQueueSize) {
+ if (queueSize > highestQueueSize) {
atMaxThreads = true;
- maxQueueSize = queueSize;
+ highestQueueSize = queueSize;
}
} else {
activeCount++;
- maxActiveCount = Math.max(activeCount, maxActiveCount);
+ highestActiveCount = Math.max(activeCount, highestActiveCount);
}
}
if (atMaxThreads) {
if (newMaxQueueSize && maximumPoolSize > 1) {
- LogManager.logWarning(LogCommonConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, maxQueueSize)); //$NON-NLS-1$
+ LogManager.logWarning(LogCommonConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
}
return;
}
@@ -250,7 +250,7 @@
}
public int getPoolSize() {
- return maximumPoolSize;
+ return activeCount;
}
public boolean isTerminated() {
@@ -268,7 +268,7 @@
}
public int getLargestPoolSize() {
- return this.maxActiveCount;
+ return this.highestActiveCount;
}
@Override
@@ -276,8 +276,9 @@
WorkerPoolStats stats = new WorkerPoolStats();
stats.name = poolName;
stats.queued = queue.size();
- stats.threads = getPoolSize();
+ stats.highestQueued = highestQueueSize;
stats.activeThreads = getActiveCount();
+ stats.maxThreads = this.maximumPoolSize;
stats.totalSubmitted = getSubmittedCount();
stats.highestActiveThreads = getLargestPoolSize();
stats.totalCompleted = getCompletedCount();
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolStats.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolStats.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolStats.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -33,7 +33,8 @@
// Current state
public int queued;
- public int threads;
+ int highestQueued;
+ public int maxThreads;
public int activeThreads;
public int highestActiveThreads;
public long totalSubmitted;
@@ -42,15 +43,48 @@
public String toString() {
StringBuffer str = new StringBuffer();
- str.append("WorkerPoolStats:\n"); //$NON-NLS-1$
+ str.append(name + " WorkerPoolStats:\n"); //$NON-NLS-1$
str.append("\tqueued = " + queued); //$NON-NLS-1$
- str.append("\tthreads = " + threads); //$NON-NLS-1$
+ str.append("\thighestQueued = " + highestQueued); //$NON-NLS-1$
+ str.append("\tmaxThreads = " + maxThreads); //$NON-NLS-1$
str.append("\tactiveThreads = " + activeThreads); //$NON-NLS-1$
str.append("\thighestActiveThreads = " + highestActiveThreads); //$NON-NLS-1$
str.append("\ttotalSubmitted = " + totalSubmitted); //$NON-NLS-1$
-
+ str.append("\ttotalCompleted = " + totalCompleted); //$NON-NLS-1$
return str.toString();
}
+
+ public int getActiveThreads() {
+ return activeThreads;
+ }
+
+ public int getHighestActiveThreads() {
+ return highestActiveThreads;
+ }
+
+ public long getTotalCompleted() {
+ return totalCompleted;
+ }
+
+ public long getTotalSubmitted() {
+ return totalSubmitted;
+ }
+
+ public String getQueueName() {
+ return name;
+ }
+
+ public int getQueued() {
+ return queued;
+ }
+
+ public int getHighestQueued() {
+ return highestQueued;
+ }
+
+ public int getMaxThreads() {
+ return maxThreads;
+ }
}
Added: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/AbstractStatisticsPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/AbstractStatisticsPanel.java (rev 0)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/AbstractStatisticsPanel.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.console.ui.views.runtime;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+
+import javax.swing.JPanel;
+
+import com.metamatrix.toolbox.ui.widget.LabelWidget;
+import com.metamatrix.toolbox.ui.widget.TextFieldWidget;
+import com.metamatrix.toolbox.ui.widget.TitledBorder;
+
+public abstract class AbstractStatisticsPanel<T> extends JPanel {
+
+ protected TextFieldWidget[] textFieldWidgets;
+
+ /** Get title of the panel. */
+ public abstract String getTitle();
+
+ /** Get titles of the displayed fields. */
+ public abstract String[] getLabelStrings();
+
+ /** Populate the displayed fields from the specified VMStatistics. */
+ public abstract void populate(T vmStats);
+
+ public AbstractStatisticsPanel() {
+ super();
+ }
+
+ protected void init() {
+ this.setBorder(new TitledBorder(getTitle()));
+ GridBagLayout layout = new GridBagLayout();
+ this.setLayout(layout);
+
+ String[] labelStrings = getLabelStrings();
+ int nfields = labelStrings.length;
+
+ textFieldWidgets = new TextFieldWidget[nfields];
+ LabelWidget[] labelWidgets = new LabelWidget[nfields];
+
+ for (int i = 0; i < nfields; i++) {
+ labelWidgets[i] = new LabelWidget(labelStrings[i]);
+ textFieldWidgets[i] = new TextFieldWidget(0);
+ textFieldWidgets[i].setEditable(false);
+ this.add(labelWidgets[i]);
+ }
+
+ for (int i = 0; i < nfields; i++) {
+ this.add(textFieldWidgets[i]);
+ }
+
+ for (int i = 0; i < nfields; i++) {
+ layout.setConstraints(labelWidgets[i], new GridBagConstraints(0, i,
+ 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
+ GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
+ }
+
+ for (int i = 0; i < nfields; i++) {
+ layout.setConstraints(textFieldWidgets[i],
+ new GridBagConstraints(1, i, 1, 1, 1.0, 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4,
+ 4), 0, 0));
+ }
+ }
+
+}
Property changes on: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/AbstractStatisticsPanel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatistics.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatistics.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatistics.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.console.ui.views.runtime;
-
-public class QueueStatistics {
- String queueName;
- int currentSize;
- int highestSize;
- int totalEnqueued;
- int totalDequeued;
- int numThreads;
-
- public QueueStatistics(String qName, int curSize, int highSize,
- int totEnqueued, int totDequeued, int numThreads) {
- super();
- queueName = qName;
- currentSize = curSize;
- highestSize = highSize;
- totalEnqueued = totEnqueued;
- totalDequeued = totDequeued;
- this.numThreads = numThreads;
- }
-
- public String getQueueName() {
- return queueName;
- }
-
- public int getCurrentSize() {
- return currentSize;
- }
-
- public int getHighestSize() {
- return highestSize;
- }
-
- public int getTotalEnqueued() {
- return totalEnqueued;
- }
-
- public int getTotalDequeued() {
- return totalDequeued;
- }
-
- public int getNumThreads() {
- return numThreads;
- }
-}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsDisplayHandler.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsDisplayHandler.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsDisplayHandler.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -37,6 +37,7 @@
import javax.swing.JFrame;
import javax.swing.JPanel;
+import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.console.ui.ViewManager;
import com.metamatrix.console.util.StaticUtilities;
@@ -69,7 +70,7 @@
* The caller must subsequently call QueueStatisticsFrame.show() to display the frame.
*/
public QueueStatisticsFrame startDisplayForService(String serviceDisplayName, ServiceData sd,
- QueueStatistics[] queueStatistics) {
+ WorkerPoolStats[] queueStatistics) {
QueueStatisticsPanel panel = new QueueStatisticsPanel(caller,
sd, queueStatistics);
statisticsFrame = new QueueStatisticsFrame(this,
@@ -83,7 +84,7 @@
}
public void refreshDisplayForService(String serviceDisplayName, ServiceData sd,
- QueueStatistics[] queueStatistics) {
+ WorkerPoolStats[] queueStatistics) {
QueueStatisticsFrame statisticsFrame =
(QueueStatisticsFrame)currentlyShowing.get(sd);
QueueStatisticsPanel panel = statisticsFrame.getPanel();
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsPanel.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsPanel.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -32,22 +32,19 @@
import javax.swing.AbstractButton;
import javax.swing.JPanel;
+import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.platform.admin.api.runtime.ServiceData;
-
import com.metamatrix.toolbox.ui.widget.ButtonWidget;
-import com.metamatrix.toolbox.ui.widget.LabelWidget;
-import com.metamatrix.toolbox.ui.widget.TextFieldWidget;
-import com.metamatrix.toolbox.ui.widget.TitledBorder;
public class QueueStatisticsPanel extends JPanel {
private ServiceData serviceData;
private QueueStatisticsRefreshRequestHandler controller;
- private QueueStatistics[] queueStatistics;
+ private WorkerPoolStats[] queueStatistics;
private SingleQueueStatisticsPanel[] subPanels;
private AbstractButton closeButton;
public QueueStatisticsPanel(QueueStatisticsRefreshRequestHandler ctrlr,
- ServiceData sd, QueueStatistics[] queueStat) {
+ ServiceData sd, WorkerPoolStats[] queueStat) {
super();
controller = ctrlr;
serviceData = sd;
@@ -75,11 +72,7 @@
for (int i = 0; i < queueStatistics.length; i++) {
subPanels[i] = new SingleQueueStatisticsPanel(
queueStatistics[i].getQueueName());
- subPanels[i].populate(new Integer(queueStatistics[i].getCurrentSize()),
- new Integer(queueStatistics[i].getHighestSize()),
- new Integer(queueStatistics[i].getTotalEnqueued()),
- new Integer(queueStatistics[i].getTotalDequeued()),
- new Integer(queueStatistics[i].getNumThreads()));
+ subPanels[i].populate(queueStatistics[i]);
statsPanel.add(subPanels[i]);
}
this.add(statsPanel);
@@ -97,7 +90,7 @@
}
- public void repopulate(QueueStatistics[] queueStat) {
+ public void repopulate(WorkerPoolStats[] queueStat) {
queueStatistics = queueStat;
for (int i = 0; i < subPanels.length; i++) {
String subPanelQueueName = subPanels[i].getQueueName();
@@ -111,14 +104,9 @@
}
}
if (matchLoc < 0) {
- subPanels[i].populate(null, null, null, null, null);
+ subPanels[i].populate(null);
} else {
- subPanels[i].populate(
- new Integer(queueStatistics[matchLoc].getCurrentSize()),
- new Integer(queueStatistics[matchLoc].getHighestSize()),
- new Integer(queueStatistics[matchLoc].getTotalEnqueued()),
- new Integer(queueStatistics[matchLoc].getTotalDequeued()),
- new Integer(queueStatistics[matchLoc].getNumThreads()));
+ subPanels[i].populate(queueStatistics[matchLoc]);
}
}
}
@@ -130,108 +118,44 @@
-class SingleQueueStatisticsPanel extends JPanel {
+class SingleQueueStatisticsPanel extends AbstractStatisticsPanel<WorkerPoolStats> {
private String queueName;
- private TextFieldWidget currentSizeTFW;
- private TextFieldWidget highestSizeTFW;
- private TextFieldWidget totalEnqueuedTFW;
- private TextFieldWidget totalDequeuedTFW;
- private TextFieldWidget numThreadsTFW;
public SingleQueueStatisticsPanel(String queName) {
super();
queueName = queName;
init();
}
-
- private void init() {
- this.setBorder(new TitledBorder("Queue: " + queueName));
- GridBagLayout layout = new GridBagLayout();
- this.setLayout(layout);
- LabelWidget currentSizeLabel = new LabelWidget("Current size:");
- LabelWidget highestSizeLabel = new LabelWidget("Highest size:");
- LabelWidget totalEnqueuedLabel = new LabelWidget("Total enqueued:");
- LabelWidget totalDequeuedLabel = new LabelWidget("Total dequeued:");
- LabelWidget numThreadsLabel = new LabelWidget("Num. threads:");
- currentSizeTFW = new TextFieldWidget(10);
- currentSizeTFW.setEditable(false);
- highestSizeTFW = new TextFieldWidget();
- highestSizeTFW.setEditable(false);
- totalEnqueuedTFW = new TextFieldWidget();
- totalEnqueuedTFW.setEditable(false);
- totalDequeuedTFW = new TextFieldWidget();
- totalDequeuedTFW.setEditable(false);
- numThreadsTFW = new TextFieldWidget();
- numThreadsTFW.setEditable(false);
- this.add(currentSizeLabel);
- this.add(highestSizeLabel);
- this.add(totalEnqueuedLabel);
- this.add(totalDequeuedLabel);
- this.add(numThreadsLabel);
- this.add(currentSizeTFW);
- this.add(highestSizeTFW);
- this.add(totalEnqueuedTFW);
- this.add(totalDequeuedTFW);
- this.add(numThreadsTFW);
- layout.setConstraints(currentSizeLabel, new GridBagConstraints(0, 0, 1, 1,
- 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(highestSizeLabel, new GridBagConstraints(0, 1, 1, 1,
- 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(totalEnqueuedLabel, new GridBagConstraints(0, 2, 1, 1,
- 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(totalDequeuedLabel, new GridBagConstraints(0, 3, 1, 1,
- 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(numThreadsLabel, new GridBagConstraints(0, 4, 1, 1,
- 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(currentSizeTFW, new GridBagConstraints(1, 0, 1, 1,
- 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(highestSizeTFW, new GridBagConstraints(1, 1, 1, 1,
- 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(totalEnqueuedTFW, new GridBagConstraints(1, 2, 1, 1,
- 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(totalDequeuedTFW, new GridBagConstraints(1, 3, 1, 1,
- 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(4, 4, 4, 4), 0, 0));
- layout.setConstraints(numThreadsTFW, new GridBagConstraints(1, 4, 1, 1,
- 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(4, 4, 4, 4), 0, 0));
+
+ @Override
+ public String[] getLabelStrings() {
+ return new String[] {
+ "Current size",
+ "Highest size",
+ "Total submitted",
+ "Total completed",
+ "Current threads",
+ "Highest threads" };
}
+
+ @Override
+ public String getTitle() {
+ return "Queue: " + queueName;
+ }
- public void populate(Integer currentSize, Integer highestSize,
- Integer totalEnqueued, Integer totalDequeued, Integer numThreads) {
- if (currentSize == null) {
- currentSizeTFW.setText("");
+ public void populate(WorkerPoolStats stats) {
+ if (stats == null) {
+ for (int i = 0; i < textFieldWidgets.length; i++) {
+ textFieldWidgets[i].setText("");
+ }
} else {
- currentSizeTFW.setText(currentSize.toString());
+ textFieldWidgets[0].setText(String.valueOf(stats.getQueued()));
+ textFieldWidgets[1].setText(String.valueOf(stats.getHighestQueued()));
+ textFieldWidgets[2].setText(String.valueOf(stats.getTotalSubmitted()));
+ textFieldWidgets[3].setText(String.valueOf(stats.getTotalCompleted()));
+ textFieldWidgets[4].setText(String.valueOf(stats.getActiveThreads()));
+ textFieldWidgets[5].setText(String.valueOf(stats.getHighestActiveThreads()));
}
- if (highestSize == null) {
- highestSizeTFW.setText("");
- } else {
- highestSizeTFW.setText(highestSize.toString());
- }
- if (totalEnqueued == null) {
- totalEnqueuedTFW.setText("");
- } else {
- totalEnqueuedTFW.setText(totalEnqueued.toString());
- }
- if (totalDequeued == null) {
- totalDequeuedTFW.setText("");
- } else {
- totalDequeuedTFW.setText(totalDequeued.toString());
- }
- if (numThreads == null) {
- numThreadsTFW.setText("");
- } else {
- numThreadsTFW.setText(numThreads.toString());
- }
}
public String getQueueName() {
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsRefreshRequestHandlerImp.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsRefreshRequestHandlerImp.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/QueueStatisticsRefreshRequestHandlerImp.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -68,7 +68,7 @@
sd = currentServiceData;
}
}
- QueueStatistics[] qss = getQueueStatistics(sd);
+ WorkerPoolStats[] qss = getQueueStatistics(sd);
if (qss.length != 0) {
qsdh.refreshDisplayForService(sd.getName(),sd,qss);
}
@@ -113,25 +113,16 @@
}
- public QueueStatistics[] getQueueStatistics(ServiceData sd) {
+ public WorkerPoolStats[] getQueueStatistics(ServiceData sd) {
Collection serviceCollection = null;
serviceCollection = getServiceCollection(sd);
- QueueStatistics[] qss = new QueueStatistics[serviceCollection.size()];
+ WorkerPoolStats[] qss = new WorkerPoolStats[serviceCollection.size()];
if (serviceCollection.isEmpty() ) {
return qss;
}
- if (serviceCollection != null) {
- Iterator iter = serviceCollection.iterator();
- int i = 0;
- while ( i < serviceCollection.size()) {
- if (iter.hasNext()) {
- WorkerPoolStats wps = (WorkerPoolStats)iter.next();
- qss[i] = new QueueStatistics(wps.name, wps.queued,
- 0, (int)wps.totalSubmitted,
- (int)wps.totalCompleted, wps.threads);
- i++;
- }
- }
+ Iterator iter = serviceCollection.iterator();
+ for (int i = 0; i < serviceCollection.size(); i++) {
+ qss[i] = (WorkerPoolStats)iter.next();
}
return qss;
}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/VMStatisticsPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/VMStatisticsPanel.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/runtime/VMStatisticsPanel.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -32,21 +32,16 @@
import javax.swing.AbstractButton;
import javax.swing.JPanel;
-import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.platform.admin.api.runtime.ProcessData;
-import com.metamatrix.platform.vm.controller.SocketListenerStats;
import com.metamatrix.platform.vm.controller.ProcessStatistics;
+import com.metamatrix.platform.vm.controller.SocketListenerStats;
import com.metamatrix.toolbox.ui.widget.ButtonWidget;
-import com.metamatrix.toolbox.ui.widget.LabelWidget;
-import com.metamatrix.toolbox.ui.widget.TextFieldWidget;
-import com.metamatrix.toolbox.ui.widget.TitledBorder;
public class VMStatisticsPanel extends JPanel{
private ProcessData processData;
private QueueStatisticsRefreshRequestHandler controller;
private ProcessStatistics vmStatistics;
private ProcessVMStatisticsPanel processPanel;
- private QueueVMStatisticsPanel queuePanel;
private SocketVMStatisticsPanel socketPanel;
private AbstractButton closeButton;
@@ -88,13 +83,10 @@
JPanel statsPanel = new JPanel(statsLayout);
processPanel = new ProcessVMStatisticsPanel(vmStatistics.name);
processPanel.populate(vmStatistics);
- queuePanel = new QueueVMStatisticsPanel();
- queuePanel.populate(vmStatistics);
socketPanel = new SocketVMStatisticsPanel();
socketPanel.populate(vmStatistics);
statsPanel.add(processPanel);
- statsPanel.add(queuePanel);
statsPanel.add(socketPanel);
this.add(statsPanel);
@@ -108,9 +100,6 @@
statsLayout.setConstraints(processPanel, new GridBagConstraints(0, 0, 1, 1,
1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(4, 4, 4, 4), 0, 0));
- statsLayout.setConstraints(queuePanel, new GridBagConstraints(0, 1, 1, 1,
- 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(4, 4, 4, 4), 0, 0));
statsLayout.setConstraints(socketPanel, new GridBagConstraints(0, 2, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(4, 4, 4, 4), 0, 0));
@@ -127,7 +116,6 @@
public void repopulate(ProcessStatistics vmStat) {
vmStatistics = vmStat;
processPanel.populate(vmStatistics);
- queuePanel.populate(vmStatistics);
socketPanel.populate(vmStatistics);
}
@@ -136,68 +124,7 @@
}
}//end QueueStatisticsPanel
-
-
-
-abstract class AbstractVMStatisticsPanel extends JPanel {
-
- protected TextFieldWidget[] textFieldWidgets;
-
- /**Get title of the panel.*/
- public abstract String getTitle();
-
- /**Get titles of the displayed fields.*/
- public abstract String[] getLabelStrings();
-
- /**Populate the displayed fields from the specified VMStatistics.*/
- public abstract void populate(ProcessStatistics vmStats);
-
-
- public AbstractVMStatisticsPanel() {
- super();
- }
-
- protected void init() {
- this.setBorder(new TitledBorder(getTitle()));
- GridBagLayout layout = new GridBagLayout();
- this.setLayout(layout);
-
- String[] labelStrings = getLabelStrings();
- int nfields = labelStrings.length;
-
- textFieldWidgets = new TextFieldWidget[nfields];
- LabelWidget[] labelWidgets = new LabelWidget[nfields];
-
-
- for (int i=0; i<nfields; i++) {
- labelWidgets[i] = new LabelWidget(labelStrings[i]);
- textFieldWidgets[i] = new TextFieldWidget(0);
- textFieldWidgets[i].setEditable(false);
- this.add(labelWidgets[i]);
- }
-
- for (int i=0; i<nfields; i++) {
- this.add(textFieldWidgets[i]);
- }
-
- for (int i=0; i<nfields; i++) {
- layout.setConstraints(labelWidgets[i], new GridBagConstraints(0, i, 1, 1,
- 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
- new Insets(4, 4, 4, 4), 0, 0));
- }
-
- for (int i=0; i<nfields; i++) {
- layout.setConstraints(textFieldWidgets[i], new GridBagConstraints(1, i, 1, 1,
- 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(4, 4, 4, 4), 0, 0));
- }
- }
-
-}
-
-
-
-class ProcessVMStatisticsPanel extends AbstractVMStatisticsPanel {
+class ProcessVMStatisticsPanel extends AbstractStatisticsPanel<ProcessStatistics> {
private String processName;
private static final String[] labelStrings = {
@@ -232,55 +159,15 @@
}
}
+class SocketVMStatisticsPanel extends AbstractStatisticsPanel<ProcessStatistics> {
-
-class QueueVMStatisticsPanel extends AbstractVMStatisticsPanel {
-
private static final String[] labelStrings = {
- "Current Size",
- "Highest Size",
- "Total Enqueued",
- "Total Dequeued",
- "Num. Threads",
- };
-
-
- public QueueVMStatisticsPanel() {
- super();
- init();
- }
-
- /**Get title of the panel.*/
- public String getTitle() {
- return "Socket Worker Queue";
- }
-
- /**Get titles of the displayed fields.*/
- public String[] getLabelStrings() {
- return labelStrings;
- }
-
- /**Populate the displayed fields from the specified VMStatistics.*/
- public void populate(ProcessStatistics vmStats) {
- WorkerPoolStats poolStats = vmStats.processPoolStats;
- textFieldWidgets[0].setText(Integer.toString(poolStats.queued));
- textFieldWidgets[1].setText(Integer.toString(0));
- textFieldWidgets[2].setText(Long.toString(poolStats.totalSubmitted));
- textFieldWidgets[3].setText(Long.toString(poolStats.totalCompleted));
- textFieldWidgets[4].setText(Integer.toString(poolStats.threads));
- }
-}
-
-
-class SocketVMStatisticsPanel extends AbstractVMStatisticsPanel {
-
- private static final String[] labelStrings = {
- "MetaMatrix Packets Read",
- "MetaMatrix Packets Written",
+ "Message Packets Read",
+ "Message Packets Written",
"Num. Sockets",
"Highest Num. Sockets",
- "Num. Client Connections",
- "Highest Num. Client Connections",
+ "Current Thread Count",
+ "Highest Thread Count",
};
@@ -305,9 +192,8 @@
textFieldWidgets[1].setText(Long.toString(listenerStats.objectsWritten));
textFieldWidgets[2].setText(Integer.toString(listenerStats.sockets));
textFieldWidgets[3].setText(Integer.toString(listenerStats.maxSockets));
- textFieldWidgets[4].setText("0"); //$NON-NLS-1$
- textFieldWidgets[5].setText("0"); //$NON-NLS-1$
-
+ textFieldWidgets[4].setText(Integer.toString(vmStats.processPoolStats.getActiveThreads()));
+ textFieldWidgets[5].setText(Integer.toString(vmStats.processPoolStats.getHighestActiveThreads()));
}
}
\ No newline at end of file
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -30,13 +30,14 @@
import java.util.Properties;
import java.util.Set;
+import org.teiid.dqp.internal.process.Util;
+
import com.metamatrix.admin.api.exception.AdminComponentException;
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.admin.api.objects.AdminObject;
import com.metamatrix.admin.api.objects.Cache;
import com.metamatrix.admin.api.objects.ExtensionModule;
-import com.metamatrix.admin.api.objects.QueueWorkerPool;
import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.admin.api.objects.SystemObject;
import com.metamatrix.admin.objects.MMAdminObject;
@@ -46,7 +47,6 @@
import com.metamatrix.admin.objects.MMLogConfiguration;
import com.metamatrix.admin.objects.MMModel;
import com.metamatrix.admin.objects.MMPropertyDefinition;
-import com.metamatrix.admin.objects.MMQueueWorkerPool;
import com.metamatrix.admin.objects.MMRequest;
import com.metamatrix.admin.objects.MMSession;
import com.metamatrix.admin.objects.MMSystem;
@@ -58,7 +58,6 @@
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.log.config.BasicLogConfiguration;
import com.metamatrix.common.object.PropertyDefinition;
-import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.common.vdb.api.VDBArchive;
@@ -223,7 +222,7 @@
}
else if (src != null && src instanceof com.metamatrix.common.queue.WorkerPoolStats) {
com.metamatrix.common.queue.WorkerPoolStats stats = (com.metamatrix.common.queue.WorkerPoolStats)src;
- return convertStats(stats);
+ return Util.convertStats(stats, stats.getQueueName());
}
else if (src != null && src instanceof ServerConnection) {
ServerConnection conn = (ServerConnection)src;
@@ -262,21 +261,6 @@
return session;
}
- private QueueWorkerPool convertStats(final WorkerPoolStats src) {
- MMQueueWorkerPool pool = new MMQueueWorkerPool(new String[] {src.name});
- pool.setDeployed(true);
- pool.setRegistered(true);
- pool.setDequeues(0);
- pool.setEnqueues(0);
- pool.setHighwaterMark(0);
- pool.setQueued(src.queued);
- pool.setThreads(src.threads);
- pool.setTotalDequeues(src.totalCompleted);
- pool.setTotalEnqueues(src.totalSubmitted);
- pool.setTotalHighwaterMark(0);
- return pool;
- }
-
/**
* Convert LogConfiguration to Admin Object
*/
Added: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import com.metamatrix.admin.objects.MMQueueWorkerPool;
+import com.metamatrix.common.queue.WorkerPoolStats;
+
+public class Util {
+
+ public static MMQueueWorkerPool convertStats(final WorkerPoolStats src, String ... identifier) {
+ MMQueueWorkerPool pool = new MMQueueWorkerPool(identifier);
+ pool.setDeployed(true);
+ pool.setRegistered(true);
+ pool.setQueued(src.getQueued());
+ pool.setThreads(src.getActiveThreads());
+ pool.setHighestQueued(src.getHighestQueued());
+ pool.setHighestThreads(src.getHighestActiveThreads());
+ pool.setTotalCompleted(src.getTotalCompleted());
+ pool.setTotalSubmitted(src.getTotalSubmitted());
+ return pool;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -22,6 +22,8 @@
package com.metamatrix.admin.server;
+import static org.teiid.dqp.internal.process.Util.*;
+
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
@@ -93,10 +95,9 @@
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.service.api.exception.ServiceException;
import com.metamatrix.platform.util.ProductInfoConstants;
-import com.metamatrix.platform.vm.controller.SocketListenerStats;
import com.metamatrix.platform.vm.controller.ProcessStatistics;
+import com.metamatrix.platform.vm.controller.SocketListenerStats;
import com.metamatrix.server.serverapi.RequestInfo;
-
/**
* @since 4.3
*/
@@ -611,16 +612,7 @@
WorkerPoolStats workerStats = statistics.processPoolStats;
if (workerStats != null) {
- String[] workerPoolIdentifierParts = new String[] {hostName, processName, workerStats.name};
- MMQueueWorkerPool workerPool = new MMQueueWorkerPool(workerPoolIdentifierParts);
- workerPool.setDequeues(0);
- workerPool.setEnqueues(0);
- workerPool.setHighwaterMark(0);
- workerPool.setThreads(workerStats.threads);
- workerPool.setQueued(workerStats.queued);
- workerPool.setTotalDequeues(workerStats.totalCompleted);
- workerPool.setTotalEnqueues(workerStats.totalSubmitted);
- workerPool.setTotalHighwaterMark(0);
+ MMQueueWorkerPool workerPool = convertStats(workerStats, hostName, processName, workerStats.name);
process.setQueueWorkerPool(workerPool);
}
@@ -741,18 +733,7 @@
binding.getDeployedName(),
name};
if (identifierMatches(identifier, identifierParts)) {
- MMQueueWorkerPool pool = new MMQueueWorkerPool(identifierParts);
- pool.setDeployed(true);
- pool.setRegistered(true);
- pool.setDequeues(0);
- pool.setEnqueues(0);
- pool.setHighwaterMark(0);
- pool.setQueued(stats.queued);
- pool.setThreads(stats.threads);
- pool.setTotalDequeues(stats.totalCompleted);
- pool.setTotalEnqueues(stats.totalSubmitted);
- pool.setTotalHighwaterMark(0);
-
+ MMQueueWorkerPool pool = convertStats(stats, identifierParts);
results.add(pool);
}
}
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java 2009-04-02 15:53:15 UTC (rev 695)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java 2009-04-02 16:09:56 UTC (rev 696)
@@ -86,7 +86,7 @@
LogManager.logDetail(SocketVMController.SOCKET_CONTEXT, "server = " + this.server + "binding to port:" + port); //$NON-NLS-1$ //$NON-NLS-2$
}
- ChannelFactory factory = new NioServerSocketChannelFactory(bossService, workerPool, workerPool.getPoolSize());
+ ChannelFactory factory = new NioServerSocketChannelFactory(bossService, workerPool, maxWorkers);
ServerBootstrap bootstrap = new ServerBootstrap(factory);
this.channelHandler = new SSLAwareChannelHandler(this, engine, Thread.currentThread().getContextClassLoader());
15 years, 8 months
teiid SVN: r695 - trunk/server/src/main/resources/com/metamatrix/server.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-02 11:53:15 -0400 (Thu, 02 Apr 2009)
New Revision: 695
Modified:
trunk/server/src/main/resources/com/metamatrix/server/i18n.properties
Log:
fixing message key
Modified: trunk/server/src/main/resources/com/metamatrix/server/i18n.properties
===================================================================
--- trunk/server/src/main/resources/com/metamatrix/server/i18n.properties 2009-04-02 15:50:39 UTC (rev 694)
+++ trunk/server/src/main/resources/com/metamatrix/server/i18n.properties 2009-04-02 15:53:15 UTC (rev 695)
@@ -697,7 +697,7 @@
QueryService.send_sync=QueryService.send (synch) - clientIdentifier: {0} ClientConnection ID: {1} Message: {2}
QueryService.send_async=QueryService.send (asynch) - clientIdentifier: {0} ClientConnection ID: {1} Message: {2}
QueryService.setMessageReceiver=QueryService.setMessageReceiver - ClientID: {0} Message Receiver {1} Properties {2}
-queryService.no_udf=No UDF function model found in the extensions modules.
+QueryService.no_udf=No UDF function model found in the extensions modules.
QueryServiceProxy.Error__Could_not_clear_cache_in_Query_Service,_service_is_not_initialized=Could not clear cache in Query Service, service is not initialized.
15 years, 8 months
teiid SVN: r694 - in trunk: server/src/main/java/com/metamatrix/server and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-02 11:50:39 -0400 (Thu, 02 Apr 2009)
New Revision: 694
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/ResourceNames.java
trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java
Log:
TEIID-74 web service resource has been removed
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/ResourceNames.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/ResourceNames.java 2009-04-02 03:42:32 UTC (rev 693)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/ResourceNames.java 2009-04-02 15:50:39 UTC (rev 694)
@@ -38,7 +38,6 @@
public static final String MEMBERSHIP_SERVICE = "MembershipService"; //$NON-NLS-1$
public static final String XA_TRANSACTION_MANAGER = "XATransactionManager"; //$NON-NLS-1$
public static final String INDEXING_SERVICE = "IndexingService"; //$NON-NLS-1$
- public static final String WEB_SERVICES = "WebServices"; //$NON-NLS-1$
public static final String JGROUPS = "JGroups"; //$NON-NLS-1$
public static final String SSL = "SSL"; //$NON-NLS-1$
}
Modified: trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java 2009-04-02 03:42:32 UTC (rev 693)
+++ trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java 2009-04-02 15:50:39 UTC (rev 694)
@@ -97,11 +97,6 @@
configprops = configmodel.getResource(ResourceNames.JGROUPS).getProperties();
sb.append(PropertiesUtils.prettyPrint(configprops));
- sb.append("\n---- WebServices Resource Properties ----\n"); //$NON-NLS-1$
- configprops = configmodel.getResource(ResourceNames.WEB_SERVICES).getProperties();
- sb.append(PropertiesUtils.prettyPrint(configprops));
-
-
sb.append(info.getClasspathInfo());
15 years, 8 months
teiid SVN: r693 - trunk/server/src/main/java/com/metamatrix/server.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-01 23:42:32 -0400 (Wed, 01 Apr 2009)
New Revision: 693
Modified:
trunk/server/src/main/java/com/metamatrix/server/HostController.java
trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java
Log:
TEIID-1 adding logging of stdout and error streams to host controller launched processes.
Modified: trunk/server/src/main/java/com/metamatrix/server/HostController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-02 03:40:16 UTC (rev 692)
+++ trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-02 03:42:32 UTC (rev 693)
@@ -22,14 +22,18 @@
package com.metamatrix.server;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
import com.google.inject.Guice;
import com.google.inject.Inject;
@@ -46,6 +50,7 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.util.LogCommonConstants;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.registry.ClusteredRegistryState;
@@ -58,11 +63,71 @@
@Singleton
public class HostController implements HostManagement {
+ private final static class StreamLogger extends Thread {
+ private BufferedReader r;
+ private boolean error;
+
+ private StreamLogger(InputStream is, boolean error, String processName) {
+ r = new BufferedReader(new InputStreamReader(is));
+ this.error = error;
+ this.setName(processName + (error?" error":" stdout") + " reader"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ this.setDaemon(true);
+ }
+
+ @Override
+ public void run() {
+ String s = null;
+ try {
+ while ((s = r.readLine()) != null) {
+ LogManager.log(error?MessageLevel.ERROR:MessageLevel.INFO, LogCommonConstants.CTX_CONTROLLER, s);
+ }
+ } catch (IOException e) {
+ LogManager.logDetail(LogCommonConstants.CTX_CONTROLLER, e, "Error reading stream"); //$NON-NLS-1$
+ } finally {
+ try {
+ r.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ protected class MonitoredProcess {
+ private Process process;
+ private Thread errorReader;
+ private Thread stdoutReader;
+
+ MonitoredProcess(Process p, final String processName) {
+ this.process = p;
+ errorReader = new StreamLogger(p.getErrorStream(), true, processName);
+ errorReader.start();
+ stdoutReader = new StreamLogger(p.getInputStream(), false, processName);
+ stdoutReader.start();
+ Thread monitorThread = new Thread(processName + " monitor") { //$NON-NLS-1$
+ @Override
+ public void run() {
+ try {
+ int outputValue = process.waitFor();
+ LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER, "Exiting "+ processName +" with value " +outputValue); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ } finally {
+ errorReader.interrupt();
+ stdoutReader.interrupt();
+ processMap.remove(processName);
+ }
+ }
+ };
+ monitorThread.start();
+ }
+
+ }
+
private static final String DEFAULT_JAVA_MAIN = "com.metamatrix.server.Main"; //$NON-NLS-1$
private Host host;
- private Map<String, Process> processMap = new HashMap<String, Process>();
+ private Map<String, Process> processMap = new ConcurrentHashMap<String, Process>();
private ClusteredRegistryState registry;
@@ -273,7 +338,9 @@
private Process startDeployVM( String processName, String hostName, Properties vmprops) {
LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER, "Start deploy VM = " + processName + " on host = "+ hostName); //$NON-NLS-1$ //$NON-NLS-2$
String command = buildVMCommand(processName, vmprops);
- return execCommand(command);
+ Process p = execCommand(command);
+ new MonitoredProcess(p, processName);
+ return p;
}
private String buildVMCommand(String processName, Properties vmprops) {
@@ -354,7 +421,6 @@
Process process = processMap.get(processName.toUpperCase());
if (process != null) {
- processMap.remove(processName.toUpperCase());
process.destroy();
}
}
Modified: trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java 2009-04-02 03:40:16 UTC (rev 692)
+++ trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java 2009-04-02 03:42:32 UTC (rev 693)
@@ -123,6 +123,7 @@
is.close();
} catch (Exception e) {
+ e.printStackTrace();
System.err.println("Error writing application info to " + applFileName + ", msg: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
//Ignore, we are dieing anyway.
} finally {
15 years, 8 months
teiid SVN: r692 - in trunk: server/src/main/java/com/metamatrix/server and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-01 23:40:16 -0400 (Wed, 01 Apr 2009)
New Revision: 692
Modified:
trunk/pom.xml
trunk/server/src/main/java/com/metamatrix/server/Main.java
Log:
TEIID-453, TEIID-442, TEIID-441, TEIID-136 simplifies configuration to only a current configuration.
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-04-02 01:19:18 UTC (rev 691)
+++ trunk/pom.xml 2009-04-02 03:40:16 UTC (rev 692)
@@ -140,6 +140,10 @@
</excludes>
<systemProperties>
<property>
+ <name>user.dir</name>
+ <value>${basedir}/target</value>
+ </property>
+ <property>
<name>java.io.tmpdir</name>
<value>${basedir}/target</value>
</property>
Modified: trunk/server/src/main/java/com/metamatrix/server/Main.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-04-02 01:19:18 UTC (rev 691)
+++ trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-04-02 03:40:16 UTC (rev 692)
@@ -75,7 +75,7 @@
final Host host = CurrentConfiguration.getInstance().getDefaultHost();
- Thread t = new Thread(new Runnable() {
+ Thread t = new Thread("Main Info Thread") { //$NON-NLS-1$
@Override
public void run() {
try {
@@ -86,7 +86,7 @@
// write info log
writeInfoLog(host, processName);
}
- }, "Main Info Thread"); //$NON-NLS-1$
+ };
t.start();
createTempDirectory();
@@ -148,11 +148,13 @@
}
private static void saveCurrentConfigurationToFile(Host host, String processName) throws ConfigurationException {
- FilePersistentUtil.writeModel(CONFIG_PREFIX+FileLimitSizeLogWriter.getDate()+".xml", host.getConfigDirectory(), //$NON-NLS-1$
+ String configDir = host.getConfigDirectory();
+ File f = new File(configDir);
+ f.mkdirs();
+ FilePersistentUtil.writeModel(CONFIG_PREFIX+FileLimitSizeLogWriter.getDate()+".xml", configDir, //$NON-NLS-1$
CurrentConfiguration.getInstance().getConfigurationModel(),
processName);
//remove old instances
- File f = new File(host.getConfigDirectory());
String[] result = f.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
15 years, 8 months
teiid SVN: r691 - trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2009-04-01 21:19:18 -0400 (Wed, 01 Apr 2009)
New Revision: 691
Modified:
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java
Log:
TEIIDDES-133
The Connector was not checking for a null ExecutionContext.
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java 2009-04-01 21:43:13 UTC (rev 690)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java 2009-04-02 01:19:18 UTC (rev 691)
@@ -57,6 +57,10 @@
}
public Connection getConnection(ExecutionContext context) throws ConnectorException {
+ if(null == context) {
+ return null;
+ }
+
if (m_state == null) {
throw new ConnectorException(Messages.getString("XMLConnector.state.not.set")); //$NON-NLS-1$
}
15 years, 8 months
teiid SVN: r690 - trunk/server/src/main/java/com/metamatrix/server.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-01 17:43:13 -0400 (Wed, 01 Apr 2009)
New Revision: 690
Modified:
trunk/server/src/main/java/com/metamatrix/server/HostController.java
Log:
fixing regression in host controller. start with an controller running should still start the processes
Modified: trunk/server/src/main/java/com/metamatrix/server/HostController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-01 21:41:45 UTC (rev 689)
+++ trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-01 21:43:13 UTC (rev 690)
@@ -23,6 +23,7 @@
package com.metamatrix.server;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -61,7 +62,7 @@
private Host host;
- private Map processMap = new HashMap(3);
+ private Map<String, Process> processMap = new HashMap<String, Process>();
private ClusteredRegistryState registry;
@@ -78,8 +79,12 @@
}
public void run(boolean startProcesses) throws Throwable {
+ HostControllerRegistryBinding hc = getRunningHost();
- if (isHostRunning()) {
+ if (hc != null) {
+ if (startProcesses) {
+ hc.getHostController().startServers(host.getFullName());
+ }
System.err.println(PlatformPlugin.Util.getString("HostController.Host_is_already_running_startprocesses", host.getFullName())); //$NON-NLS-1$
System.exit(-1);
}
@@ -120,13 +125,7 @@
}
private boolean isHostRunning() {
- List<HostControllerRegistryBinding> hosts = this.registry.getHosts();
- for(HostControllerRegistryBinding host:hosts) {
- if (host.getHostName().equalsIgnoreCase(this.host.getFullName())) {
- return true;
- }
- }
- return false;
+ return getRunningHost() != null;
}
private HostControllerRegistryBinding getRunningHost() {
@@ -353,7 +352,7 @@
}
}
- Process process = (Process) processMap.get(processName.toUpperCase());
+ Process process = processMap.get(processName.toUpperCase());
if (process != null) {
processMap.remove(processName.toUpperCase());
process.destroy();
@@ -379,15 +378,9 @@
// must copy the map so that when
// doKillVM tries to remove it from the map
// while its being iterated over.
- Map copyMap = new HashMap();
- copyMap.putAll(processMap);
-
- Iterator processes = copyMap.keySet().iterator();
- while (processes.hasNext()) {
- String processName = (String) processes.next();
+ for (String processName : new ArrayList<String>(processMap.keySet())) {
killServer(hostName, processName, stopNow);
}
- processMap.clear();
}
else {
HostManagement remoteHost = getRemoteHost(hostName);
15 years, 8 months