[teiid-commits] teiid SVN: r1244 - in trunk: client/src/main/java/com/metamatrix/common/comm/api and 9 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Fri Aug 14 23:23:38 EDT 2009
Author: shawkins
Date: 2009-08-14 23:23:38 -0400 (Fri, 14 Aug 2009)
New Revision: 1244
Modified:
trunk/build/kit-runtime/deploy/log4j.xml
trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
trunk/runtime/src/main/java/com/metamatrix/jdbc/Log4JUtil.java
trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
trunk/runtime/src/main/java/org/teiid/Server.java
trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java
trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-785 TEIID-509 adding back the notion of a process info log and addressing embedded usage concerns
Modified: trunk/build/kit-runtime/deploy/log4j.xml
===================================================================
--- trunk/build/kit-runtime/deploy/log4j.xml 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/build/kit-runtime/deploy/log4j.xml 2009-08-15 03:23:38 UTC (rev 1244)
@@ -7,7 +7,7 @@
</appender>
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
- <param name="File" value="${dqp.log4jFile}"/>
+ <param name="File" value="log/teiid.log"/>
<param name="MaxFileSize" value="1000KB"/>
<param name="MaxBackupIndex" value="25"/>
@@ -48,7 +48,7 @@
<!-- un-comment to enable COMMAND log
<appender name="COMMAND" class="org.apache.log4j.RollingFileAppender">
- <param name="File" value="log/command.log"/>
+ <param name="File" value="log/command.log"/>
<param name="MaxFileSize" value="1000KB"/>
<param name="MaxBackupIndex" value="25"/>
<layout class="org.apache.log4j.PatternLayout">
@@ -64,7 +64,7 @@
<!-- Un-comment to enable AUDIT log
<appender name="AUDIT" class="org.apache.log4j.RollingFileAppender">
- <param name="File" value="log/audit.log"/>
+ <param name="File" value="log/audit.log"/>
<param name="MaxFileSize" value="1000KB"/>
<param name="MaxBackupIndex" value="25"/>
<layout class="org.apache.log4j.PatternLayout">
@@ -77,7 +77,23 @@
<appender-ref ref="AUDIT"/>
</category>
-->
+
+ <!-- Un-comment to enable Process Info log
+ <appender name="PROCESS_INFO" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="log/process_info.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="MaxBackupIndex" value="25"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %p [%t] %c - %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.teiid.PROCESS_INFO_LOG">
+ <priority value="INFO"/>
+ <appender-ref ref="PROCESS_INFO"/>
+ </category>
+ -->
+
<root>
<appender-ref ref="ASYNC"/>
</root>
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -26,9 +26,12 @@
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.core.MetaMatrixCoreException;
public interface ServerConnectionFactory {
+ void initialize(Properties info) throws MetaMatrixCoreException;
+
/**
* Establish a connection to the server.
* @param connProps The properties used by the transport to find a connection. These
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -170,7 +170,7 @@
}
}
}
- INSTANCE.init(props);
+ INSTANCE.initialize(props);
}
return INSTANCE;
}
@@ -178,11 +178,12 @@
public SocketServerConnectionFactory() {
}
-
- public void init(final Properties props) {
- PropertiesUtils.setBeanProperties(this, props, "org.teiid.sockets"); //$NON-NLS-1$
+
+ @Override
+ public void initialize(Properties info) {
+ PropertiesUtils.setBeanProperties(this, info, "org.teiid.sockets"); //$NON-NLS-1$
this.pingTimer = new Timer("SocketPing", true); //$NON-NLS-1$
- this.channelFactory = new OioOjbectChannelFactory(props);
+ this.channelFactory = new OioOjbectChannelFactory(info);
}
public SocketServerInstance getServerInstance(HostInfo info, boolean ssl) throws CommunicationException, IOException {
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -55,6 +55,8 @@
import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
@@ -141,9 +143,9 @@
}
// now create the connection
- EmbeddedTransport transport = getDQPTransport(dqpURL, info);
+ EmbeddedTransport transport = getDQPTransport(dqpURL);
- MMConnection conn = transport.createConnection(dqpURL, info);
+ MMConnection conn = transport.createConnection(info);
return conn;
}
@@ -156,13 +158,13 @@
* @throws SQLException
* @since 4.4
*/
- private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL, Properties info) throws SQLException {
+ private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL) throws SQLException {
EmbeddedTransport transport = currentTransport;
if (transport == null || !currentTransport.getURL().equals(dqpURL)) {
// shutdown any previous instance; we do encourage single instance in a given VM
shutdown();
try {
- transport = new EmbeddedTransport(dqpURL, info);
+ transport = new EmbeddedTransport(dqpURL);
} catch (SQLException e) {
logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
throw e;
@@ -290,21 +292,18 @@
private ServerConnectionFactory connectionFactory;
private ClassLoader classLoader;
private URL url;
- Properties props;
- public EmbeddedTransport(URL dqpURL, Properties info) throws SQLException {
-
+ public EmbeddedTransport(URL dqpURL) throws SQLException {
this.url = dqpURL;
//Load the properties from dqp.properties file
- this.props = loadDQPProperties(dqpURL);
- this.props.putAll(info);
+ Properties props = loadDQPProperties(dqpURL);
- this.props = PropertiesUtils.resolveNestedProperties(this.props);
+ props = PropertiesUtils.resolveNestedProperties(props);
// a non-delegating class loader will be created from where all third party dependent jars can be loaded
ArrayList<URL> runtimeClasspathList = new ArrayList<URL>();
- String libLocation = this.props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
+ String libLocation = props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
if (!libLocation.endsWith("/")) { //$NON-NLS-1$
libLocation = libLocation + "/"; //$NON-NLS-1$
}
@@ -315,7 +314,7 @@
runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation, MMURLConnection.DATE));
try {
- String configLocation = this.props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "./deploy/"); //$NON-NLS-1$
+ String configLocation = props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "./deploy/"); //$NON-NLS-1$
if (!configLocation.endsWith("/")) { //$NON-NLS-1$
configLocation = configLocation + "/"; //$NON-NLS-1$
}
@@ -331,15 +330,23 @@
String logMsg = getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
+ props.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
+ props.setProperty(DQPEmbeddedProperties.TEIID_HOME, getHomeDirectory(props));
// Now using this class loader create the connection factory to the dqp.
ClassLoader current = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.classLoader);
String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
- Class<?> clazz = this.classLoader.loadClass(className);
- this.connectionFactory = (ServerConnectionFactory)clazz.newInstance();
- } catch (Exception e) {
- throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$
+ try {
+ this.connectionFactory = (ServerConnectionFactory)ReflectionHelper.create(className, null, this.classLoader);
+ } catch (MetaMatrixCoreException e) {
+ throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$
+ }
+ try {
+ this.connectionFactory.initialize(props);
+ } catch (MetaMatrixCoreException e) {
+ throw MMSQLException.create(e);
+ }
} finally {
Thread.currentThread().setContextClassLoader(current);
}
@@ -416,14 +423,12 @@
* @param info
* @return Connection
*/
- MMConnection createConnection(URL url, Properties info) throws SQLException {
+ MMConnection createConnection(Properties info) throws SQLException {
ClassLoader current = null;
try {
current = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
- info.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
- info.setProperty(DQPEmbeddedProperties.TEIID_HOME, getHomeDirectory(url));
ServerConnection conn = connectionFactory.createConnection(info);
return new MMConnection(conn, info, url.toExternalForm());
} catch (CommunicationException e) {
@@ -436,15 +441,9 @@
}
}
- String getHomeDirectory(URL url) throws SQLException {
+ String getHomeDirectory(Properties props) throws SQLException {
try {
- // check the system wide
- String teiidHome = System.getProperty(DQPEmbeddedProperties.TEIID_HOME);
-
- // then check the deploy.properties
- if (teiidHome == null) {
- teiidHome = this.props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
- }
+ String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
if (teiidHome == null) {
if (EmbeddedProfile.getDefaultConnectionURL().equals(url.toString())) {
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -32,6 +32,7 @@
public static final String CTX_EXTENSION_SOURCE = "EXTENSION_MODULE"; //$NON-NLS-1$
public static final String CTX_COMMANDLOGGING = "COMMAND_LOG"; //$NON-NLS-1$
public static final String CTX_AUDITLOGGING = "AUDIT_LOG"; //$NON-NLS-1$
+ public static final String CTX_PROCESS_INFO_LOG = "PROCESS_INFO_LOG"; //$NON-NLS-1$
public static final String CTX_ADMIN_API = "ADMIN_API"; //$NON-NLS-1$
public static final String CTX_QUERY_SERVICE = "QUERY_SERVICE"; //$NON-NLS-1$
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -53,7 +53,6 @@
import com.metamatrix.common.config.model.BasicConnectorBinding;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.common.vdb.api.VDBDefn;
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -22,7 +22,7 @@
package com.metamatrix.jdbc;
-import static org.teiid.dqp.internal.process.Util.convertStats;
+import static org.teiid.dqp.internal.process.Util.*;
import java.io.File;
import java.io.IOException;
@@ -31,6 +31,7 @@
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.URL;
+import java.net.UnknownHostException;
import java.util.Date;
import java.util.Properties;
@@ -58,7 +59,9 @@
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.JMXUtil;
+import com.metamatrix.common.util.NetUtils;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.MixinProxy;
import com.metamatrix.dqp.ResourceFinder;
@@ -89,21 +92,15 @@
private Thread shutdownThread;
private ClientServiceRegistry clientServices;
private String workspaceDirectory;
- private boolean init = false;
private SocketTransport socketTransport;
private JMXUtil jmxServer;
private boolean restart = false;
+ private InetAddress address;
@Override
public ServerConnection createConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
- try {
- initialize(connectionProperties);
- return new LocalServerConnection(connectionProperties, this.clientServices);
- } catch (ApplicationInitializationException e) {
- throw new ConnectionException(e, e.getMessage());
- }
+ return new LocalServerConnection(connectionProperties, this.clientServices);
}
-
/**
* When the DQP is restarted using the admin API, it only shuts it down, it gets
@@ -114,26 +111,13 @@
* @throws ApplicationInitializationException
* @since 4.3
*/
- public synchronized void initialize(Properties info) throws ApplicationInitializationException {
- if (this.init) {
- return;
- }
+ public void initialize(Properties props) throws MetaMatrixCoreException {
+ URL bootstrapURL = URLHelper.buildURL(props.getProperty(DQPEmbeddedProperties.BOOTURL));
+ String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME, "embedded"); //$NON-NLS-1$
- URL bootstrapURL = null;
- Properties props = new Properties(System.getProperties());
- String processName = "embedded"; //$NON-NLS-1$
-
try {
- bootstrapURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.BOOTURL));
- props.putAll(PropertiesUtils.loadFromURL(bootstrapURL));
- props.putAll(info);
- props = PropertiesUtils.resolveNestedProperties(props);
-
- processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME, processName);
- props.setProperty(DQPEmbeddedProperties.PROCESSNAME, processName);
-
// Create a temporary workspace directory
- String teiidHome = info.getProperty(DQPEmbeddedProperties.TEIID_HOME);
+ String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
this.workspaceDirectory = createWorkspace(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR, "work"), processName); //$NON-NLS-1$
props.setProperty(DQPEmbeddedProperties.DQP_WORKDIR, this.workspaceDirectory);
@@ -158,8 +142,9 @@
}
this.jmxServer = new JMXUtil(processName);
-
- EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, this.jmxServer);
+ address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
+
+ EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, this.jmxServer, address);
Injector injector = Guice.createInjector(config);
ResourceFinder.setInjector(injector);
config.setInjector(injector);
@@ -182,16 +167,30 @@
boolean enableSocketTransport = PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.ENABLE_SOCKETS, false);
if (enableSocketTransport) {
this.socketTransport = new SocketTransport(props, this.clientServices, (SessionServiceInterface)findService(DQPServiceNames.SESSION_SERVICE));
- this.socketTransport.start();
+ this.socketTransport.start(address);
}
this.shutdownThread = new ShutdownWork();
Runtime.getRuntime().addShutdownHook(this.shutdownThread);
this.starttime = System.currentTimeMillis();
- this.init = true;
DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
}
+
+ public InetAddress getAddress() {
+ return address;
+ }
+
+ private InetAddress resolveHostAddress(String bindAddress) {
+ try {
+ if (bindAddress == null) {
+ return NetUtils.getInstance().getInetAddress();
+ }
+ return NetUtils.resolveHostByName(bindAddress);
+ } catch (UnknownHostException e) {
+ throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+ }
+ }
private ClientServiceRegistry createClientServices(ConfigurationService configService) {
ClientServiceRegistry services = new ClientServiceRegistry();
@@ -339,8 +338,6 @@
// shutdown the cache.
ResourceFinder.getCacheFactory().destroy();
- this.init = false;
-
this.restart = restart;
}
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -24,7 +24,6 @@
import java.net.InetAddress;
import java.net.URL;
-import java.net.UnknownHostException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -46,7 +45,6 @@
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.JMXUtil;
-import com.metamatrix.common.util.NetUtils;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.LogListener;
@@ -70,12 +68,14 @@
private Properties props;
private URL bootstrapURL;
private JMXUtil jmx;
+ private InetAddress bindAddress;
Injector injector;
- public EmbeddedGuiceModule(URL bootstrapURL, Properties props, JMXUtil jmxUtil) {
+ public EmbeddedGuiceModule(URL bootstrapURL, Properties props, JMXUtil jmxUtil, InetAddress bindAddress) {
this.bootstrapURL = bootstrapURL;
this.props = props;
this.jmx = jmxUtil;
+ this.bindAddress = bindAddress;
}
@Override
@@ -87,9 +87,7 @@
bind(Properties.class).annotatedWith(Names.named("DQPProperties")).toInstance(this.props); //$NON-NLS-1$
bind(JMXUtil.class).annotatedWith(Names.named("jmx")).toInstance(this.jmx); //$NON-NLS-1$
- InetAddress address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
- bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(address);
- this.props.put(DQPEmbeddedProperties.HOST_ADDRESS, address);
+ bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(bindAddress);
bind(Cache.class).toProvider(CacheProvider.class).in(Scopes.SINGLETON);
bind(CacheFactory.class).to(JBossCacheFactory.class).in(Scopes.SINGLETON);
@@ -103,18 +101,7 @@
// this needs to be removed.
binder().requestStaticInjection(LogManager.class);
}
-
- private InetAddress resolveHostAddress(String bindAddress) {
- try {
- if (bindAddress == null) {
- return NetUtils.getInstance().getInetAddress();
- }
- return NetUtils.resolveHostByName(bindAddress);
- } catch (UnknownHostException e) {
- throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
- }
- }
-
+
private void configureServices() {
Map<String, Class<? extends ApplicationService>> defaults = getDefaultServiceClasses();
for(int i=0; i<DQPServiceNames.ALL_SERVICES.length; i++) {
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/Log4JUtil.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/Log4JUtil.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/Log4JUtil.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -106,6 +106,7 @@
contexts.add(ROOT_CONTEXT+com.metamatrix.dqp.util.LogConstants.CTX_COMMANDLOGGING);
contexts.add(ROOT_CONTEXT+com.metamatrix.dqp.util.LogConstants.CTX_AUDITLOGGING);
contexts.add(ROOT_CONTEXT+com.metamatrix.dqp.util.LogConstants.CTX_QUERY_SERVICE);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.dqp.util.LogConstants.CTX_PROCESS_INFO_LOG);
contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_CONFIG);
contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_COMMUNICATION);
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -22,7 +22,6 @@
package com.metamatrix.jdbc;
-import java.io.File;
import java.util.Properties;
import org.apache.log4j.Logger;
@@ -32,7 +31,6 @@
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.metamatrix.core.log.LogListener;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@Singleton
class LogListernerProvider implements Provider<LogListener> {
@@ -42,11 +40,6 @@
@Override
public LogListener get() {
- String logDirectory = this.props.getProperty(DQPEmbeddedProperties.DQP_LOGDIR);
- String processName = this.props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
-
- File logFile = new File(logDirectory, "teiid_"+processName+".log"); //$NON-NLS-1$ //$NON-NLS-2$
- System.setProperty("dqp.log4jFile", logFile.getAbsolutePath()); //$NON-NLS-1$ // hack
return new Log4jListener();
}
Modified: trunk/runtime/src/main/java/org/teiid/Server.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/Server.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/org/teiid/Server.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -27,13 +27,26 @@
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
+import java.util.Iterator;
import java.util.Properties;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.config.api.ExtensionModule;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.ApplicationInfo;
+import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.util.JMXUtil.FailedToRegisterException;
+import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.ZipFileUtil;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.dqp.embedded.services.EmbeddedConfigurationService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
public class Server extends EmbeddedConnectionFactoryImpl implements ServerMBean {
@@ -50,11 +63,11 @@
initialize(this.props);
getJMXServer().register(TYPE, NAME, this);
-
- } catch (ApplicationInitializationException e) {
- throw new MetaMatrixRuntimeException(e);
+
} catch (FailedToRegisterException e) {
throw new MetaMatrixRuntimeException(e.getCause());
+ } catch (MetaMatrixCoreException e) {
+ throw new MetaMatrixRuntimeException(e);
}
}
@@ -85,7 +98,6 @@
}
return true;
}
-
private static Properties loadConfiguration(String configFile) {
File f = new File (configFile);
@@ -97,13 +109,14 @@
Properties props = null;
try {
FileReader bootProperties = new FileReader(f);
- props = new Properties();
+ props = new Properties(System.getProperties());
props.load(bootProperties);
// enable socket communication by default.
props.setProperty(DQPEmbeddedProperties.ENABLE_SOCKETS, Boolean.TRUE.toString());
props.setProperty(DQPEmbeddedProperties.BOOTURL, f.getCanonicalPath());
props.setProperty(DQPEmbeddedProperties.TEIID_HOME, System.getProperty(DQPEmbeddedProperties.TEIID_HOME,f.getParentFile().getCanonicalPath()));
+ props = PropertiesUtils.resolveNestedProperties(props);
} catch (IOException e) {
System.out.println("Failed to load bootstrap properties file."); //$NON-NLS-1$
e.printStackTrace();
@@ -173,6 +186,10 @@
System.out.println("Teiid Server started on port = "+ port + " in "+time/1000+" Secs"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_PROCESS_INFO_LOG, MessageLevel.INFO)) {
+ s.logProcessInfo();
+ }
+
// wait.
while(s.isAlive()) {
try {
@@ -192,4 +209,79 @@
System.exit(10);
}
}
+
+ public void logProcessInfo() {
+ ApplicationInfo info = ApplicationInfo.getInstance();
+ StringBuffer sb = new StringBuffer("Process Information"); //$NON-NLS-1$
+
+ sb.append('\n');
+ sb.append(" Process Name: " + props.getProperty(DQPEmbeddedProperties.PROCESSNAME) ); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" Hostname: " + getAddress().getCanonicalHostName() ); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" Version: ").append(ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" Build Date: ").append(ApplicationInfo.getInstance().getBuildDate()); //$NON-NLS-1$
+
+ sb.append("\n---- System Properties ----\n"); //$NON-NLS-1$
+ sb.append(PropertiesUtils.prettyPrint(System.getProperties()));
+
+ sb.append("\n---- Deploy Properties ----\n"); //$NON-NLS-1$
+ sb.append(PropertiesUtils.prettyPrint(props));
+
+ sb.append("\n# of Processors: " + java.lang.Runtime.getRuntime().availableProcessors());//$NON-NLS-1$
+ sb.append("\nMax Avail memory: " + java.lang.Runtime.getRuntime().maxMemory());//$NON-NLS-1$
+ sb.append("\nFree memory: " + java.lang.Runtime.getRuntime().freeMemory());//$NON-NLS-1$
+
+ sb.append(info.getClasspathInfo());
+
+ sb.append("\n\n---- Extension Jars Manifest Info ----\n"); //$NON-NLS-1$
+
+ logManifestInfoForExtensionModules(sb);
+
+ LogManager.logInfo(LogConstants.CTX_PROCESS_INFO_LOG, sb.toString());
+ }
+
+ private void logManifestInfoForExtensionModules(StringBuffer sb) {
+ try {
+ EmbeddedConfigurationService ecs = (EmbeddedConfigurationService)getDQP().getEnvironment().findService(DQPServiceNames.CONFIGURATION_SERVICE);
+ for (ExtensionModule module : ecs.getExtensionModules()) {
+ sb.append("\n == Jar: " + module.getName() + " ===== " ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ File tempArchive = File.createTempFile("teiid", ".jar"); //$NON-NLS-1$ //$NON-NLS-2$
+ tempArchive.deleteOnExit();
+ FileUtils.write(module.getFileContents(), tempArchive);
+
+ Manifest m = ZipFileUtil.getManifest(tempArchive);
+ tempArchive.delete();
+ if (m != null) {
+ // only print the manifest info for MetaMatrix related jars that have
+ // the product information section
+ Attributes manifestAttributes = m.getMainAttributes();
+ if(manifestAttributes == null || manifestAttributes.isEmpty()){
+ continue;
+
+ }
+
+ for (Iterator ita = manifestAttributes.keySet().iterator(); ita.hasNext();) {
+ Object n = ita.next();
+ Object v = manifestAttributes.get(n);
+
+ sb.append("\n");//$NON-NLS-1$
+ sb.append(" ");//$NON-NLS-1$
+ sb.append(n.toString());
+ sb.append(": "); //$NON-NLS-1$
+ sb.append(v.toString());
+
+ }
+ sb.append("\n");//$NON-NLS-1$
+
+ }
+ }
+ } catch(Exception e) {
+ sb.append("**** Error: Unable to list manifest - msg: " + e.getMessage());//$NON-NLS-1$
+ }
+
+ }
+
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -27,6 +27,7 @@
import java.security.GeneralSecurityException;
import java.util.Properties;
+import com.google.inject.name.Named;
import com.metamatrix.common.comm.ClientServiceRegistry;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.queue.WorkerPoolStats;
@@ -61,12 +62,12 @@
this.sessionSerice = sessionService;
}
- public void start() {
+ public void start(@Named(DQPEmbeddedProperties.HOST_ADDRESS) InetAddress hostAddress) {
int socketPort = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.SERVER_PORT, DEFAULT_SERVER_PORT);
int maxThreads = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.MAX_THREADS, DEFAULT_MAX_THREADS);
int inputBufferSize = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.INPUT_BUFFER_SIZE, DEFAULT_INPUT_BUFFER_SIZE);
int outputBufferSize = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.OUTPUT_BUFFER_SIZE, DEFAULT_OUTPUT_BUFFER_SIZE);
- String bindAddress = ((InetAddress)props.get(DQPEmbeddedProperties.HOST_ADDRESS)).getHostAddress();
+ String bindAddress = hostAddress.getHostAddress();
try {
SSLConfiguration helper = new SSLConfiguration();
Modified: trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
===================================================================
--- trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -22,6 +22,7 @@
package com.metamatrix.dqp.embedded;
+import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
@@ -54,7 +55,7 @@
URL url = buildDQPUrl(UnitTestUtil.getTestDataPath() + "/bqt/fakebqt.properties"); //$NON-NLS-1$
p.load(url.openStream());
- EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p, new JMXUtil("test")); //$NON-NLS-1$
+ EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p, new JMXUtil("test"), InetAddress.getLocalHost() ); //$NON-NLS-1$
Injector injector = Guice.createInjector(source);
source.setInjector(injector);
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2009-08-13 22:41:24 UTC (rev 1243)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2009-08-15 03:23:38 UTC (rev 1244)
@@ -164,7 +164,7 @@
p.setProperty(MMURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
if (sscf == null) {
sscf = new SocketServerConnectionFactory();
- sscf.init(socketConfig);
+ sscf.initialize(socketConfig);
}
return sscf.createConnection(p);
}
More information about the teiid-commits
mailing list