teiid SVN: r1705 - in trunk: engine/src/main/java/com/metamatrix/common/buffer and 17 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-24 00:21:00 -0500 (Thu, 24 Dec 2009)
New Revision: 1705
Removed:
trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManagerPropertyNames.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/storage/file/
trunk/engine/src/main/java/com/metamatrix/connector/metadata/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CacheResults.java
Modified:
trunk/build/kit-runtime/deploy.properties
trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/storage/file/TestFileStorageManager.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java
trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java
Log:
TEIID-913 intermediate commit in removing old implementation - chaning the defaults for batch sizes and adding a new property to control max processing batches.
Modified: trunk/build/kit-runtime/deploy.properties
===================================================================
--- trunk/build/kit-runtime/deploy.properties 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/build/kit-runtime/deploy.properties 2009-12-24 05:21:00 UTC (rev 1705)
@@ -47,11 +47,11 @@
# BufferManager Settings
#
-#The max size of a batch sent between connector and query service. Should be even multiple of processorBatchSize. (default 2000)
-dqp.buffer.connectorBatchSize=2000
+#The max size of a batch sent between connector and query service. Should be even multiple of processorBatchSize. (default 2048)
+dqp.buffer.connectorBatchSize=2048
-#The max size of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 2000)
-dqp.buffer.processorBatchSize=2000
+#The max size of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 1024)
+dqp.buffer.processorBatchSize=1024
#Defines whether to use disk buffering or not. (default true)
dqp.buffer.useDisk=true
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -31,7 +31,7 @@
*/
public class BlockedException extends MetaMatrixComponentException {
- public static final BlockedException INSTANCE = new BlockedException(""); //$NON-NLS-1$
+ public static final BlockedException INSTANCE = new BlockedException();
/**
* No-arg costructor required by Externalizable semantics
@@ -40,44 +40,4 @@
super();
}
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public BlockedException( String message ) {
- super( message );
- }
-
- /**
- * Construct an instance with the message and error code specified.
- *
- * @param message A message describing the exception
- * @param code The error code
- */
- public BlockedException( String code, String message ) {
- super( code, message );
- }
-
- /**
- * Construct an instance from a message and an exception to chain to this one.
- *
- * @param message A message describing the exception
- * @param e An exception to nest within this one
- */
- public BlockedException( Throwable e, String message ) {
- super( e, message );
- }
-
- /**
- * Construct an instance from a message and a code and an exception to
- * chain to this one.
- *
- * @param e An exception to nest within this one
- * @param message A message describing the exception
- * @param code A code denoting the exception
- */
- public BlockedException( Throwable e, String code, String message ) {
- super( e, code, message );
- }
}
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -48,6 +48,48 @@
FINAL
}
+ /**
+ * Optional property - the max size of a batch sent between connector and query service.
+ * Making batches larger reduces communication overhead between connector and query service
+ * but increases the granularity of memory management on those batches. This value should
+ * be a positive integer and defaults to 1000.
+ */
+ public static final String CONNECTOR_BATCH_SIZE = "metamatrix.buffer.connectorBatchSize"; //$NON-NLS-1$
+ /**
+ * Optional property - the max size of a batch sent internally within the query processor.
+ * In general, these batches should be smaller than the connector batch size as there are
+ * no communication costs with these batches. Smaller batches typically allow a user to
+ * get their first results quicker and allow fine-grained buffer management on intermediate
+ * results. This value should be a positive integer and defaults to 100.
+ */
+ public static final String PROCESSOR_BATCH_SIZE = "metamatrix.buffer.processorBatchSize"; //$NON-NLS-1$
+ /**
+ * Optional property - this value specifies the location to store temporary buffers to
+ * large to fit in memory. Temporary buffer files will be created and destroyed in this
+ * directory. This value should be a string specifying an absolute directory path.
+ */
+ public static final String BUFFER_STORAGE_DIRECTORY = "metamatrix.buffer.storageDirectory"; //$NON-NLS-1$
+ /**
+ * Optional property - this values specifies how many open file descriptors should be cached
+ * in the storage directory. Increasing this value in heavy load may improve performance
+ * but will use more file descriptors, which are a limited system resource. The default
+ * is 10.
+ */
+ public static final String MAX_OPEN_FILES = "metamatrix.buffer.maxOpenFiles"; //$NON-NLS-1$
+ /**
+ * Optional property - this values specifies the maximum size in MegaBytes that a buffer file can reach.
+ * The default is 2048 MB (i.e. 2GB).
+ */
+ public static final String MAX_FILE_SIZE = "metamatrix.buffer.maxFileSize"; //$NON-NLS-1$
+ /**
+ * Optional property - the max number of batches to process at once in algorithms such as sorting.
+ */
+ public static final String MAX_PROCESSING_BATCHES = "metamatrix.buffer.maxProcessingBatches"; //$NON-NLS-1$
+
+ public static int DEFAULT_CONNECTOR_BATCH_SIZE = 2048;
+ public static int DEFAULT_PROCESSOR_BATCH_SIZE = 1024;
+ public static int DEFAULT_MAX_PROCESSING_BATCHES = 16;
+
/**
* Get the batch size to use during query processing.
* @return Batch size (# of rows)
@@ -73,4 +115,6 @@
void removeTupleBuffers(String groupName)
throws MetaMatrixComponentException;
+ int getMaxProcessingBatches();
+
}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManagerPropertyNames.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManagerPropertyNames.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManagerPropertyNames.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer;
-
-/**
- * This class holds constants for all the buffer manager properties.
- */
-public final class BufferManagerPropertyNames {
-
- /**
- * Optional property - the amount of memory (in megabytes) that buffer management should use.
- * This value should be a positive integer (less than the the max heap size) and defaults to
- * 128.
- */
- public static final String MEMORY_AVAILABLE = "metamatrix.buffer.memoryAvailable"; //$NON-NLS-1$
-
- /**
- * Optional property - the percent of buffer management memory that a particular session
- * can use. This property can be used to prevent a single user from consuming too many
- * resources. This value should be in the range [1..100] and defaults to 50.
- */
- public static final String SESSION_USE_PERCENTAGE = "metamatrix.buffer.sessionUsePercentage"; //$NON-NLS-1$
-
- /**
- * Optional property - the percent of buffer management memory that serves as a threshold
- * for active memory management. Below the threshold, no active memory management occurs
- * and no data is moved between memory and persistent storage in the background. Above
- * the threshold, a background thread attempts to clean the in-memory buffers using an LRU
- * algorithm. This value should be in the range [1..100] and defaults to 75.
- */
- public static final String ACTIVE_MEMORY_THRESHOLD = "metamatrix.buffer.activeMemoryThreshold"; //$NON-NLS-1$
-
- /**
- * Optional property - the period between checking whether active memory clean up
- * should occur, in milliseconds. This value should be a millisecond value and defaults
- * to 500 ms. A value of 0 indicates that no active management should occur.
- */
- public static final String MANAGEMENT_INTERVAL = "metamatrix.buffer.managementInterval"; //$NON-NLS-1$
-
- /**
- * Optional property - the max size of a batch sent between connector and query service.
- * Making batches larger reduces communication overhead between connector and query service
- * but increases the granularity of memory management on those batches. This value should
- * be a positive integer and defaults to 1000.
- */
- public static final String CONNECTOR_BATCH_SIZE = "metamatrix.buffer.connectorBatchSize"; //$NON-NLS-1$
-
- /**
- * Optional property - the max size of a batch sent internally within the query processor.
- * In general, these batches should be smaller than the connector batch size as there are
- * no communication costs with these batches. Smaller batches typically allow a user to
- * get their first results quicker and allow fine-grained buffer management on intermediate
- * results. This value should be a positive integer and defaults to 100.
- */
- public static final String PROCESSOR_BATCH_SIZE = "metamatrix.buffer.processorBatchSize"; //$NON-NLS-1$
-
- /**
- * Optional property - this value specifies the location to store temporary buffers to
- * large to fit in memory. Temporary buffer files will be created and destroyed in this
- * directory. This value should be a string specifying an absolute directory path.
- */
- public static final String BUFFER_STORAGE_DIRECTORY = "metamatrix.buffer.storageDirectory"; //$NON-NLS-1$
-
- /**
- * Optional property - this values specifies how many open file descriptors should be cached
- * in the storage directory. Increasing this value in heavy load may improve performance
- * but will use more file descriptors, which are a limited system resource. The default
- * is 10.
- */
- public static final String MAX_OPEN_FILES = "metamatrix.buffer.maxOpenFiles"; //$NON-NLS-1$
- /**
- * Optional property - this values specifies the maximum size in MegaBytes that a buffer file can reach.
- * The default is 2048 MB (i.e. 2GB).
- */
- public static final String MAX_FILE_SIZE = "metamatrix.buffer.maxFileSize"; //$NON-NLS-1$
-
- /**
- * Optional property - this value specifies how often the buffer statistics should be
- * collected and logged. This is primarily useful during debugging and defaults to a value
- * of 0, which indicates no stats logging. This value should be either 0 to indicate no
- * logging or a positive integer indicating the period in milliseconds between logging.
- */
- public static final String LOG_STATS_INTERVAL = "metamatrix.buffer.logStatsInterval"; //$NON-NLS-1$
-
- /**
- * The environment property name for the class that is to be used for the MetadataConnectionFactory implementation.
- * This property is required (there is no default).
- */
- public static final String CONNECTION_FACTORY = "metamatrix.buffer.connection.Factory"; //$NON-NLS-1$
-
- /**
- * The environment property name for the class of the driver.
- * This property is optional.
- */
- public static final String CONNECTION_DRIVER = "metamatrix.buffer.connection.Driver"; //$NON-NLS-1$
-
- /**
- * The environment property name for the protocol for connecting to the metadata store.
- * This property is optional.
- */
- public static final String CONNECTION_PROTOCOL = "metamatrix.buffer.connection.Protocol"; //$NON-NLS-1$
-
- /**
- * The environment property name for the name of the metadata store database.
- * This property is optional.
- */
- public static final String CONNECTION_DATABASE = "metamatrix.buffer.connection.Database"; //$NON-NLS-1$
-
- /**
- * The environment property name for the username that is to be used for connecting to the metadata store.
- * This property is optional.
- */
- public static final String CONNECTION_USERNAME = "metamatrix.buffer.connection.User"; //$NON-NLS-1$
-
- /**
- * The environment property name for the password that is to be used for connecting to the metadata store.
- * This property is optional.
- */
- public static final String CONNECTION_PASSWORD = "metamatrix.buffer.connection.Password"; //$NON-NLS-1$
-
- /**
- * The environment property name for the maximum number of milliseconds that a metadata connection
- * may remain unused before it becomes a candidate for garbage collection.
- * This property is optional.
- */
- public static final String CONNECTION_POOL_MAXIMUM_AGE = "metamatrix.buffer.connection.MaximumAge"; //$NON-NLS-1$
-
- /**
- * The environment property name for the maximum number of concurrent users of a single metadata connection.
- * This property is optional.
- */
- public static final String CONNECTION_POOL_MAXIMUM_CONCURRENT_USERS = "metamatrix.buffer.connection.MaximumConcurrentReaders"; //$NON-NLS-1$
-
-
- // Can't construct
- private BufferManagerPropertyNames() {
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -1,232 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer.impl;
-
-import java.util.Properties;
-
-import com.metamatrix.common.buffer.BufferManagerPropertyNames;
-
-/**
- * Encapsulates all configuration information for the BufferManagerImpl,
- * including both properties that are set and some that are derived.
- */
-public class BufferConfig {
-
- public static int DEFAULT_CONNECTOR_BATCH_SIZE = 2000;
- public static int DEFAULT_PROCESSOR_BATCH_SIZE = 2000;
-
- // Configuration
- private long totalAvailableMemory = 100000000;
- private int groupUsePercentage = 80;
- private int activeMemoryThreshold = 75;
- private int managementInterval = 500;
- private int connectorBatchSize = DEFAULT_CONNECTOR_BATCH_SIZE;
- private int processorBatchSize = DEFAULT_PROCESSOR_BATCH_SIZE;
- private String bufferStorageDirectory = "../buffer"; //$NON-NLS-1$
- private int logStatInterval = 0;
-
- // Derived state
- private long availableSessionLevel = 0;
- private long activeMemoryLevel = 0;
-
- /**
- * Constructor for BufferConfig - use all defaults
- */
- public BufferConfig() {
- computeDerived();
- }
-
- /**
- * Constructor for BufferConfig - set from properties.
- * @param props Properties as defined in
- * {@link com.metamatrix.common.buffer.BufferManagerPropertyNames}.
- */
- public BufferConfig(Properties props) {
- // Read totalAvailableMemory
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE);
- if(propStr != null) {
- totalAvailableMemory = Integer.parseInt(propStr) * 1000000L;
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read groupUsePercentage
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.SESSION_USE_PERCENTAGE);
- if(propStr != null) {
- groupUsePercentage = Integer.parseInt(propStr);
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read activeMemoryThreshold
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.ACTIVE_MEMORY_THRESHOLD);
- if(propStr != null) {
- activeMemoryThreshold = Integer.parseInt(propStr);
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read managementInterval
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL);
- if(propStr != null) {
- managementInterval = Integer.parseInt(propStr);
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read connectorBatchSize
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.CONNECTOR_BATCH_SIZE);
- if(propStr != null) {
- connectorBatchSize = Integer.parseInt(propStr);
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read processorBatchSize
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.PROCESSOR_BATCH_SIZE);
- if(propStr != null) {
- processorBatchSize = Integer.parseInt(propStr);
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read bufferStorageDirectory
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY);
- if(propStr != null) {
- bufferStorageDirectory = propStr;
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- // Read logStatInterval
- try {
- String propStr = props.getProperty(BufferManagerPropertyNames.LOG_STATS_INTERVAL);
- if(propStr != null) {
- logStatInterval = Integer.parseInt(propStr);
- }
- } catch(NumberFormatException e) {
- // use default
- }
-
- computeDerived();
- }
-
- // Direct state management
-
- public long getTotalAvailableMemory() {
- return this.totalAvailableMemory;
- }
-
- public void setTotalAvailableMemory(long totalAvailableMemory) {
- this.totalAvailableMemory = totalAvailableMemory;
- computeDerived();
- }
-
- public int getGroupUsePercentage() {
- return this.groupUsePercentage;
- }
-
- public void setGroupUsePercentage(int groupUsePercentage) {
- this.groupUsePercentage = groupUsePercentage;
- computeDerived();
- }
-
- public int getActiveMemoryThreshold() {
- return this.activeMemoryThreshold;
- }
-
- public void setActiveMemoryThreshold(int activeMemoryThreshold) {
- this.activeMemoryThreshold = activeMemoryThreshold;
- computeDerived();
- }
-
- public int getConnectorBatchSize() {
- return this.connectorBatchSize;
- }
-
- public void setConnectorBatchSize(int connectorBatchSize) {
- this.connectorBatchSize = connectorBatchSize;
- }
-
- public int getProcessorBatchSize() {
- return this.processorBatchSize;
- }
-
- public void setProcessorBatchSize(int processorBatchSize) {
- this.processorBatchSize = processorBatchSize;
- }
-
- public int getManagementInterval() {
- return this.managementInterval;
- }
-
- public void setManagementInterval(int managementInterval) {
- this.managementInterval = managementInterval;
- }
-
- public String getBufferStorageDirectory() {
- return this.bufferStorageDirectory;
- }
-
- public void setBufferStorageDirectory(String bufferStorageDirectory) {
- this.bufferStorageDirectory = bufferStorageDirectory;
- }
-
- public int getLogStatInterval() {
- return this.logStatInterval;
- }
-
- public void setStatUpdateInterval(int logStatInterval) {
- this.logStatInterval = logStatInterval;
- }
-
- // Derived state management
-
- private void computeDerived() {
- this.availableSessionLevel = (int) (this.totalAvailableMemory * (this.groupUsePercentage / 100.0));
- this.activeMemoryLevel = (int) (this.totalAvailableMemory * (this.activeMemoryThreshold / 100.0));
- }
-
- public long getMaxAvailableSession() {
- return this.availableSessionLevel;
- }
-
- public long getActiveMemoryLevel() {
- return this.activeMemoryLevel;
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -43,6 +43,7 @@
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.util.LogConstants;
@@ -55,31 +56,34 @@
*/
public class BufferManagerImpl implements BufferManager, StorageManager {
- // Initialized stuff
private String lookup;
- private BufferConfig config;
-
+
+ // Configuration
+ private int connectorBatchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
+ private int processorBatchSize = BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE;
+ private int maxProcessingBatches = BufferManager.DEFAULT_MAX_PROCESSING_BATCHES;
+
private Map<TupleSourceID, TupleBuffer> tupleSourceMap = new ConcurrentHashMap<TupleSourceID, TupleBuffer>();
private Map<String, Set<TupleSourceID>> groupInfos = new HashMap<String, Set<TupleSourceID>>();
private StorageManager diskMgr;
private AtomicLong currentTuple = new AtomicLong(0);
+
+ public int getMaxProcessingBatches() {
+ return maxProcessingBatches;
+ }
+
+ public void setMaxProcessingBatches(int maxProcessingBatches) {
+ this.maxProcessingBatches = maxProcessingBatches;
+ }
/**
- * Get the configuration of the buffer manager
- * @return Configuration
- */
- public BufferConfig getConfig() {
- return this.config;
- }
-
- /**
* Get processor batch size
* @return Number of rows in a processor batch
*/
public int getProcessorBatchSize() {
- return config.getProcessorBatchSize();
+ return this.processorBatchSize;
}
/**
@@ -87,9 +91,17 @@
* @return Number of rows in a connector batch
*/
public int getConnectorBatchSize() {
- return config.getConnectorBatchSize();
+ return this.connectorBatchSize;
}
+
+ public void setConnectorBatchSize(int connectorBatchSize) {
+ this.connectorBatchSize = connectorBatchSize;
+ }
+ public void setProcessorBatchSize(int processorBatchSize) {
+ this.processorBatchSize = processorBatchSize;
+ }
+
/**
* Add a storage manager to this buffer manager, order is unimportant
* @param storageManager Storage manager to add
@@ -100,6 +112,10 @@
this.diskMgr = storageManager;
}
+ public StorageManager getStorageManager() {
+ return diskMgr;
+ }
+
@Override
public TupleBuffer createTupleBuffer(List elements, String groupName,
TupleSourceType tupleSourceType)
@@ -224,8 +240,8 @@
@Override
public void initialize(Properties props)
throws MetaMatrixComponentException {
- this.config = new BufferConfig(props);
this.lookup = "local"; //$NON-NLS-1$
+ PropertiesUtils.setBeanProperties(this, props, "metamatrix.buffer"); //$NON-NLS-1$
}
@Override
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -40,7 +40,7 @@
import java.util.Properties;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManagerPropertyNames;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSourceID;
@@ -90,12 +90,12 @@
/**
* Initialize with properties
* @param props Initialization properties
- * @see com.metamatrix.common.buffer.BufferManagerPropertyNames#BUFFER_STORAGE_DIRECTORY
- * @see com.metamatrix.common.buffer.BufferManagerPropertyNames#MAX_OPEN_FILES
- * @see com.metamatrix.common.buffer.BufferManagerPropertyNames#MAX_FILE_SIZE
+ * @see com.metamatrix.common.buffer.BufferManager#BUFFER_STORAGE_DIRECTORY
+ * @see com.metamatrix.common.buffer.BufferManager#MAX_OPEN_FILES
+ * @see com.metamatrix.common.buffer.BufferManager#MAX_FILE_SIZE
*/
public void initialize(Properties props) throws MetaMatrixComponentException {
- this.directory = props.getProperty(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY);
+ this.directory = props.getProperty(BufferManager.BUFFER_STORAGE_DIRECTORY);
if(this.directory == null) {
throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.no_directory")); //$NON-NLS-1$
}
@@ -111,11 +111,15 @@
}
// Set up max number of open file descriptors
- maxOpenFiles = PropertiesUtils.getIntProperty(props, BufferManagerPropertyNames.MAX_OPEN_FILES, 10);
+ maxOpenFiles = PropertiesUtils.getIntProperty(props, BufferManager.MAX_OPEN_FILES, 10);
// Set the max file size
- maxFileSize = PropertiesUtils.getIntProperty(props, BufferManagerPropertyNames.MAX_FILE_SIZE, 2048) * 1024L * 1024L; // Multiply by 1MB
+ maxFileSize = PropertiesUtils.getIntProperty(props, BufferManager.MAX_FILE_SIZE, 2048) * 1024L * 1024L; // Multiply by 1MB
}
+
+ public String getDirectory() {
+ return directory;
+ }
/**
* Look up tuple source info and possibly create. First the file map is used to find an
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -31,7 +31,7 @@
import org.teiid.connector.xa.api.TransactionContext;
import org.teiid.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.common.buffer.impl.BufferConfig;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.query.sql.lang.Command;
@@ -74,7 +74,7 @@
private Command command;
// results fetch size
- private int fetchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
+ private int fetchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
// The time when the command was created by the client
private Date submittedTimestamp;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -36,7 +36,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.buffer.impl.BufferConfig;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.QueryPlugin;
@@ -904,7 +904,7 @@
float numberComparisons = merge?(leftChildCardinality + rightChildCardinality):(leftChildCardinality * rightChildCardinality);
- float connectorBatchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
+ float connectorBatchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
if(context != null) {
connectorBatchSize = context.getConnectorBatchSize();
}
@@ -965,8 +965,8 @@
return UNKNOWN_VALUE;
}
- float connectorBatchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
- float processorBatchSize = BufferConfig.DEFAULT_PROCESSOR_BATCH_SIZE;
+ float connectorBatchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
+ float processorBatchSize = BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE;
if(context != null) {
connectorBatchSize = context.getConnectorBatchSize();
processorBatchSize = context.getProcessorBatchSize();
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -26,7 +26,6 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.tempdata.TempTableStore;
import com.metamatrix.query.util.CommandContext;
@@ -62,7 +61,6 @@
* If a temp group is <i>not</i> being selected from, then this request will be
* passed through to the underlying ProcessorDataManager.
* @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.processor.ProcessorDataManager#registerRequest(Object, Command, String, String, TupleSourceID)
*/
public TupleSource registerRequest(
Object processorID,
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -97,7 +97,7 @@
}
}
- public void close() throws MetaMatrixComponentException {
+ public void close() {
if (dvs != null) {
sortUtility = null;
dvs.getTupleBuffer().remove();
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -194,7 +194,7 @@
functions[i] = new Max();
}
- if(aggSymbol.isDistinct()) {
+ if(aggSymbol.isDistinct() && !function.equals(ReservedWords.MIN) && !function.equals(ReservedWords.MAX)) {
functions[i] = new DuplicateFilter(functions[i], getBufferManager(), getConnectionID());
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -24,9 +24,6 @@
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-
/**
* Nested loop is currently implemented as a degenerate case of merge join.
*
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -24,8 +24,8 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -73,15 +73,15 @@
//constructor state
private TupleSource sourceID;
private Mode mode;
- protected BufferManager bufferManager;
+ private BufferManager bufferManager;
private String groupName;
- protected List schema;
+ private List<SingleElementSymbol> schema;
private ListNestedSortComparator comparator;
private TupleBuffer output;
private boolean doneReading;
private int phase = INITIAL_SORT;
- protected List<TupleBuffer> activeTupleBuffers = new ArrayList<TupleBuffer>();
+ private List<TupleBuffer> activeTupleBuffers = new ArrayList<TupleBuffer>();
private int masterSortIndex;
// Phase constants for readability
@@ -100,7 +100,7 @@
if (mode != Mode.SORT) {
if (sortElements != null && sortElements.size() < schema.size()) {
sortElements = new ArrayList(sortElements);
- List toAdd = new ArrayList(schema);
+ List<SingleElementSymbol> toAdd = new ArrayList<SingleElementSymbol>(schema);
toAdd.removeAll(sortElements);
sortElements.addAll(toAdd);
sortTypes = new ArrayList<Boolean>(sortTypes);
@@ -113,13 +113,11 @@
int[] cols = new int[sortElements.size()];
- Iterator iter = sortElements.iterator();
-
- for (int i = 0; i < cols.length; i++) {
- SingleElementSymbol elem = (SingleElementSymbol)iter.next();
+ for (ListIterator<SingleElementSymbol> iter = sortElements.listIterator(); iter.hasNext();) {
+ SingleElementSymbol elem = iter.next();
- cols[i] = schema.indexOf(elem);
- Assertion.assertTrue(cols[i] != -1);
+ cols[iter.previousIndex()] = schema.indexOf(elem);
+ Assertion.assertTrue(cols[iter.previousIndex()] != -1);
}
this.comparator = new ListNestedSortComparator(cols, sortTypes);
this.comparator.setDistinctIndex(distinctIndex);
@@ -150,12 +148,13 @@
}
/**
- * creates sort sublists stored in tuplebuffers
+ * creates sorted sublists stored in tuplebuffers
*/
protected void initialSort() throws MetaMatrixComponentException, MetaMatrixProcessingException {
while(!doneReading) {
- List<List<Object>> workingTuples = new ArrayList<List<Object>>();
- while(!doneReading) { //TODO: limit rows
+ List<List<?>> workingTuples = new ArrayList<List<?>>();
+ int maxRows = bufferManager.getMaxProcessingBatches() * bufferManager.getProcessorBatchSize();
+ while(!doneReading && workingTuples.size() < maxRows) {
try {
List<?> tuple = sourceID.nextTuple();
@@ -183,7 +182,7 @@
//perform a stable sort
Collections.sort(workingTuples, comparator);
}
- for (List<Object> list : workingTuples) {
+ for (List<?> list : workingTuples) {
activeID.addTuple(list);
}
}
@@ -195,7 +194,7 @@
this.phase = MERGE;
}
- protected void addTuple(List workingTuples, List tuple) {
+ protected void addTuple(List<List<?>> workingTuples, List<?> tuple) {
if (this.mode == Mode.SORT) {
workingTuples.add(tuple);
return;
@@ -214,7 +213,8 @@
TupleBuffer merged = createTupleBuffer();
int sortedIndex = 0;
- for(; sortedIndex<activeTupleBuffers.size(); sortedIndex++) { //TODO: limit activeTupleIDs
+ int maxSortIndex = Math.min(this.bufferManager.getMaxProcessingBatches() * 2, activeTupleBuffers.size());
+ for(; sortedIndex<maxSortIndex; sortedIndex++) {
TupleBuffer activeID = activeTupleBuffers.get(sortedIndex);
SortedSublist sortedSublist = new SortedSublist();
sortedSublist.its = activeID.createIndexedTupleSource();
@@ -228,7 +228,7 @@
if (!sortedSublist.duplicate) {
merged.addTuple(sortedSublist.tuple);
if (this.output != null && sortedSublist.index != masterSortIndex && sortedIndex > masterSortIndex) {
- this.output.addTuple(sortedSublist.tuple);
+ this.output.addTuple(sortedSublist.tuple); //a new distinct row
}
}
addWorkingTuple(workingTuples, sortedSublist);
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -31,7 +31,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryProcessingException;
-import com.metamatrix.common.buffer.impl.BufferConfig;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.SecurityFunctionEvaluator;
@@ -57,9 +57,9 @@
/** Identify a group of related commands, which typically get cleaned up together */
private String connectionID;
- private int processorBatchSize = BufferConfig.DEFAULT_PROCESSOR_BATCH_SIZE;
+ private int processorBatchSize = BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE;
- private int connectorBatchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
+ private int connectorBatchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
private String userName;
@@ -106,7 +106,6 @@
/**
* Construct a new context.
- * @param collectNodeStatistics TODO
*/
public CommandContext(Object processorID, String connectionID, String userName,
Serializable commandPayload, String vdbName, String vdbVersion, Properties envProperties, boolean processDebug, boolean collectNodeStatistics) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -32,7 +32,7 @@
import org.teiid.dqp.internal.cache.DQPContextCache;
import com.metamatrix.cache.Cache;
-import com.metamatrix.common.buffer.impl.BufferConfig;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.core.util.HashCodeUtil;
/**
@@ -68,7 +68,7 @@
private DQPContextCache contextCache;
- private int batchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
+ private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
private List<Exception> warnings = new LinkedList<Exception>();
public ExecutionContextImpl(String vdbName, String vdbVersion, String userName,
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CacheResults.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CacheResults.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CacheResults.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -1,68 +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 org.teiid.dqp.internal.process;
-
-import java.io.Serializable;
-import java.util.List;
-
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
-public class CacheResults implements Serializable {
- private TupleSourceID results;
- private AnalysisRecord analysisRecord;
- private Command command;
-
- public CacheResults(TupleSourceID results){
- this.results = results;
- }
-
- public TupleSourceID getResults() {
- return results;
- }
-
- public List<SingleElementSymbol> getElements() {
- if (command == null) {
- return null;
- }
- return command.getProjectedSymbols();
- }
-
- public Command getCommand() {
- return command;
- }
-
- public void setCommand(Command command) {
- this.command = command;
- }
-
- public AnalysisRecord getAnalysisRecord() {
- return analysisRecord;
- }
-
- public void setAnalysisRecord(AnalysisRecord analysisRecord) {
- this.analysisRecord = analysisRecord;
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -52,10 +52,6 @@
if (INSTANCE == null) {
BufferManagerImpl bufferMgr = new BufferManagerImpl();
Properties props = new Properties();
- props.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, String.valueOf(Long.MAX_VALUE));
- props.setProperty(BufferManagerPropertyNames.SESSION_USE_PERCENTAGE, "100"); //$NON-NLS-1$
- props.setProperty(BufferManagerPropertyNames.LOG_STATS_INTERVAL, "0"); //$NON-NLS-1$
- props.setProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL, "0"); //$NON-NLS-1$
bufferMgr.initialize(props);
// Add unmanaged memory storage manager
Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/storage/file/TestFileStorageManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/storage/file/TestFileStorageManager.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/storage/file/TestFileStorageManager.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -36,7 +36,7 @@
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManagerPropertyNames;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSourceID;
@@ -61,23 +61,15 @@
}
// Set up the fixture for this testcase: the tables for this test.
- public StorageManager getStorageManager(String MAX_FILE_SIZE) {
- try {
- Properties resourceProps = new Properties();
- resourceProps.put(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, UnitTestUtil.getTestScratchPath());
- if (MAX_FILE_SIZE != null) {
- resourceProps.put(BufferManagerPropertyNames.MAX_FILE_SIZE, MAX_FILE_SIZE);
- }
- StorageManager sm = new FileStorageManager();
- sm.initialize(resourceProps);
- return sm;
- } catch(Exception e) {
- e.printStackTrace();
- fail("Failure during storage manager initialization: " + e.getMessage()); //$NON-NLS-1$
-
- // won't be called
- return null;
+ public StorageManager getStorageManager(String MAX_FILE_SIZE) throws MetaMatrixComponentException {
+ Properties resourceProps = new Properties();
+ resourceProps.put(BufferManager.BUFFER_STORAGE_DIRECTORY, UnitTestUtil.getTestScratchPath());
+ if (MAX_FILE_SIZE != null) {
+ resourceProps.put(BufferManager.MAX_FILE_SIZE, MAX_FILE_SIZE);
}
+ StorageManager sm = new FileStorageManager();
+ sm.initialize(resourceProps);
+ return sm;
}
public static TupleBatch exampleBatch(int begin, int end) {
@@ -146,17 +138,13 @@
}
}
- public void helpTestMultiThreaded(int OPEN_FILES, int NUM_THREADS, int NUM_BATCHES, int BATCH_SIZE) {
+ public void helpTestMultiThreaded(int OPEN_FILES, int NUM_THREADS, int NUM_BATCHES, int BATCH_SIZE) throws MetaMatrixComponentException {
Properties resourceProps = new Properties();
String nonExistentDirectory = UnitTestUtil.getTestScratchPath() + File.separator + "testMultiThread"; //$NON-NLS-1$
- resourceProps.put(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, nonExistentDirectory);
- resourceProps.put(BufferManagerPropertyNames.MAX_OPEN_FILES, "" + OPEN_FILES); //$NON-NLS-1$
+ resourceProps.put(BufferManager.BUFFER_STORAGE_DIRECTORY, nonExistentDirectory);
+ resourceProps.put(BufferManager.MAX_OPEN_FILES, "" + OPEN_FILES); //$NON-NLS-1$
final StorageManager sm = getStorageManager(null);
- try {
- sm.initialize(resourceProps);
- } catch(MetaMatrixComponentException e) {
- fail("Unexpected exception during initialization: " + e.getMessage()); //$NON-NLS-1$
- }
+ sm.initialize(resourceProps);
// Create threads
AddGetWorker[] threads = new AddGetWorker[NUM_THREADS];
@@ -198,17 +186,13 @@
}
- public void helpTestRandomThreads(int OPEN_FILES, int NUM_THREADS, int NUM_BATCHES, int BATCH_SIZE, int RANDOM_OPS) {
+ public void helpTestRandomThreads(int OPEN_FILES, int NUM_THREADS, int NUM_BATCHES, int BATCH_SIZE, int RANDOM_OPS) throws MetaMatrixComponentException {
Properties resourceProps = new Properties();
String nonExistentDirectory = UnitTestUtil.getTestScratchPath() + File.separator + "testMultiThread"; //$NON-NLS-1$
- resourceProps.put(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, nonExistentDirectory);
- resourceProps.put(BufferManagerPropertyNames.MAX_OPEN_FILES, "" + OPEN_FILES); //$NON-NLS-1$
+ resourceProps.put(BufferManager.BUFFER_STORAGE_DIRECTORY, nonExistentDirectory);
+ resourceProps.put(BufferManager.MAX_OPEN_FILES, "" + OPEN_FILES); //$NON-NLS-1$
final StorageManager sm = getStorageManager(null);
- try {
- sm.initialize(resourceProps);
- } catch(MetaMatrixComponentException e) {
- fail("Unexpected exception during initialization: " + e.getMessage()); //$NON-NLS-1$
- }
+ sm.initialize(resourceProps);
// Create threads
RandomAccessWorker[] threads = new RandomAccessWorker[NUM_THREADS];
@@ -296,7 +280,7 @@
Properties resourceProps = new Properties();
String nonExistentDirectory = UnitTestUtil.getTestScratchPath() + File.separator + "GONZO"; //$NON-NLS-1$
- resourceProps.put(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, nonExistentDirectory);
+ resourceProps.put(BufferManager.BUFFER_STORAGE_DIRECTORY, nonExistentDirectory);
StorageManager sm = new FileStorageManager();
sm.initialize(resourceProps);
@@ -327,27 +311,27 @@
}
// Test with more open files than number of threads
- public void testMultiThreaded1() {
+ public void testMultiThreaded1() throws Exception {
helpTestMultiThreaded(6, 5, 5, 100);
}
// Test with fewer open files than number of threads
- public void testMultiThreaded2() {
+ public void testMultiThreaded2() throws Exception {
helpTestMultiThreaded(1, 2, 5, 100);
}
// Test 1 random thread
- public void testRandomThreads1() {
+ public void testRandomThreads1() throws Exception {
helpTestRandomThreads(10, 1, 5, 20, 30);
}
// Test several random threads
- public void testRandomThreads2() {
+ public void testRandomThreads2() throws Exception {
helpTestRandomThreads(10, 5, 5, 20, 30);
}
// Test several random threads, low open files
- public void testRandomThreads3() {
+ public void testRandomThreads3() throws Exception {
helpTestRandomThreads(2, 4, 5, 20, 30);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -226,8 +226,8 @@
public static void doProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults, CommandContext context) throws Exception {
BufferManagerImpl bufferMgr = (BufferManagerImpl)BufferManagerFactory.getStandaloneBufferManager();
- bufferMgr.getConfig().setProcessorBatchSize(context.getProcessorBatchSize());
- bufferMgr.getConfig().setConnectorBatchSize(context.getProcessorBatchSize());
+ bufferMgr.setProcessorBatchSize(context.getProcessorBatchSize());
+ bufferMgr.setConnectorBatchSize(context.getProcessorBatchSize());
context.getNextRand(0);
TupleBuffer id = null;
try {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -38,7 +38,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerPropertyNames;
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
@@ -495,12 +494,8 @@
private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
BufferManagerImpl bufferMgr = new BufferManagerImpl();
Properties props = new Properties();
- props.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, String.valueOf(Long.MAX_VALUE));
- props.setProperty(BufferManagerPropertyNames.SESSION_USE_PERCENTAGE, "100"); //$NON-NLS-1$
- props.setProperty(BufferManagerPropertyNames.LOG_STATS_INTERVAL, "0"); //$NON-NLS-1$
- props.setProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL, "0"); //$NON-NLS-1$
- props.setProperty(BufferManagerPropertyNames.PROCESSOR_BATCH_SIZE, String.valueOf(batchSize));
- props.setProperty(BufferManagerPropertyNames.CONNECTOR_BATCH_SIZE, String.valueOf(batchSize));
+ props.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, String.valueOf(batchSize));
+ props.setProperty(BufferManager.CONNECTOR_BATCH_SIZE, String.valueOf(batchSize));
bufferMgr.initialize(props);
// Add unmanaged memory storage manager
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -26,7 +26,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerPropertyNames;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.buffer.impl.MemoryStorageManager;
@@ -41,9 +40,8 @@
// Get the properties for BufferManager
Properties bmProps = new Properties();
- bmProps.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, "" + bytesAvailable); //$NON-NLS-1$
- bmProps.setProperty(BufferManagerPropertyNames.PROCESSOR_BATCH_SIZE, "" + procBatchSize); //$NON-NLS-1$
- bmProps.setProperty(BufferManagerPropertyNames.CONNECTOR_BATCH_SIZE, "" + connectorBatchSize); //$NON-NLS-1$
+ bmProps.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, "" + procBatchSize); //$NON-NLS-1$
+ bmProps.setProperty(BufferManager.CONNECTOR_BATCH_SIZE, "" + connectorBatchSize); //$NON-NLS-1$
return createBufferManager(bmProps);
}
@@ -51,14 +49,12 @@
// Get the properties for BufferManager
Properties bmProps = new Properties();
- bmProps.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, "" + bytesAvailable); //$NON-NLS-1$
- bmProps.setProperty(BufferManagerPropertyNames.PROCESSOR_BATCH_SIZE, "" + procBatchSize); //$NON-NLS-1$
+ bmProps.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, "" + procBatchSize); //$NON-NLS-1$
return createBufferManager(bmProps);
}
static BufferManager createBufferManager(Properties bmProps) {
BufferManagerImpl bufferManager = new BufferManagerImpl();
- bmProps.setProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL, "0"); //$NON-NLS-1$
try {
bufferManager.initialize(bmProps);
} catch (MetaMatrixComponentException e) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -207,7 +207,7 @@
// Same as test2, but uses processor batch size smaller than number of groups
public void test3() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- ((BufferManagerImpl)mgr).getConfig().setProcessorBatchSize(5);
+ ((BufferManagerImpl)mgr).setProcessorBatchSize(5);
GroupingNode node = getExampleGroupingNode();
CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
@@ -308,7 +308,7 @@
private void helpTestLookupFunctionInAggregate(int batchSize) throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- ((BufferManagerImpl)mgr).getConfig().setProcessorBatchSize(batchSize);
+ ((BufferManagerImpl)mgr).setProcessorBatchSize(batchSize);
// Set up
GroupingNode node = new GroupingNode(1);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -214,7 +214,10 @@
public void helpTestJoin() throws MetaMatrixComponentException, MetaMatrixProcessingException {
for (int batchSize : new int[] {1, 10, leftTuples.length, 100}) {
- helpCreateJoin();
+ helpCreateJoin();
+ if (batchSize == 0) {
+ continue;
+ }
helpTestJoinDirect(expected, batchSize);
List[] temp = leftTuples;
leftTuples = rightTuples;
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -34,7 +34,6 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.Cache;
import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.EmbeddedLogger;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.RuntimeStateAdmin;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -42,7 +41,6 @@
import com.metamatrix.admin.objects.MMRequest;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.RequestID;
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -34,7 +34,6 @@
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerPropertyNames;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.buffer.impl.FileStorageManager;
@@ -51,12 +50,6 @@
*/
public class EmbeddedBufferService extends EmbeddedBaseDQPService implements BufferService {
- // Constants
- private static final String DEFAULT_MANAGEMENT_INTERVAL = "500"; //$NON-NLS-1$
- private static final String DEFAULT_LOG_STATS_INTERVAL = "60000"; //$NON-NLS-1$ // every minute
- private static final String DEFAULT_SESSION_USE_PERCENTAGE = "100"; //$NON-NLS-1$
- private static final String DEFAULT_MAX_OPEN_FILES = "10"; //$NON-NLS-1$
-
// Instance
private BufferManagerImpl bufferMgr;
private File bufferDir;
@@ -95,22 +88,14 @@
boolean useDisk = configurationSvc.useDiskBuffering();
bufferDir = configurationSvc.getDiskBufferDirectory();
- String memAvail = configurationSvc.getBufferMemorySize();
String processorBatchSize = configurationSvc.getProcessorBatchSize();
String connectorBatchSize = configurationSvc.getConnectorBatchSize();
// Set up buffer configuration properties
Properties bufferProps = new Properties();
- bufferProps.setProperty(BufferManagerPropertyNames.SESSION_USE_PERCENTAGE, DEFAULT_SESSION_USE_PERCENTAGE);
- bufferProps.setProperty(BufferManagerPropertyNames.LOG_STATS_INTERVAL, DEFAULT_LOG_STATS_INTERVAL);
- bufferProps.setProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL, DEFAULT_MANAGEMENT_INTERVAL);
- bufferProps.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, memAvail);
- bufferProps.setProperty(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, bufferDir.getCanonicalPath());
- bufferProps.setProperty(BufferManagerPropertyNames.PROCESSOR_BATCH_SIZE, processorBatchSize);
- bufferProps.setProperty(BufferManagerPropertyNames.CONNECTOR_BATCH_SIZE, connectorBatchSize);
- // These are not set yet..
- //CONNECTOR_BATCH_SIZE
- //PROCESSOR_BATCH_SIZE
+ bufferProps.setProperty(BufferManager.BUFFER_STORAGE_DIRECTORY, bufferDir.getCanonicalPath());
+ bufferProps.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, processorBatchSize);
+ bufferProps.setProperty(BufferManager.CONNECTOR_BATCH_SIZE, connectorBatchSize);
// Construct and initialize the buffer manager
this.bufferMgr = new BufferManagerImpl();
@@ -120,8 +105,7 @@
if(useDisk) {
// Get the properties for FileStorageManager and create.
Properties fsmProps = new Properties();
- fsmProps.setProperty(BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, bufferDir.getCanonicalPath());
- fsmProps.setProperty(BufferManagerPropertyNames.MAX_OPEN_FILES, DEFAULT_MAX_OPEN_FILES);
+ fsmProps.setProperty(BufferManager.BUFFER_STORAGE_DIRECTORY, bufferDir.getCanonicalPath());
StorageManager fsm = new FileStorageManager();
fsm.initialize(fsmProps);
this.bufferMgr.setStorageManager(fsm);
Modified: trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java
===================================================================
--- trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java 2009-12-24 05:03:40 UTC (rev 1704)
+++ trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java 2009-12-24 05:21:00 UTC (rev 1705)
@@ -28,8 +28,8 @@
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.buffer.impl.BufferConfig;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
+import com.metamatrix.common.buffer.impl.FileStorageManager;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.embedded.EmbeddedTestUtil;
@@ -90,9 +90,7 @@
assertTrue(cs.useDiskBuffering());
BufferManagerImpl mgr = (BufferManagerImpl) svc.getBufferManager();
- BufferConfig config = mgr.getConfig();
- assertEquals("Did not get expected memory level", 96000000L, config.getTotalAvailableMemory()); //$NON-NLS-1$
- assertTrue(config.getBufferStorageDirectory().endsWith(cs.getDiskBufferDirectory().getName()));
+ assertTrue(((FileStorageManager)mgr.getStorageManager()).getDirectory().endsWith(cs.getDiskBufferDirectory().getName()));
}
public void testCheckMemPropertyGotSet2() throws Exception {
@@ -110,10 +108,6 @@
// all the properties are set
assertFalse(cs.useDiskBuffering());
-
- BufferManagerImpl mgr = (BufferManagerImpl) svc.getBufferManager();
- BufferConfig config = mgr.getConfig();
- assertEquals("Did not get expected memory level", 64000000L, config.getTotalAvailableMemory()); //$NON-NLS-1$
}
}
15 years
teiid SVN: r1704 - in trunk/engine/src: test/java/org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-24 00:03:40 -0500 (Thu, 24 Dec 2009)
New Revision: 1704
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
Log:
TEIID-915 adding more graceful handling of exceptions occurring in between batch requests
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-12-23 22:55:47 UTC (rev 1703)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-12-24 05:03:40 UTC (rev 1704)
@@ -41,7 +41,6 @@
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.comm.api.ResultsReceiver;
@@ -75,35 +74,6 @@
public class RequestWorkItem extends AbstractWorkItem {
- protected static class ResultsCursor {
- int begin;
- int end;
- boolean resultsRequested;
-
- /**
- * Ask for results.
- * @param beginRow
- * @param endRow
- * @param isPoll
- */
- synchronized void requestResults(int beginRow, int endRow, boolean isPoll) {
- if (this.resultsRequested) {
- if (!isPoll) {
- throw new IllegalStateException("Results already requested"); //$NON-NLS-1$\
- } else if (begin != beginRow || end != endRow) {
- throw new IllegalStateException("Polling for different results than previously requested"); //$NON-NLS-1$
- }
- }
- this.begin = beginRow;
- this.end = endRow;
- this.resultsRequested = true;
- }
-
- synchronized void resultsSent() {
- this.resultsRequested = false;
- }
- }
-
private enum ProcessingState {NEW, PROCESSING, CLOSE}
private ProcessingState state = ProcessingState.NEW;
@@ -117,13 +87,16 @@
final RequestMessage requestMsg;
final RequestID requestID;
protected Request request; //provides the processing plan, held on a temporary basis
- final private BufferManager bufferMgr;
final private int processorTimeslice;
//protected ResultSetCache rsCache;
//protected CacheID cid;
final private TransactionService transactionService;
final DQPWorkContext dqpWorkContext;
+
+ //results request
ResultsReceiver<ResultsMessage> resultsReceiver;
+ private int begin;
+ private int end;
/*
* obtained during new
@@ -150,16 +123,11 @@
private volatile boolean isCanceled;
private volatile boolean closeRequested;
- /** Range of rows requested by the client */
- protected ResultsCursor resultsCursor = new ResultsCursor();
-
private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
this.requestMsg = requestMsg;
this.requestID = requestID;
- this.resultsCursor.requestResults(1, requestMsg.getFetchSize(), false);
- this.bufferMgr = dqpCore.getBufferManager();
this.processorTimeslice = dqpCore.getProcessorTimeSlice();
/*this.rsCache = dqpCore.getRsCache();
if (this.rsCache != null) {
@@ -168,10 +136,24 @@
this.transactionService = dqpCore.getTransactionServiceDirect();
this.dqpCore = dqpCore;
this.request = request;
- this.resultsReceiver = receiver;
this.dqpWorkContext = workContext;
+ this.requestResults(1, requestMsg.getFetchSize(), receiver);
}
+ /**
+ * Ask for results.
+ * @param beginRow
+ * @param endRow
+ */
+ synchronized void requestResults(int beginRow, int endRow, ResultsReceiver<ResultsMessage> receiver) {
+ if (this.resultsReceiver != null) {
+ throw new IllegalStateException("Results already requested"); //$NON-NLS-1$\
+ }
+ this.resultsReceiver = receiver;
+ this.begin = beginRow;
+ this.end = endRow;
+ }
+
@Override
protected boolean isDoneProcessing() {
return isClosed;
@@ -257,7 +239,7 @@
cr.setAnalysisRecord(analysisRecord);
}*/
if (this.transactionState == TransactionState.ACTIVE) {
- boolean end = true;
+ boolean endState = true;
/*
* TEIID-14 if we are done producing batches, then proactively close transactional
* executions even ones that were intentionally kept alive. this may
@@ -267,10 +249,10 @@
for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
if (connectorRequest.isTransactional()) {
connectorRequest.fullyCloseSource();
- end = false;
+ endState = false;
}
}
- if (end) {
+ if (endState) {
this.transactionState = TransactionState.END;
}
}
@@ -382,71 +364,74 @@
* Send results if they have been requested. This should only be called from the processing thread.
*/
protected void sendResultsIfNeeded(TupleBatch batch) throws MetaMatrixComponentException {
-
- synchronized (resultsCursor) {
- if (!this.resultsCursor.resultsRequested
- || (this.resultsCursor.begin > this.processor.getHighestRow() && !doneProducingBatches)
+ ResultsMessage response = null;
+ ResultsReceiver<ResultsMessage> receiver = null;
+ synchronized (this) {
+ if (this.resultsReceiver == null
+ || (this.begin > this.processor.getHighestRow() && !doneProducingBatches)
|| (this.transactionState == TransactionState.ACTIVE)) {
return;
}
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID: " + requestID + " resultsID: " + this.resultsBuffer + " done: " + doneProducingBatches ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ if (batch == null || batch.getBeginRow() > this.begin) {
+ batch = resultsBuffer.getBatch(begin);
+ //TODO: support fetching more than 1 batch
+ int count = this.end - this.begin + 1;
+ if (batch.getRowCount() > count) {
+ int beginRow = Math.min(this.begin, batch.getEndRow() - count + 1);
+ int endRow = Math.min(beginRow + count - 1, batch.getEndRow());
+ int firstOffset = beginRow - batch.getBeginRow();
+ List[] memoryRows = batch.getAllTuples();
+ List[] rows = new List[count];
+ System.arraycopy(memoryRows, firstOffset, rows, 0, endRow - beginRow + 1);
+ batch = new TupleBatch(beginRow, rows);
+ }
+ }
+ int finalRowCount = doneProducingBatches?this.processor.getHighestRow():-1;
+
+ response = createResultsMessage(requestMsg, batch.getAllTuples(), this.processor.getProcessorPlan().getOutputElements(), analysisRecord);
+ response.setFirstRow(batch.getBeginRow());
+ response.setLastRow(batch.getEndRow());
+ response.setUpdateResult(this.returnsUpdateCount);
+ // set final row
+ response.setFinalRow(finalRowCount);
+
+ // send any schemas associated with the results
+ response.setSchemas(this.schemas);
+
+ // send any warnings with the response object
+ List<Throwable> responseWarnings = new ArrayList<Throwable>();
+ List<Exception> currentWarnings = processor.getAndClearWarnings();
+ if (currentWarnings != null) {
+ responseWarnings.addAll(currentWarnings);
+ }
+ synchronized (warnings) {
+ responseWarnings.addAll(this.warnings);
+ this.warnings.clear();
+ }
+ response.setWarnings(responseWarnings);
+
+ // If it is stored procedure, set parameters
+ if (originalCommand instanceof StoredProcedure) {
+ StoredProcedure proc = (StoredProcedure)originalCommand;
+ if (proc.returnParameters()) {
+ response.setParameters(getParameterInfo(proc));
+ }
+ }
+ /*
+ * mark the results sent at this point.
+ * communication exceptions will be treated as non-recoverable
+ */
+ receiver = this.resultsReceiver;
+ this.resultsReceiver = null;
}
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID: " + requestID + " resultsID: " + this.resultsBuffer + " done: " + doneProducingBatches ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- if (batch == null || batch.getBeginRow() > this.resultsCursor.begin) {
- batch = resultsBuffer.getBatch(resultsCursor.begin);
- //TODO: support fetching more than 1 batch
- int count = this.resultsCursor.end - this.resultsCursor.begin + 1;
- if (batch.getRowCount() > count) {
- int beginRow = Math.min(this.resultsCursor.begin, batch.getEndRow() - count + 1);
- int endRow = Math.min(beginRow + count - 1, batch.getEndRow());
- int firstOffset = beginRow - batch.getBeginRow();
- List[] memoryRows = batch.getAllTuples();
- List[] rows = new List[count];
- System.arraycopy(memoryRows, firstOffset, rows, 0, endRow - beginRow + 1);
- batch = new TupleBatch(beginRow, rows);
- }
- }
- int finalRowCount = doneProducingBatches?this.processor.getHighestRow():-1;
+ receiver.receiveResults(response);
- ResultsMessage response = createResultsMessage(requestMsg, batch.getAllTuples(), this.processor.getProcessorPlan().getOutputElements(), analysisRecord);
- response.setFirstRow(batch.getBeginRow());
- response.setLastRow(batch.getEndRow());
- response.setUpdateResult(this.returnsUpdateCount);
- // set final row
- response.setFinalRow(finalRowCount);
-
- // send any schemas associated with the results
- response.setSchemas(this.schemas);
-
- // send any warnings with the response object
- List<Throwable> responseWarnings = new ArrayList<Throwable>();
- List<Exception> currentWarnings = processor.getAndClearWarnings();
- if (currentWarnings != null) {
- responseWarnings.addAll(currentWarnings);
- }
- synchronized (warnings) {
- responseWarnings.addAll(this.warnings);
- this.warnings.clear();
- }
- response.setWarnings(responseWarnings);
-
- // If it is stored procedure, set parameters
- if (originalCommand instanceof StoredProcedure) {
- StoredProcedure proc = (StoredProcedure)originalCommand;
- if (proc.returnParameters()) {
- response.setParameters(getParameterInfo(proc));
- }
- }
-
- /*
- * mark the results sent at this point.
- * communication exceptions will be treated as non-recoverable
- */
- this.resultsCursor.resultsSent();
- this.resultsReceiver.receiveResults(response);
}
public static ResultsMessage createResultsMessage(RequestMessage message, List[] batch, List columnSymbols, AnalysisRecord analysisRecord) {
@@ -490,7 +475,13 @@
}
private void sendError() {
- LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Sedning error to client", requestID); //$NON-NLS-1$
+ synchronized (this) {
+ if (this.resultsReceiver == null) {
+ LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Unable to send error to client as results were already sent.", requestID); //$NON-NLS-1$
+ return;
+ }
+ }
+ LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Sending error to client", requestID); //$NON-NLS-1$
ResultsMessage response = new ResultsMessage(requestMsg);
response.setException(processingException);
setAnalysisRecords(response, analysisRecord);
@@ -594,8 +585,7 @@
}
public void requestMore(int batchFirst, int batchLast, ResultsReceiver<ResultsMessage> receiver) {
- this.resultsReceiver = receiver;
- this.resultsCursor.requestResults(batchFirst, batchLast, false);
+ this.requestResults(batchFirst, batchLast, receiver);
this.moreWork();
}
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-12-23 22:55:47 UTC (rev 1703)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-12-24 05:03:40 UTC (rev 1704)
@@ -113,8 +113,7 @@
DQPCore rm = new DQPCore();
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
- assertTrue(workItem.resultsCursor.resultsRequested);
+ addRequest(rm, r0, requestID, null, null);
}
public void testWarnings1() {
15 years
teiid SVN: r1703 - in branches/JCA: client/src/main/java/com/metamatrix/dqp/client and 29 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-23 17:55:47 -0500 (Wed, 23 Dec 2009)
New Revision: 1703
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
Removed:
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
Modified:
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
branches/JCA/jboss-embedded/
branches/JCA/jboss-integration/pom.xml
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
branches/JCA/runtime/pom.xml
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
Log:
TEIID-910: adding sessions
Deleted: branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -1,273 +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.admin.objects;
-
-import java.util.Date;
-
-import org.teiid.adminapi.Session;
-
-import com.metamatrix.admin.AdminPlugin;
-import com.metamatrix.core.util.DateUtil;
-
-/**
- * MetaMatrix Session
- *
- */
-public class MMSession extends MMAdminObject implements Session {
-
- private static final long serialVersionUID = 4939105946380675244L;
- private String userName = ""; //$NON-NLS-1$;
- private String applicationName = ""; //$NON-NLS-1$
- private String sessionID;
- private String vdbName = ""; //$NON-NLS-1$
- private String vdbVersion = ""; //$NON-NLS-1$
- private String ipAddress = ""; //$NON-NLS-1$
- private String hostName = ""; //$NON-NLS-1$
- private long lastPingTime;
- private int sessionState;
-
-
-
- /**
- * constructor
- * @param identifierParts
- */
- public MMSession(String[] identifierParts) {
- super(identifierParts);
- this.sessionID = getIdentifier();
- }
-
-
- /**
- * Convert a Session to a String
- *
- * @see java.lang.Object#toString()
- * @since 4.3
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(AdminPlugin.Util.getString("MMSession.MMSession")).append(getIdentifier()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.User_Name")).append(userName); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.Application")).append(applicationName); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.ID")).append(sessionID); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.VDB_Name")).append(vdbName); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.VDB_Version")).append(vdbVersion); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.Last_Ping_Time")).append(getLastPingTimeString()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.State")).append(getStateAsString()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.IPAddress")).append(ipAddress); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.HostName")).append(hostName); //$NON-NLS-1$
-
- return result.toString();
- }
-
- /**
- * Get the Last time Client has checked to see if the server is still available
- *
- * @return Date of the last ping to the server.
- */
- public Date getLastPingTime() {
- return new Date(lastPingTime);
- }
-
-
- /**
- * Get the Time the User logged into the System as a String
- *
- * @return String
- */
- public String getLastPingTimeString() {
- return DateUtil.getDateAsString(getLastPingTime());
- }
-
- /**
- * Set the Last time Client has checked to see if the server is still available
- * @param lastPingTime
- */
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
-
-
- /**
- * Get the SessionState
- *
- * @return String with the SessionState
- */
- public String getStateAsString() {
- String result = ""; //$NON-NLS-1$
- switch (sessionState) {
- case STATE_EXPIRED :
- result = EXPIRED_STATE_DESC;
- break;
- case STATE_ACTIVE :
- result = ACTIVE_STATE_DESC;
- break;
- case STATE_CLOSED :
- result = CLOSED_STATE_DESC;
- break;
- case STATE_TERMINATED :
- result = TERMINATED_STATE_DESC;
- break;
- case STATE_PASSIVATED :
- result = PASSIVATED_STATE_DESC;
- break;
- default :
- result = UNKNOWN_STATE_DESC;
- }
- return result;
- }
-
-
- /**
- * Set the SessionState
- * @param state
- */
- public void setSessionState(int state) {
- this.sessionState = state;
- }
-
- /**
- * Get the Application Name
- *
- * @return String of the Application Name
- */
- public String getApplicationName() {
- return applicationName;
- }
-
- /**
- * Set the ApplicationName
- * @param name
- */
- public void setApplicationName(String name) {
- this.applicationName = name;
- }
-
- /**
- * Get the unique MetaMatrix session
- * within a given MetaMatrix System
- *
- * @return Strings of the Session ID
- */
- public String getSessionID() {
- return sessionID;
- }
-
- /**
- * Get the State of the Session
- *
- * @return int of the Session's state
- */
- public int getState() {
- return sessionState;
- }
-
- /**
- * Get User Name for this Session
- *
- * @return String of UserName
- */
- public String getUserName() {
- return userName;
- }
-
- /**
- * Set User Name for this Session
- * @param userName
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * Get the VDB Name for this Session
- *
- * @return String name of the VDB
- */
- public String getVDBName() {
- return vdbName;
- }
-
- /**
- * Set VDBName for this Session
- * @param vdbName
- */
- public void setVDBName(String vdbName) {
- this.vdbName = vdbName;
- }
-
- /**
- * Get the VDB Version for this Session
- *
- * @return String name/number of the VDB Version
- */
- public String getVDBVersion() {
- return vdbVersion;
- }
-
- /**
- * Set VDBVersion for this Session
- * @param vdbVersion
- */
- public void setVDBVersion(String vdbVersion) {
- this.vdbVersion = vdbVersion;
- }
-
- /**
- * Set IPAddress for this Session
- * @param ipAddress
- */
- public void setIPAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
-
- /**
- * Get the IPAddress for this Session
- * @return IPAddress
- */
- public String getIPAddress() {
- return this.ipAddress;
- }
-
- /**
- * Set information defined by the client at runtime
- * @param clientMachineName
- */
- public void setHostName(String clientMachineName) {
- this.hostName = clientMachineName;
- }
-
-
- /**
- * Get the host name of the machine the client is
- * accessing from
- * @return IPAddress
- */
- public String getHostName() {
- return this.hostName;
- }
-
-
-}
Modified: branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -32,7 +32,7 @@
public class TransactionImpl extends MMAdminObject implements Transaction {
private static final long serialVersionUID = -8588785315218789068L;
- private String associatedSession;
+ private long associatedSession;
private String scope;
private MMXid xid;
@@ -40,11 +40,11 @@
super(id);
}
- public String getAssociatedSession() {
+ public long getAssociatedSession() {
return associatedSession;
}
- public void setAssociatedSession(String associatedSession) {
+ public void setAssociatedSession(long associatedSession) {
this.associatedSession = associatedSession;
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -34,7 +34,6 @@
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
public interface ClientSideDQP {
@@ -56,7 +55,7 @@
MetadataResult getMetadata(long requestID, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException;
- void terminateConnection(MetaMatrixSessionID sessionId) throws MetaMatrixComponentException;
+ void terminateConnection(long sessionId) throws MetaMatrixComponentException;
// local transaction
void begin() throws XATransactionException;
Modified: branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -23,7 +23,6 @@
package com.metamatrix.platform.security.api;
import java.io.Serializable;
-import java.util.Properties;
import java.util.TimeZone;
@@ -38,18 +37,19 @@
private static final long serialVersionUID = 4481443514871448269L;
private TimeZone timeZone = TimeZone.getDefault();
- private final Properties productInfo;
private String clusterName;
private SessionToken sessionToken;
+ private String vdbName;
+ private int vdbVersion;
public LogonResult() {
- this.productInfo = new Properties();
}
- public LogonResult(SessionToken token, Properties productInfo, String clusterName) {
- this.productInfo = productInfo;
+ public LogonResult(SessionToken token, String vdbName, int vdbVersion, String clusterName) {
this.clusterName = clusterName;
this.sessionToken = token;
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
}
/**
@@ -57,7 +57,7 @@
* @return
* @since 4.3
*/
- public MetaMatrixSessionID getSessionID() {
+ public long getSessionID() {
return this.sessionToken.getSessionID();
}
@@ -65,9 +65,6 @@
return timeZone;
}
- public String getProductInfo(String key) {
- return this.productInfo.getProperty(key);
- }
public String getUserName() {
return this.sessionToken.getUsername();
@@ -80,5 +77,13 @@
public SessionToken getSessionToken() {
return sessionToken;
}
+
+ public String getVdbName() {
+ return vdbName;
+ }
+
+ public int getVdbVersion() {
+ return vdbVersion;
+ }
}
Deleted: branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -1,85 +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.api;
-
-import java.io.Serializable;
-
-/**
- * This immutable class represents an identifier for a unique session.
- */
-public final class MetaMatrixSessionID implements
- Serializable {
-
- public final static long serialVersionUID = -7872739911360962975L;
-
- private long id;
-
- public MetaMatrixSessionID(long id) {
- this.id = id;
- }
-
- /**
- * Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with
- * <code>compareTo()</code>.
- *
- * @param obj
- * the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- public boolean equals(Object obj) {
- // Check if instances are identical ...
- if (this == obj) {
- return true;
- }
-
- // Check if object can be compared to this one
- // (this includes checking for null ) ...
- if (obj instanceof MetaMatrixSessionID) {
- MetaMatrixSessionID that = (MetaMatrixSessionID)obj;
- return this.id == that.id;
- }
-
- // Otherwise not comparable ...
- return false;
- }
-
- /**
- * Returns the hash code value for this object.
- *
- * @return a hash code value for this object.
- */
- public final int hashCode() {
- return (int)id;
- }
-
- /**
- * Returns a string representing the current state of the object.
- *
- * @return the string representation of this instance.
- */
- public final String toString() {
- return String.valueOf(id);
- }
-
-}
-
Modified: branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -38,7 +38,7 @@
public final static long serialVersionUID = -2853708320435636107L;
/** The session ID */
- private MetaMatrixSessionID sessionID;
+ private long sessionID;
private String userName;
private UUID secret;
@@ -46,7 +46,7 @@
* Fake SessionToken representing a trusted user
*/
public SessionToken() {
- this.sessionID = new MetaMatrixSessionID(-1);
+ this.sessionID = -1L;
this.userName = "trusted"; //$NON-NLS-1$
this.secret = new UUID(1,1);
}
@@ -61,7 +61,7 @@
* (String) the userName for this session
* @throws IllegalArgumentException
*/
- public SessionToken(MetaMatrixSessionID id, String userName) {
+ public SessionToken(long id, String userName) {
this.sessionID = id;
this.userName = userName;
this.secret = UUID.randomUUID();
@@ -76,20 +76,11 @@
*
* @return the session ID
*/
- public MetaMatrixSessionID getSessionID() {
+ public long getSessionID() {
return this.sessionID;
}
/**
- * Returns unique session identifier
- *
- * @return the session ID value
- */
- public String getSessionIDValue() {
- return this.sessionID.toString();
- }
-
- /**
* Get the principal name for this session's user.
*
* @return the user name
@@ -119,7 +110,7 @@
return false;
}
SessionToken that = (SessionToken) obj;
- return (this.sessionID.equals(that.sessionID))
+ return (this.sessionID == that.sessionID)
&& this.userName.equals(that.userName)
&& this.secret.equals(that.secret);
}
@@ -132,14 +123,14 @@
* @see Object#equals(Object)
*/
public int hashCode() {
- return this.sessionID.hashCode();
+ return new Long(this.sessionID).hashCode();
}
/**
* Returns a string representing the current state of the object.
*/
public String toString() {
- return "SessionToken[" + getUsername() + "," + getSessionIDValue() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "SessionToken[" + getUsername() + "," + this.sessionID + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -93,20 +93,6 @@
Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName, int vdbVersion) throws AdminException;
/**
- * Get the Extension Modules that correspond to the specified identifier pattern
- * @param extensionModuleIdentifier - the unique identifier for {@link ExtensionModule}
- * <ul>
- * <li> <code>"*"</code> - for all extension modules in the system
- * <li> <code>"name*"</code> - for all the extension modules in that begin with given name
- * <li><code>"name"</code> - for a single extension module identified by given name
- * </ul>
- * @return Collection of {@link ExtensionModule}
- * @throws AdminException if there's a system error.
- * @since 4.3
- */
- Collection<ExtensionModule> getExtensionModules(String extensionModuleIdentifier) throws AdminException;
-
- /**
* Get the Queue Worker Pools that correspond to the specified identifier pattern.
*
* @param identifier - an identfier for the queues {@link QueueWorkerPool}
@@ -158,18 +144,11 @@
Collection<Cache> getCaches(String identifier) throws AdminException;
/**
- * Get the Sessions that correspond to the specified identifier pattern
- * @param identifier - an unique identifier for {@link Session}
- * <ul>
- * <li> <code>"*"</code> - for all current sessions of the system
- * <li> <code>"number*"</code> - for all the sessions that begin with given number
- * <li><code>"number"</code> - for a single current session in the system
- * </ul>
+ * Get all the current Sessions.
* @return Collection of {@link Session}
* @throws AdminException if there's a system error.
- * @since 4.3
*/
- Collection<Session> getSessions(String identifier) throws AdminException;
+ Collection<Session> getSessions() throws AdminException;
/**
* Get the Requests that correspond to the specified identifier pattern
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -69,7 +69,7 @@
* @throws AdminException if there's a system error.
* @since 4.3
*/
- void terminateSession(String identifier) throws AdminException;
+ void terminateSession(long sessionId) throws AdminException;
/**
* Cancel Request
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -22,104 +22,24 @@
package org.teiid.adminapi;
-import java.util.Date;
/**
- * A Session is a lasting connection between a client and a MetaMatrix System.
+ * A Session is a lasting connection between a client and a Teiid System.
*
* A user may be allowed to have multiple sessions active simultaneously.
*
- * <p>a Session identifier gets automatically assigned
- * to a connection when user logs into the system</p>
- *
- * @since 4.3
*/
-public interface Session extends
- AdminObject {
+public interface Session extends AdminObject {
-
/**
- * The session is open (active).
- */
- public static final int STATE_ACTIVE = 1;
-
- /**
- * The ejb server has passivated the session - it may become
- *open again in the future
- */
- public static final int STATE_PASSIVATED = 2;
-
- /**
- * The session is closed - this state cannot change once it
- *is reached.
- */
- public static final int STATE_CLOSED = 3;
-
- /**
- * The session has expired - this state cannot change once it
- *is reached.
- */
- public static final int STATE_EXPIRED = 4;
-
- /**
- * The session is terminated - this state cannot change once it
- *is reached.
- */
- public static final int STATE_TERMINATED = 5;
-
- /**
- * The description when the session has expired - this state cannot change once it
- * is reached.
- */
- public static final String EXPIRED_STATE_DESC = "Expired"; //$NON-NLS-1$
-
- /**
- * The description when the session is open (active).
- */
- public static final String ACTIVE_STATE_DESC = "Active";//$NON-NLS-1$
-
- /**
- * The description when the session is closed - this state cannot change once it
- * is reached.
- */
- public static final String CLOSED_STATE_DESC = "Closed";//$NON-NLS-1$
-
- /**
- * The description when the session is terminated - this state cannot change once it
- *is reached.
- */
- public static final String TERMINATED_STATE_DESC = "Terminated";//$NON-NLS-1$
-
- /**
- * The description when the ejb server has passivated the session - it may become
- * open again in the future
- */
- public static final String PASSIVATED_STATE_DESC = "Passivated";//$NON-NLS-1$
-
- /**
- * The description when the state of the session is not known.
- */
- public static final String UNKNOWN_STATE_DESC = "Unknown";//$NON-NLS-1$
-
-
-
-
- /**
* Get the Last time Client has check to see if the server is still available
*
* @return Date of the last ping to the server.
*/
- public Date getLastPingTime();
+ public long getLastPingTime();
/**
- * Get the Session State as a String.
- *
- * @return SessionState
- */
- public String getStateAsString();
-
- /**
* Get the Application Name
*
* @return String of the Application Name
@@ -127,21 +47,14 @@
public String getApplicationName();
/**
- * Get the unique MetaMatrix session
- * within a given MetaMatrix System
+ * Get the unique Teiid session
+ * within a given Teiid System
*
* @return String of the Session ID
*/
- public String getSessionID();
+ public long getSessionId();
/**
- * Get the State of the Session
- *
- * @return int of the Session's state
- */
- public int getState();
-
- /**
* Get User Name for this Session
*
* @return String of UserName
@@ -160,7 +73,7 @@
*
* @return String name/number of the VDB Version
*/
- public String getVDBVersion();
+ public int getVDBVersion();
/**
* Get the IPAddress for this Session
@@ -174,13 +87,19 @@
* accessing from
* @return
*/
- public String getHostName() ;
+ public String getClientHostName();
/**
* Get the time the {@link Session} was created.
* @return
*/
- public Date getCreatedDate();
+ public long getCreatedTime();
+
+ /**
+ * Security Domain user logged into currently
+ * @return
+ */
+ public String getSecurityDomain();
}
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -202,14 +202,7 @@
return null;
}
- @Override
- public Collection<ExtensionModule> getExtensionModules(
- String extensionModuleIdentifier) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
@Override
public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
throws AdminException {
@@ -224,12 +217,6 @@
return null;
}
- @Override
- public Collection<Session> getSessions(String identifier)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
@Override
public Collection<Request> getSourceRequests(String identifier)
@@ -285,12 +272,6 @@
@Override
- public void terminateSession(String identifier) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
public void terminateTransaction(Xid transactionId) throws AdminException {
// rameshTODO Auto-generated method stub
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -33,7 +33,7 @@
* May be null for an unassociated Global transaction.
* @return
*/
- String getAssociatedSession();
+ long getAssociatedSession();
/**
* Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -86,6 +86,15 @@
}
+ public Object addAttchment(String key, Object attachment) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type");
+ Object result = this.attachments.put(key, attachment);
+ if (result == null)
+ return null;
+ return result;
+ }
+
/**
* Remove attachment
*
@@ -103,6 +112,14 @@
return type.cast(result);
}
+ public Object removeAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type");
+ Object result = this.attachments.remove(key);
+ if (result == null)
+ return null;
+ return result;
+ }
/**
* Get attachment
*
@@ -119,4 +136,13 @@
return null;
return type.cast(result);
}
+
+ public Object getAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type");
+ Object result = this.attachments.get(key);
+ if (result == null)
+ return null;
+ return result;
+ }
}
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.teiid.adminapi.Session;
+
+
+/**
+ * Add and delete properties also in the Mapper class for correct wrapping for profile service.
+ */
+@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="session"))
+(a)MetaMapping(SessionMetadataMapper.class)
+public class SessionMetadata extends AdminObjectImpl implements Session {
+
+ private static final long serialVersionUID = 918638989081830034L;
+ private String applicationName;
+ private long lastPingTime;
+ private long createdTime;
+ private String ipAddress;
+ private String clientHostName;
+ private String userName;
+ private String vdbName;
+ private int vdbVersion;
+ private long sessionId;
+ private String securityDomain;
+
+ @Override
+ @ManagementProperty(description="Application assosiated with Session", readOnly=true)
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ @Override
+ @ManagementProperty(description="When session created", readOnly=true)
+ public long getCreatedTime() {
+ return this.createdTime;
+ }
+
+ public void setCreatedTime(long createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ @Override
+ @ManagementProperty(description="Host name from where the session created", readOnly=true)
+ public String getClientHostName() {
+ return this.clientHostName;
+ }
+
+ public void setClientHostName(String clientHostname) {
+ this.clientHostName = clientHostname;
+ }
+
+ @Override
+ @ManagementProperty(description="IP address from where session is created", readOnly=true)
+ public String getIPAddress() {
+ return this.ipAddress;
+ }
+
+ public void setIPAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ @Override
+ @ManagementProperty(description="Last ping time", readOnly=true)
+ public long getLastPingTime() {
+ return this.lastPingTime;
+ }
+
+ public void setLastPingTime(long lastPingTime) {
+ this.lastPingTime = lastPingTime;
+ }
+
+ @Override
+ @ManagementProperty(description="Session ID", readOnly=true)
+ @ManagementObjectID(type="session")
+ public long getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(long sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ @ManagementProperty(description="User name assosiated with session", readOnly=true)
+ public String getUserName() {
+ return this.userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ @ManagementProperty(description="VDB name assosiated with session", readOnly=true)
+ public String getVDBName() {
+ return this.vdbName;
+ }
+
+ public void setVDBName(String vdbName) {
+ this.vdbName = vdbName;
+ }
+
+ @Override
+ @ManagementProperty(description="VDB version name assosiated with session", readOnly=true)
+ public int getVDBVersion() {
+ return this.vdbVersion;
+ }
+
+ public void setVDBVersion(int vdbVersion) {
+ this.vdbVersion = vdbVersion;
+ }
+
+ @Override
+ @ManagementProperty(description="Security Domain that session logged into", readOnly=true)
+ public String getSecurityDomain() {
+ return this.securityDomain;
+ }
+
+ public void setSecurityDomain(String domain) {
+ this.securityDomain = domain;
+ }
+}
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.teiid.adminapi.VDB;
+
+public class SessionMetadataMapper extends MetaMapper<SessionMetadata> {
+ private static final MutableCompositeMetaType metaType;
+ private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+
+ static {
+ metaType = new MutableCompositeMetaType(VDB.class.getName(), "The Session domain meta data");
+ metaType.addItem("applicationName", "applicationName", SimpleMetaType.STRING);
+ metaType.addItem("createdTime", "createdTime", SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem("clientHostName", "clientHostName", SimpleMetaType.STRING);
+ metaType.addItem("IPAddress", "IPAddress", SimpleMetaType.STRING);
+ metaType.addItem("lastPingTime", "lastPingTime", SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem("sessionId", "sessionId", SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem("userName", "userName", SimpleMetaType.STRING);
+ metaType.addItem("VDBName", "VDBName", SimpleMetaType.STRING);
+ metaType.addItem("VDBVersion", "VDBVersion", SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.addItem("securityDomain", "SecurityDomain", SimpleMetaType.STRING);
+ metaType.freeze();
+ }
+
+ @Override
+ public Type mapToType() {
+ return SessionMetadata.class;
+ }
+
+ @Override
+ public MetaType getMetaType() {
+ return metaType;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, SessionMetadata object) {
+ if (object == null)
+ return null;
+ if (metaType instanceof CompositeMetaType) {
+ CompositeMetaType composite = (CompositeMetaType) metaType;
+ CompositeValueSupport session = new CompositeValueSupport(composite);
+
+ session.set("applicationName", SimpleValueSupport.wrap(object.getName()));
+ session.set("createdTime", SimpleValueSupport.wrap(object.getCreatedTime()));
+ session.set("clientHostName", SimpleValueSupport.wrap(object.getClientHostName()));
+ session.set("IPAddress", SimpleValueSupport.wrap(object.getIPAddress()));
+ session.set("lastPingTime", SimpleValueSupport.wrap(object.getLastPingTime()));
+ session.set("sessionId", SimpleValueSupport.wrap(object.getSessionId()));
+ session.set("userName", SimpleValueSupport.wrap(object.getUserName()));
+ session.set("VDBName",SimpleValueSupport.wrap(object.getVDBName()));
+ session.set("VDBVersion", SimpleValueSupport.wrap(object.getVDBVersion()));
+ session.set("securityDomain", SimpleValueSupport.wrap(object.getSecurityDomain()));
+
+ return session;
+ }
+ throw new IllegalArgumentException("Cannot convert session " + object);
+ }
+
+ @Override
+ public SessionMetadata unwrapMetaValue(MetaValue metaValue) {
+ if (metaValue == null)
+ return null;
+
+ if (metaValue instanceof CompositeValue) {
+ CompositeValue compositeValue = (CompositeValue) metaValue;
+
+ SessionMetadata session = new SessionMetadata();
+ session.setApplicationName((String) metaValueFactory.unwrap(compositeValue.get("applicationName")));
+ session.setCreatedTime((Long) metaValueFactory.unwrap(compositeValue.get("createdTime")));
+ session.setClientHostName((String) metaValueFactory.unwrap(compositeValue.get("clientHostName")));
+ session.setIPAddress((String) metaValueFactory.unwrap(compositeValue.get("IPAddress")));
+ session.setLastPingTime((Long) metaValueFactory.unwrap(compositeValue.get("lastPingTime")));
+ session.setSessionId((Long) metaValueFactory.unwrap(compositeValue.get("sessionId")));
+ session.setUserName((String) metaValueFactory.unwrap(compositeValue.get("userName")));
+ session.setVDBName((String) metaValueFactory.unwrap(compositeValue.get("VDBName")));
+ session.setVDBVersion((Integer) metaValueFactory.unwrap(compositeValue.get("VDBVersion")));
+ session.setSecurityDomain((String) metaValueFactory.unwrap(compositeValue.get("securityDomain")));
+ return session;
+ }
+ throw new IllegalStateException("Unable to unwrap session " + metaValue);
+ }
+
+}
Modified: branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java
===================================================================
--- branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -45,7 +45,6 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
/**
@@ -82,7 +81,7 @@
Properties connectionProperties)
throws LogonException,
MetaMatrixComponentException {
- return new LogonResult(new SessionToken(new MetaMatrixSessionID(1), "fooUser"), new Properties(), "fake"); //$NON-NLS-1$ //$NON-NLS-2$
+ return new LogonResult(new SessionToken(1, "fooUser"), "foo", 1, "fake"); //$NON-NLS-1$ //$NON-NLS-2$
}
//## JDBC4.0-begin ##
@@ -152,7 +151,7 @@
public void testLogon() throws Exception {
SocketServerConnection connection = createConnection(null);
- assertEquals("1", connection.getLogonResult().getSessionID().toString()); //$NON-NLS-1$
+ assertEquals(1, connection.getLogonResult().getSessionID()); //$NON-NLS-1$
}
/**
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -236,7 +236,7 @@
* @throws SQLException
*/
public String getConnectionId() {
- return this.serverConn.getLogonResult().getSessionID().toString();
+ return String.valueOf(this.serverConn.getLogonResult().getSessionID());
}
long currentRequestId() {
@@ -479,12 +479,12 @@
checkConnection();
//get the virtual database name to which we are connected.
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_NAME);
+ return this.serverConn.getLogonResult().getVdbName();
}
- public String getVDBVersion() throws SQLException {
+ public int getVDBVersion() throws SQLException {
checkConnection();
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_VERSION);
+ return this.serverConn.getLogonResult().getVdbVersion();
}
/**
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -41,6 +41,6 @@
*/
Admin getAdminAPI() throws SQLException;
- String getVDBVersion() throws SQLException;
+ int getVDBVersion() throws SQLException;
}
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -22,24 +22,23 @@
package com.metamatrix.jdbc;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
import java.sql.SQLException;
import java.util.Properties;
import junit.framework.TestCase;
-import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestMMConnection extends TestCase {
protected static final String STD_DATABASE_NAME = "QT_Ora9DS"; //$NON-NLS-1$
- protected static final String STD_DATABASE_VERSION = "1"; //$NON-NLS-1$
+ protected static final int STD_DATABASE_VERSION = 1; //$NON-NLS-1$
static String serverUrl = "jdbc:metamatrix:QT_Ora9DS@mm://localhost:7001;version=1;user=metamatrixadmin;password=mm"; //$NON-NLS-1$
@@ -52,12 +51,9 @@
stub(mock.getService(ClientSideDQP.class)).toReturn(mock(ClientSideDQP.class));
Properties props = new Properties();
props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
- props.setProperty(BaseDataSource.VDB_VERSION, STD_DATABASE_VERSION);
+ props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
- Properties productInfo = new Properties();
- productInfo.setProperty(MMURL.JDBC.VDB_NAME, STD_DATABASE_NAME);
- productInfo.setProperty(MMURL.JDBC.VDB_VERSION, STD_DATABASE_VERSION);
- stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(new MetaMatrixSessionID(1), "metamatrixadmin"), productInfo, "fake")); //$NON-NLS-1$
+ stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
return new MMConnection(mock, props, serverUrl);
}
Deleted: branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -1,177 +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.api;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import javax.security.auth.login.LoginContext;
-
-import org.teiid.adminapi.impl.VDBMetaData;
-
-/**
- * This class represents an immutable informational object describing
- * the attributes of a unique MetaMatrix session within a given MetaMatrix System.
- */
-public class MetaMatrixSessionInfo implements Serializable, Cloneable {
-
- public final static long serialVersionUID = -9120197553960136239L;
-
- private SessionToken sessionToken; // immutable
- private long lastPingTime;
- private long timeCreated;
- private String applicationName;
- private Properties productInfo;
- private String clientIp;
- private String clientHostname;
- private transient LoginContext loginContext;
- private String securityDomain;
- private Object securityContext;
- private VDBMetaData vdb;
- /**
- * Master constructor, allows a MetaMatrixSessionInfo to be created with
- * any state and any timestamps.
- */
- public MetaMatrixSessionInfo(MetaMatrixSessionID sessionID,
- String userName, LoginContext context, String securityDomain,
- Object securityContext, long timeCreated, String applicationName,
- Properties productInfo, String clientIp, String clientHostname, VDBMetaData vdb) {
- this.timeCreated = timeCreated;
- this.lastPingTime = timeCreated;
- this.applicationName = applicationName;
- this.sessionToken = new SessionToken(sessionID, userName);
- this.productInfo = productInfo;
- this.clientIp = clientIp;
- this.clientHostname = clientHostname;
- this.loginContext = context;
- this.securityDomain = securityDomain;
- this.securityContext = securityContext;
- this.vdb = vdb;
- }
-
- public MetaMatrixSessionID getSessionID() {
- return this.sessionToken.getSessionID();
- }
-
- public String getUserName() {
- return this.sessionToken.getUsername();
- }
-
- public String getApplicationName() {
- return this.applicationName;
- }
-
- public long getTimeCreated() {
- return this.timeCreated;
- }
-
- /**
- * Get the time the server was last pinged by this session.
- * Note that the session's "last ping time" will only be acurate
- * if the session is in the ACTIVE state.
- * @return The time the server was last pinged by this session.
- */
- public long getLastPingTime() {
- return lastPingTime;
- }
-
- /**
- * Used <i><b>ONLY</b></i> by the session service to set the
- * time this session last initiated a server ping.
- * @param lastPingTime The last time this session pinged the server.
- */
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
- public SessionToken getSessionToken(){
- return this.sessionToken;
- }
-
- /**
- * Return a cloned instance of this object.
- * @return the object that is the clone of this instance.
- */
- public Object clone() {
- try {
- // Everything is immutable, so bit-wise copy (of references) is okay!
- return super.clone();
- } catch ( CloneNotSupportedException e ) {
- }
- return null;
- }
-
- /**
- * Returns a string representing the current state of the object.
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append("MetaMatrixSessionInfo[ "); //$NON-NLS-1$
- s.append(this.sessionToken.toString());
- s.append(", "); //$NON-NLS-1$
- s.append("application:"); //$NON-NLS-1$
- s.append(this.applicationName);
- s.append(", created:"); //$NON-NLS-1$
- s.append(this.timeCreated);
- s.append(", last pinged server:"); //$NON-NLS-1$
- s.append(this.lastPingTime);
- s.append("]"); //$NON-NLS-1$
- return s.toString();
- }
-
- /**
- * @return Returns the productInfo.
- * @since 4.3
- */
- public String getProductInfo(String key) {
- return this.productInfo.getProperty(key);
- }
-
- public Properties getProductInfo() {
- return this.productInfo;
- }
-
- public String getClientIp() {
- return clientIp;
- }
-
- public String getClientHostname() {
- return clientHostname;
- }
-
- public LoginContext getLoginContext() {
- return this.loginContext;
- }
-
- public String getSecurityDomain() {
- return this.securityDomain;
- }
-
- public Object getSecurityContext() {
- return this.securityContext;
- }
-
- public VDBMetaData getVDB() {
- return this.vdb;
- }
-}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -27,12 +27,12 @@
import javax.security.auth.login.LoginException;
+import org.teiid.adminapi.impl.SessionMetadata;
+
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
/**
* <p>
@@ -64,7 +64,7 @@
/**
* Create a session for the given user authenticating against the given <code>Credentials</code>.
*/
- public MetaMatrixSessionInfo createSession(String userName,
+ public SessionMetadata createSession(String userName,
Credentials credentials,
String applicationName,
Properties properties)
@@ -79,7 +79,7 @@
* session
* @throws SessionServiceException
*/
- void closeSession(MetaMatrixSessionID sessionID) throws InvalidSessionException;
+ void closeSession(long sessionID) throws InvalidSessionException;
/**
* Terminates the specified session. This is an administrative action.
@@ -93,14 +93,14 @@
* does not have authority to terminate the <code>terminatedSessionID</code> session
* @throws SessionServiceException
*/
- boolean terminateSession(MetaMatrixSessionID terminatedSessionID, MetaMatrixSessionID adminSessionID);
+ boolean terminateSession(long terminatedSessionID, long adminSessionID);
/**
* Get the collection of active user sessions on the system.
* @return The collection of MetaMatrixSessionInfo objects of active users on
* the system - possibly empty, never null.
*/
- Collection<MetaMatrixSessionInfo> getActiveSessions() throws SessionServiceException;
+ Collection<SessionMetadata> getActiveSessions() throws SessionServiceException;
/**
* Get the number of active user sessions on the system.
@@ -117,7 +117,7 @@
* session
* @throws SessionServiceException
*/
- MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
+ SessionMetadata validateSession(long sessionID)
throws InvalidSessionException, SessionServiceException;
/**
@@ -127,7 +127,7 @@
* @param VDBVersion The version of the VDB.
* @throws SessionServiceException when transaction with database fails or unexpected exception happens
*/
- Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName, String VDBVersion)
+ Collection<SessionMetadata> getSessionsLoggedInToVDB(String VDBName, int VDBVersion)
throws SessionServiceException;
/**
@@ -135,10 +135,10 @@
*
* @param sessionID - identifies the client
*/
- public void pingServer(MetaMatrixSessionID sessionID) throws InvalidSessionException;
+ public void pingServer(long sessionID) throws InvalidSessionException;
- public void setLocalSession(MetaMatrixSessionID sessionID);
+ public void setLocalSession(long sessionID);
- MetaMatrixSessionInfo getActiveSession(MetaMatrixSessionID sessionID);
+ SessionMetadata getActiveSession(long sessionID);
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -260,7 +260,7 @@
case SERVICE:
return contextCache.getServiceScopedCache(getConnectorIdentifier());
case SESSION:
- return contextCache.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
+ return contextCache.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
case VDB:
return contextCache.getVDBScopedCache(context.getVdbName(), context.getVdbVersion());
case GLOBAL:
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -38,13 +38,11 @@
import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
-import org.teiid.ContainerUtil;
import org.teiid.dqp.internal.cache.CacheID;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.cache.ResultSetCache;
import org.teiid.dqp.internal.cache.ResultSetCacheUtil;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -77,7 +75,6 @@
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.service.SessionService;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.processor.ProcessorDataManager;
@@ -400,9 +397,9 @@
* @since 4.2
*/
@Override
- public void terminateConnection(MetaMatrixSessionID id) throws MetaMatrixComponentException {
+ public void terminateConnection(long id) throws MetaMatrixComponentException {
- String sessionId = id.toString();
+ String sessionId = String.valueOf(id);
// sometimes there will not be any atomic requests pending, in that
// situation we still need to clear the master request from our map
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -29,7 +29,6 @@
import org.teiid.adminapi.impl.VDBMetaData;
import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class DQPWorkContext implements Serializable {
@@ -115,15 +114,12 @@
}
public String getConnectionID() {
- if (this.sessionToken == null) {
- return null;
- }
- return this.sessionToken.getSessionIDValue();
+ return String.valueOf(getSessionId());
}
- public MetaMatrixSessionID getSessionId() {
+ public long getSessionId() {
if (this.sessionToken == null) {
- return null;
+ return -1;
}
return this.sessionToken.getSessionID();
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -508,7 +508,7 @@
continue;
}
TransactionImpl txnImpl = new TransactionImpl(processName, TransactionContext.getXid().toString());
- txnImpl.setAssociatedSession(TransactionContext.getThreadId());
+ txnImpl.setAssociatedSession(Long.parseLong(TransactionContext.getThreadId()));
txnImpl.setCreated(new Date(TransactionContext.getCreationTime()));
txnImpl.setScope(TransactionContext.getTransactionType().toString());
txnImpl.setXid((MMXid)TransactionContext.getXid());
Modified: branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -30,7 +30,6 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestAtomicRequestMessage extends TestCase {
@@ -46,7 +45,7 @@
public static AtomicRequestMessage example() {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(2), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(2, "foo")); //$NON-NLS-1$
AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
message.setCommand(TestQueryImpl.helpExample());
message.setFetchSize(100);
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -37,7 +37,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.vdb.ModelType;
import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingAttribute;
@@ -72,7 +71,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(vdb.getName());
workContext.setVdbVersion(vdb.getVersion());
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(5, "foo")); //$NON-NLS-1$
workContext.setVdb(vdb);
workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
DQPWorkContext.setWorkContext(workContext);
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -27,7 +27,6 @@
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -46,7 +45,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
workContext.setVdbVersion(1); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
return workContext;
}
@@ -56,17 +55,17 @@
Cache cache = this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString());
cache.put("key", "request-value"); //$NON-NLS-1$ //$NON-NLS-2$
- cache = this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
+ cache = this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
cache.put("key", "session-value"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("request-value", this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
// close the request
this.cacheContext.removeRequestScopedCache(context.getRequestID(12L).toString());
assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$
- assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -31,12 +31,9 @@
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
@@ -59,7 +56,6 @@
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -98,7 +94,7 @@
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT, FakeMetadataFactory.exampleBQTVDB());
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -48,7 +48,6 @@
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.dqp.service.FakeBufferService;
import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -221,7 +220,7 @@
private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(sessionid), userName));
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(sessionid, userName));
if (txnAutoWrap) {
reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -36,7 +36,6 @@
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -45,7 +44,7 @@
*/
public class TestDQPCoreRequestHandling extends TestCase {
- private static final String SESSION_STRING = new MetaMatrixSessionID(2).toString();
+ private static final String SESSION_STRING = "2";
public TestDQPCoreRequestHandling(String name) {
super(name);
@@ -143,7 +142,7 @@
if (workContext == null) {
workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(Long.valueOf(id.getConnectionID())), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(Long.valueOf(id.getConnectionID()), "foo")); //$NON-NLS-1$
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
workItem.setOriginalCommand(originalCommand);
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -22,12 +22,9 @@
package org.teiid.dqp.internal.process;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
import junit.framework.TestCase;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestDQPWorkContext extends TestCase {
@@ -46,7 +43,7 @@
message.setVdbName("vdbName"); //$NON-NLS-1$
message.setVdbVersion(1); //$NON-NLS-1$
message.setAppName("querybuilder"); //$NON-NLS-1$
- message.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "userName")); //$NON-NLS-1$
+ message.setSessionToken(new SessionToken(5, "userName")); //$NON-NLS-1$
return message;
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -43,7 +43,6 @@
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer;
@@ -251,7 +250,7 @@
}
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(conn), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(conn, "foo")); //$NON-NLS-1$
PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
@Override
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -40,8 +40,6 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -295,7 +295,7 @@
assertEquals(1, server.getTransactions().size());
Transaction t = server.getTransactions().iterator().next();
- assertEquals(THREAD1, t.getAssociatedSession());
+ assertEquals(Long.parseLong(THREAD1), t.getAssociatedSession());
assertNotNull(t.getXid());
}
Property changes on: branches/JCA/jboss-embedded
___________________________________________________________________
Name: svn:ignore
- .settings
.project
.classpath
+ .settings
.project
.classpath
target
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/jboss-integration/pom.xml 2009-12-23 22:55:47 UTC (rev 1703)
@@ -14,7 +14,7 @@
<build>
<testResources>
<testResource>
- <directory>target/jboss-embedded</directory>
+ <directory>target/test-classes/jboss-embedded</directory>
</testResource>
</testResources>
<plugins>
@@ -35,7 +35,7 @@
<artifactId>teiid-jboss-embedded</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
- <outputDirectory>target/jboss-embedded</outputDirectory>
+ <outputDirectory>target/test-classes/jboss-embedded</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
Modified: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -41,10 +41,13 @@
import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.ProfileService;
@@ -54,15 +57,18 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.ConnectorBinding;
import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Session;
import org.teiid.adminapi.TeiidAdminMBean;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.Visibility;
import org.teiid.adminapi.impl.BaseAdmin;
import org.teiid.adminapi.impl.ConnectorBindingMetaData;
import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import com.metamatrix.core.CoreConstants;
+import com.metamatrix.platform.security.session.service.SessionServiceImpl;
@JMX(name="jboss.teiid:service=teiid-admin", exposedInterface=TeiidAdminMBean.class, registerDirectly=true)
public class Admin extends BaseAdmin implements TeiidAdminMBean{
@@ -72,6 +78,7 @@
private static ComponentType MODELTYPE = new ComponentType("teiid", "model");
private static ComponentType NOTXTYPE = new ComponentType("ConnectionFactory", "NoTx");
private static ComponentType TXTYPE = new ComponentType("ConnectionFactory", "Tx");
+ private static ComponentType SESSIONSTYPE = new ComponentType("teiid", "sessions");
private ManagementView getView() throws AdminComponentException {
try {
@@ -427,4 +434,35 @@
return model;
}
+
+ @Override
+ public Collection<Session> getSessions() throws AdminException {
+ try {
+ Collection<Session> sessionList = new ArrayList<Session>();
+ ManagedComponent mc = getView().getComponent(SessionServiceImpl.class.getName(), SESSIONSTYPE);
+ ManagedProperty mp = mc.getProperty("activeSessions");
+ MetaValue[] sessions = ((CollectionValueSupport)mp.getValue()).getElements();
+ for (MetaValue mv:sessions) {
+ sessionList.add((SessionMetadata)MetaValueFactory.getInstance().unwrap(mv));
+ }
+ return sessionList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void terminateSession(long sessionId) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(SessionServiceImpl.class.getName(), SESSIONSTYPE);
+ Set<ManagedOperation> operations = mc.getOperations();
+ for (ManagedOperation mo:operations) {
+ mo.getName().equals("terminate");
+ // TODO: Finish this. rareddy
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+
+ }
}
Modified: branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -76,5 +76,4 @@
//
// assertNull(admin.getVDB("TransactionsRevisited", 1));
}
-
}
Modified: branches/JCA/runtime/pom.xml
===================================================================
--- branches/JCA/runtime/pom.xml 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/pom.xml 2009-12-23 22:55:47 UTC (rev 1703)
@@ -41,14 +41,8 @@
<artifactId>teiid-engine</artifactId>
<type>test-jar</type>
</dependency>
- <!-- Will open this later on once runtime is fixed
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-jboss-integration</artifactId>
- </dependency>
- -->
- <dependency>
- <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-metadata</artifactId>
</dependency>
<dependency>
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -38,7 +37,6 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.Cache;
import org.teiid.adminapi.ExtensionModule;
-import org.teiid.adminapi.Session;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.process.Util;
@@ -47,8 +45,6 @@
import com.metamatrix.admin.objects.MMLogConfiguration;
import com.metamatrix.admin.objects.MMPropertyDefinition;
import com.metamatrix.admin.objects.MMRequest;
-import com.metamatrix.admin.objects.MMSession;
-import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeDefn;
import com.metamatrix.common.config.api.ConnectorBinding;
@@ -59,7 +55,6 @@
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -206,10 +201,10 @@
com.metamatrix.common.queue.WorkerPoolStats stats = (com.metamatrix.common.queue.WorkerPoolStats)src;
return Util.convertStats(stats, stats.getQueueName());
}
- else if (src != null && src instanceof MetaMatrixSessionInfo) {
- MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
- return convertConnection(conn);
- }
+// else if (src != null && src instanceof MetaMatrixSessionInfo) {
+// MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
+// return convertConnection(conn);
+// }
else if (src != null && src instanceof com.metamatrix.common.config.api.ExtensionModule) {
com.metamatrix.common.config.api.ExtensionModule extModule = (com.metamatrix.common.config.api.ExtensionModule)src;
return convertExtensionModule(extModule);
@@ -239,18 +234,18 @@
return module;
}
- private Session convertConnection(MetaMatrixSessionInfo src) {
- MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
- session.setVDBName(src.getProductInfo(MMURL.JDBC.VDB_NAME));
- session.setVDBVersion(src.getProductInfo(MMURL.JDBC.VDB_VERSION));
- session.setApplicationName(src.getApplicationName());
- session.setIPAddress(src.getClientIp());
- session.setHostName(src.getClientHostname());
- session.setUserName(src.getUserName());
- session.setLastPingTime(src.getLastPingTime());
- session.setCreated(new Date(src.getTimeCreated()));
- return session;
- }
+// private Session convertConnection(MetaMatrixSessionInfo src) {
+// MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
+// session.setVDBName(src.getProductInfo(MMURL.JDBC.VDB_NAME));
+// session.setVDBVersion(src.getProductInfo(MMURL.JDBC.VDB_VERSION));
+// session.setApplicationName(src.getApplicationName());
+// session.setIPAddress(src.getClientIp());
+// session.setHostName(src.getClientHostname());
+// session.setUserName(src.getUserName());
+// session.setLastPingTime(src.getLastPingTime());
+// session.setCreated(new Date(src.getTimeCreated()));
+// return session;
+// }
/**
* Convert LogConfiguration to Admin Object
@@ -427,30 +422,30 @@
* @return
* @since 4.3
*/
- MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
- Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
- for (MetaMatrixSessionInfo info:sessions) {
- if (info.getSessionID().toString().equals(identifier)) {
- return info;
- }
- }
- return null;
- }
+// MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
+// Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+// for (MetaMatrixSessionInfo info:sessions) {
+// if (info.getSessionID().toString().equals(identifier)) {
+// return info;
+// }
+// }
+// return null;
+// }
/**
* Get all the available connections
* @return
* @throws AdminException
*/
- Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException {
+// Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException {
// try {
// return getSessionService().getActiveSessions();
// } catch (SessionServiceException e) {
// // SessionServiceException not in the client known exception (in common-internal)
// throw new AdminComponentException(e.getMessage(), e.getCause());
// }
- return null;
- }
+// return null;
+// }
boolean matches(String regEx, String value) {
regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*"); //$NON-NLS-1$
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -219,11 +219,12 @@
*/
public Collection<Session> getSessions(String identifier)
throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
- return matchedCollection(identifier, (List)convertToAdminObjects(getClientConnections()));
+//
+// if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+// }
+// return matchedCollection(identifier, (List)convertToAdminObjects(getClientConnections()));
+ return null;
}
/**
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -22,30 +22,21 @@
package com.metamatrix.dqp.embedded.admin;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
import javax.transaction.xa.Xid;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminObject;
import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ConnectorBinding;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.RuntimeStateAdmin;
-import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.objects.MMRequest;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
/**
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -39,6 +39,12 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.deployers.VDBRepository;
@@ -53,14 +59,14 @@
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
import com.metamatrix.platform.security.membership.service.MembershipServiceImpl;
/**
* This class serves as the primary implementation of the Session Service.
*/
+@ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="sessions"), properties=ManagementProperties.EXPLICIT)
public class SessionServiceImpl implements SessionService, Serializable {
private static final long serialVersionUID = 3366022966048148299L;
@@ -73,7 +79,7 @@
private long sessionExpirationTimeLimit = DEFAULT_SESSION_EXPIRATION;
private VDBRepository vdbRepository;
- private Map<MetaMatrixSessionID, MetaMatrixSessionInfo> sessionCache = new ConcurrentHashMap<MetaMatrixSessionID, MetaMatrixSessionInfo>();
+ private Map<Long, SessionMetadata> sessionCache = new ConcurrentHashMap<Long, SessionMetadata>();
private transient Timer sessionMonitor = new Timer("SessionMonitor", true);
private AtomicLong idSequence = new AtomicLong();
private boolean isSecurityEnabled = false;
@@ -86,33 +92,34 @@
private void monitorSessions() {
long currentTime = System.currentTimeMillis();
- for (MetaMatrixSessionInfo info : sessionCache.values()) {
+ for (SessionMetadata info : sessionCache.values()) {
try {
if (currentTime - info.getLastPingTime() > ServerConnection.PING_INTERVAL * 5) {
- LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString( "SessionServiceImpl.keepaliveFailed", info.getSessionID())); //$NON-NLS-1$
- closeSession(info.getSessionID());
- } else if (sessionExpirationTimeLimit > 0 && currentTime - info.getTimeCreated() > sessionExpirationTimeLimit) {
- LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString( "SessionServiceImpl.expireSession", info.getSessionID())); //$NON-NLS-1$
- closeSession(info.getSessionID());
+ LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString( "SessionServiceImpl.keepaliveFailed", info.getSessionId())); //$NON-NLS-1$
+ closeSession(info.getSessionId());
+ } else if (sessionExpirationTimeLimit > 0 && currentTime - info.getCreatedTime() > sessionExpirationTimeLimit) {
+ LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString( "SessionServiceImpl.expireSession", info.getSessionId())); //$NON-NLS-1$
+ closeSession(info.getSessionId());
}
} catch (Exception e) {
- LogManager.logDetail(LogConstants.CTX_SESSION, e, "error running session monitor, unable to monitor: " + info.getSessionID()); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_SESSION, e, "error running session monitor, unable to monitor: " + info.getSessionId()); //$NON-NLS-1$
}
}
}
@Override
- public void closeSession(MetaMatrixSessionID sessionID) throws InvalidSessionException {
+ public void closeSession(long sessionID) throws InvalidSessionException {
LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"closeSession", sessionID}); //$NON-NLS-1$
- MetaMatrixSessionInfo info = this.sessionCache.remove(sessionID);
+ SessionMetadata info = this.sessionCache.remove(sessionID);
if (info == null) {
throw new InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
}
// try to log out of the context.
try {
- if (info.getLoginContext() != null) {
- info.getLoginContext().logout();
+ LoginContext context = info.getAttachment(LoginContext.class);
+ if (context != null) {
+ context.logout();
}
} catch (LoginException e) {
LogManager.logWarning(LogConstants.CTX_SESSION,e,"Exception terminitating session"); //$NON-NLS-1$
@@ -120,7 +127,7 @@
}
@Override
- public MetaMatrixSessionInfo createSession(String userName, Credentials credentials, String applicationName, Properties properties)
+ public SessionMetadata createSession(String userName, Credentials credentials, String applicationName, Properties properties)
throws LoginException, SessionServiceException {
ArgCheck.isNotNull(applicationName);
ArgCheck.isNotNull(properties);
@@ -151,14 +158,14 @@
}
else {
vdb = this.vdbRepository.getVDB(vdbName, Integer.parseInt(vdbVersion));
- }
+ }
+
+ // Reset product info with validated constants
+ productInfo.put(MMURL.JDBC.VDB_NAME, vdb.getName());
+ productInfo.put(MMURL.JDBC.VDB_VERSION, vdb.getVersion());
} catch (VirtualDatabaseException e) {
throw new SessionServiceException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, vdbVersion==null?"latest":vdbVersion)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Reset product info with validated constants
- productInfo.put(MMURL.JDBC.VDB_NAME, vdb.getName());
- productInfo.put(MMURL.JDBC.VDB_VERSION, vdb.getVersion());
+ }
}
if (sessionMaxLimit > 0 && getActiveSessionsCount() >= sessionMaxLimit) {
@@ -167,22 +174,28 @@
long creationTime = System.currentTimeMillis();
- // Get a new ID for this new session record
- MetaMatrixSessionID id = new MetaMatrixSessionID(idSequence.getAndIncrement());
-
// Return a new session info object
- MetaMatrixSessionInfo newSession = new MetaMatrixSessionInfo(id,
- userName,
- loginContext,
- securityDomain,
- securityContext,
- creationTime,
- applicationName,
- productInfo,
- properties.getProperty(MMURL.CONNECTION.CLIENT_IP_ADDRESS),
- properties.getProperty(MMURL.CONNECTION.CLIENT_HOSTNAME),
- vdb);
- this.sessionCache.put(newSession.getSessionID(), newSession);
+ long id = idSequence.getAndIncrement();
+ SessionMetadata newSession = new SessionMetadata();
+ newSession.setSessionId(id);
+ newSession.setUserName(userName);
+ newSession.setCreatedTime(creationTime);
+ newSession.setApplicationName(applicationName);
+ newSession.setClientHostName(properties.getProperty(MMURL.CONNECTION.CLIENT_HOSTNAME));
+ newSession.setIPAddress(properties.getProperty(MMURL.CONNECTION.CLIENT_IP_ADDRESS));
+ newSession.setSecurityDomain(securityDomain);
+ if (vdb != null) {
+ newSession.setVDBName(vdb.getName());
+ newSession.setVDBVersion(vdb.getVersion());
+ }
+
+ // these are local no need for monitoring.
+ newSession.addAttchment(LoginContext.class, loginContext);
+ newSession.addAttchment("SecurityContext", securityContext);
+ newSession.addAttchment(VDBMetaData.class, vdb);
+ newSession.addAttchment(SessionToken.class, new SessionToken(id, userName));
+
+ this.sessionCache.put(newSession.getSessionId(), newSession);
return newSession;
}
@@ -194,29 +207,31 @@
}
@Override
- public Collection<MetaMatrixSessionInfo> getActiveSessions() throws SessionServiceException {
- return new ArrayList<MetaMatrixSessionInfo>(this.sessionCache.values());
+ @ManagementProperty(description="Active sessions", use={ViewUse.STATISTIC}, readOnly=true)
+ public Collection<SessionMetadata> getActiveSessions() throws SessionServiceException {
+ return new ArrayList<SessionMetadata>(this.sessionCache.values());
}
@Override
- public MetaMatrixSessionInfo getActiveSession(MetaMatrixSessionID sessionID) {
+ public SessionMetadata getActiveSession(long sessionID) {
return this.sessionCache.get(sessionID);
}
@Override
+ @ManagementProperty(description="Active session count", use={ViewUse.STATISTIC}, readOnly=true)
public int getActiveSessionsCount() throws SessionServiceException{
return this.sessionCache.size();
}
@Override
- public Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName, String VDBVersion)
+ public Collection<SessionMetadata> getSessionsLoggedInToVDB(String VDBName, int vdbVersion)
throws SessionServiceException {
- if (VDBName == null || VDBVersion == null) {
+ if (VDBName == null || vdbVersion <= 0) {
return Collections.emptyList();
}
- ArrayList<MetaMatrixSessionInfo> results = new ArrayList<MetaMatrixSessionInfo>();
- for (MetaMatrixSessionInfo info : this.sessionCache.values()) {
- if (VDBName.equalsIgnoreCase(info.getProductInfo(MMURL.JDBC.VDB_NAME)) && VDBVersion.equalsIgnoreCase(info.getProductInfo(MMURL.JDBC.VDB_VERSION))) {
+ ArrayList<SessionMetadata> results = new ArrayList<SessionMetadata>();
+ for (SessionMetadata info : this.sessionCache.values()) {
+ if (VDBName.equalsIgnoreCase(info.getVDBName()) && vdbVersion == info.getVDBVersion()) {
results.add(info);
}
}
@@ -224,15 +239,14 @@
}
@Override
- public void pingServer(MetaMatrixSessionID sessionID)
- throws InvalidSessionException {
- MetaMatrixSessionInfo info = getSessionInfo(sessionID);
+ public void pingServer(long sessionID) throws InvalidSessionException {
+ SessionMetadata info = getSessionInfo(sessionID);
info.setLastPingTime(System.currentTimeMillis());
this.sessionCache.put(sessionID, info);
}
@Override
- public boolean terminateSession(MetaMatrixSessionID terminatedSessionID,MetaMatrixSessionID adminSessionID) {
+ public boolean terminateSession(long terminatedSessionID, long adminSessionID) {
Object[] params = {adminSessionID, terminatedSessionID};
LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString( "SessionServiceImpl.terminateSession", params)); //$NON-NLS-1$
try {
@@ -245,15 +259,14 @@
}
@Override
- public MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
- throws InvalidSessionException, SessionServiceException {
- MetaMatrixSessionInfo info = getSessionInfo(sessionID);
+ public SessionMetadata validateSession(long sessionID) throws InvalidSessionException, SessionServiceException {
+ SessionMetadata info = getSessionInfo(sessionID);
return info;
}
- private MetaMatrixSessionInfo getSessionInfo(MetaMatrixSessionID sessionID)
+ private SessionMetadata getSessionInfo(long sessionID)
throws InvalidSessionException {
- MetaMatrixSessionInfo info = this.sessionCache.get(sessionID);
+ SessionMetadata info = this.sessionCache.get(sessionID);
if (info == null) {
throw new InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
}
@@ -299,8 +312,8 @@
}
@Override
- public void setLocalSession(MetaMatrixSessionID sessionID) {
- MetaMatrixSessionInfo info = this.sessionCache.get(sessionID);
+ public void setLocalSession(long sessionID) {
+ SessionMetadata info = this.sessionCache.get(sessionID);
if (info != null) {
info.setLastPingTime(Long.MAX_VALUE);
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -136,7 +136,7 @@
* @since 5.0
*/
private Object[] buildAuditMessage(SessionToken adminToken, String requiredRoleName, Method invocation) {
- return new Object[] {adminToken.getUsername(), adminToken.getSessionID().toString(), requiredRoleName, invocation.getName()};
+ return new Object[] {adminToken.getUsername(), adminToken.getSessionID(), requiredRoleName, invocation.getName()};
}
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -24,8 +24,11 @@
import java.util.Properties;
+import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
@@ -42,8 +45,6 @@
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
@@ -73,10 +74,10 @@
}
try {
- MetaMatrixSessionInfo sessionInfo = service.createSession(user,credential, applicationName, connProps);
- MetaMatrixSessionID sessionID = updateDQPContext(sessionInfo);
+ SessionMetadata sessionInfo = service.createSession(user,credential, applicationName, connProps);
+ long sessionID = updateDQPContext(sessionInfo);
LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"Logon successful for \"", user, "\" - created SessionID \"", "" + sessionID, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getProductInfo(), clusterName);
+ return new LogonResult(sessionInfo.getAttachment(SessionToken.class), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
} catch (LoginException e) {
throw new LogonException(e.getMessage());
} catch (SessionServiceException e) {
@@ -84,19 +85,26 @@
}
}
- private MetaMatrixSessionID updateDQPContext(MetaMatrixSessionInfo sessionInfo) {
- MetaMatrixSessionID sessionID = sessionInfo.getSessionID();
+ private long updateDQPContext(SessionMetadata s) {
+ long sessionID = s.getSessionId();
+
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- workContext.setSessionToken(sessionInfo.getSessionToken());
- workContext.setAppName(sessionInfo.getApplicationName());
- workContext.setVdbName(sessionInfo.getVDB().getName());
- workContext.setVdbVersion(sessionInfo.getVDB().getVersion());
- if (sessionInfo.getLoginContext() != null) {
- workContext.setSubject(sessionInfo.getLoginContext().getSubject());
- workContext.setSecurityDomain(sessionInfo.getSecurityDomain());
- workContext.setSecurityContext(sessionInfo.getSecurityContext());
+ workContext.setSessionToken(s.getAttachment(SessionToken.class));
+ workContext.setAppName(s.getApplicationName());
+
+ LoginContext loginContext = s.getAttachment(LoginContext.class);
+ if (loginContext != null) {
+ workContext.setSubject(loginContext.getSubject());
+ workContext.setSecurityDomain(s.getSecurityDomain());
+ workContext.setSecurityContext(s.getAttachment("SecurityContext"));
}
- workContext.setVdb(sessionInfo.getVDB());
+
+ VDBMetaData vdb = s.getAttachment(VDBMetaData.class);
+ if (vdb != null) {
+ workContext.setVdbName(vdb.getName());
+ workContext.setVdbVersion(vdb.getVersion());
+ workContext.setVdb(vdb);
+ }
return sessionID;
}
@@ -109,36 +117,41 @@
public ResultsFuture<?> ping() throws InvalidSessionException,MetaMatrixComponentException {
// ping is double used to alert the aliveness of the client, as well as check the server instance is
// alive by socket server instance, so that they can be cached.
- MetaMatrixSessionID id = DQPWorkContext.getWorkContext().getSessionId();
- if (id != null) {
+ long id = DQPWorkContext.getWorkContext().getSessionId();
+ if (id != -1) {
this.service.pingServer(id);
}
return null;
}
@Override
- public void assertIdentity(SessionToken sessionId) throws InvalidSessionException, MetaMatrixComponentException {
- MetaMatrixSessionInfo sessionInfo;
+ public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, MetaMatrixComponentException {
+ SessionMetadata sessionInfo = null;
try {
- sessionInfo = this.service.validateSession(sessionId.getSessionID());
+ sessionInfo = this.service.validateSession(checkSession.getSessionID());
} catch (SessionServiceException e) {
throw new MetaMatrixComponentException(e);
}
- if (!sessionInfo.getSessionToken().equals(sessionInfo.getSessionToken())) {
+ if (sessionInfo == null) {
throw new InvalidSessionException();
}
+
+ SessionToken st = sessionInfo.getAttachment(SessionToken.class);
+ if (!st.equals(checkSession)) {
+ throw new InvalidSessionException();
+ }
this.updateDQPContext(sessionInfo);
}
@Override
public void terminate(SessionToken terminatee) {
- MetaMatrixSessionID terminator = DQPWorkContext.getWorkContext().getSessionId();
+ long terminator = DQPWorkContext.getWorkContext().getSessionId();
- MetaMatrixSessionInfo info = this.service.getActiveSession(terminatee.getSessionID());
+ SessionMetadata info = this.service.getActiveSession(terminatee.getSessionID());
if (info != null) {
try {
- if (info.getProductInfo(MMURL.JDBC.VDB_NAME) != null) {
+ if (info.getVDBName() != null) {
this.dqpService.terminateConnection(terminatee.getSessionID());
}
} catch (MetaMatrixComponentException e) {
Modified: branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java
===================================================================
--- branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -42,7 +42,6 @@
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
import com.metamatrix.core.util.SimpleMock;
import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -53,7 +52,7 @@
@Before public void setUp() throws Exception {
DQPWorkContext.setWorkContext(new DQPWorkContext());
- DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "gojo")); //$NON-NLS-1$
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(1, "gojo")); //$NON-NLS-1$
}
@After public void tearDown() throws Exception {
@@ -108,7 +107,7 @@
@Test(expected=AdminProcessingException.class) public void testReadOnlyFails() throws Exception {
Set<String> userRoles = new HashSet<String>();
Admin serverAdmin = getTestServerAdmin(userRoles, Admin.class);
- serverAdmin.getSessions("*"); //$NON-NLS-1$
+ serverAdmin.getSessions(); //$NON-NLS-1$
}
@Test public void testBounce_succeed() throws Exception {
Modified: branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -11,11 +11,10 @@
import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.adminapi.impl.SessionMetadata;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.membership.service.MembershipServiceImpl;
public class TestSessionServiceImpl {
@@ -37,24 +36,23 @@
ssi.setSecurityDomains("somedomain");
- MetaMatrixSessionID id1 = new MetaMatrixSessionID(1);
try {
- ssi.validateSession(id1);
+ ssi.validateSession(1);
fail("exception expected"); //$NON-NLS-1$
} catch (InvalidSessionException e) {
}
- MetaMatrixSessionInfo info = ssi.createSession("steve", null, "foo", new Properties()); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionMetadata info = ssi.createSession("steve", null, "foo", new Properties()); //$NON-NLS-1$ //$NON-NLS-2$
if (securityEnabled) {
Mockito.verify(impl).authenticateUser("steve", null, "foo", domains);
}
- id1 = info.getSessionID();
+ long id1 = info.getSessionId();
ssi.validateSession(id1);
assertEquals(1, ssi.getActiveSessionsCount());
- assertEquals(0, ssi.getSessionsLoggedInToVDB("a", "1").size()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(0, ssi.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$ //$NON-NLS-2$
ssi.closeSession(id1);
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2009-12-23 22:55:47 UTC (rev 1703)
@@ -28,13 +28,12 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.api.MMURL;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
public class TestLogonImpl extends TestCase {
@@ -48,18 +47,19 @@
p.setProperty(MMURL.CONNECTION.USER_NAME, userName);
p.setProperty(MMURL.CONNECTION.APP_NAME, applicationName);
- MetaMatrixSessionInfo resultInfo = new MetaMatrixSessionInfo(
- new MetaMatrixSessionID(1), userName, null, "securitydomain", null, 0, applicationName, new Properties(),
- null, null, Mockito.mock(VDBMetaData.class));
+ SessionMetadata session = new SessionMetadata();
+ session.setUserName(userName);
+ session.setApplicationName(applicationName);
+ session.setSessionId(1);
+ session.addAttchment(SessionToken.class, new SessionToken(1, userName));
- Mockito.stub(ssi.createSession(userName, null, applicationName,
- p)).toReturn(resultInfo);
+ Mockito.stub(ssi.createSession(userName, null, applicationName,p)).toReturn(session);
LogonImpl impl = new LogonImpl(ssi, null, "fakeCluster"); //$NON-NLS-1$
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
- assertEquals(new MetaMatrixSessionID(1), result.getSessionID());
+ assertEquals(1, result.getSessionID());
}
15 years
teiid SVN: r1702 - in trunk/engine/src/test/java: org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-23 12:10:18 -0500 (Wed, 23 Dec 2009)
New Revision: 1702
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
Log:
TEIID-911 consolidating fake processing plans
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java 2009-12-23 16:52:32 UTC (rev 1701)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java 2009-12-23 17:10:18 UTC (rev 1702)
@@ -24,30 +24,20 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.processor.FakeProcessorPlan;
/**
* @since 4.2
*/
public class TestBatchedUpdatePlan extends TestCase {
- private int plansOpened = 0;
- private int nextBatchesCalled = 0;
- public TestBatchedUpdatePlan(String name) {
+
+ public TestBatchedUpdatePlan(String name) {
super(name);
}
@@ -75,7 +65,7 @@
plan.open();
// First plan may or may not be opened, but all subsequent plans should not be opened.
for (int i = 1; i < plans.length; i++) {
- assertFalse(plans[i].opened);
+ assertFalse(plans[i].isOpened());
}
}
@@ -91,38 +81,4 @@
helpTestNextBatch(new int[] {1, 1, 1, 1});
}
- private class FakeProcessorPlan extends ProcessorPlan {
- private int counts = 0;
- private boolean opened = false;
- private int updateConnectorCount = 1;
- private FakeProcessorPlan(int commands) {
- counts = commands;
- }
- public FakeProcessorPlan clone() {return null;}
- public void close() throws MetaMatrixComponentException {}
- public void connectTupleSource(TupleSource source, int dataRequestID) {}
- public List getOutputElements() {return null;}
- public int getUpdateCount() {return updateConnectorCount;}
- public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {}
- public TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException {
- nextBatchesCalled++;
- assertTrue(opened);
- assertTrue(nextBatchesCalled == plansOpened);
- List[] rows = new List[counts];
- for (int i = 0; i < counts; i++) {
- rows[i] = Arrays.asList(new Object[] {new Integer(1)});
- }
- TupleBatch batch = new TupleBatch(1, rows);
- batch.setTerminationFlag(true);
- return batch;
- }
- public void open() throws MetaMatrixComponentException {
- assertFalse("ProcessorPlan.open() should not be called more than once", opened); //$NON-NLS-1$
- opened = true;
- plansOpened++;
- }
- public Map getDescriptionProperties() {return null;}
- public Collection getChildPlans() {return Collections.EMPTY_LIST;}
-
- }
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-12-23 16:52:32 UTC (rev 1701)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-12-23 17:10:18 UTC (rev 1702)
@@ -22,11 +22,8 @@
package org.teiid.dqp.internal.process;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import junit.framework.TestCase;
@@ -39,9 +36,6 @@
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
@@ -61,8 +55,6 @@
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.dynamic.SimpleQueryProcessorFactory;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.sql.lang.Command;
@@ -316,23 +308,6 @@
}
}
- private static class FakeProcessorPlan extends ProcessorPlan {
- public FakeProcessorPlan clone() {return this;}
- public void close() throws MetaMatrixComponentException {}
- public List getOutputElements() {return Collections.EMPTY_LIST;}
- public void initialize(CommandContext context,ProcessorDataManager dataMgr,BufferManager bufferMgr) {}
- public TupleBatch nextBatch() throws BlockedException,MetaMatrixComponentException {
- ArrayList one = new ArrayList(); one.add("1");
- ArrayList two = new ArrayList(); two.add("2");
- List[] results = {one, two};
- return new TupleBatch(1, results);
- }
- public void open() throws MetaMatrixComponentException {}
- public void reset() {}
- public Map getDescriptionProperties() {return null;}
- public Collection getChildPlans() { return Collections.EMPTY_LIST; }
- }
-
private static class FakeDataService implements DataService {
private int failOnCall = 10000;
private int calls = 0;
15 years
teiid SVN: r1701 - trunk/engine/src/test/java/com/metamatrix/query/processor.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-23 11:52:32 -0500 (Wed, 23 Dec 2009)
New Revision: 1701
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
Log:
TEIID-911 consolidating fake processing plans
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2009-12-23 16:39:47 UTC (rev 1700)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2009-12-23 16:52:32 UTC (rev 1701)
@@ -22,10 +22,20 @@
package com.metamatrix.query.processor;
-import java.util.*;
+import static org.junit.Assert.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.*;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.util.CommandContext;
/**
@@ -36,7 +46,8 @@
private List batches;
int batchIndex = 0;
private int nextBatchRow = 1;
-
+ private boolean opened = false;
+
/**
* Constructor for FakeProcessorPlan.
* @param batches List of things to return in response to nextBatch() - typically
@@ -47,6 +58,21 @@
this.outputElements = outputElements;
this.batches = batches;
}
+
+ public FakeProcessorPlan(int counts) {
+ List[] rows = new List[counts];
+ for (int i = 0; i < counts; i++) {
+ rows[i] = Arrays.asList(new Object[] {new Integer(1)});
+ }
+ TupleBatch batch = new TupleBatch(1, rows);
+ batch.setTerminationFlag(true);
+ this.batches = Arrays.asList(batch);
+ this.outputElements = Command.getUpdateCommandSymbol();
+ }
+
+ public boolean isOpened() {
+ return opened;
+ }
/**
* @see java.lang.Object#clone()
@@ -67,13 +93,6 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#connectTupleSource(com.metamatrix.common.buffer.TupleSource, com.metamatrix.common.buffer.TupleSourceID)
- */
- public void connectTupleSource(TupleSource source, int dataRequestID) {
- // nothing
- }
-
- /**
* @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
*/
public List getOutputElements() {
@@ -84,7 +103,8 @@
* @see com.metamatrix.query.processor.ProcessorPlan#open()
*/
public void open() throws MetaMatrixComponentException {
- // nothing
+ assertFalse("ProcessorPlan.open() should not be called more than once", opened); //$NON-NLS-1$
+ opened = true;
}
/**
@@ -122,14 +142,6 @@
return this.outputElements;
}
- /* (non-Javadoc)
- * @see com.metamatrix.query.processor.ProcessorPlan#getUpdateCount()
- */
- public int getUpdateCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
public Map getDescriptionProperties() {
return new HashMap();
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java 2009-12-23 16:39:47 UTC (rev 1700)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java 2009-12-23 16:52:32 UTC (rev 1701)
@@ -22,20 +22,12 @@
package com.metamatrix.query.processor;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.util.CommandContext;
public class TestBaseProcessorPlan extends TestCase {
@@ -44,7 +36,7 @@
}
public void testGetAndClearWarnings() {
- FakeProcessorPlan plan = new FakeProcessorPlan();
+ FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(), Collections.emptyList());
MetaMatrixException warning = new MetaMatrixException("test"); //$NON-NLS-1$
plan.addWarning(warning);
@@ -53,64 +45,4 @@
assertEquals("Did not get expected warning", warning, warnings.get(0)); //$NON-NLS-1$
assertNull("Did not clear warnings from plan", plan.getAndClearWarnings()); //$NON-NLS-1$
}
-
- private static class FakeProcessorPlan extends ProcessorPlan {
-
-
- /**
- * @see java.lang.Object#clone()
- */
- public FakeProcessorPlan clone() {
- return null;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#close()
- */
- public void close() throws MetaMatrixComponentException {
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
- */
- public List getOutputElements() {
- return null;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#initialize(com.metamatrix.query.processor.ProcessorDataManager, java.lang.Object, com.metamatrix.common.buffer.BufferManager, java.lang.String, int)
- */
- public void initialize(
- CommandContext context,
- ProcessorDataManager dataMgr,
- BufferManager bufferMgr) {
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#nextBatch()
- */
- public TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#open()
- */
- public void open() throws MetaMatrixComponentException {
- }
-
- public Map getDescriptionProperties() {
- return new HashMap();
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- return Collections.EMPTY_LIST;
- }
-
-
- }
}
15 years
teiid SVN: r1700 - trunk/engine/src/test/java/com/metamatrix/query/processor.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-23 11:39:47 -0500 (Wed, 23 Dec 2009)
New Revision: 1700
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
Log:
TEIID-168 TEIID-913 intermediate commit in removing old implementation of result set caching and addressing buffermanager shortcomings.
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-23 15:14:00 UTC (rev 1699)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-23 16:39:47 UTC (rev 1700)
@@ -48,9 +48,8 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
+import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.XMLType;
@@ -198,19 +197,20 @@
}
}
- private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager) throws TupleSourceNotFoundException, MetaMatrixComponentException {
+ private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager) {
helpProcessException(plan, dataManager, null);
}
- private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager, String expectedErrorMessage) throws TupleSourceNotFoundException, MetaMatrixComponentException {
- TupleSourceID tsId = null;
+ private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager, String expectedErrorMessage) {
+ TupleBuffer tsId = null;
BufferManager bufferMgr = null;
try {
bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("0", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- tsId = processor.getResultsID();
- processor.process();
+ processor.setNonBlocking(true);
+ BatchCollector collector = processor.createBatchCollector();
+ tsId = collector.collectTuples();
fail("Expected error during processing, but got none."); //$NON-NLS-1$
} catch(MetaMatrixCoreException e) {
// ignore - this is expected
@@ -218,7 +218,9 @@
assertEquals(expectedErrorMessage, e.getMessage());
}
} finally {
- bufferMgr.removeTupleSource(tsId);
+ if (tsId != null) {
+ tsId.remove();
+ }
}
}
@@ -227,15 +229,19 @@
bufferMgr.getConfig().setProcessorBatchSize(context.getProcessorBatchSize());
bufferMgr.getConfig().setConnectorBatchSize(context.getProcessorBatchSize());
context.getNextRand(0);
- TupleSourceID id = null;
+ TupleBuffer id = null;
try {
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- id = processor.getResultsID();
- processor.process();
- assertEquals(0, bufferMgr.getPinnedCount());
- if ( expectedResults != null ) examineResults(expectedResults, bufferMgr, processor.getResultsID());
+ processor.setNonBlocking(true);
+ BatchCollector collector = processor.createBatchCollector();
+ id = collector.collectTuples();
+ if ( expectedResults != null ) {
+ examineResults(expectedResults, bufferMgr, id);
+ }
} finally {
- bufferMgr.removeTupleSource(id);
+ if (id != null) {
+ id.remove();
+ }
}
}
@@ -247,16 +253,16 @@
* @throws MetaMatrixProcessingException
* @since 4.3
*/
- static void examineResults(List[] expectedResults,BufferManager bufferMgr,TupleSourceID tsID)
+ static void examineResults(List[] expectedResults,BufferManager bufferMgr,TupleBuffer tsID)
throws MetaMatrixComponentException,SQLException, MetaMatrixProcessingException {
// Create QueryResults from TupleSource
- TupleSource ts = bufferMgr.getTupleSource(tsID);
- int count = bufferMgr.getFinalRowCount(tsID);
+ TupleSource ts = tsID.createIndexedTupleSource();
+ int count = tsID.getRowCount();
if(DEBUG) {
- System.out.println("\nResults:\n" + bufferMgr.getTupleSchema(tsID)); //$NON-NLS-1$
- TupleSource ts2 = bufferMgr.getTupleSource(tsID);
+ System.out.println("\nResults:\n" + tsID.getSchema()); //$NON-NLS-1$
+ TupleSource ts2 = tsID.createIndexedTupleSource();
for(int j=0; j<count; j++) {
System.out.println("" + j + ": " + ts2.nextTuple()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -276,6 +282,7 @@
if(cellValue instanceof XMLType){
XMLType id = (XMLType)cellValue;
String actualDoc = id.getString();
+ record = new ArrayList(record);
record.set(0, actualDoc);
}
}
@@ -289,7 +296,7 @@
Properties props = new Properties();
props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", "1", props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", "1", props, DEBUG, DEBUG); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
context.setProcessorBatchSize(2000);
context.setConnectorBatchSize(2000);
return context;
@@ -369,9 +376,8 @@
Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
} );
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -425,9 +431,8 @@
Arrays.asList(new Object[] { "cc", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
} );
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -528,9 +533,8 @@
} );
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -570,9 +574,8 @@
dataMgr.registerTuples(groupID, elementSymbols, tuples);
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -602,9 +605,8 @@
dataMgr.registerTuples(groupID, elementSymbols, tuples);
}
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -647,9 +649,8 @@
dataMgr.registerTuples(groupID, elementSymbols, tuples);
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -673,9 +674,8 @@
dataMgr.registerTuples(groupID, elementSymbols, tuples);
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
15 years
teiid SVN: r1699 - in trunk/engine/src: main/java/com/metamatrix/query/processor and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-23 10:14:00 -0500 (Wed, 23 Dec 2009)
New Revision: 1699
Removed:
trunk/engine/src/main/java/com/metamatrix/query/processor/BaseProcessorPlan.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java
trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
Log:
TEIID-911 fix for virtual bulk updates. the variablecontext was not being used by BatchedUpdatePlan
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -96,6 +96,10 @@
List updateCommands = batchedUpdateCommand.getUpdateCommands();
int numCommands = updateCommands.size();
List<VariableContext> allContexts = batchedUpdateCommand.getVariableContexts();
+ List<VariableContext> planContexts = null;
+ if (allContexts != null) {
+ planContexts = new ArrayList<VariableContext>(allContexts.size());
+ }
for (int commandIndex = 0; commandIndex < numCommands; commandIndex++) {
// Potentially the first command of a batch
Command updateCommand = (Command)updateCommands.get(commandIndex);
@@ -153,6 +157,9 @@
projectNode.addChild(batchNode);
// Add a new RelationalPlan that represents the plan for this batch.
childPlans.add(new RelationalPlan(projectNode));
+ if (planContexts != null) {
+ planContexts.add(new VariableContext());
+ }
// Skip those commands that were added to this batch
commandIndex += batch.size() - 1;
commandWasBatched = true;
@@ -166,9 +173,12 @@
plan = QueryOptimizer.optimizePlan(cmd, metadata, idGenerator, capFinder, analysisRecord, context);
}
childPlans.add(plan);
+ if (allContexts != null) {
+ planContexts.add(allContexts.get(commandIndex));
+ }
}
}
- return new BatchedUpdatePlan(childPlans, batchedUpdateCommand.getUpdateCommands().size());
+ return new BatchedUpdatePlan(childPlans, batchedUpdateCommand.getUpdateCommands().size(), planContexts);
}
/**
Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/BaseProcessorPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/BaseProcessorPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/BaseProcessorPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -1,85 +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.query.processor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- */
-public abstract class BaseProcessorPlan implements ProcessorPlan{
-
- private List warnings = null;
-
- private CommandContext context;
-
- /**
- * Constructor for BaseProcessorPlan.
- */
- public BaseProcessorPlan() {
- super();
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getAndClearWarnings()
- */
- public List getAndClearWarnings() {
- if (warnings == null) {
- return null;
- }
- List copied = warnings;
- warnings = null;
- return copied;
- }
-
- protected void addWarning(MetaMatrixException warning) {
- if (warnings == null) {
- warnings = new ArrayList(1);
- }
- warnings.add(warning);
- }
-
- /**
- * @return
- */
- public CommandContext getContext() {
- return context;
- }
-
- /**
- * @param context
- */
- public void setContext(CommandContext context) {
- this.context = context;
- }
-
- public void reset() {
- warnings = null;
- }
-
- public abstract Object clone();
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -22,10 +22,12 @@
package com.metamatrix.query.processor;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.*;
import com.metamatrix.query.processor.BatchCollector.BatchProducer;
@@ -44,7 +46,11 @@
* the call to {@link #close}.
* </p>
*/
-public interface ProcessorPlan extends Cloneable, Describable, BatchProducer {
+public abstract class ProcessorPlan implements Cloneable, Describable, BatchProducer {
+
+ private List warnings = null;
+
+ private CommandContext context;
/**
* Initialize the plan with some required pieces of data for making
@@ -56,7 +62,7 @@
* @param dataMgr Data manager reference
* @param bufferMgr Buffer manager reference
*/
- void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr);
+ public abstract void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr);
/**
* Get all warnings found while processing this plan. These warnings may
@@ -65,30 +71,52 @@
* the current warnings list. The warnings are in order they were detected.
* @return Current list of warnings, never null
*/
- List<Exception> getAndClearWarnings();
+ public List getAndClearWarnings() {
+ if (warnings == null) {
+ return null;
+ }
+ List copied = warnings;
+ warnings = null;
+ return copied;
+ }
+ protected void addWarning(MetaMatrixException warning) {
+ if (warnings == null) {
+ warnings = new ArrayList(1);
+ }
+ warnings.add(warning);
+ }
+
/**
* Reset a plan so that it can be processed again.
*/
- void reset();
+ public void reset() {
+ this.warnings = null;
+ }
/**
* Get list of resolved elements describing output columns for this plan.
* @return List of SingleElementSymbol
*/
- List getOutputElements();
+ public abstract List getOutputElements();
/**
* Get the processor context, which can be modified.
* @return context object
*/
- CommandContext getContext();
+ public CommandContext getContext() {
+ return context;
+ }
+ public void setContext(CommandContext context) {
+ this.context = context;
+ }
+
/**
* Open the plan for processing.
* @throws MetaMatrixComponentException
*/
- void open() throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ public abstract void open() throws MetaMatrixComponentException, MetaMatrixProcessingException;
/**
* Get a batch of results or possibly an Exception.
@@ -98,15 +126,14 @@
* @throws MetaMatrixProcessingException for business rule exception, related
* to user input or modeling
*/
- TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException;
+ public abstract TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException;
/**
* Close the plan after processing.
* @throws MetaMatrixComponentException
*/
- void close() throws MetaMatrixComponentException;
+ public abstract void close() throws MetaMatrixComponentException;
-
/**
* Return a safe clone of the ProcessorPlan. A ProcessorPlan may only be
* safely cloned in between processings. That is, it is only safe to clone
@@ -115,12 +142,12 @@
* @return safe clone of this ProcessorPlan, as long as it is not open for
* processing
*/
- Object clone();
+ public abstract ProcessorPlan clone();
/**
* Finds all nested plans and returns them.
* @return List of ProcessorPlan
* @since 4.2
*/
- Collection getChildPlans();
+ public abstract Collection getChildPlans();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -34,20 +34,23 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.util.CommandContext;
/**
* Plan for execution for a batched update command. The plan executes the child plans of the
* individual commands in order.
+ *
+ * If variableContexts are provided, then this is a bulk update where all plans are the same object.
+ *
* @since 4.2
*/
-public class BatchedUpdatePlan extends BaseProcessorPlan {
+public class BatchedUpdatePlan extends ProcessorPlan {
/** Array that holds the child update plans */
private ProcessorPlan[] updatePlans;
@@ -60,6 +63,8 @@
/** The position of the command for which the update count is being retrieved */
private int commandIndex = 0;
+ private List<VariableContext> contexts; //only set for bulk updates
+
/**
*
* @param childPlans the child update plans for this batch
@@ -67,22 +72,29 @@
* commands have been batched together.
* @since 4.2
*/
- public BatchedUpdatePlan(List childPlans, int commandsInBatch) {
+ public BatchedUpdatePlan(List childPlans, int commandsInBatch, List<VariableContext> contexts) {
this.updatePlans = (ProcessorPlan[])childPlans.toArray(new ProcessorPlan[childPlans.size()]);
this.planOpened = new boolean[updatePlans.length];
this.updateCounts = new List[commandsInBatch];
+ this.contexts = contexts;
}
/**
* @see java.lang.Object#clone()
* @since 4.2
*/
- public Object clone() {
- List clonedPlans = new ArrayList(updatePlans.length);
- for (int i = 0; i < updatePlans.length; i++) {
- clonedPlans.add(updatePlans[i].clone());
+ public BatchedUpdatePlan clone() {
+ List<ProcessorPlan> clonedPlans = new ArrayList<ProcessorPlan>(updatePlans.length);
+
+ clonedPlans.add((ProcessorPlan)updatePlans[0].clone());
+ for (int i = 1; i <updatePlans.length; i++) {
+ if (contexts == null) {
+ clonedPlans.add((ProcessorPlan)updatePlans[1].clone());
+ } else {
+ clonedPlans.add(clonedPlans.get(0));
+ }
}
- return new BatchedUpdatePlan(clonedPlans, updateCounts.length);
+ return new BatchedUpdatePlan(clonedPlans, updateCounts.length, contexts);
}
/**
@@ -90,8 +102,11 @@
* @since 4.2
*/
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
+ context = (CommandContext)context.clone();
+ context.setVariableContext(new VariableContext()); //start a new root variable context
+ this.setContext(context);
// Initialize all the child plans
- for (int i = 0; i < updatePlans.length; i++) {
+ for (int i = 0; i < getPlanCount(); i++) {
updatePlans[i].initialize(context, dataMgr, bufferMgr);
}
}
@@ -111,8 +126,7 @@
public void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
// It's ok to open() the first plan, as it is not dependent on any prior commands.
// See note for defect 16166 in the nextBatch() method.
- updatePlans[0].open();
- planOpened[0] = true;
+ openPlan();
}
/**
@@ -130,8 +144,7 @@
* guarantee that the commands in the previous plan are completed before the commands in any subsequent
* plans are executed.
*/
- updatePlans[planIndex].open();
- planOpened[planIndex] = true;
+ openPlan();
}
// Execute nextBatch() on each plan in sequence
List[] currentBatch = updatePlans[planIndex].nextBatch().getAllTuples(); // Can throw BlockedException
@@ -148,6 +161,19 @@
return batch;
}
+ private void openPlan() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
+ if (this.contexts != null && !this.contexts.isEmpty()) {
+ CommandContext context = updatePlans[planIndex].getContext();
+ context.getVariableContext().clear();
+ VariableContext currentValues = this.contexts.get(planIndex);
+ context.getVariableContext().putAll(currentValues);
+ }
+ updatePlans[planIndex].reset();
+ updatePlans[planIndex].open();
+ planOpened[planIndex] = true;
+ }
+
/**
* @see com.metamatrix.query.processor.ProcessorPlan#close()
* @since 4.2
@@ -185,7 +211,7 @@
Map props = new HashMap();
props.put(PROP_TYPE, "Batched Update Plan"); //$NON-NLS-1$
List children = new ArrayList();
- for (int i = 0; i < updatePlans.length; i++) {
+ for (int i = 0; i < getPlanCount(); i++) {
children.add(updatePlans[i].getDescriptionProperties());
}
props.put(PROP_CHILDREN, children);
@@ -195,7 +221,7 @@
public String toString() {
StringBuffer val = new StringBuffer("BatchedUpdatePlan {\n"); //$NON-NLS-1$
- for (int i = 0; i < updatePlans.length; i++) {
+ for (int i = 0; i < getPlanCount(); i++) {
val.append(updatePlans[i])
.append("\n"); //$NON-NLS-1$
}
@@ -203,6 +229,10 @@
return val.toString();
}
+ private int getPlanCount() {
+ return (contexts != null?1:updatePlans.length);
+ }
+
/**
* Returns the child plans for this batch. Used primarily for unit tests.
* @return
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -47,7 +47,6 @@
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.BatchIterator;
import com.metamatrix.query.processor.CollectionTupleSource;
import com.metamatrix.query.processor.DescribableUtil;
@@ -71,7 +70,7 @@
import com.metamatrix.query.util.ErrorMessageKeys;
/**
*/
-public class ProcedurePlan extends BaseProcessorPlan {
+public class ProcedurePlan extends ProcessorPlan {
public static class CursorState {
private QueryProcessor processor;
@@ -320,7 +319,7 @@
return "ProcedurePlan:\n" + ProgramUtil.programToString(this.originalProgram); //$NON-NLS-1$
}
- public Object clone(){
+ public ProcessorPlan clone(){
ProcedurePlan plan = new ProcedurePlan((Program)originalProgram.clone());
plan.setUpdateProcedure(this.isUpdateProcedure());
plan.setOutputElements(this.getOutputElements());
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -35,7 +35,6 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -44,7 +43,7 @@
/**
*/
-public class RelationalPlan extends BaseProcessorPlan {
+public class RelationalPlan extends ProcessorPlan {
// Initialize state - don't reset
private RelationalNode root;
@@ -130,7 +129,7 @@
return this.root.toString();
}
- public Object clone(){
+ public RelationalPlan clone(){
RelationalPlan plan = new RelationalPlan((RelationalNode)root.clone());
plan.setOutputElements(new ArrayList(( outputCols != null ? outputCols : Collections.EMPTY_LIST )));
return plan;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -73,7 +73,6 @@
import com.metamatrix.common.types.XMLType;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -89,7 +88,7 @@
/**
*
*/
-public class XMLPlan extends BaseProcessorPlan {
+public class XMLPlan extends ProcessorPlan {
// State passed during construction
private XMLProcessorEnvironment env;
@@ -645,7 +644,7 @@
* in other words, it's only safe to call clone() on a plan after nextTuple() returns null,
* meaning the plan has finished processing.
*/
- public Object clone(){
+ public XMLPlan clone(){
XMLPlan xmlPlan = new XMLPlan((XMLProcessorEnvironment)this.env.clone());
return xmlPlan;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -40,9 +40,9 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.Streamable;
import com.metamatrix.common.types.XMLType;
-import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.dynamic.SqlEval;
import com.metamatrix.query.processor.xml.XMLUtil;
import com.metamatrix.query.sql.lang.XQuery;
@@ -54,7 +54,7 @@
/**
* XQuery execution Plan
*/
-public class XQueryPlan extends BaseProcessorPlan {
+public class XQueryPlan extends ProcessorPlan {
private XQuery xQuery;
private BufferManager bufferMgr;
private String xmlFormat;
@@ -76,7 +76,7 @@
/**
* @see java.lang.Object#clone()
*/
- public Object clone() {
+ public XQueryPlan clone() {
XQuery clonedQuery = (XQuery)this.xQuery.clone();
return new XQueryPlan(clonedQuery);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -177,4 +177,12 @@
return this.variableMap.toString();
}
+ public void clear() {
+ this.variableMap.clear();
+ }
+
+ public void putAll(VariableContext other) {
+ this.variableMap.putAll(other.variableMap);
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -191,11 +191,13 @@
throw new QueryValidatorException("No batch values sent for prepared batch update"); //$NON-NLS-1$
}
boolean supportPreparedBatchUpdate = false;
+ Command command = null;
if (this.processPlan instanceof RelationalPlan) {
RelationalPlan rPlan = (RelationalPlan)this.processPlan;
if (rPlan.getRootNode() instanceof AccessNode) {
AccessNode aNode = (AccessNode)rPlan.getRootNode();
String modelName = aNode.getModelName();
+ command = aNode.getCommand();
SourceCapabilities caps = capabilitiesFinder.findCapabilities(modelName);
supportPreparedBatchUpdate = caps.supportsCapability(SourceCapabilities.Capability.BULK_UPDATE);
}
@@ -216,11 +218,13 @@
List<Object> multiValue = multiValues.get(i);
multiValue.add(values.get(i));
}
- continue;
+ } else { //just accumulate copies of the command/plan - clones are not necessary
+ if (command == null) {
+ command = this.prepPlan.getCommand();
+ command.setProcessorPlan(this.processPlan);
+ }
+ commands.add(command);
}
- Command c = (Command)this.prepPlan.getCommand().clone();
- commands.add(c);
- c.setProcessorPlan((ProcessorPlan)this.processPlan.clone());
}
if (paramValues.size() > 1) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -67,9 +67,9 @@
super(name);
}
- public static List helpGetCommands(String[] sql, QueryMetadataInterface md) throws QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
+ public static List<Command> helpGetCommands(String[] sql, QueryMetadataInterface md) throws QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
- List commands = new ArrayList(sql.length);
+ List<Command> commands = new ArrayList<Command>(sql.length);
for (int i = 0; i < sql.length; i++) {
Command command = QueryParser.getQueryParser().parseCommand(sql[i]);
QueryResolver.resolveCommand(command, md);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -76,18 +76,26 @@
// Track history to verify it later
private List<String> queries = new ArrayList<String>();
+ private boolean recordingCommands = true;
- public FakeDataManager() {
- }
-
/**
* Return string form of all queries run against this FDM
- * @return List<String>
+ * @return List<String> recorded commands
*/
public List<String> getQueries() {
return this.queries;
}
+ /**
+ * Clears the list of recorded commands and returns a copy
+ * @return a copy of the recorded commands prior to clearing the list
+ */
+ public List<String> clearQueries() {
+ List<String> rc = new ArrayList<String>(this.getQueries());
+ this.queries.clear();
+ return rc;
+ }
+
public void registerTuples(Object groupID, List elements, List[] data) {
tuples.put(groupID, new Object[] { elements, data });
}
@@ -101,9 +109,10 @@
LogManager.logTrace(LOG_CONTEXT, new Object[]{"Register Request:", command, ",processorID:", processorID, ",model name:", modelName,",TupleSourceID nodeID:",new Integer(nodeID)}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- if (! (command instanceof BatchedUpdateCommand) ) {
- this.queries.add(command.toString());
+ if (this.recordingCommands) {
+ if (! (command instanceof BatchedUpdateCommand) ) {
+ this.queries.add(command.toString());
+ }
}
if (ReferenceCollectorVisitor.getReferences(command).size() > 0) {
@@ -122,9 +131,11 @@
if ( command.getSubCommands().get(0) instanceof Update ) {
group = ((Update)command.getSubCommands().get(0)).getGroup();
}
- for ( Iterator<Command> it = ((BatchedUpdateCommand) command).getUpdateCommands().iterator(); it.hasNext(); ) {
- this.queries.add(it.next().toString());
- }
+ if (this.recordingCommands) {
+ for ( Iterator<Command> it = ((BatchedUpdateCommand) command).getUpdateCommands().iterator(); it.hasNext(); ) {
+ this.queries.add(it.next().toString());
+ }
+ }
}
Object groupID = group.getMetadataID();
@@ -350,8 +361,31 @@
}
@Override
- public void clearCodeTables() {
-
- }
+ public void clearCodeTables() {/* does nothing */}
+ /**
+ * Are commands/queries that are registered with the data manager being
+ * recorded?
+ * <p>
+ * Recorded commands can be retrieved by {@link #getQueries()}
+ *
+ * @return whether or not commands should be recorded
+ */
+ public boolean isRecordingCommands() {
+ return recordingCommands;
+ }
+
+ /**
+ * Indicate whether or not commands/queries registered with the data
+ * manager are to be recorded in {@link #queries}.
+ * <p>
+ * Recorded commands can be retrieved by {@link #getQueries()}
+ *
+ * @param shouldRecord should commands be recorded?
+ */
+ public void setRecordingCommands(boolean shouldRecord) {
+ this.recordingCommands = shouldRecord;
+ }
+
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -30,7 +30,7 @@
/**
*/
-public class FakeProcessorPlan extends BaseProcessorPlan {
+public class FakeProcessorPlan extends ProcessorPlan {
private List outputElements;
private List batches;
@@ -51,7 +51,7 @@
/**
* @see java.lang.Object#clone()
*/
- public Object clone() {
+ public FakeProcessorPlan clone() {
throw new UnsupportedOperationException();
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -35,7 +35,6 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.query.util.CommandContext;
public class TestBaseProcessorPlan extends TestCase {
@@ -55,15 +54,13 @@
assertNull("Did not clear warnings from plan", plan.getAndClearWarnings()); //$NON-NLS-1$
}
-
-
- private static class FakeProcessorPlan extends BaseProcessorPlan {
+ private static class FakeProcessorPlan extends ProcessorPlan {
/**
* @see java.lang.Object#clone()
*/
- public Object clone() {
+ public FakeProcessorPlan clone() {
return null;
}
@@ -74,12 +71,6 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#connectTupleSource(com.metamatrix.common.buffer.TupleSource, int)
- */
- public void connectTupleSource(TupleSource source, int dataRequestID) {
- }
-
- /**
* @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
*/
public List getOutputElements() {
@@ -108,14 +99,6 @@
public void open() throws MetaMatrixComponentException {
}
- /* (non-Javadoc)
- * @see com.metamatrix.query.processor.ProcessorPlan#getUpdateCount()
- */
- public int getUpdateCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
public Map getDescriptionProperties() {
return new HashMap();
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -36,8 +36,8 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.util.CommandContext;
@@ -58,7 +58,7 @@
totalCommands += commandsPerPlan[i];
plans.add(new FakeProcessorPlan(commandsPerPlan[i]));
}
- BatchedUpdatePlan plan = new BatchedUpdatePlan(plans, totalCommands);
+ BatchedUpdatePlan plan = new BatchedUpdatePlan(plans, totalCommands, null);
TupleBatch batch = plan.nextBatch();
assertEquals(totalCommands, batch.getRowCount());
for (int i = 1; i <= totalCommands; i++) {
@@ -71,7 +71,7 @@
for (int i = 0; i < plans.length; i++) {
plans[i] = new FakeProcessorPlan(1);
}
- BatchedUpdatePlan plan = new BatchedUpdatePlan(Arrays.asList(plans), plans.length);
+ BatchedUpdatePlan plan = new BatchedUpdatePlan(Arrays.asList(plans), plans.length, null);
plan.open();
// First plan may or may not be opened, but all subsequent plans should not be opened.
for (int i = 1; i < plans.length; i++) {
@@ -91,14 +91,14 @@
helpTestNextBatch(new int[] {1, 1, 1, 1});
}
- private class FakeProcessorPlan extends BaseProcessorPlan {
+ private class FakeProcessorPlan extends ProcessorPlan {
private int counts = 0;
private boolean opened = false;
private int updateConnectorCount = 1;
private FakeProcessorPlan(int commands) {
counts = commands;
}
- public Object clone() {return null;}
+ public FakeProcessorPlan clone() {return null;}
public void close() throws MetaMatrixComponentException {}
public void connectTupleSource(TupleSource source, int dataRequestID) {}
public List getOutputElements() {return null;}
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -887,8 +887,10 @@
QueryNode vspqn41 = new QueryNode("vsp41", "CREATE VIRTUAL PROCEDURE BEGIN SELECT e1 FROM pm1.g1 where e2=15; END"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vsp41 = createVirtualProcedure("pm1.vsp41", pm1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn41); //$NON-NLS-1$
- vm1g1.putProperty(FakeMetadataObject.Props.INSERT_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = INSERT INTO pm1.g1(e2) values(INPUT.e2); END"); //$NON-NLS-1$
- vm1g1.putProperty(FakeMetadataObject.Props.UPDATE_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = UPDATE pm1.g1 SET e2 = INPUT.e2; END"); //$NON-NLS-1$
+ vm1g1.putProperty(FakeMetadataObject.Props.INSERT_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = INSERT INTO pm1.g1(e1, e2, e3, e4) values(INPUT.e1, INPUT.e2, INPUT.e3, INPUT.e4); END"); //$NON-NLS-1$
+ vm1g1.putProperty(FakeMetadataObject.Props.UPDATE_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = UPDATE pm1.g1 SET e1 = INPUT.e1, e2 = INPUT.e2, e3 = INPUT.e3, e4=INPUT.e4 WHERE TRANSLATE CRITERIA; END"); //$NON-NLS-1$
+ vm1g1.putProperty(FakeMetadataObject.Props.DELETE_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = DELETE FROM pm1.g1 WHERE TRANSLATE CRITERIA; END"); //$NON-NLS-1$
+
vm1g37.putProperty(FakeMetadataObject.Props.INSERT_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = INSERT INTO pm4.g1(e1, e2, e3, e4) values(INPUT.e1, INPUT.e2, INPUT.e3, INPUT.e4); END"); //$NON-NLS-1$
vm1g37.putProperty(FakeMetadataObject.Props.DELETE_PROCEDURE, "CREATE PROCEDURE BEGIN ROWS_UPDATED = DELETE FROM pm4.g1 where translate criteria; END"); //$NON-NLS-1$
QueryNode vspqn37 = new QueryNode("vsp37", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; VARIABLES.x=5; INSERT INTO vm1.g1(e2) values(VARIABLES.x); END"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -29,10 +29,10 @@
import java.util.Map;
import java.util.Properties;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-
import junit.framework.TestCase;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
@@ -316,11 +316,9 @@
}
}
- private static class FakeProcessorPlan implements ProcessorPlan {
- public Object clone() {return this;}
+ private static class FakeProcessorPlan extends ProcessorPlan {
+ public FakeProcessorPlan clone() {return this;}
public void close() throws MetaMatrixComponentException {}
- public List getAndClearWarnings() {return null;}
- public CommandContext getContext() {return null;}
public List getOutputElements() {return Collections.EMPTY_LIST;}
public void initialize(CommandContext context,ProcessorDataManager dataMgr,BufferManager bufferMgr) {}
public TupleBatch nextBatch() throws BlockedException,MetaMatrixComponentException {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -124,9 +124,22 @@
//make sure the plan is only created once
assertEquals("should reuse the plan", exHitCount, prepPlanCache.hitCount); //$NON-NLS-1$
+ // If we are using FakeDataManager, stop command recording to prevent
+ // duplicate commands
+ boolean dmir = false;
+ if (dataManager instanceof FakeDataManager && ((FakeDataManager) dataManager).isRecordingCommands()) {
+ dmir = true;
+ ((FakeDataManager) dataManager).setRecordingCommands(false);
+ }
// Run query again
TestProcessor.doProcess(plan.processPlan, dataManager, expected, plan.context);
+ // If we are using FakeDataManager and we stopped it from recording,
+ // start it back up again
+ if (dmir == true) {
+ ((FakeDataManager) dataManager).setRecordingCommands(true);
+ }
+
//get the plan again with a new connection
assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, 7, callableStatement, false));
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2009-12-22 19:36:54 UTC (rev 1698)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2009-12-23 15:14:00 UTC (rev 1699)
@@ -48,19 +48,53 @@
*/
public class TestPreparedStatementBatchedUpdate {
+ @Test public void testBatchedUpdatePushdown() throws Exception {
+ // Create query
+ String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+
+ // Create a testable prepared plan cache
+ TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("UPDATE pm1.g1 SET e1 = ?, e3 = ? WHERE pm1.g1.e2 = ?", new List[] {Arrays.asList(4)}); //$NON-NLS-1$
+ // Source capabilities must support batched updates
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // batch with two commands
+ ArrayList<ArrayList<Object>> values = new ArrayList<ArrayList<Object>>(2);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null, Boolean.FALSE, new Integer(1) })));
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(4)
+ };
+
+ // Create the plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+ Update update = (Update)dataManager.getCommandHistory().iterator().next();
+ assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
+ }
+
/**
* Test prepared statements that use batched updates using the same prepared
- * command with varying number of commands in the batch.
+ * command with same number of commands in the batch.
* <p>
- * The test verifies that no errors occur when planning the same batched
- * command SQL with varying number of batched command parameter value sets.
- * For example, if the first executeBatch() call were to occur with three
- * batched commands a repeated call with only two batched commands should
- * not result in an error.
+ * The test verifies that no errors occur when planning and executing the
+ * same batched command SQL with the same number of batched command parameter
+ * value sets. For example, if the first executeBatch() call were to occur
+ * with two batched commands a repeated call with two batched commands
+ * should not result in an error during planning or execution and the value
+ * used in the second batched command should be used instead of any values
+ * from the first batched command.
* <p>
- * The test also verifies that a cached version of the PreparedStatement plan
- * is used on each subsequent execution of the same SQL command even though
- * the number of batched commands may vary.
+ * The test also verifies that the correct SQL is pushed to the data manager
+ * to verify that the parameter substitution occurred and is correct and the
+ * correct number of statements made it to the data manager for the respective
+ * batch command.
* <p>
* The batched command "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"
* will appear as:
@@ -69,51 +103,169 @@
* UPDATE pm1.g1 SET pm1.g1.e1=null, pm1.g1.e3=false WHERE pm1.g1.e2=1
* <p>
* UPDATE pm1.g1 SET pm1.g1.e1='a', pm1.g1.e3=false WHERE pm1.g1.e2=0
- * <p>
- * UPDATE pm1.g1 SET pm1.g1.e1='a', pm1.g1.e3=false WHERE pm1.g1.e2=0
- * UPDATE pm1.g1 SET pm1.g1.e1=null, pm1.g1.e3=false WHERE pm1.g1.e2=1
- * UPDATE pm1.g1 SET pm1.g1.e1='c', pm1.g1.e3=true WHERE pm1.g1.e2=4
* UPDATE pm1.g1 SET pm1.g1.e1='b', pm1.g1.e3=true WHERE pm1.g1.e2=5
* <p>
- * The result should be that only one command is in the plan cache and
- * no plan creation or validation errors will occur.
+ * The result should be that one command is in the plan cache and
+ * no plan creation, validation, or execution errors will occur and
+ * a predetermined set of queries were executed in the data manager.
*
* @throws Exception
*/
- @Test public void testPlanCache_VarNumCmds() throws Exception {
+ @Test public void testUpdateSameNumCmds() throws Exception {
// Create query
String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+ // Create a testable prepared plan cache
+ TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Source capabilities must support batched updates
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.BATCHED_UPDATES, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Create PrepareedPlanCache
- PreparedPlanCache prepPlanCache = new PreparedPlanCache();
+ // Something to hold our final query list
+ List<String> finalQueryList = new ArrayList<String>(13);
+
+ // Create expected results
+ // first command should result in 2 rows affected
+ // second command should result in 2 rows affected
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(2) })
+ };
+
+ // batch with two commands
+ List<List<Object>> values = new ArrayList<List<Object>>(2);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null, Boolean.FALSE, new Integer(1) })));
+
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
+
+ // Create the plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+
+ // Repeat with different number of commands in batch
+ // Create expected results
+ // first command should result in 2 rows affected
+ expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+ // batch with two commands
+ values = new ArrayList<List<Object>>(1);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "b", Boolean.TRUE, new Integer(5) }))); //$NON-NLS-1$
+
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
+
+ // Use the cached plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+
+ // Verify all the queries that were run
+ assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
+ }
+
+ /**
+ * Test prepared statements that use batched updates using the same prepared
+ * command with same number of commands in the batch. Update is performed
+ * against a view model instead of a source model.
+ * <p>
+ * The test verifies that no errors occur when planning and executing the
+ * same batched command SQL with the same number of batched command parameter
+ * value sets. For example, if the first executeBatch() call were to occur
+ * with two batched commands a repeated call with two batched commands
+ * should not result in an error during planning or execution and the value
+ * used in the second batched command should be used instead of any values
+ * from the first batched command.
+ * <p>
+ * The test also verifies that the correct SQL is pushed to the data manager
+ * to verify that the parameter substitution occurred and is correct and the
+ * correct number of statements made it to the data manager for the respective
+ * batch command.
+ * <p>
+ * The batched command "UPDATE vm1.g1 SET vm1.g1.e2=? WHERE vm1.g1.e1=?"
+ * will appear as:
+ * <p>
+ * UPDATE pm1.g1 SET e2=0 WHERE pm1.g1.e1='a'
+ * UPDATE pm1.g1 SET e2=1 WHERE pm1.g1.e1='b'
+ * <p>
+ * UPDATE pm1.g1 SET e2=2 WHERE pm1.g1.e1='c'
+ * UPDATE pm1.g1 SET e2=3 WHERE pm1.g1.e1='d'
+ * <p>
+ * The result should be that one command is in the plan cache and
+ * no plan creation, validation, or execution errors will occur and
+ * a predetermined set of queries were executed in the data manager.
+ *
+ * @throws Exception
+ */
+ @Test public void testUpdateSameNumCmds_Virtual() throws Exception {
+ // Create query
+ String preparedSql = "UPDATE vm1.g1 SET vm1.g1.e2=? WHERE vm1.g1.e1=?"; //$NON-NLS-1$
+ // Create a testable prepared plan cache
+ TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Source capabilities must support batched updates
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.BATCHED_UPDATES, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Something to hold our final query list
+ List<String> finalQueryList = new ArrayList<String>();
+
+ // Create expected results
+ List<?>[] expected = new List[] {
+ Arrays.asList(3),
+ Arrays.asList(1)
+ };
+
// batch with two commands
ArrayList<ArrayList<Object>> values = new ArrayList<ArrayList<Object>>(2);
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { "a", Boolean.FALSE, new Integer(0) } ) ) ); //$NON-NLS-1$
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { null, Boolean.FALSE, new Integer(1) } ) ) );
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { new Integer(0), "a" }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { new Integer(1), "b" }))); //$NON-NLS-1$
- //Create plan
- TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, prepPlanCache);
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 0 WHERE pm1.g1.e1 = 'a'")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 1 WHERE pm1.g1.e1 = 'b'")); //$NON-NLS-1$
+
+ // Create the plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
- // batch with one command
+ // Repeat
+ expected = new List[] {
+ Arrays.asList(1),
+ Arrays.asList(0)
+ };
+
+ // batch with two commands
values = new ArrayList<ArrayList<Object>>(1);
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { "a", Boolean.FALSE, new Integer(0) } ) ) ); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { new Integer(2), "c" }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { new Integer(3), "d" }))); //$NON-NLS-1$
- //Create plan
- TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, prepPlanCache);
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 2 WHERE pm1.g1.e1 = 'c'")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 3 WHERE pm1.g1.e1 = 'd'")); //$NON-NLS-1$
+
+ // Use the cached plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
- // batch with four commands
- values = new ArrayList<ArrayList<Object>>(4);
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { "a", Boolean.FALSE, new Integer(0) } ) ) ); //$NON-NLS-1$
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { null, Boolean.FALSE, new Integer(1) } ) ) );
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { "c", Boolean.TRUE, new Integer(4) } ) ) ); //$NON-NLS-1$
- values.add( new ArrayList<Object>( Arrays.asList( new Object[] { "b", Boolean.TRUE, new Integer(5) } ) ) ); //$NON-NLS-1$
-
- //Create plan
- TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, prepPlanCache);
- assertEquals("PreparedPlanCache size is invalid - ", 1, prepPlanCache.getSpaceUsed() ); //$NON-NLS-1$
+ // Verify all the queries that were run
+ assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
}
-
+
/**
* Test prepared statements that use batched updates using the same prepared
* command with varying number of commands in the batch.
@@ -124,14 +276,10 @@
* with two batched commands a repeated call with only one batched command
* should not result in an error during planning or execution.
* <p>
- * The test also verifies that a cached version of the PreparedStatement plan
- * is used on each subsequent execution of the same SQL command even though
- * the number of batched commands may vary.
- * <p>
* The test also verifies that the correct SQL is pushed to the data manager
* to verify that the parameter substitution occurred and is correct and the
* correct number of statements made it to the data manager for the respective
- * batch.
+ * batch command.
* <p>
* The batched command "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"
* will appear as:
@@ -146,16 +294,15 @@
* UPDATE pm1.g1 SET pm1.g1.e1='c', pm1.g1.e3=true WHERE pm1.g1.e2=4
* UPDATE pm1.g1 SET pm1.g1.e1='b', pm1.g1.e3=true WHERE pm1.g1.e2=5
* <p>
- * The result should be that only one command is in the plan cache and
+ * The result should be that three commands are in the plan cache and
* no plan creation, validation, or execution errors will occur and
* a predetermined set of queries were executed in the data manager.
*
* @throws Exception
*/
- @Test public void testProcessor_VarNumCmds() throws Exception {
+ @Test public void testUpdateVarNumCmds() throws Exception {
// Create query
String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
- int executionsPerTest = 2;
// Create a testable prepared plan cache
TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
@@ -186,10 +333,8 @@
values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null, Boolean.FALSE, new Integer(1) })));
// Add our expected queries to the final query list
- for ( int i = 0; i < executionsPerTest; i++ ) {
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
- }
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
// Create the plan and process the query
TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
@@ -206,9 +351,7 @@
values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
// Add our expected queries to the final query list
- for (int i = 0; i < executionsPerTest; i++) {
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
- }
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
// Use the cached plan and process the query
TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
@@ -234,12 +377,10 @@
values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "b", Boolean.TRUE, new Integer(5)} ))); //$NON-NLS-1$
// Add our expected queries to the final query list
- for (int i = 0; i < executionsPerTest; i++) {
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = TRUE WHERE pm1.g1.e2 = 4")); //$NON-NLS-1$
- finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
- }
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = TRUE WHERE pm1.g1.e2 = 4")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
@@ -247,35 +388,118 @@
assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
}
- @Test public void testBatchedUpdatePushdown() throws Exception {
+ /**
+ * Test prepared statements that use batched updates using the same prepared
+ * command with varying number of commands in the batch. Update is
+ * performed against a view model instead of a source model.
+ * <p>
+ * The test verifies that no errors occur when planning and executing the
+ * same batched command SQL with varying number of batched command parameter
+ * value sets. For example, if the first executeBatch() call were to occur
+ * with two batched commands a repeated call with only one batched command
+ * should not result in an error during planning or execution.
+ * <p>
+ * The test also verifies that the correct SQL is pushed to the data manager
+ * to verify that the parameter substitution occurred and is correct and the
+ * correct number of statements made it to the data manager for the respective
+ * batch command.
+ * <p>
+ * The batched command "UPDATE vm1.g1 SET vm1.g1.e1=?, vm1.g1.e3=? WHERE vm1.g1.e2=?"
+ * will appear as:
+ * <p>
+ * UPDATE pm1.g1 SET e1='a', e3=false WHERE pm1.g1.e2=0
+ * UPDATE pm1.g1 SET e1='b', e3=true WHERE pm1.g1.e2=1
+ * <p>
+ * UPDATE pm1.g1 SET e1='c', e3=false WHERE pm1.g1.e2=1
+ * <p>
+ * UPDATE pm1.g1 SET e1='d', e3=false WHERE pm1.g1.e2=1
+ * UPDATE pm1.g1 SET e1='e', e3=false WHERE pm1.g1.e2=0
+ * UPDATE pm1.g1 SET e1='f', e3=true WHERE pm1.g1.e2=2
+ * UPDATE pm1.g1 SET e1='g', e3=true WHERE pm1.g1.e2=3
+ * <p>
+ * The result should be that three commands are in the plan cache and
+ * no plan creation, validation, or execution errors will occur and
+ * a predetermined set of queries were executed in the data manager.
+ *
+ * @throws Exception
+ */
+ @Test public void testUpdateVarNumCmds_Virtual() throws Exception {
// Create query
- String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
-
+ String preparedSql = "UPDATE vm1.g1 SET vm1.g1.e1=?, vm1.g1.e3=? WHERE vm1.g1.e2=?"; //$NON-NLS-1$
// Create a testable prepared plan cache
TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
// Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("UPDATE pm1.g1 SET e1 = ?, e3 = ? WHERE pm1.g1.e2 = ?", new List[] {Arrays.asList(4)}); //$NON-NLS-1$
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
// Source capabilities must support batched updates
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.BULK_UPDATE, true);
+ caps.setCapabilitySupport(Capability.BATCHED_UPDATES, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ // Something to hold our final query list
+ List<String> finalQueryList = new ArrayList<String>(13);
+
+ // Create expected results
+ List<?>[] expected = new List[] {
+ Arrays.asList(2),
+ Arrays.asList(2)
+ };
+
// batch with two commands
ArrayList<ArrayList<Object>> values = new ArrayList<ArrayList<Object>>(2);
values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
- values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null, Boolean.FALSE, new Integer(1) })));
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "b", Boolean.TRUE, new Integer(1) }))); //$NON-NLS-1$
- List<?>[] expected = new List[] {
- Arrays.asList(4)
- };
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
// Create the plan and process the query
TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
- Update update = (Update)dataManager.getCommandHistory().iterator().next();
- assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
+
+ // Repeat with different number of commands in batch
+ expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2) })
+ };
+
+ // batch with one command
+ values = new ArrayList<ArrayList<Object>>(1);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "c", Boolean.FALSE, new Integer(1) }))); //$NON-NLS-1$
+
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
+
+ // Use the cached plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+
+ // Repeat with different number of commands in batch
+ expected = new List[] {
+ Arrays.asList(2),
+ Arrays.asList(2),
+ Arrays.asList(1),
+ Arrays.asList(1)
+ };
+
+ // batch with four commands
+ values = new ArrayList<ArrayList<Object>>(4);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "d", Boolean.FALSE, new Integer(1)} ))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "e", Boolean.FALSE, new Integer(0)} ))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "f", Boolean.TRUE, new Integer(2)} ))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "g", Boolean.TRUE, new Integer(3)} ))); //$NON-NLS-1$
+
+ // Add our expected queries to the final query list
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'd', e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'e', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'f', e3 = TRUE WHERE pm1.g1.e2 = 2")); //$NON-NLS-1$
+ finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'g', e3 = TRUE WHERE pm1.g1.e2 = 3")); //$NON-NLS-1$
+
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+
+ // Verify all the queries that were run
+ assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
}
-
+
}
15 years