[teiid-commits] teiid SVN: r1048 - in trunk: embedded/src/main/java/com/metamatrix/dqp/embedded/admin and 2 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Fri Jun 12 12:09:08 EDT 2009
Author: shawkins
Date: 2009-06-12 12:09:08 -0400 (Fri, 12 Jun 2009)
New Revision: 1048
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
Log:
TEIID-658 TEIID-659 changing drivermanager logging to java logging and cleaning up misc embedded issues
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -46,5 +46,5 @@
/**
* Shutdown the connection factory, including the DQP and all its existing connections
*/
- public void shutdown() throws SQLException;
+ public void shutdown();
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -33,11 +33,12 @@
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -88,7 +89,7 @@
} catch(SQLException e) {
// Logging
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.MMDQP_DRIVER_could_not_be_registered"); //$NON-NLS-1$
- DriverManager.println(logMsg);
+ logger.log(Level.SEVERE, logMsg);
}
}
@@ -154,16 +155,15 @@
*/
private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL, Properties info) throws SQLException {
EmbeddedTransport transport = currentTransport;
- if (transport != null && currentTransport.getURL().equals(dqpURL)) {
- String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_existing_transport"); //$NON-NLS-1$
- DriverManager.println(logMsg);
- }
- else {
+ if (transport == null || !currentTransport.getURL().equals(dqpURL)) {
// shutdown any previous instance; we do encourage single instance in a given VM
shutdown();
- transport = new EmbeddedTransport(dqpURL, info);
- String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_new_transport"); //$NON-NLS-1$
- DriverManager.println(logMsg);
+ try {
+ transport = new EmbeddedTransport(dqpURL, info);
+ } catch (SQLException e) {
+ logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
+ throw e;
+ }
}
currentTransport = transport;
return transport;
@@ -182,7 +182,6 @@
void parseURL(String url, Properties info) throws SQLException {
if (url == null || url.trim().length() == 0) {
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.URL_must_be_specified"); //$NON-NLS-1$
- DriverManager.println(logMsg);
throw new SQLException(logMsg);
}
@@ -222,10 +221,7 @@
info.setProperty(BaseDataSource.APP_NAME, BaseDataSource.DEFAULT_APP_NAME);
}
} catch (Exception e) {
- String logMsg = e.getClass() +": "+e.getMessage(); //$NON-NLS-1$
- DriverManager.println(logMsg);
- DriverManager.println(e.getStackTrace().toString());
- throw new SQLException(logMsg);
+ throw new SQLException(e);
}
}
@@ -251,7 +247,6 @@
value = info.getProperty(BaseDataSource.VDB_NAME);
if (value == null || value.trim().length() == 0) {
String logMsg = BaseDataSource.getResourceMessage("MMDataSource.Virtual_database_name_must_be_specified"); //$NON-NLS-1$
- DriverManager.println(logMsg);
throw new SQLException(logMsg);
}
@@ -319,12 +314,8 @@
*/
public static synchronized void shutdown() {
if (currentTransport != null) {
- try {
- currentTransport.shutdown();
- currentTransport = null;
- } catch (SQLException e) {
- DriverManager.println(e.getMessage());
- }
+ currentTransport.shutdown();
+ currentTransport = null;
}
}
@@ -371,11 +362,8 @@
this.classLoader = new PostDelegatingClassLoader(dqpClassPath, this.getClass().getClassLoader(), new MetaMatrixURLStreamHandlerFactory());
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
- DriverManager.println(logMsg);
- for (int i = 0; i < dqpClassPath.length; i++) {
- DriverManager.println(dqpClassPath[i].toString());
- }
-
+ logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
+
// Now using this class loader create the connection factory to the dqp.
ClassLoader current = Thread.currentThread().getContextClassLoader();
try {
@@ -385,7 +373,6 @@
this.connectionFactory = (EmbeddedConnectionFactory)clazz.newInstance();
this.connectionFactory.initialize(dqpURL, props);
} catch (Exception e) {
- DriverManager.println(e.getClass() +": "+e.getMessage()); //$NON-NLS-1$
throw new EmbeddedSQLException(e);
} finally {
Thread.currentThread().setContextClassLoader(current);
@@ -438,16 +425,10 @@
props.load(in);
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_properties"); //$NON-NLS-1$
- DriverManager.println(logMsg);
- for (Iterator i = props.keySet().iterator(); i.hasNext();) {
- String key = (String)i.next();
- DriverManager.println(key+"="+props.getProperty(key)); //$NON-NLS-1$
- }
+ logger.log(Level.FINER, logMsg + props);
return props;
}catch(IOException e) {
String logMsg = BaseDataSource.getResourceMessage("EmbeddedTransport.invalid_dqpproperties_path", new Object[] {dqpURL}); //$NON-NLS-1$
- DriverManager.println(e.getClass() +": "+e.getMessage()); //$NON-NLS-1$
- DriverManager.println(e.getStackTrace().toString());
throw new EmbeddedSQLException(e, logMsg);
}finally {
if (in != null) {
@@ -459,7 +440,7 @@
/**
* Shutdown the current transport
*/
- void shutdown() throws SQLException{
+ void shutdown() {
this.connectionFactory.shutdown();
// remove any artifacts which are not cleaned-up
@@ -517,10 +498,9 @@
throw MMSQLException.create(e);
}
}
- String dir = baseDir + "/" + identity; //$NON-NLS-1$
- System.setProperty(DQPEmbeddedProperties.DQP_TMPDIR, dir + "/temp"); //$NON-NLS-1$S
+ System.setProperty(DQPEmbeddedProperties.DQP_TMPDIR, baseDir + "/temp"); //$NON-NLS-1$S
- File f = new File(dir);
+ File f = new File(baseDir, identity);
// If directory already exists then try to delete it; because we may have
// failed to delete at end of last run (JVM holds lock on jar files)
@@ -532,7 +512,7 @@
if (!f.exists()) {
f.mkdirs();
}
- return dir;
+ return f.getAbsolutePath();
}
/**
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -30,6 +30,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
+import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -82,7 +83,7 @@
} catch(SQLException e) {
// Logging
String logMsg = JDBCPlugin.Util.getString("MMDriver.Err_registering", e.getMessage()); //$NON-NLS-1$
- DriverManager.println(logMsg);
+ logger.log(Level.SEVERE, logMsg);
}
}
@@ -125,7 +126,7 @@
myConnection = createMMConnection(url, info);
} catch (MetaMatrixCoreException e) {
- DriverManager.println(e.getMessage());
+ logger.log(Level.SEVERE, "Could not create connection", e); //$NON-NLS-1$
throw MMSQLException.create(e, e.getMessage());
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -22,7 +22,6 @@
package com.metamatrix.dqp.embedded.admin;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -66,14 +65,10 @@
*/
public void stop(int millisToWait) throws AdminException {
// TODO: rreddy need to implement the time to wait.
- try {
- // First terminate all the sessions to the DQP currently have
- terminateSession(AdminObject.WILDCARD);
-
- getManager().shutdown();
- } catch (SQLException e) {
- throw new AdminComponentException(e);
- }
+ // First terminate all the sessions to the DQP currently have
+ terminateSession(AdminObject.WILDCARD);
+
+ getManager().shutdown();
}
/**
@@ -81,16 +76,12 @@
* @since 4.3
*/
public void restart() throws AdminException {
- try {
- // First terminate all the sessions to the DQP currently have
- terminateSession(AdminObject.WILDCARD);
-
- // Now shutdown the DQP, it will automatically start next timea new connection is
- // requested.
- getManager().shutdown();
- } catch (SQLException e) {
- throw new AdminComponentException(e);
- }
+ // First terminate all the sessions to the DQP currently have
+ terminateSession(AdminObject.WILDCARD);
+
+ // Now shutdown the DQP, it will automatically start next timea new connection is
+ // requested.
+ getManager().shutdown();
}
/**
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -1436,8 +1436,7 @@
public File getWorkDir() {
String workDirectory = getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_WORKSPACE);
- URL bufferURL = getFullyQualifiedPath(workDirectory);
- File workDir = new File(bufferURL.getPath());
+ File workDir = new File(workDirectory);
workDir.mkdirs();
return workDir;
}
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -26,8 +26,6 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -67,8 +65,6 @@
private long starttime = -1L;
private Thread shutdownThread;
- private EmbeddedConnectionListener listener = new EmbeddedConnectionListener();
-
/**
* @see com.metamatrix.jdbc.EmbeddedConnectionFactory#createConnection()
*/
@@ -81,7 +77,7 @@
ServerConnection serverConn = this.handler.createConnection(props);
// Should occur every time in class loader using existing attributes
- return new EmbeddedConnection(this, serverConn, props, listener);
+ return new EmbeddedConnection(this, serverConn, props, null);
} catch (ConnectionException e) {
throw new EmbeddedSQLException(e);
}
@@ -130,11 +126,7 @@
@Override
public void run() {
- try {
- shutdown(false);
- } catch (SQLException e) {
- // ignore
- }
+ shutdown(false);
}
}
@@ -171,11 +163,11 @@
*
* @see com.metamatrix.jdbc.EmbeddedConnectionFactory#shutdown()
*/
- public void shutdown() throws SQLException {
+ public void shutdown() {
shutdown(true);
}
- private synchronized void shutdown(boolean undoShutdownHook) throws SQLException {
+ private synchronized void shutdown(boolean undoShutdownHook) {
if (undoShutdownHook) {
Runtime.getRuntime().removeShutdownHook(this.shutdownThread);
@@ -189,10 +181,6 @@
// this will by pass, and only let shutdown called once.
shutdownInProgress = true;
- // First close any connections hanging around; this will only happen if
- // connections are not properly closed; or somebody called shutdown.
- listener.closeConnections();
-
try {
this.dqp.stop();
} catch (ApplicationLifecycleException e) {
@@ -265,52 +253,4 @@
throw new EmbeddedSQLException(JDBCPlugin.Util.getString("EmbeddedConnectionFactory.vdb_notavailable", new Object[] {vdbName, EmbeddedDataSource.USE_LATEST_VDB_VERSION})); //$NON-NLS-1$
}
- /**
- * A internal connection listener for the connections; based on this
- * it manages the DQP instance. These are client side (JDBC) connections
- */
- private class EmbeddedConnectionListener implements ConnectionListener{
-
- // List of connections created
- HashMap connections = new HashMap();
-
- public void connectionAdded(String id, Connection connection) {
- // Add the connection to locol count
- connections.put(id, connection);
- }
-
- public void connectionRemoved(String id, Connection connection) {
- // remove from local count
- connections.remove(id);
- }
-
- /**
- * Loop through all the connections and close the connections.
- * @throws EmbeddedSQLException
- */
- private void closeConnections() throws SQLException {
- Exception firstException = null;
-
- // loop all the available connections and close them; make sure we avoid the
- // concurrent modification of the list of connections.
- while (this.connections.size() != 0) {
- try {
- Iterator i = this.connections.keySet().iterator();
- if (i.hasNext()) {
- Connection connection = (Connection)this.connections.get(i.next());
- connection.close();
- }
- } catch (Exception ex) {
- if (firstException == null) {
- firstException = ex;
- }
- }
- }
-
- // if there was any exception then let them know.
- if (firstException != null) {
- throw new EmbeddedSQLException(firstException);
- }
- }
- }
}
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-06-12 15:52:32 UTC (rev 1047)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-06-12 16:09:08 UTC (rev 1048)
@@ -58,7 +58,6 @@
bindConstant().annotatedWith(Names.named("ProcessName")).to(props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY)); //$NON-NLS-1$
String workspaceDir = props.getProperty(DQPEmbeddedProperties.DQP_WORKSPACE);
bindConstant().annotatedWith(Names.named("WorkspaceDir")).to(workspaceDir); //$NON-NLS-1$
- this.props.setProperty(DQPEmbeddedProperties.DQP_TMPDIR, workspaceDir);
bind(Properties.class).annotatedWith(Names.named("DQPProperties")).toInstance(this.props); //$NON-NLS-1$
bind(DQPContextCache.class).in(Scopes.SINGLETON);
More information about the teiid-commits
mailing list