[teiid-commits] teiid SVN: r1053 - in trunk: common-internal/src/main/java/com/metamatrix/common/log and 18 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Mon Jun 15 16:21:27 EDT 2009
Author: rareddy
Date: 2009-06-15 16:21:26 -0400 (Mon, 15 Jun 2009)
New Revision: 1053
Added:
trunk/engine/src/main/java/com/metamatrix/dqp/service/AuditMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java
Removed:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTrackingService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/TrackingService.java
trunk/engine/src/main/java/com/metamatrix/dqp/spi/CommandLoggerSPI.java
trunk/engine/src/main/java/com/metamatrix/dqp/spi/TrackerLogConstants.java
trunk/engine/src/main/java/com/metamatrix/dqp/spi/basic/
trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java
trunk/engine/src/test/java/com/metamatrix/dqp/spi/basic/
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/tracker/
Modified:
trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
trunk/common-internal/src/main/java/com/metamatrix/common/util/LogContextsUtil.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java
trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/AuditMessageFormat.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/DelimitedAuditMessageFormat.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/ReadableAuditMessageFormat.java
trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java
trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java
Log:
TEIID-667, TEIID-668: removing the custom loggers for audit and command logging.
Modified: trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -41,7 +41,7 @@
public LogMessage(String context, int level, Object[] msgParts ) {
this.context = context;
this.level = level;
- this.msgParts = convertMsgParts(msgParts);
+ this.msgParts = msgParts;
this.timestamp = System.currentTimeMillis();
this.threadName = Thread.currentThread().getName();
}
@@ -84,20 +84,8 @@
return this.exception;
}
-
-
- //do a toString() to the object array before adding to the worker
- //to make sure the current state is recorded
- private Object[] convertMsgParts(Object[] oriMsgParts){
- if(oriMsgParts == null){
- return oriMsgParts;
- }
- for(int i=0; i<oriMsgParts.length; i++){
- if(oriMsgParts[i] != null){
- oriMsgParts[i] = oriMsgParts[i].toString();
- }
- }
- return oriMsgParts;
+ public Object[] getMessageParts() {
+ return this.msgParts;
}
public String getText() {
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -295,7 +295,7 @@
* @param message the individual parts of the log message; the message is
* not logged if this parameter is null
*/
- public static void log(int msgLevel, String context, String message) {
+ public static void log(int msgLevel, String context, Object message) {
logMessage(msgLevel, context, message);
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/util/LogContextsUtil.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/util/LogContextsUtil.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/util/LogContextsUtil.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -67,16 +67,8 @@
public static final String CTX_EXTENSION_SOURCE = "EXTENSION_MODULE"; //$NON-NLS-1$
public static final String CTX_EXTENSION_SOURCE_JDBC = "JDBC_EXT_MODULE_TRANSACTION"; //$NON-NLS-1$
public static final String CTX_COMMUNICATION = "COMMUNICATION"; //$NON-NLS-1$
-
-
-
- // Types
- public static final String TYPE_INFO = "INFO"; //$NON-NLS-1$
- public static final String TYPE_TRACE = "TRACE"; //$NON-NLS-1$
- public static final String TYPE_ERROR = "ERROR"; //$NON-NLS-1$
- public static final String TYPE_DEBUG = "DEBUG"; //$NON-NLS-1$
- public static final String TYPE_EXCEPTION = "EXCEPTION"; //$NON-NLS-1$
- public static final String TYPE_WARNING = "WARNING"; //$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 class SecurityConstants {
@@ -141,12 +133,6 @@
public static final String CTX_QUERY_SERVICE = "QUERY_SERVICE"; //$NON-NLS-1$
}
- public static class ODBCConstants {
-
- public static final String ODBC_CONNECTION = "ODBC_CONNECTION"; //$NON-NLS-1$
- public static final String ODBC_STATEMENT = "ODBC_STATEMENT"; //$NON-NLS-1$
- }
-
/**
* The Set of all String logging contexts of all parts of the server.
*/
@@ -215,9 +201,6 @@
allContexts.add(ServerConstants.CTX_ROUTER);
allContexts.add(ServerConstants.CTX_QUERY_SERVICE);
- allContexts.add(ODBCConstants.ODBC_CONNECTION);
- allContexts.add(ODBCConstants.ODBC_STATEMENT);
-
ALL_CONTEXTS = Collections.unmodifiableSet(allContexts);
}
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -42,7 +42,6 @@
import com.metamatrix.dqp.embedded.services.EmbeddedConfigurationService;
import com.metamatrix.dqp.embedded.services.EmbeddedDataService;
import com.metamatrix.dqp.embedded.services.EmbeddedMetadataService;
-import com.metamatrix.dqp.embedded.services.EmbeddedTrackingService;
import com.metamatrix.dqp.embedded.services.EmbeddedTransactionService;
import com.metamatrix.dqp.embedded.services.EmbeddedVDBService;
import com.metamatrix.dqp.service.DQPServiceNames;
@@ -93,7 +92,6 @@
public Map<String, Class<? extends ApplicationService>> getDefaultServiceClasses() {
Map<String, Class<? extends ApplicationService>> result = new HashMap<String, Class<? extends ApplicationService>>();
result.put(DQPServiceNames.CONFIGURATION_SERVICE, EmbeddedConfigurationService.class);
- result.put(DQPServiceNames.TRACKING_SERVICE, EmbeddedTrackingService.class);
result.put(DQPServiceNames.BUFFER_SERVICE, EmbeddedBufferService.class);
result.put(DQPServiceNames.VDB_SERVICE, EmbeddedVDBService.class);
result.put(DQPServiceNames.METADATA_SERVICE, EmbeddedMetadataService.class);
Deleted: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTrackingService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTrackingService.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTrackingService.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,118 +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.dqp.embedded.services;
-
-import java.util.Properties;
-
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.dqp.service.TrackingService;
-
-public class EmbeddedTrackingService extends EmbeddedBaseDQPService implements TrackingService {
- //public static HashMap traceData = new HashMap();
-
- /*
- * @see com.metamatrix.dqp.service.TrackingService#log(java.lang.String, long, java.lang.String, short, java.lang.String, java.lang.String, short, java.lang.String, java.lang.String, java.lang.String, int)
- */
- public void log(
- String requestId,
- long nodeID,
- String subTxnUid,
- short status,
- String modelName,
- String cbName,
- short cmdPoint,
- String sessionUid,
- String principal,
- String sql,
- int rowCount,
- ExecutionContext context) {
-
- }
-
- /*
- * @see com.metamatrix.dqp.service.TrackingService#log(java.lang.String, short, short, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void log(
- String txnUid,
- short txnPoint,
- short status,
- String sessionUid,
- String principal,
- String vdbName,
- String vdbVersion) {
-
- }
-
- /*
- * @see com.metamatrix.dqp.service.TrackingService#log(java.lang.String, java.lang.String, short, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void log(
- String requestId,
- String txnUid,
- short cmdPoint,
- short status,
- String sessionUid,
- String applicationName,
- String principal,
- String vdbName,
- String vdbVersion,
- String sql,
- int rowCount) {
-
- }
-
- public boolean willRecordMMCmd() {
- return false;
- }
- public boolean willRecordSrcCmd() {
- return false;
- }
- public boolean willRecordTxn() {
- return false;
- }
-
- /**
- * @see com.metamatrix.dqp.embedded.services.EmbeddedBaseDQPService#initializeService(java.util.Properties)
- * @since 4.3
- */
- public void initializeService(Properties properties) throws ApplicationInitializationException {
- }
-
- /**
- * @see com.metamatrix.dqp.embedded.services.EmbeddedBaseDQPService#startService(com.metamatrix.common.application.ApplicationEnvironment)
- * @since 4.3
- */
- public void startService(ApplicationEnvironment environment) throws ApplicationLifecycleException {
- }
-
- /**
- * @see com.metamatrix.dqp.embedded.services.EmbeddedBaseDQPService#stopService()
- * @since 4.3
- */
- public void stopService() throws ApplicationLifecycleException {
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -45,7 +45,6 @@
public static final String PROCESS_POOL_MAX_THREADS = "ProcessPoolMaxThreads"; //$NON-NLS-1$
public static final String PROCESSOR_DEBUG_ALLOWED = "ProcessorDebugAllowed"; //$NON-NLS-1$
- public static final String COMMAND_LOGGER_CLASSNAME = "metamatrix.server.commandLoggerClassname"; //$NON-NLS-1$
/**
* Get the DQP properties, as described in {@link DQPProperties}.
Copied: trunk/engine/src/main/java/com/metamatrix/dqp/service/AuditMessage.java (from rev 1051, trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/AuditMessage.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/AuditMessage.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -0,0 +1,133 @@
+/*
+ * 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.dqp.service;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+
+import com.metamatrix.common.config.CurrentConfiguration;
+
+public class AuditMessage {
+ public static final String PROCESS_NAME = CurrentConfiguration.getInstance().getProcessName();
+ public static final String HOST_NAME = CurrentConfiguration.getInstance().getConfigurationName();
+
+ private static final String RESOURCE_DELIMITER = ", "; //$NON-NLS-1$
+
+ private String context;
+ private String activity;
+ private String principal;
+ private Object[] resources;
+
+ public AuditMessage(String context, String activity, String principal, Object[] resources ) {
+ this.context = context;
+ this.activity = activity;
+ this.principal = principal;
+ this.resources = resources;
+ }
+
+ public String getContext() {
+ return this.context;
+ }
+
+ public String getActivity() {
+ return this.activity;
+ }
+
+ public String getPrincipal() {
+ return this.principal;
+ }
+
+ public Object[] getResources() {
+ return this.resources;
+ }
+
+ public String getText() {
+ StringBuffer text = new StringBuffer();
+ if(resources != null && resources.length > 0 ) {
+ Object resource = resources[0];
+ if ( resource != null ) {
+ text.append(resource.toString());
+ }
+ for(int i=1; i<resources.length; ++i) {
+ text.append(RESOURCE_DELIMITER);
+ resource = resources[i];
+ if ( resource != null ) {
+ text.append(resource.toString());
+ }
+ }
+ }
+ return text.toString();
+ }
+
+ public String getText( String delimiter ) {
+ StringBuffer text = new StringBuffer();
+ if ( delimiter != null ) {
+ if(resources != null && resources.length > 0 ) {
+ Object resource = resources[0];
+ if ( resource != null ) {
+ text.append(resource.toString());
+ }
+ for(int i=1; i<resources.length; ++i) {
+ text.append(delimiter);
+ resource = resources[i];
+ if ( resource != null ) {
+ text.append(resource.toString());
+ }
+ }
+ }
+ } else {
+ if(resources != null && resources.length > 0 ) {
+ Object resource = resources[0];
+ if ( resource != null ) {
+ text.append(resource.toString());
+ }
+ for(int i=1; i<resources.length; ++i) {
+ text.append(RESOURCE_DELIMITER);
+ resource = resources[i];
+ if ( resource != null ) {
+ text.append(resource.toString());
+ }
+ }
+ }
+ }
+ return text.toString();
+ }
+
+ public String toString() {
+ StringBuffer msg = new StringBuffer();
+ msg.append(" ["); //$NON-NLS-1$
+ msg.append( getPrincipal() );
+ msg.append("] <"); //$NON-NLS-1$
+ msg.append( getContext() );
+ msg.append('.');
+ msg.append( getActivity() );
+ msg.append("> "); //$NON-NLS-1$
+ msg.append( getText() );
+
+ return msg.toString();
+ }
+
+}
Copied: trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java (from rev 1051, trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingMessage.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -0,0 +1,190 @@
+/*
+ * 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.dqp.service;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.teiid.connector.api.ExecutionContext;
+
+
+
+public class CommandLogMessage {
+
+ static final int USER_COMMAND_START = 0;
+ static final int USER_COMMAND_END = 1;
+ static final int DATASOURCE_COMMAND_START = 2;
+ static final int DATASOURCE_COMMAND_END = 3;
+
+ public static final short CMD_POINT_BEGIN = 1;
+ public static final short CMD_POINT_END = 2;
+
+ public static final short CMD_STATUS_NEW = 1;
+ public static final short CMD_STATUS_END = 2;
+ public static final short CMD_STATUS_CANCEL = 3;
+ public static final short CMD_STATUS_ERROR = 4;
+
+ private static final String TIMESTAMP_FORMAT = "yyyy.MM.dd HH:mm:ss.SSS"; //$NON-NLS-1$
+ private static DateFormat TIMESTAMP_FORMATTER = new SimpleDateFormat(TIMESTAMP_FORMAT);
+
+ int type;
+ long timestamp;
+
+ // Transaction info
+ String transactionID;
+ String subTransactionID;
+ boolean isCommit;
+
+ // Session info
+ String sessionID;
+ String applicationName;
+ String principal;
+ String vdbName;
+ String vdbVersion;
+
+ // RequestInfo
+ String requestID;
+ long sourceCommandID;
+ String sql;
+ int rowCount;
+ String modelName;
+ String connectorBindingName;
+ boolean isCancelled;
+ boolean errorOccurred;
+ ExecutionContext executionContext;
+
+
+ public CommandLogMessage(long timestamp,
+ String requestID,
+ String transactionID,
+ String sessionID,
+ String applicationName,
+ String principal,
+ String vdbName,
+ String vdbVersion,
+ String sql) {
+ // userCommandStart
+ this.type = USER_COMMAND_START;
+ this.timestamp = timestamp;
+ this.requestID = requestID;
+ this.transactionID = transactionID;
+ this.sessionID = sessionID;
+ this.applicationName = applicationName;
+ this.principal = principal;
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
+ this.sql = sql;
+ }
+ public CommandLogMessage(long timestamp,
+ String requestID,
+ String transactionID,
+ String sessionID,
+ String principal,
+ String vdbName,
+ String vdbVersion,
+ int finalRowCount,
+ boolean isCancelled,
+ boolean errorOccurred) {
+ // userCommandEnd
+ this.type = USER_COMMAND_END;
+ this.timestamp = timestamp;
+ this.requestID = requestID;
+ this.transactionID = transactionID;
+ this.sessionID = sessionID;
+ this.principal = principal;
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
+ this.rowCount = finalRowCount;
+ this.isCancelled = isCancelled;
+ this.errorOccurred = errorOccurred;
+ }
+ public CommandLogMessage(long timestamp,
+ String requestID,
+ long sourceCommandID,
+ String subTransactionID,
+ String modelName,
+ String connectorBindingName,
+ String sessionID,
+ String principal,
+ String sql,
+ ExecutionContext context) {
+ // dataSourceCommandStart
+ this.type = DATASOURCE_COMMAND_START;
+ this.timestamp = timestamp;
+ this.requestID = requestID;
+ this.sourceCommandID = sourceCommandID;
+ this.subTransactionID = subTransactionID;
+ this.modelName = modelName;
+ this.connectorBindingName = connectorBindingName;
+ this.sessionID = sessionID;
+ this.principal = principal;
+ this.sql = sql;
+ this.executionContext = context;
+ }
+ public CommandLogMessage(long timestamp,
+ String requestID,
+ long sourceCommandID,
+ String subTransactionID,
+ String modelName,
+ String connectorBindingName,
+ String sessionID,
+ String principal,
+ int finalRowCount,
+ boolean isCancelled,
+ boolean errorOccurred,
+ ExecutionContext context) {
+ // dataSourceCommandEnd
+ this.type = DATASOURCE_COMMAND_END;
+ this.timestamp = timestamp;
+ this.requestID = requestID;
+ this.sourceCommandID = sourceCommandID;
+ this.subTransactionID = subTransactionID;
+ this.modelName = modelName;
+ this.connectorBindingName = connectorBindingName;
+ this.sessionID = sessionID;
+ this.principal = principal;
+ this.rowCount = finalRowCount;
+ this.isCancelled = isCancelled;
+ this.errorOccurred = errorOccurred;
+ this.executionContext = context;
+ }
+
+ public String toString() {
+ switch (this.type) {
+ case USER_COMMAND_START:
+ return getTimestampString(new Date()) + "\tSTART USER COMMAND:\tstartTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tapplicationName=" + applicationName + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ case USER_COMMAND_END:
+ return getTimestampString(new Date()) + "\tEND USER COMMAND:\tendTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tfinalRowCount=" + rowCount + "\tisCancelled=" + isCancelled + "\terrorOccurred=" + errorOccurred; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
+ case DATASOURCE_COMMAND_START:
+ return getTimestampString(new Date()) + "\tSTART DATA SRC COMMAND:\tstartTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\tsubTxID=" + subTransactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ case DATASOURCE_COMMAND_END:
+ return getTimestampString(new Date()) + "\tEND DATA SRC COMMAND:\tendTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\tsubTxID=" + subTransactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tfinalRowCount=" + rowCount + "\tisCancelled=" + isCancelled + "\terrorOccurred=" + errorOccurred; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
+ }
+ return null;
+ }
+
+ private String getTimestampString(Date date) {
+ return TIMESTAMP_FORMATTER.format(date);
+ }
+}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingMessage.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingMessage.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,250 +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.dqp.service;
-
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.dqp.spi.CommandLoggerSPI;
-
-
-
-class CustomizableTrackingMessage implements Runnable {
-
- static final int USER_COMMAND_START = 0;
- static final int USER_COMMAND_END = 1;
- static final int DATASOURCE_COMMAND_START = 2;
- static final int DATASOURCE_COMMAND_END = 3;
- static final int TRANSACTION_START = 4;
- static final int TRANSACTION_END = 5;
-
- int type;
- long timestamp;
-
- // Transaction info
- String transactionID;
- String subTransactionID;
- boolean isCommit;
-
- // Session info
- String sessionID;
- String applicationName;
- String principal;
- String vdbName;
- String vdbVersion;
-
- // RequestInfo
- String requestID;
- long sourceCommandID;
- String sql;
- int rowCount;
- String modelName;
- String connectorBindingName;
- boolean isCancelled;
- boolean errorOccurred;
- ExecutionContext executionContext;
-
- CommandLoggerSPI commandLogger;
-
- CustomizableTrackingMessage(long timestamp,
- String requestID,
- String transactionID,
- String sessionID,
- String applicationName,
- String principal,
- String vdbName,
- String vdbVersion,
- String sql) {
- // userCommandStart
- this.type = USER_COMMAND_START;
- this.timestamp = timestamp;
- this.requestID = requestID;
- this.transactionID = transactionID;
- this.sessionID = sessionID;
- this.applicationName = applicationName;
- this.principal = principal;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
- this.sql = sql;
- }
- CustomizableTrackingMessage(long timestamp,
- String requestID,
- String transactionID,
- String sessionID,
- String principal,
- String vdbName,
- String vdbVersion,
- int finalRowCount,
- boolean isCancelled,
- boolean errorOccurred) {
- // userCommandEnd
- this.type = USER_COMMAND_END;
- this.timestamp = timestamp;
- this.requestID = requestID;
- this.transactionID = transactionID;
- this.sessionID = sessionID;
- this.principal = principal;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
- this.rowCount = finalRowCount;
- this.isCancelled = isCancelled;
- this.errorOccurred = errorOccurred;
- }
- CustomizableTrackingMessage(long timestamp,
- String requestID,
- long sourceCommandID,
- String subTransactionID,
- String modelName,
- String connectorBindingName,
- String sessionID,
- String principal,
- String sql,
- ExecutionContext context) {
- // dataSourceCommandStart
- this.type = DATASOURCE_COMMAND_START;
- this.timestamp = timestamp;
- this.requestID = requestID;
- this.sourceCommandID = sourceCommandID;
- this.subTransactionID = subTransactionID;
- this.modelName = modelName;
- this.connectorBindingName = connectorBindingName;
- this.sessionID = sessionID;
- this.principal = principal;
- this.sql = sql;
- this.executionContext = context;
- }
- CustomizableTrackingMessage(long timestamp,
- String requestID,
- long sourceCommandID,
- String subTransactionID,
- String modelName,
- String connectorBindingName,
- String sessionID,
- String principal,
- int finalRowCount,
- boolean isCancelled,
- boolean errorOccurred,
- ExecutionContext context) {
- // dataSourceCommandEnd
- this.type = DATASOURCE_COMMAND_END;
- this.timestamp = timestamp;
- this.requestID = requestID;
- this.sourceCommandID = sourceCommandID;
- this.subTransactionID = subTransactionID;
- this.modelName = modelName;
- this.connectorBindingName = connectorBindingName;
- this.sessionID = sessionID;
- this.principal = principal;
- this.rowCount = finalRowCount;
- this.isCancelled = isCancelled;
- this.errorOccurred = errorOccurred;
- this.executionContext = context;
- }
- CustomizableTrackingMessage(long timestamp,
- String transactionID,
- String sessionID,
- String principal,
- String vdbName,
- String vdbVersion) {
- // transactionStart
- this.type = TRANSACTION_START;
- this.timestamp = timestamp;
- this.transactionID = transactionID;
- this.sessionID = sessionID;
- this.principal = principal;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
- }
- CustomizableTrackingMessage(long timestamp,
- String transactionID,
- String sessionID,
- String principal,
- String vdbName,
- String vdbVersion,
- boolean isCommit) {
- // transactionEnd
- this.type = TRANSACTION_END;
- this.timestamp = timestamp;
- this.transactionID = transactionID;
- this.sessionID = sessionID;
- this.principal = principal;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
- this.isCommit = isCommit;
- }
-
- public void run() {
- switch(type) {
- case CustomizableTrackingMessage.USER_COMMAND_START:
- commandLogger.userCommandStart(timestamp,
- requestID,
- transactionID,
- sessionID,
- applicationName,
- principal,
- vdbName,
- vdbVersion,
- sql);
- break;
- case CustomizableTrackingMessage.USER_COMMAND_END:
- commandLogger.userCommandEnd(timestamp,
- requestID,
- transactionID,
- sessionID,
- principal,
- vdbName,
- vdbVersion,
- rowCount,
- isCancelled,
- errorOccurred);
- break;
- case CustomizableTrackingMessage.DATASOURCE_COMMAND_START:
- commandLogger.dataSourceCommandStart(timestamp,
- requestID,
- sourceCommandID,
- subTransactionID,
- modelName,
- connectorBindingName,
- sessionID,
- principal,
- sql,
- executionContext);
-
- break;
- case CustomizableTrackingMessage.DATASOURCE_COMMAND_END:
- commandLogger.dataSourceCommandEnd(timestamp,
- requestID,
- sourceCommandID,
- subTransactionID,
- modelName,
- connectorBindingName,
- sessionID,
- principal,
- rowCount,
- isCancelled,
- errorOccurred,
- executionContext);
- break;
- }
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,258 +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.dqp.service;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
-import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.spi.CommandLoggerSPI;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
-
-
-/**
- * Tracking service implementation that defers to a {@link CommandLoggerSPI}
- * service provider.
- *
- * A value for the {@link DQPServiceProperties.TrackingService#COMMAND_LOGGER_CLASSNAME}
- * must be supplied in the DQP properties in order to use this Tracking Service
- * implementation.
- */
-public class CustomizableTrackingService implements TrackingService {
-
- /**
- * Whether to log transaction. Defaults to false.
- */
- public static final String SYSTEM_TXN_STORE_TXN = "metamatrix.transaction.log.storeTXN"; //$NON-NLS-1$
-
- /**
- * Whether to log MetaMatrix command. Defaults to false.
- */
- public static final String SYSTEM_TXN_STORE_MMCMD = "metamatrix.transaction.log.storeMMCMD"; //$NON-NLS-1$
-
- /**
- * Whether to log source command. Defaults to false.
- */
- public static final String SYSTEM_TXN_STORE_SRCCMD = "metamatrix.transaction.log.storeSRCCMD"; //$NON-NLS-1$
-
- private CommandLoggerSPI commandLogger;
- private boolean recordUserCommands;
- private boolean recordSourceCommands;
-
- private WorkerPool logQueue;
-
- /**
- * @see com.metamatrix.dqp.service.TrackingService#log(java.lang.String, java.lang.String, short, short, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.metamatrix.query.sql.lang.Command)
- */
- public void log(String requestId,
- String txnUid,
- short cmdPoint,
- short status,
- String sessionUid,
- String applicationName,
- String principal,
- String vdbName,
- String vdbVersion,
- String sql,
- int rowCount) {
-
- if (this.willRecordMMCmd()) {
- CustomizableTrackingMessage message = null;
- if (cmdPoint == TrackerLogConstants.CMD_POINT.BEGIN) {
- message = new CustomizableTrackingMessage(System.currentTimeMillis(), requestId, txnUid, sessionUid, applicationName, principal, vdbName, vdbVersion, sql);
- } else {
- boolean isCancelled = false;
- boolean errorOccurred = false;
-
- if (status == TrackerLogConstants.CMD_STATUS.CANCEL) {
- isCancelled = true;
- } else if (status == TrackerLogConstants.CMD_STATUS.ERROR) {
- errorOccurred = true;
- }
- message = new CustomizableTrackingMessage(System.currentTimeMillis(), requestId, txnUid, sessionUid, principal, vdbName, vdbVersion, rowCount, isCancelled, errorOccurred);
- }
- addWork(message);
- }
- }
-
- /**
- * @see com.metamatrix.dqp.service.TrackingService#log(java.lang.String, long, java.lang.String, short, java.lang.String, java.lang.String, short, java.lang.String, java.lang.String, com.metamatrix.query.sql.lang.Command, int)
- */
- public void log(String requestId,
- long nodeID,
- String subTxnUid,
- short status,
- String modelName,
- String cbName,
- short cmdPoint,
- String sessionUid,
- String principal,
- String sql,
- int rowCount,
- ExecutionContext context) {
-
- if (this.willRecordSrcCmd()) {
- CustomizableTrackingMessage message = null;
- if (cmdPoint == TrackerLogConstants.CMD_POINT.BEGIN) {
- message = new CustomizableTrackingMessage(System.currentTimeMillis(), requestId, nodeID, subTxnUid, modelName, cbName, sessionUid, principal, sql, context);
-
- } else {
- boolean isCancelled = false;
- boolean errorOccurred = false;
-
- if (status == TrackerLogConstants.CMD_STATUS.CANCEL) {
- isCancelled = true;
- } else if (status == TrackerLogConstants.CMD_STATUS.ERROR) {
- errorOccurred = true;
- }
- message = new CustomizableTrackingMessage(System.currentTimeMillis(), requestId, nodeID, subTxnUid, modelName, cbName, sessionUid, principal, rowCount, isCancelled, errorOccurred, context);
- }
- addWork(message);
- }
- }
-
- /**
- * @see com.metamatrix.dqp.service.TrackingService#willRecordMMCmd()
- */
- public boolean willRecordMMCmd() {
- return this.recordUserCommands;
- }
-
- /**
- * @see com.metamatrix.dqp.service.TrackingService#willRecordSrcCmd()
- */
- public boolean willRecordSrcCmd() {
- return this.recordSourceCommands;
- }
-
- /**
- * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
- */
- public void initialize(Properties props) throws ApplicationInitializationException {
- String commandLoggerClassnameProperty = props.getProperty(DQPConfigSource.COMMAND_LOGGER_CLASSNAME);
-
- // Search for additional, implementation-specific properties stuff into
- // this string.
- // They should be delimited by semi-colon - TODO clean this up - sbale 5
- // /3/05
- //
- // Possible examples of expected value of commandLoggerClassnameProperty
- // String variable:
- //
- // com.metamatrix.dqp.spi.basic.FileCommandLogger;dqp.commandLogger.
- // fileName=commandLogFile.txt
- // com.myCode.MyCommandLoggerClass;myFirstCustomProperty=someValue;
- // mySecondCustomProperty=otherValue
-
- List tokens = StringUtil.getTokens(commandLoggerClassnameProperty, ";"); //$NON-NLS-1$
-
- // 1st token is the classname property
- String commandLoggerClassname = (String) tokens.remove(0);
-
- // Additional tokens are name/value pairs, properties specific to
- // service provider impl
- props = new Properties(props);
- Iterator i = tokens.iterator();
- while (i.hasNext()) {
- String nameValueString = (String) i.next();
- List nameValuePair = StringUtil.getTokens(nameValueString, "="); //$NON-NLS-1$
- String name = (String) nameValuePair.get(0);
- String value = (String) nameValuePair.get(1);
- props.setProperty(name, value);
- }
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try {
- CommandLoggerSPI logger = (CommandLoggerSPI)loader.loadClass(commandLoggerClassname).newInstance();
- logger.initialize(props);
- this.commandLogger = logger;
- } catch (Exception e) {
- throw new ApplicationInitializationException(e);
- }
-
- String propvalue = props.getProperty(SYSTEM_TXN_STORE_MMCMD);
- if(propvalue != null){
- recordUserCommands = Boolean.valueOf(propvalue).booleanValue();
- }
- propvalue = props.getProperty(SYSTEM_TXN_STORE_SRCCMD);
- if(propvalue != null){
- recordSourceCommands = Boolean.valueOf(propvalue).booleanValue();
- }
- }
-
- /**
- * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
- */
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
- logQueue = WorkerPoolFactory.newWorkerPool("CustomTracker", //$NON-NLS-1$
- 1);
- }
-
- /**
- * @see com.metamatrix.common.application.ApplicationService#stop()
- */
- public void stop() throws ApplicationLifecycleException {
- if (logQueue != null) {
- logQueue.shutdown();
- try {
- logQueue.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- }
- logQueue = null;
- }
- if (commandLogger != null) {
- this.commandLogger.close();
- }
- }
-
- private void addWork(CustomizableTrackingMessage work) {
- try {
- if (logQueue != null) {
- work.commandLogger = this.commandLogger;
- logQueue.execute(work);
- } else {
- LogManager.logWarning(LogCommonConstants.CTX_TXN_LOG, DQPPlugin.Util.getString("CustomizableTrackingService.not_started")); //$NON-NLS-1$
- }
- } catch (RejectedExecutionException e) {
- LogManager.logWarning(LogCommonConstants.CTX_TXN_LOG, e.getMessage());
- }
- }
-
- public CommandLoggerSPI getCommandLogger() {
- return commandLogger;
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -45,9 +45,6 @@
/** VDB service - provides access to vdb information */
public static final String VDB_SERVICE = "dqp.vdb"; //$NON-NLS-1$
- /** Tracking service - provides access to vdb information */
- public static final String TRACKING_SERVICE = "dqp.tracking"; //$NON-NLS-1$
-
/** Transaction service - provides access to MMTtransactionManager */
public static final String TRANSACTION_SERVICE = "dqp.transaction"; //$NON-NLS-1$
@@ -61,7 +58,6 @@
*/
public static final String[] ALL_SERVICES = new String[] {
CONFIGURATION_SERVICE,
- TRACKING_SERVICE,
BUFFER_SERVICE,
AUTHORIZATION_SERVICE,
TRANSACTION_SERVICE,
@@ -72,7 +68,6 @@
public static final Class[] ALL_SERVICE_CLASSES = new Class[] {
ConfigurationService.class,
- TrackingService.class,
BufferService.class,
AuthorizationService.class,
TransactionService.class,
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/TrackingService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TrackingService.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TrackingService.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,97 +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.dqp.service;
-
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.common.application.ApplicationService;
-
-/**
- * This service is used to log transactions and commands,
- * as well as store profiling data.
- */
-public interface TrackingService extends ApplicationService {
- /**
- * Log the command if the value of the property
- * "metamatrix.transaction.log.storeMMCMD" is "true".
- *
- * @param requestId Unique command ID.
- * @param txnUid Unique transaction ID.
- * @param cmdPoint Point in command being logged -
- * TransactionLogConstants.POINT.BEGIN,
- * or TransactionLogConstants.POINT.END.
- * @param sessionUid Session ID.
- * @param applicationName name of the user application
- * @param principal User name.
- * @param vdbName VDB name.
- * @param vdbVersion VDB version.
- * @param sql SQL for the command.
- * @param rowCount Final row count.
- */
- public void log(String requestId, String txnUid, short cmdPoint, short status,
- String sessionUid, String applicationName, String principal, String vdbName, String vdbVersion, String sql, int rowCount);
-
- /**
- * Log the command if the value of the property
- * "metamatrix.transaction.log.storeSRCCMD" is "true".
- *
- * @param requestId Unique command ID.
- * @param nodeID Subcommand ID
- * @param subTxnUid Unique subtransaction ID.
- * @param status Type of request - TransactionLogConstants.SRCCMD_STATUS.NEW,
- * or TransactionLogConstants.SRCCMD_STATUS.CANCEL, or TransactionLogConstants.SRCCMD_STATUS.END,
- * or TransactionLogConstants.SRCCMD_STATUS.ERROR.
- * @param modelName Name of model.
- * @param cbName Connector binding name.
- * @param cmdPoint Point in command being logged - TransactionLogConstants.POINT.BEGIN,
- * or TransactionLogConstants.POINT.END.
- * @param sessionUid Session ID.
- * @param principal User name.
- * @param sql SQL for the command.
- * @param rowCount Final row count.
- */
- public void log(String requestId, long nodeID, String subTxnUid,
- short status, String modelName, String cbName, short cmdPoint,
- String sessionUid, String principal, String sql, int rowCount,
- ExecutionContext context);
-
- /**
- * Returns whether the tracker will record MM commands.
- * @param txnPoint
- * @return
- * @since 4.2
- */
- public boolean willRecordMMCmd();
-
- /**
- * Returns whether the tracker will record source commands.
- * @param txnPoint
- * @return
- * @since 4.2
- */
- public boolean willRecordSrcCmd();
-
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/spi/CommandLoggerSPI.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/spi/CommandLoggerSPI.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/spi/CommandLoggerSPI.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,124 +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.dqp.spi;
-
-import java.util.Properties;
-
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.dqp.service.TrackingService;
-
-/**
- * Defines a service-provider interface for accepting command and transaction
- * information, suitable for logging, from MetaMatrix DQP.
- * (See DQP {@link TrackingService} interface.)
- */
-public interface CommandLoggerSPI {
-
- /**
- * Initialize this service provider with the specified properties. Properties
- * must be specified in the DQP properties (along with the property defining
- * the concrete classname of the implementation of this interface).
- * @param props Initialialization properties
- */
- public void initialize(Properties props);
-
- /**
- * Close this service provider, release any external resources
- */
- public void close();
-
- /**
- * A user command has started. This method will be called when the command
- * starts.
- * @param timestamp time in milliseconds marking the start of the command
- * @param requestID Unique command ID.
- * @param transactionID Unique transaction ID (optional, may be null)
- * @param sessionID Session ID.
- * @param applicationName name of the user application
- * @param principal User name.
- * @param vdbName VDB name.
- * @param vdbVersion VDB version.
- * @param sql SQL for the command.
- */
- public void userCommandStart(long timestamp, String requestID, String transactionID,
- String sessionID, String applicationName, String principal, String vdbName,
- String vdbVersion, String sql);
-
- /**
- * A user command has ended. This method will be called as the command
- * ends, either successfully, with an error, or by being cancelled.
- * @param timestamp time in milliseconds marking the end of the command.
- * @param requestID Unique command ID.
- * @param transactionID Unique transaction ID (optional, may be null)
- * @param sessionID Session ID.
- * @param principal User name.
- * @param vdbName VDB name.
- * @param vdbVersion VDB version.
- * @param finalRowCount total rows returned to the user.
- * @param isCancelled true if command was requested to be cancelled, false otherwise.
- * @param errorOccurred true if error occurred, false if status is okay.
- */
- public void userCommandEnd(long timestamp, String requestID, String transactionID,
- String sessionID, String principal, String vdbName, String vdbVersion,
- int finalRowCount, boolean isCancelled, boolean errorOccurred);
-
-
- /**
- * A data source-specific command has started. This method will be called as the
- * command starts.
- * @param timestamp time in milliseconds marking the start of the source command.
- * @param requestID Unique command ID.
- * @param sourceCommandID unique ID of source command, which is also the
- * ID of the plan node representing that source command.
- * @param subTransactionID Unique subtransaction ID (optional, may be null).
- * @param modelName Name of model.
- * @param connectorBindingName Connector binding name.
- * @param sessionID Session ID.
- * @param principal User name.
- * @param sql SQL for the command.
- */
- public void dataSourceCommandStart(long timestamp, String requestID, long sourceCommandID, String subTransactionID, String modelName,
- String connectorBindingName, String sessionID, String principal, String sql, ExecutionContext context);
-
- /**
- * Data source-specific command has ended. This method will be called as the
- * command ends, either normally, by being cancelled, or with an error.
- * @param timestamp time in milliseconds marking the end of the source command.
- * @param requestID Unique command ID.
- * @param sourceCommandID unique ID of source command, which is also the
- * ID of the plan node representing that source command.
- * @param subTransactionID Unique subtransaction ID (optional, may be null).
- * @param modelName Name of model.
- * @param connectorBindingName Connector binding name.
- * @param sessionID Session ID.
- * @param principal User name.
- * @param finalRowCount Final row count.
- * @param isCancelled true if command was requested to be cancelled, false otherwise.
- * @param errorOccurred true if error occurred, false if status is okay.
- */
- public void dataSourceCommandEnd(long timestamp, String requestID, long sourceCommandID, String subTransactionID, String modelName,
- String connectorBindingName, String sessionID, String principal, int finalRowCount,
- boolean isCancelled, boolean errorOccurred, ExecutionContext context);
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/spi/TrackerLogConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/spi/TrackerLogConstants.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/spi/TrackerLogConstants.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,65 +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.dqp.spi;
-
-/**
- *
- */
-public class TrackerLogConstants {
- public static class CMD_POINT{
- public static final short BEGIN = 1;
- public static final short END = 2;
- }
-
- public static class TXN_POINT{
- public static final short BEGIN = 1;
- public static final short END = 2;
- public static final short ERROR = 3;
- public static final short INTERMEDIATE = 4;
-
- }
-
- public static class TXN_STATUS{
- public static final short BEGIN = 1;
- public static final short COMMIT = 2;
- public static final short ROLLBACK = 3;
- public static final short SET_ROLLBACK_ONLY = 4;
-
- public static class PARTICIPATE {
- public static final short START = 5;
- public static final short END = 6;
- public static final short PREPARE = 7;
- public static final short COMMIT = 8;
- public static final short FORGET = 9;
- public static final short RECOVER = 10;
- public static final short ROLLBACK = 11;
- }
- }
-
- public static class CMD_STATUS{
- public static final short NEW = 1;
- public static final short END = 2;
- public static final short CANCEL = 3;
- public static final short ERROR = 4;
- }
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -68,8 +68,10 @@
import com.metamatrix.common.queue.WorkerPoolFactory;
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.stats.ConnectionPoolStats;
+import com.metamatrix.common.util.LogContextsUtil;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.core.util.StringUtil;
@@ -81,11 +83,10 @@
import com.metamatrix.dqp.message.AtomicResultsMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.CommandLogMessage;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.TrackingService;
import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -117,7 +118,6 @@
//services acquired in start
private MetadataService metadataService;
- private TrackingService tracker;
private TransactionService transactionService;
private BufferService bufferService;
@@ -326,8 +326,6 @@
throw new ApplicationLifecycleException(DQPPlugin.Util.getString("Failed_to_find_service", new Object[]{DQPServiceNames.METADATA_SERVICE, connectorName})); //$NON-NLS-1$
}
- this.tracker = (TrackingService) env.findService(DQPServiceNames.TRACKING_SERVICE);
-
this.maxResultRows = PropertiesUtils.getIntProperty(props, ConnectorPropertyNames.MAX_RESULT_ROWS, 0);
this.exceptionOnMaxRows = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.EXCEPTION_ON_MAX_ROWS, false);
this.synchWorkers = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.SYNCH_WORKERS, true);
@@ -425,7 +423,7 @@
}
}
if (this.synchWorkers) {
- SynchronousWorkers synchWorkerAnnotation = (SynchronousWorkers) c.getClass().getAnnotation(SynchronousWorkers.class);
+ SynchronousWorkers synchWorkerAnnotation = c.getClass().getAnnotation(SynchronousWorkers.class);
if (synchWorkerAnnotation != null) {
this.synchWorkers = synchWorkerAnnotation.enabled();
}
@@ -480,7 +478,7 @@
private Connector wrapPooledConnector(Connector c, ConnectorEnvironment connectorEnv) {
//the pooling annotation overrides the connector binding
- ConnectionPooling connectionPooling = (ConnectionPooling) c.getClass().getAnnotation(ConnectionPooling.class);
+ ConnectionPooling connectionPooling = c.getClass().getAnnotation(ConnectionPooling.class);
boolean connectionPoolPropertyEnabled = PropertiesUtils.getBooleanProperty(connectorEnv.getProperties(), ConnectorPropertyNames.CONNECTION_POOL_ENABLED, true);
boolean propertySet = connectorEnv.getProperties().contains(ConnectorPropertyNames.CONNECTION_POOL_ENABLED);
boolean poolingEnabled = false;
@@ -595,11 +593,8 @@
* @param qr Request that contains the MetaMatrix command information in the transaction.
*/
void logSRCCommand(AtomicRequestMessage qr, ExecutionContext context, short cmdStatus, int finalRowCnt) {
- if(tracker == null || !tracker.willRecordSrcCmd()){
- return;
- }
String sqlStr = null;
- if(cmdStatus == TrackerLogConstants.CMD_STATUS.NEW){
+ if(cmdStatus == CommandLogMessage.CMD_STATUS_NEW){
Command cmd = qr.getCommand();
sqlStr = cmd != null ? cmd.toString() : null;
}
@@ -611,11 +606,26 @@
String modelName = qr.getModelName();
AtomicRequestID id = qr.getAtomicRequestID();
-
- tracker.log(qr.getRequestID().toString(), id.getNodeID(), transactionID,
- cmdStatus, modelName == null ? "null" : modelName, connectorName, //$NON-NLS-1$
- cmdStatus == TrackerLogConstants.CMD_STATUS.NEW ? TrackerLogConstants.CMD_POINT.BEGIN : TrackerLogConstants.CMD_POINT.END,
- qr.getWorkContext().getConnectionID(), userName == null ? "unknown" : userName, sqlStr, finalRowCnt, context); //$NON-NLS-1$
+
+ short cmdPoint = cmdStatus == CommandLogMessage.CMD_STATUS_NEW ? CommandLogMessage.CMD_POINT_BEGIN : CommandLogMessage.CMD_POINT_END;
+ String principal = userName == null ? "unknown" : userName; //$NON-NLS-1$
+
+ CommandLogMessage message = null;
+ if (cmdPoint == CommandLogMessage.CMD_POINT_BEGIN) {
+ message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName, qr.getWorkContext().getConnectionID(), principal, sqlStr, context);
+ }
+ else {
+ boolean isCancelled = false;
+ boolean errorOccurred = false;
+
+ if (cmdStatus == CommandLogMessage.CMD_STATUS_CANCEL) {
+ isCancelled = true;
+ } else if (cmdStatus == CommandLogMessage.CMD_STATUS_ERROR) {
+ errorOccurred = true;
+ }
+ message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName, qr.getWorkContext().getConnectionID(), principal, finalRowCnt, isCancelled, errorOccurred, context);
+ }
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_COMMANDLOGGING, message);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -56,7 +56,7 @@
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
+import com.metamatrix.dqp.service.CommandLogMessage;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -193,7 +193,7 @@
try {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing CANCEL request"}); //$NON-NLS-1$
asynchCancel();
- this.manager.logSRCCommand(this.requestMsg, this.securityContext, TrackerLogConstants.CMD_STATUS.CANCEL, -1);
+ this.manager.logSRCCommand(this.requestMsg, this.securityContext, CommandLogMessage.CMD_STATUS_CANCEL, -1);
} catch (ConnectorException e) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, DQPPlugin.Util.getString("Cancel_request_failed", this.id)); //$NON-NLS-1$
} finally {
@@ -219,7 +219,7 @@
}
private void handleError(Throwable t) {
- manager.logSRCCommand(this.requestMsg, this.securityContext, TrackerLogConstants.CMD_STATUS.ERROR, -1);
+ manager.logSRCCommand(this.requestMsg, this.securityContext, CommandLogMessage.CMD_STATUS_ERROR, -1);
String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed", this.id); //$NON-NLS-1$
if (isCancelled) {
@@ -242,7 +242,7 @@
this.isClosed = true;
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing Close :", this.requestMsg.getCommand()}); //$NON-NLS-1$
if (success) {
- manager.logSRCCommand(this.requestMsg, this.securityContext, TrackerLogConstants.CMD_STATUS.END, this.rowCount);
+ manager.logSRCCommand(this.requestMsg, this.securityContext, CommandLogMessage.CMD_STATUS_END, this.rowCount);
}
try {
if (execution != null) {
@@ -353,7 +353,7 @@
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Obtained execution"}); //$NON-NLS-1$
//Log the Source Command (Must be after obtaining the execution context)
- manager.logSRCCommand(this.requestMsg, this.securityContext, TrackerLogConstants.CMD_STATUS.NEW, -1);
+ manager.logSRCCommand(this.requestMsg, this.securityContext, CommandLogMessage.CMD_STATUS_NEW, -1);
}
protected void handleBatch()
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -57,6 +57,7 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.queue.WorkerPool;
import com.metamatrix.common.queue.WorkerPoolFactory;
+import com.metamatrix.common.util.LogContextsUtil;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
@@ -75,14 +76,13 @@
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.CommandLogMessage;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.TrackingService;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -135,7 +135,6 @@
private BufferManager bufferManager;
private ProcessorDataManager dataTierMgr;
private PreparedPlanCache prepPlanCache;
- private TrackingService tracker;
private TransactionService transactionService;
private MetadataService metadataService;
private ResultSetCache rsCache;
@@ -511,9 +510,6 @@
}
void logMMCommand(RequestWorkItem workItem, boolean isBegin, boolean isCancel, int rowCount) {
- if(this.tracker == null || !tracker.willRecordMMCmd()){
- return;
- }
RequestMessage msg = workItem.requestMsg;
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID rID = new RequestID(workContext.getConnectionID(), msg.getExecutionId());
@@ -528,26 +524,30 @@
}
String appName = workContext.getAppName();
// Log to request log
- short point = isBegin? TrackerLogConstants.CMD_POINT.BEGIN:TrackerLogConstants.CMD_POINT.END;
- short status = TrackerLogConstants.CMD_STATUS.NEW;
+ short point = isBegin? CommandLogMessage.CMD_POINT_BEGIN:CommandLogMessage.CMD_POINT_END;
+ short status = CommandLogMessage.CMD_STATUS_NEW;
if(!isBegin){
if(isCancel){
- status = TrackerLogConstants.CMD_STATUS.CANCEL;
+ status = CommandLogMessage.CMD_STATUS_CANCEL;
}else{
- status = TrackerLogConstants.CMD_STATUS.END;
+ status = CommandLogMessage.CMD_STATUS_END;
}
}
- tracker.log(rID.toString(),
- txnID,
- point,
- status,
- workContext.getConnectionID(),
- appName,
- workContext.getUserName(),
- workContext.getVdbName(),
- workContext.getVdbVersion(),
- command,
- rowCount);
+ CommandLogMessage message = null;
+ if (point == CommandLogMessage.CMD_POINT_BEGIN) {
+ message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getConnectionID(), appName, workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), command);
+ } else {
+ boolean isCancelled = false;
+ boolean errorOccurred = false;
+
+ if (status == CommandLogMessage.CMD_STATUS_CANCEL) {
+ isCancelled = true;
+ } else if (status == CommandLogMessage.CMD_STATUS_ERROR) {
+ errorOccurred = true;
+ }
+ message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getConnectionID(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, isCancelled, errorOccurred);
+ }
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_COMMANDLOGGING, message);
}
ProcessorDataManager getDataTierManager() {
@@ -562,14 +562,6 @@
return bufferManager;
}
- TrackingService getTracker() {
- return tracker;
- }
-
- void setTracker(TrackingService tracker) {
- this.tracker = tracker;
- }
-
public TransactionService getTransactionService() {
if (transactionService == null) {
throw new MetaMatrixRuntimeException("Transactions are not enabled"); //$NON-NLS-1$
@@ -633,8 +625,6 @@
bufferManager = bufferService.getBufferManager();
contextCache = bufferService.getContextCache();
- //Get tracking service
- tracker = (TrackingService) env.findService(DQPServiceNames.TRACKING_SERVICE);
transactionService = (TransactionService )env.findService(DQPServiceNames.TRANSACTION_SERVICE);
metadataService = (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE);
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-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -56,6 +56,7 @@
import com.metamatrix.common.lob.LobChunk;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.util.LogContextsUtil;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.log.MessageLevel;
@@ -67,8 +68,8 @@
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.service.CommandLogMessage;
import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.analysis.QueryAnnotation;
@@ -661,24 +662,12 @@
* Log the command to the MM cmd log.
*/
private void logCommandError() {
- if ( dqpCore.getTracker() == null || !dqpCore.getTracker().willRecordMMCmd()) {
- return;
- }
String transactionID = null;
if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
transactionID = this.transactionContext.getTxnID();
}
- dqpCore.getTracker().log(requestID.toString(),
- transactionID == null ? null : transactionID,
- TrackerLogConstants.CMD_POINT.END,
- TrackerLogConstants.CMD_STATUS.ERROR,
- requestID.getConnectionID(),
- dqpWorkContext.getAppName(),
- dqpWorkContext.getUserName(),
- dqpWorkContext.getVdbName(),
- dqpWorkContext.getVdbVersion(),
- requestMsg.getCommandString(),
- -1);
+ CommandLogMessage message = new CommandLogMessage(System.currentTimeMillis(), requestID.toString(), transactionID == null ? null : transactionID, requestID.getConnectionID(), dqpWorkContext.getUserName(), dqpWorkContext.getVdbName(), dqpWorkContext.getVdbVersion(), -1, false, true);
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_COMMANDLOGGING, message);
}
boolean isCanceled() {
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,532 +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.dqp.service;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import junit.framework.TestCase;
-
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.dqp.spi.CommandLoggerSPI;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.TestQuery;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-/**
- * Tests the DQP Tracking service implementation which uses a CommandLogger service
- * provider
- */
-public class TestCustomizableTrackingService extends TestCase {
-
- /**
- * Constructor for TestConnectorCapabilitiesFinder.
- * @param name
- */
- public TestCustomizableTrackingService(String name) {
- super(name);
- }
-
- // ========================================================================================================
- // tests
- // ========================================================================================================
-
- public void testLogAll() throws Exception {
- CustomizableTrackingService trackingService = getTrackingService(true, true, true);
- List expectedResults = new ArrayList();
- expectedResults.add(logExampleSourceCommandStart(trackingService));
- expectedResults.add(logExampleUserCommandStart(trackingService));
- expectedResults.add(logExampleUserCommandEnd(trackingService));
- expectedResults.add(logExampleSourceCommandCancelled(trackingService));
- trackingService.stop();
- assertEquals(expectedResults, ((FakeCommandLogger)trackingService.getCommandLogger()).logEntries);
- }
-
- public void testLogJustTransactions() throws Exception {
- CustomizableTrackingService trackingService = getTrackingService(true, false, false);
- List expectedResults = new ArrayList();
- logExampleSourceCommandStart(trackingService);
- logExampleSourceCommandCancelled(trackingService);
- logExampleUserCommandStart(trackingService);
- logExampleUserCommandEnd(trackingService);
- trackingService.stop();
- assertEquals(expectedResults, ((FakeCommandLogger)trackingService.getCommandLogger()).logEntries);
- }
-
- public void testLogJustCommands() throws Exception {
- CustomizableTrackingService trackingService = getTrackingService(false, true, true);
- List expectedResults = new ArrayList();
- expectedResults.add(logExampleSourceCommandStart(trackingService));
- expectedResults.add(logExampleUserCommandStart(trackingService));
- expectedResults.add(logExampleUserCommandEnd(trackingService));
- expectedResults.add(logExampleSourceCommandCancelled(trackingService));
- trackingService.stop();
- assertEquals(expectedResults, ((FakeCommandLogger)trackingService.getCommandLogger()).logEntries);
- }
-
- public void testLogJustUserCommands() throws Exception {
- CustomizableTrackingService trackingService = getTrackingService(false, true, false);
- List expectedResults = new ArrayList();
- logExampleSourceCommandStart(trackingService);
- expectedResults.add(logExampleUserCommandStart(trackingService));
- expectedResults.add(logExampleUserCommandEnd(trackingService));
- logExampleSourceCommandCancelled(trackingService);
- trackingService.stop();
- assertEquals(expectedResults, ((FakeCommandLogger)trackingService.getCommandLogger()).logEntries);
- }
-
- /**
- * Test the tracking service as it is invoked by DQP during query processing
- * using a <code>String</code> as the query object.
- * <p>
- * This test creates a sample query statement of type <code>String</code> along
- * with an instance of <code>TrackingService</code> returned by a call to
- * <code>getTrackingService()</code> asking for a <code>TrackingService</code> that
- * will log the user-command. The query and <code>TrackingService</code> instance
- * are passed to the helper method <code>logUserCommandViaDQP()</code> and the
- * expected results returned from the helper method are compared to the actual
- * results logged by <code>FakeCommandLogger</code>.
- * <p>
- * This test can only succeed if the log entry sent to <code>FakeCommandLogger</code>
- * from <code>DQPCore</code> matches the expected results returned by the
- * helper method.
- *
- * @see #getTrackingService(boolean, boolean, boolean)
- * @see #helpLogUserCommandViaDQP(TrackingService, Serializable)
- * @since 6
- * @throws Exception
- */
- public void testUserCommandFromDQP_String() throws Exception {
- String sql = "SELECT SQRT(100)"; //$NON-NLS-1$
- CustomizableTrackingService trackingService = getTrackingService(false, true, false);
- helpLogUserCommandViaDQP(trackingService, sql);
- }
-
- // ========================================================================================================
- // test utilities
- // ========================================================================================================
-
- private CustomizableTrackingService getTrackingService(boolean willRecordTransactions,
- boolean willRecordUserCommands, boolean willRecordSourceCommands) throws ApplicationInitializationException, ApplicationLifecycleException {
-
- CustomizableTrackingService service = new CustomizableTrackingService();
- Properties p = new Properties();
- p.setProperty(CustomizableTrackingService.SYSTEM_TXN_STORE_SRCCMD, String.valueOf(willRecordSourceCommands));
- p.setProperty(CustomizableTrackingService.SYSTEM_TXN_STORE_MMCMD, String.valueOf(willRecordUserCommands));
- p.setProperty(CustomizableTrackingService.SYSTEM_TXN_STORE_TXN, String.valueOf(willRecordTransactions));
- p.setProperty(DQPConfigSource.COMMAND_LOGGER_CLASSNAME, FakeCommandLogger.class.getName());
- service.initialize(p);
- service.start(null);
- return service;
- }
-
- /**
- * Helper method that creates an instance of <code>DQPCore</code> and sends
- * it a <code>RequestMessage</code> along with the value passed in <code>ts</code>
- * so that <code>DQPCore</code> can use it as the tracking service to log the
- * user-command <code>command</code> if <code>ts</code> is set to capture
- * user-commands.
- * <p>
- * If <code>ts</code> is set to record the user-command, this method will
- * return two log entries. The first log entry represents the START state
- * of the user-command and the second represents the END state of the
- * user command.
- * <p>
- * <code>command</code> must be valid and DQP must be able to parse the query.
- * Because this helper method does not actually build or establish any metadata
- * for DQP or define any sources, <code>command</code> should only contain scalar
- * functions or constant values for its symbols. Because DQP can receive either
- * a <code>String</code> or a <code>Command</code> object representing the
- * user-command, <code>command</code> can be of either type. <code>command</code>
- * will be passed to the <code>RequestMessage</code> that is sent to <code>DQPCore</code>
- *
- * @param ts A configured and running instance of a <code>TrackingService</code>.
- * @param command The query representing the user-command.
- * @return If <code>ts</code> has been set to record the user-command, two log entries
- * should be returned. Each entry is made up of one or more <code>Object</code>
- * types and is contained within a <code>List</code> object. The final two log
- * entries are also contained in a <code>List</code> object.
- * @throws InterruptedException
- * @throws ExecutionException
- * @throws TimeoutException
- * @throws MetaMatrixProcessingException
- * @throws ApplicationLifecycleException
- */
- private void helpLogUserCommandViaDQP(CustomizableTrackingService ts, String command) throws InterruptedException, ExecutionException, TimeoutException, MetaMatrixProcessingException, ApplicationLifecycleException {
- String principal = "stuart"; //$NON-NLS-1$
- String vdbName = "bqt"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
- MetaMatrixSessionID sessionID = new MetaMatrixSessionID(1);
- int requestID = 100;
- int finalRowCount = 1;
- List<Object> expectedStartLogEntry = new ArrayList<Object>();
- List<Object> expectedEndLogEntry = new ArrayList<Object>();
- List<List<Object>> expectedLogEntries = new ArrayList<List<Object>>();
-
- if ( ts.willRecordMMCmd() ) {
- expectedStartLogEntry.add(sessionID + "." + requestID); // Request ID //$NON-NLS-1$
- expectedStartLogEntry.add(null); // Transaction ID
- expectedStartLogEntry.add(sessionID.toString()); // Session ID
- expectedStartLogEntry.add(null); // Application Name
- expectedStartLogEntry.add(principal); // Principal Name
- expectedStartLogEntry.add(vdbName); // VDB Name
- expectedStartLogEntry.add(vdbVersion); // VDB Version
- expectedStartLogEntry.add(command.toString()); // SQL
- expectedLogEntries.add(expectedStartLogEntry);
-
- expectedEndLogEntry.add(sessionID + "." + requestID); // Request ID //$NON-NLS-1$
- expectedEndLogEntry.add(null); // Transaction ID
- expectedEndLogEntry.add(sessionID.toString()); // Session ID
- expectedEndLogEntry.add(principal); // Principal Name
- expectedEndLogEntry.add(vdbName); // VDB Name
- expectedEndLogEntry.add(vdbVersion); // VDB Version
- expectedEndLogEntry.add(new Integer(finalRowCount)); // Expected Number of Rows
- expectedEndLogEntry.add(Boolean.FALSE); // isCanceled?
- expectedEndLogEntry.add(Boolean.FALSE); // wasError?
- expectedLogEntries.add(expectedEndLogEntry);
- }
-
- ApplicationEnvironment env = new ApplicationEnvironment();
- env.bindService(DQPServiceNames.BUFFER_SERVICE, new FakeBufferService());
- FakeMetadataService mdSvc = new FakeMetadataService();
- mdSvc.addVdb(vdbName, vdbVersion, FakeMetadataFactory.exampleBQTCached());
- env.bindService(DQPServiceNames.METADATA_SERVICE, mdSvc);
- env.bindService(DQPServiceNames.DATA_SERVICE, new AutoGenDataService());
- env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
- env.bindService(DQPServiceNames.TRACKING_SERVICE, ts);
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addBinding(vdbName, vdbVersion, "BQT1", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addBinding(vdbName, vdbVersion, "BQT2", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addBinding(vdbName, vdbVersion, "BQT3", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addModel(vdbName, vdbVersion, "BQT3", ModelInfo.PRIVATE, false); //$NON-NLS-1$
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
-
- DQPCore core = new DQPCore(env);
- core.start(new Properties());
-
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(vdbName);
- workContext.setVdbVersion(vdbVersion);
- workContext.setSessionToken(new SessionToken(sessionID, principal));
- DQPWorkContext.setWorkContext(workContext);
-
- RequestMessage reqMsg = new RequestMessage(command);
- reqMsg.setCallableStatement(false);
- reqMsg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
- reqMsg.setFetchSize(10);
- reqMsg.setPartialResults(false);
- reqMsg.setExecutionId(requestID);
-
- ResultsMessage results = null;
- Future<ResultsMessage> message = null;
-
- // Execute reqMsg
- message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- results = message.get(50000, TimeUnit.MILLISECONDS);
- assertNull("executeRequest resulted in " + results.getException(), results.getException()); //$NON-NLS-1$
- core.closeRequest(requestID);
- FakeCommandLogger fcl = (FakeCommandLogger)ts.getCommandLogger();
- //close is fully asynch, calling stop immediately may take effect before the work item is requeued
- synchronized (fcl) {
- for (int i = 0; i < 10 && fcl.logEntries.size() != expectedLogEntries.size(); i++) {
- fcl.wait(50);
- }
- }
- core.stop();
- ts.stop();
- assertEquals(expectedLogEntries, fcl.logEntries);
- }
-
- private List logExampleUserCommandStart(TrackingService trackingService) {
-
- String requestID = "req1"; //$NON-NLS-1$
- String transactionID = "35"; //$NON-NLS-1$
- short cmdPoint = TrackerLogConstants.CMD_POINT.BEGIN;
- short status = TrackerLogConstants.CMD_STATUS.NEW;
- String sessionID = "ses1"; //$NON-NLS-1$
- String applicationName = "myApp"; //$NON-NLS-1$
- String principal = "stuart"; //$NON-NLS-1$
- String vdbName = "myVDB"; //$NON-NLS-1$
- String vdbVersion = "2"; //$NON-NLS-1$
- Command sql = TestQuery.sample1();
- int rows = 10000;
-
- String sqlStr = sql != null ? sql.toString() : null;
- trackingService.log(requestID, transactionID, cmdPoint, status, sessionID, applicationName, principal, vdbName, vdbVersion, sqlStr, rows);
-
- List expectedLogEntry = new ArrayList();
- expectedLogEntry.add(requestID);
- expectedLogEntry.add(transactionID);
- expectedLogEntry.add(sessionID);
- expectedLogEntry.add(applicationName);
- expectedLogEntry.add(principal);
- expectedLogEntry.add(vdbName);
- expectedLogEntry.add(vdbVersion);
- expectedLogEntry.add(sql.toString());
-
- return expectedLogEntry;
- }
-
- private List logExampleUserCommandEnd(TrackingService trackingService) {
-
- String requestID = "req1"; //$NON-NLS-1$
- String transactionID = "35"; //$NON-NLS-1$
- short cmdPoint = TrackerLogConstants.CMD_POINT.END;
- short status = TrackerLogConstants.CMD_STATUS.END;
- String sessionID = "ses1"; //$NON-NLS-1$
- String applicationName = "myApp"; //$NON-NLS-1$
- String principal = "stuart"; //$NON-NLS-1$
- String vdbName = "myVDB"; //$NON-NLS-1$
- String vdbVersion = "2"; //$NON-NLS-1$
- Command sql = null;
- int rows = 10000;
- boolean isCancelled = false;
- boolean errorOccurred = false;
-
- String sqlStr = sql != null ? sql.toString() : null;
- trackingService.log(requestID, transactionID, cmdPoint, status, sessionID, applicationName, principal, vdbName, vdbVersion, sqlStr, rows);
-
- List expectedLogEntry = new ArrayList();
- expectedLogEntry.add(requestID);
- expectedLogEntry.add(transactionID);
- expectedLogEntry.add(sessionID);
- expectedLogEntry.add(principal);
- expectedLogEntry.add(vdbName);
- expectedLogEntry.add(vdbVersion);
- expectedLogEntry.add(new Integer(rows));
- expectedLogEntry.add(Boolean.valueOf(isCancelled));
- expectedLogEntry.add(Boolean.valueOf(errorOccurred));
-
- return expectedLogEntry;
- }
-
- private List logExampleSourceCommandStart(TrackingService trackingService) {
- String requestID = "req1"; //$NON-NLS-1$
- long sourceCommandID = 2112l;
- String subTransactionID = "42"; //$NON-NLS-1$
- String modelName = "myModel"; //$NON-NLS-1$
- String connectorBindingName = "myBinding"; //$NON-NLS-1$
- String sessionID = "ses1"; //$NON-NLS-1$
- String principal = "stuart"; //$NON-NLS-1$
- Command sql = TestQuery.sample1();
- short cmdPoint = TrackerLogConstants.CMD_POINT.BEGIN;
- short status = TrackerLogConstants.CMD_STATUS.NEW;
- int finalRowCount = 3;
-
- String sqlStr = sql != null ? sql.toString() : null;
- trackingService.log(requestID, sourceCommandID, subTransactionID, status, modelName, connectorBindingName,
- cmdPoint, sessionID, principal, sqlStr, finalRowCount, null);
-
- List expectedLogEntry = new ArrayList();
- expectedLogEntry.add(requestID);
- expectedLogEntry.add(new Long(sourceCommandID));
- expectedLogEntry.add(subTransactionID);
- expectedLogEntry.add(modelName);
- expectedLogEntry.add(connectorBindingName);
- expectedLogEntry.add(sessionID);
- expectedLogEntry.add(principal);
- expectedLogEntry.add(sql.toString());
-
- return expectedLogEntry;
- }
-
- private List logExampleSourceCommandCancelled(TrackingService trackingService) {
- String requestID = "req1"; //$NON-NLS-1$
- long sourceCommandID = 3113l;
- String subTransactionID = "42"; //$NON-NLS-1$
- String modelName = "myModel"; //$NON-NLS-1$
- String connectorBindingName = "myBinding2"; //$NON-NLS-1$
- String sessionID = "ses1"; //$NON-NLS-1$
- String principal = "stuart"; //$NON-NLS-1$
- Command sql = null;
- short cmdPoint = TrackerLogConstants.CMD_POINT.END;
- short status = TrackerLogConstants.CMD_STATUS.CANCEL;
- int finalRowCount = 3;
- boolean isCancelled = true;
- boolean errorOccurred = false;
-
- String sqlStr = sql != null ? sql.toString() : null;
- trackingService.log(requestID, sourceCommandID, subTransactionID, status, modelName, connectorBindingName,
- cmdPoint, sessionID, principal, sqlStr, finalRowCount, null);
-
- List expectedLogEntry = new ArrayList();
- expectedLogEntry.add(requestID);
- expectedLogEntry.add(new Long(sourceCommandID));
- expectedLogEntry.add(subTransactionID);
- expectedLogEntry.add(modelName);
- expectedLogEntry.add(connectorBindingName);
- expectedLogEntry.add(sessionID);
- expectedLogEntry.add(principal);
- expectedLogEntry.add(new Integer(finalRowCount));
- expectedLogEntry.add(Boolean.valueOf(isCancelled));
- expectedLogEntry.add(Boolean.valueOf(errorOccurred));
-
- return expectedLogEntry;
- }
-
-
-
- /**
- * Fake implementation of CommandLoggerSPI to use for testing.
- * Logged entries are cached in memory in Lists for later comparison
- * with expected results.
- */
- public static class FakeCommandLogger implements CommandLoggerSPI {
-
-
- private List logEntries = new ArrayList();
-
- /**
- * @see com.metamatrix.dqp.spi.CommandLoggerSPI#initialize(java.util.Properties)
- */
- public void initialize(Properties props) {
- }
- /**
- * @see com.metamatrix.dqp.spi.CommandLoggerSPI#close()
- */
- public void close() {
- }
-
- public synchronized void dataSourceCommandStart(long timestamp,
- String requestID,
- long sourceCommandID,
- String subTransactionID,
- String modelName,
- String connectorBindingName,
- String sessionID,
- String principal,
- String sql,
- ExecutionContext context) {
-
- List logEntry = new ArrayList(12);
- logEntry.add(requestID);
- logEntry.add(new Long(sourceCommandID));
- logEntry.add(subTransactionID);
- logEntry.add(modelName);
- logEntry.add(connectorBindingName);
- logEntry.add(sessionID);
- logEntry.add(principal);
- logEntry.add(sql);
- logEntries.add(logEntry);
- notifyAll();
- }
-
- public synchronized void dataSourceCommandEnd(long timestamp,
- String requestID,
- long sourceCommandID,
- String subTransactionID,
- String modelName,
- String connectorBindingName,
- String sessionID,
- String principal,
- int finalRowCount,
- boolean isCancelled,
- boolean errorOccurred,
- ExecutionContext context) {
-
- List logEntry = new ArrayList(12);
- logEntry.add(requestID);
- logEntry.add(new Long(sourceCommandID));
- logEntry.add(subTransactionID);
- logEntry.add(modelName);
- logEntry.add(connectorBindingName);
- logEntry.add(sessionID);
- logEntry.add(principal);
- logEntry.add(new Integer(finalRowCount));
- logEntry.add(Boolean.valueOf(isCancelled));
- logEntry.add(Boolean.valueOf(errorOccurred));
- logEntries.add(logEntry);
- notifyAll();
- }
-
- public synchronized void userCommandStart(long timestamp,
- String requestID,
- String transactionID,
- String sessionID,
- String applicationName,
- String principal,
- String vdbName,
- String vdbVersion,
- String sql) {
-
- List logEntry = new ArrayList(10);
- logEntry.add(requestID);
- logEntry.add(transactionID);
- logEntry.add(sessionID);
- logEntry.add(applicationName);
- logEntry.add(principal);
- logEntry.add(vdbName);
- logEntry.add(vdbVersion);
- logEntry.add(sql);
- logEntries.add(logEntry);
- notifyAll();
- }
-
- public synchronized void userCommandEnd(long timestamp,
- String requestID,
- String transactionID,
- String sessionID,
- String principal,
- String vdbName,
- String vdbVersion,
- int finalRowCount,
- boolean isCancelled,
- boolean errorOccurred) {
-
- List logEntry = new ArrayList(10);
- logEntry.add(requestID);
- logEntry.add(transactionID);
- logEntry.add(sessionID);
- logEntry.add(principal);
- logEntry.add(vdbName);
- logEntry.add(vdbVersion);
- logEntry.add(new Integer(finalRowCount));
- logEntry.add(Boolean.valueOf(isCancelled));
- logEntry.add(Boolean.valueOf(errorOccurred));
- logEntries.add(logEntry);
- notifyAll();
- }
- }
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -41,7 +41,6 @@
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.TrackingService;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.sql.lang.Command;
@@ -182,20 +181,4 @@
DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
assertNull(arInfo);
}
-
- public void testLogTxnID() {
- DQPCore rm = new DQPCore();
- TrackingService ts = Mockito.mock(TrackingService.class);
- Mockito.stub(ts.willRecordMMCmd()).toReturn(true);
- rm.setTracker(ts);
- RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
- RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
- TransactionContext tc = Mockito.mock(TransactionContext.class);
- Mockito.stub(tc.getTxnID()).toReturn("mytxnid"); //$NON-NLS-1$
- workItem.setTransactionContext(tc);
- rm.logMMCommand(workItem, true, true, -1);
- Mockito.verify(ts, Mockito.times(1)).log("C.0", "mytxnid", (short)1, (short)1, null, null, null, null, null, null, -1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
}
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -35,9 +35,13 @@
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogContextsUtil;
import com.metamatrix.common.util.LogContextsUtil.PlatformAdminConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.dqp.service.AuditMessage;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
import com.metamatrix.platform.security.audit.AuditManager;
@@ -94,7 +98,8 @@
}
boolean authorized = false;
- AuditManager.getInstance().record(PlatformAdminConstants.CTX_ADMIN_API, Arrays.toString(allowed.value())+"-request", adminToken.getUsername(), method.getName()); //$NON-NLS-1$
+ AuditMessage msg = new AuditMessage(PlatformAdminConstants.CTX_ADMIN_API, Arrays.toString(allowed.value())+"-request", adminToken.getUsername(), new Object[]{method.getName()}); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_AUDITLOGGING, msg);
for (int i = 0; i < allowed.value().length; i++) {
String requiredRoleName = allowed.value()[i];
@@ -109,7 +114,9 @@
}
}
if (!authorized) {
- AuditManager.getInstance().record(PlatformAdminConstants.CTX_ADMIN_API, Arrays.toString(allowed.value())+"-denied", adminToken.getUsername(), method.getName()); //$NON-NLS-1$
+ msg = new AuditMessage(PlatformAdminConstants.CTX_ADMIN_API, Arrays.toString(allowed.value())+"-denied", adminToken.getUsername(), new Object[]{method.getName()}); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_AUDITLOGGING, msg);
+
Object[] msgParts = buildAuditMessage(adminToken, Arrays.toString(allowed.value()), method);
String errMsg = CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_not_authorized", msgParts); //$NON-NLS-1$
throw ExceptionUtil.convertException(method, new AuthorizationException(errMsg));
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -34,6 +34,7 @@
import com.metamatrix.common.queue.WorkerPool;
import com.metamatrix.common.queue.WorkerPoolFactory;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.dqp.service.AuditMessage;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.security.api.AuthorizationPermission;
import com.metamatrix.platform.security.audit.config.AuditConfigurationException;
Deleted: trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -1,167 +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.platform.security.audit;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import com.metamatrix.common.config.CurrentConfiguration;
-
-public class AuditMessage implements Externalizable {
- public static final String PROCESS_NAME = CurrentConfiguration.getInstance().getProcessName();
- public static final String HOST_NAME = CurrentConfiguration.getInstance().getConfigurationName();
-
- private static final String RESOURCE_DELIMITER = ", "; //$NON-NLS-1$
-
- private String context;
- private String activity;
- private String principal;
- //private int level;
- private Object[] resources;
- private long timestamp;
- //private String threadName;
- private String hostName;
- private String processName;
-
- public AuditMessage() {
- }
-
- public AuditMessage(String context, String activity, String principal, Object[] resources ) {
- this.context = context;
- this.activity = activity;
- this.principal = principal;
- //this.level = level;
- this.resources = resources;
- this.timestamp = System.currentTimeMillis();
- //this.threadName = Thread.currentThread().getName();
- this.hostName = HOST_NAME;
- this.processName = PROCESS_NAME;
- }
-
- public String getContext() {
- return this.context;
- }
-
- public String getActivity() {
- return this.activity;
- }
-
- public String getPrincipal() {
- return this.principal;
- }
-
- public String getProcessName() {
- return this.processName;
- }
-
- public String getHostName() {
- return this.hostName;
- }
-
- public long getTimestamp() {
- return this.timestamp;
- }
-
- public Object[] getResources() {
- return this.resources;
- }
-
- public String getText() {
- StringBuffer text = new StringBuffer();
- if(resources != null && resources.length > 0 ) {
- Object resource = resources[0];
- if ( resource != null ) {
- text.append(resource.toString());
- }
- for(int i=1; i<resources.length; ++i) {
- text.append(RESOURCE_DELIMITER);
- resource = resources[i];
- if ( resource != null ) {
- text.append(resource.toString());
- }
- }
- }
- return text.toString();
- }
-
- public String getText( String delimiter ) {
- StringBuffer text = new StringBuffer();
- if ( delimiter != null ) {
- if(resources != null && resources.length > 0 ) {
- Object resource = resources[0];
- if ( resource != null ) {
- text.append(resource.toString());
- }
- for(int i=1; i<resources.length; ++i) {
- text.append(delimiter);
- resource = resources[i];
- if ( resource != null ) {
- text.append(resource.toString());
- }
- }
- }
- } else {
- if(resources != null && resources.length > 0 ) {
- Object resource = resources[0];
- if ( resource != null ) {
- text.append(resource.toString());
- }
- for(int i=1; i<resources.length; ++i) {
- text.append(RESOURCE_DELIMITER);
- resource = resources[i];
- if ( resource != null ) {
- text.append(resource.toString());
- }
- }
- }
- }
- return text.toString();
- }
-
- // implements Externalizable
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(context);
- out.writeObject(activity);
- out.writeObject(principal);
- //out.writeInt(level);
- out.writeObject(resources);
- out.writeLong(timestamp);
-// out.writeObject(threadName);
- out.writeObject(processName);
- }
-
- // implements Externalizable
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.context = (String) in.readObject();
- this.activity = (String) in.readObject();
- this.principal = (String) in.readObject();
- //this.level = in.readInt();
- this.resources = (Object[]) in.readObject();
- this.timestamp = in.readLong();
-// this.threadName = (String) in.readObject();
- this.processName = (String) in.readObject();
- }
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AuditDestination.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AuditDestination.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AuditDestination.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -25,7 +25,7 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.platform.security.audit.AuditMessage;
+import com.metamatrix.dqp.service.AuditMessage;
/**
* A log destination can be used to print messages - typical examples are
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -26,7 +26,7 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.platform.security.audit.AuditMessage;
+import com.metamatrix.dqp.service.AuditMessage;
import com.metamatrix.platform.security.audit.format.ReadableAuditMessageFormat;
/**
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -34,8 +34,8 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.DateUtil;
import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.dqp.service.AuditMessage;
import com.metamatrix.platform.PlatformPlugin;
-import com.metamatrix.platform.security.audit.AuditMessage;
import com.metamatrix.platform.security.util.LogSecurityConstants;
import com.metamatrix.platform.util.ErrorMessageKeys;
@@ -204,8 +204,7 @@
stmt = connection.prepareStatement(insertStr.toString());
// Timestamp column
- stmt.setString(1, DateUtil.getDateAsString(new Timestamp(message
- .getTimestamp())));
+ stmt.setString(1, DateUtil.getDateAsString(new Timestamp(System.currentTimeMillis())));
// Message context column
stmt.setString(2, StringUtil.truncString(message.getContext(),
@@ -224,11 +223,11 @@
maxGeneralLength));
// Message hostname column
- stmt.setString(6, StringUtil.truncString(message.getHostName(),
+ stmt.setString(6, StringUtil.truncString("n/a", //$NON-NLS-1$
maxGeneralLength));
// Message VM ID column
- stmt.setString(7, StringUtil.truncString(message.getProcessName(),
+ stmt.setString(7, StringUtil.truncString("n/a", //$NON-NLS-1$
maxGeneralLength));
// Insert the row into the table
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -31,8 +31,8 @@
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.dqp.service.AuditMessage;
import com.metamatrix.platform.PlatformPlugin;
-import com.metamatrix.platform.security.audit.AuditMessage;
import com.metamatrix.platform.security.util.LogSecurityConstants;
import com.metamatrix.platform.util.ErrorMessageKeys;
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/AuditMessageFormat.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/AuditMessageFormat.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/AuditMessageFormat.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -22,7 +22,7 @@
package com.metamatrix.platform.security.audit.format;
-import com.metamatrix.platform.security.audit.AuditMessage;
+import com.metamatrix.dqp.service.AuditMessage;
public interface AuditMessageFormat {
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/DelimitedAuditMessageFormat.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/DelimitedAuditMessageFormat.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/DelimitedAuditMessageFormat.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -26,7 +26,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import com.metamatrix.platform.security.audit.AuditMessage;
+import com.metamatrix.dqp.service.AuditMessage;
/**
* This class formats AuditMessages using a format with delimiters that is easily parsed.
@@ -50,11 +50,11 @@
return DEFAULT_FORMATTED_MESSAGE;
}
StringBuffer msg = new StringBuffer();
- msg.append( DATE_FORMATTER.format( new Date(message.getTimestamp()) ) );
+ msg.append( DATE_FORMATTER.format( new Date(System.currentTimeMillis()) ) );
msg.append( DELIMITER_CHAR );
- msg.append( message.getHostName() );
+ msg.append( "n/a"); //$NON-NLS-1$
msg.append( DELIMITER_CHAR );
- msg.append( message.getProcessName() );
+ msg.append( "n/a" ); //$NON-NLS-1$
msg.append( DELIMITER_CHAR );
msg.append( message.getPrincipal() );
msg.append( DELIMITER_CHAR );
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/ReadableAuditMessageFormat.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/ReadableAuditMessageFormat.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/format/ReadableAuditMessageFormat.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -26,7 +26,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import com.metamatrix.platform.security.audit.AuditMessage;
+import com.metamatrix.dqp.service.AuditMessage;
public class ReadableAuditMessageFormat implements AuditMessageFormat {
@@ -46,11 +46,11 @@
return DEFAULT_FORMATTED_MESSAGE;
}
StringBuffer msg = new StringBuffer();
- msg.append( DATE_FORMATTER.format( new Date(message.getTimestamp()) ) );
+ msg.append( DATE_FORMATTER.format( new Date(System.currentTimeMillis()) ) );
msg.append(" ["); //$NON-NLS-1$
- msg.append( message.getHostName() );
+ msg.append( "n/a" ); //$NON-NLS-1$
msg.append( '|' );
- msg.append( message.getProcessName() );
+ msg.append( "n/a" ); //$NON-NLS-1$
msg.append( '|' );
msg.append( message.getPrincipal() );
msg.append("] <"); //$NON-NLS-1$
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -53,7 +53,10 @@
import com.metamatrix.common.connection.TransactionMgr;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.properties.UnmodifiableProperties;
+import com.metamatrix.common.util.LogContextsUtil;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.ResourceFinder;
+import com.metamatrix.dqp.service.AuditMessage;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
import com.metamatrix.platform.admin.api.PermissionDataNode;
@@ -241,14 +244,17 @@
public boolean checkAccess(SessionToken sessionToken, String contextName, AuthorizationPermission request)
throws InvalidSessionException, AuthorizationMgmtException {
LogManager.logDetail(LogSecurityConstants.CTX_AUTHORIZATION, new Object[]{"checkAccess(", sessionToken, ", ", contextName, ", ", request, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
// Audit - request
- auditManager.record(contextName, "checkAccess-request", sessionToken.getUsername(), request.getResourceName()); //$NON-NLS-1$
-
+ AuditMessage msg = new AuditMessage(contextName, "checkAccess-request", sessionToken.getUsername(), new Object[]{request.getResourceName()}); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_AUDITLOGGING, msg);
+
boolean hasAccess = checkAccess(sessionToken, contextName, request, false);
if (!hasAccess) {
// Audit - denied
- auditManager.record(contextName, "checkAccess-denied", sessionToken.getUsername(), request.getResourceName()); //$NON-NLS-1$
+ msg = new AuditMessage(contextName, "checkAccess-denied", sessionToken.getUsername(), new Object[]{request.getResourceName()}); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_AUDITLOGGING, msg);
}
return hasAccess;
}
@@ -293,12 +299,23 @@
* @throws AuthorizationMgmtException if this service is unable to locate resources required
* for this operation
*/
- public Collection getInaccessibleResources(SessionToken sessionToken, String contextName, Collection requests)
+ public Collection getInaccessibleResources(SessionToken sessionToken, String context, Collection requests)
throws InvalidSessionException, AuthorizationMgmtException {
- LogManager.logDetail(LogSecurityConstants.CTX_AUTHORIZATION, new Object[]{"getInaccessibleResources(", sessionToken, ", ", contextName, ", ", requests, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ LogManager.logDetail(LogSecurityConstants.CTX_AUTHORIZATION, new Object[]{"getInaccessibleResources(", sessionToken, ", ", context, ", ", requests, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ List resources = new ArrayList();
+ if (requests != null && ! requests.isEmpty()) {
+ Iterator permItr = requests.iterator();
+ while ( permItr.hasNext() ) {
+ resources.add(((AuthorizationPermission)permItr.next()).getResourceName());
+ }
+ }
+
// Audit - request
- auditManager.record(contextName, "getInaccessibleResources-request", sessionToken.getUsername(), requests); //$NON-NLS-1$
+ if (!resources.isEmpty()) {
+ AuditMessage msg = new AuditMessage( context, "getInaccessibleResources-request", sessionToken.getUsername(), resources.toArray()); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, context, msg);
+ }
if (isEntitled(sessionToken.getUsername())) {
return Collections.EMPTY_LIST;
@@ -328,10 +345,17 @@
if (results.isEmpty()) {
// Audit - granted all requests
- auditManager.record(contextName, "getInaccessibleResources-granted all", sessionToken.getUsername(), requests); //$NON-NLS-1$
+ if (!resources.isEmpty()) {
+ AuditMessage msg = new AuditMessage( context, "getInaccessibleResources-granted all", sessionToken.getUsername(), resources.toArray()); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, context, msg);
+ }
+
} else {
// Audit - denied
- auditManager.record(contextName, "getInaccessibleResources-denied", sessionToken.getUsername(), results); //$NON-NLS-1$
+ if (!resources.isEmpty()) {
+ AuditMessage msg = new AuditMessage( context, "getInaccessibleResources-denied", sessionToken.getUsername(), resources.toArray()); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, context, msg);
+ }
}
return results;
}
@@ -1529,8 +1553,9 @@
return result;
}
// Audit - access modify
- auditManager.record(SecurityAuditContexts.CTX_AUTHORIZATION, "executeTransaction-modify", administrator.getUsername(), this.printActions(actions)); //$NON-NLS-1$
-
+ AuditMessage logMsg = new AuditMessage(SecurityAuditContexts.CTX_AUTHORIZATION, "executeTransaction-modify", administrator.getUsername(), new Object[]{this.printActions(actions)}); //$NON-NLS-1$
+ LogManager.log(MessageLevel.INFO, LogContextsUtil.CommonConstants.CTX_AUDITLOGGING, logMsg);
+
List actionsWithSameTarget = new ArrayList(7); // guessing at an initial size, probably high
Object currentTarget = null;
ActionDefinition currentAction = null;
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java 2009-06-12 18:05:14 UTC (rev 1052)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java 2009-06-15 20:21:26 UTC (rev 1053)
@@ -35,7 +35,6 @@
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.service.CustomizableTrackingService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.metadata.IndexMetadataService;
import com.metamatrix.dqp.service.metadata.QueryMetadataCache;
@@ -50,7 +49,6 @@
import com.metamatrix.server.dqp.service.PlatformDataService;
import com.metamatrix.server.dqp.service.PlatformTransactionService;
import com.metamatrix.server.dqp.service.PlatformVDBService;
-import com.metamatrix.server.dqp.service.tracker.DatabaseCommandLogger;
/**
*/
@@ -76,10 +74,6 @@
dqpProps.setProperty(DQPConfigSource.STREAMING_BATCH_SIZE, streamingBatchSize);
}
- if (dqpProps.getProperty(DQPConfigSource.COMMAND_LOGGER_CLASSNAME) == null) {
- dqpProps.setProperty(DQPConfigSource.COMMAND_LOGGER_CLASSNAME, DatabaseCommandLogger.class.getName());
- }
-
this.host = host;
this.processName = processName;
}
@@ -94,7 +88,6 @@
@Override
public Map<String, Class<? extends ApplicationService>> getDefaultServiceClasses() {
Map<String, Class<? extends ApplicationService>> result = new HashMap<String, Class<? extends ApplicationService>>();
- result.put(DQPServiceNames.TRACKING_SERVICE, CustomizableTrackingService.class);
result.put(DQPServiceNames.BUFFER_SERVICE, PlatformBufferService.class);
result.put(DQPServiceNames.VDB_SERVICE, PlatformVDBService.class);
result.put(DQPServiceNames.METADATA_SERVICE, IndexMetadataService.class);
More information about the teiid-commits
mailing list