teiid SVN: r2350 - in trunk: common-core/src/main/java/org/teiid/core/util and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-15 12:22:12 -0400 (Thu, 15 Jul 2010)
New Revision: 2350
Removed:
trunk/common-core/src/main/java/org/teiid/core/util/FileUtil.java
trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtil.java
Modified:
trunk/api/src/main/java/org/teiid/logging/CommandLogMessage.java
trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtils.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
Log:
TEIID-1151 fix for datatiertuplesource, removing fileutil, and fixing the date formatting in the command log message
Modified: trunk/api/src/main/java/org/teiid/logging/CommandLogMessage.java
===================================================================
--- trunk/api/src/main/java/org/teiid/logging/CommandLogMessage.java 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/api/src/main/java/org/teiid/logging/CommandLogMessage.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -22,8 +22,7 @@
package org.teiid.logging;
-import java.text.DateFormat;
-import java.util.Date;
+import java.sql.Timestamp;
import org.teiid.translator.ExecutionContext;
@@ -138,20 +137,17 @@
public String toString() {
if (!source && event == Event.NEW) {
- return "\tSTART USER COMMAND:\tstartTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tapplicationName=" + applicationName + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ return "\tSTART USER COMMAND:\tstartTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tapplicationName=" + applicationName + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
if (!source) {
- return "\t"+ event +" USER COMMAND:\tendTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ return "\t"+ event +" USER COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
if (event == Event.NEW) {
- return "\tSTART DATA SRC COMMAND:\tstartTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ return "\tSTART DATA SRC COMMAND:\tstartTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
- return "\t"+ event +" SRC COMMAND:\tendTime=" + getTimestampString(new Date(timestamp)) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
+ return "\t"+ event +" SRC COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
}
- private String getTimestampString(Date date) {
- return DateFormat.getDateInstance().format(date);
- }
public long getTimestamp() {
return timestamp;
}
Deleted: trunk/common-core/src/main/java/org/teiid/core/util/FileUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/FileUtil.java 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/common-core/src/main/java/org/teiid/core/util/FileUtil.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -1,185 +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.core.util;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringWriter;
-
-import org.teiid.core.TeiidRuntimeException;
-
-
-/**
- * Utility class for dealing with files. Hides exception handling and file resource management.
- */
-public class FileUtil {
- private File file;
-
- public FileUtil(String fileName) {
- this.file = new File(fileName);
- }
-
- public FileUtil(File file) {
- this.file = file;
- }
-
- private FileWriter getWriter(boolean append){
- try {
- return new FileWriter(this.file, append);
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- }
- }
-
- public void append(String text) {
- FileWriter writer = null;
- try {
- try {
- writer = getWriter(true);
- writer.write(text);
- } finally {
- if (writer != null) {
- writer.close();
- }
- }
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- }
- }
-
- public void write(String text) {
- delete();
- append(text);
- }
-
- public void delete() {
- this.file.delete();
- }
-
- public void writeBytes(byte[] bytes) {
- delete();
- FileOutputStream stream = null;
- try {
- try {
- stream = new FileOutputStream(this.file);
- stream.write(bytes);
- stream.flush();
- } finally {
- if (stream != null) {
- stream.close();
- }
- }
- } catch (FileNotFoundException e) {
- throw new TeiidRuntimeException(e);
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- }
- }
-
- public String read() {
- try {
- return readSafe();
- } catch (FileNotFoundException e) {
- throw new TeiidRuntimeException(e);
- }
- }
-
- public String readSafe() throws FileNotFoundException {
- String result;
- FileReader reader = null;
- try {
- reader = new FileReader(this.file);
- result = read(reader);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (Exception e) {
- }
- }
- }
-
- return result;
- }
-
- public static String read(Reader reader) {
- StringWriter writer = new StringWriter();
- BufferedReader bufferedReader = null;
- try {
- bufferedReader = new BufferedReader(reader);
- while (bufferedReader.ready()) {
- String line = bufferedReader.readLine();
- writer.write(line);
- writer.write(StringUtil.LINE_SEPARATOR);
- }
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- } finally {
- if (bufferedReader != null) {
- try {
- bufferedReader.close();
- } catch (Exception e) {
- }
- }
- }
- return writer.toString();
- }
-
- public byte[] readBytes() {
- try {
- return readBytesSafe();
- } catch (FileNotFoundException e) {
- throw new TeiidRuntimeException(e);
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- }
- }
-
- public byte[] readBytesSafe() throws FileNotFoundException, IOException {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- FileInputStream input = null;
- try {
- input = new FileInputStream(this.file);
- byte[] buffer = new byte[1024];
- int readCount = input.read(buffer);
- while (readCount > 0) {
- result.write(buffer, 0, readCount);
- readCount = input.read(buffer);
- }
- return result.toByteArray();
- } finally {
- if (input != null) {
- input.close();
- }
- }
-
- }
-}
Deleted: trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtil.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtil.java 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtil.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -1,49 +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.core.util;
-
-import java.io.File;
-
-import org.teiid.core.util.FileUtil;
-import org.teiid.core.util.StringUtil;
-
-import junit.framework.TestCase;
-
-public class TestFileUtil extends TestCase {
-
- public TestFileUtil(String name) {
- super(name);
- }
-
- public void testWriteBytes() {
- String text = "This is some sample text."; //$NON-NLS-1$
- byte[] bytes = text.getBytes();
- String testFileName = UnitTestUtil.getTestDataPath() + File.separator+ "fakeFileWriteBytes"; //$NON-NLS-1$
- FileUtil testFile = new FileUtil(testFileName);
- testFile.delete();
- testFile.writeBytes(bytes);
- String result = testFile.read();
- assertEquals(text + StringUtil.LINE_SEPARATOR, result);
- testFile.delete();
- }
-}
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtils.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtils.java 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestFileUtils.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -26,13 +26,11 @@
import java.io.FileInputStream;
import java.io.IOException;
-import org.teiid.core.TeiidException;
-import org.teiid.core.util.FileUtil;
-import org.teiid.core.util.FileUtils;
-
import junit.framework.TestCase;
+import org.teiid.core.TeiidException;
+
/**
* @since 4.0
*/
@@ -154,11 +152,11 @@
* @since 4.3
*/
public void testCopy() throws Exception {
- String contents1 = new FileUtil(FILE_NAME).read();
+ String contents1 = ObjectConverterUtil.convertFileToString(new File(FILE_NAME));
//positive case
FileUtils.copy(FILE_NAME, TEMP_FILE_NAME, false);
- String contents2 = new FileUtil(TEMP_FILE_NAME).read();
+ String contents2 = ObjectConverterUtil.convertFileToString(new File(TEMP_FILE_NAME));
assertEquals("Expected file contents to be the same", contents1, contents2); //$NON-NLS-1$
assertTrue("Expected original file to still exist", new File(FILE_NAME).exists()); //$NON-NLS-1$
@@ -172,7 +170,7 @@
//positive case: should succeed because we've specified to overwrite
FileUtils.copy(FILE_NAME, TEMP_FILE_NAME, true);
- contents2 = new FileUtil(TEMP_FILE_NAME).read();
+ contents2 = ObjectConverterUtil.convertFileToString(new File(TEMP_FILE_NAME));
assertEquals("Expected file contents to be the same", contents1, contents2); //$NON-NLS-1$
assertTrue("Expected original file to still exist", new File(FILE_NAME).exists()); //$NON-NLS-1$
@@ -184,13 +182,13 @@
* @since 4.3
*/
public void testRename() throws Exception {
- String contents1 = new FileUtil(FILE_NAME).read();
+ String contents1 = ObjectConverterUtil.convertFileToString(new File(FILE_NAME));
//positive case
FileUtils.copy(FILE_NAME, TEMP_FILE_NAME, true);
FileUtils.rename(TEMP_FILE_NAME, TEMP_FILE_NAME2, false);
- String contents2 = new FileUtil(TEMP_FILE_NAME2).read();
+ String contents2 = ObjectConverterUtil.convertFileToString(new File(TEMP_FILE_NAME2));
assertEquals("Expected file contents to be the same", contents1, contents2); //$NON-NLS-1$
assertFalse("Expected original file to not exist", new File(TEMP_FILE_NAME).exists()); //$NON-NLS-1$
@@ -209,7 +207,7 @@
FileUtils.copy(FILE_NAME, TEMP_FILE_NAME, true);
FileUtils.copy(FILE_NAME, TEMP_FILE_NAME2, true);
FileUtils.rename(TEMP_FILE_NAME, TEMP_FILE_NAME2, true);
- contents2 = new FileUtil(TEMP_FILE_NAME2).read();
+ contents2 = ObjectConverterUtil.convertFileToString(new File(TEMP_FILE_NAME2));
assertEquals("Expected file contents to be the same", contents1, contents2); //$NON-NLS-1$
assertFalse("Expected original file to not exist", new File(TEMP_FILE_NAME).exists()); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -65,6 +65,7 @@
private boolean closed;
private volatile boolean canceled;
private boolean executed;
+ private volatile boolean done;
private volatile ResultsFuture<AtomicResultsMessage> futureResult;
private volatile boolean running;
@@ -146,7 +147,9 @@
AtomicResultsMessage results = null;
try {
results = currentResults.get();
- addWork();
+ if (results.getFinalRow() < 0) {
+ addWork();
+ }
} catch (InterruptedException e) {
throw new TeiidRuntimeException(e);
} catch (ExecutionException e) {
@@ -192,8 +195,7 @@
}
public boolean isDone() {
- AtomicResultsMessage results = this.arm;
- return results != null && results.getFinalRow() >= 0;
+ return done;
}
public boolean isRunning() {
@@ -280,6 +282,9 @@
workItem.addSourceFailureDetails(sourceFailure);
}
}
+ if (response.getFinalRow() >= 0) {
+ done = true;
+ }
}
public AtomicRequestMessage getAtomicRequestMessage() {
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 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -27,6 +27,7 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.client.RequestMessage;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.core.TeiidException;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
@@ -34,8 +35,6 @@
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.AutoGenDataService;
import org.teiid.dqp.service.FakeBufferService;
-import org.teiid.dqp.service.TransactionContext;
-import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.parser.QueryParser;
@@ -104,16 +103,21 @@
request = new AtomicRequestMessage(original, workContext, nodeId);
request.setCommand(command);
request.setConnectorName("FakeConnectorID"); //$NON-NLS-1$
- TransactionContext tc = new TransactionContext();
- tc.setTransactionType(Scope.GLOBAL);
- request.setTransactionContext(tc);
info = new DataTierTupleSource(request, workItem, connectorManager.registerRequest(request), dtm);
}
@Test public void testDataTierTupleSource() throws Exception {
helpSetup(1);
- info.nextTuple();
+ for (int i = 0; i < 10;) {
+ try {
+ info.nextTuple();
+ i++;
+ } catch (BlockedException e) {
+ Thread.sleep(50);
+ }
+ }
assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ assertNull(info.nextTuple());
info.closeSource();
assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
}
@@ -139,7 +143,14 @@
@Test public void testNoRowsException() throws Exception {
helpSetup(3);
this.connectorManager.setRows(0);
- assertNull(info.nextTuple());
+ while (true) {
+ try {
+ assertNull(info.nextTuple());
+ break;
+ } catch (BlockedException e) {
+ Thread.sleep(50);
+ }
+ }
}
@Test public void testCodeTableResponseDataNotAvailable() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-07-15 01:21:21 UTC (rev 2349)
+++ trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-07-15 16:22:12 UTC (rev 2350)
@@ -25,6 +25,7 @@
import static org.junit.Assert.*;
import java.io.File;
+import java.io.IOException;
import java.util.TimeZone;
import net.sf.saxon.trans.XPathException;
@@ -35,26 +36,25 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.types.XMLType;
-import org.teiid.core.util.FileUtil;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.query.unittest.TimestampUtil;
@SuppressWarnings("nls")
public class TestXMLSystemFunctions {
- public String getContentOfTestFile( final String testFilePath ) {
+ public String getContentOfTestFile( final String testFilePath ) throws IOException {
final File file = UnitTestUtil.getTestDataFile(testFilePath);
- final FileUtil util = new FileUtil(file.getAbsolutePath());
- return util.read();
+ return ObjectConverterUtil.convertFileToString(file);
}
- public String helpTestXpathValue(final String xmlFilePath, final String xpath, final String expected) throws XPathException, TeiidProcessingException {
+ public String helpTestXpathValue(final String xmlFilePath, final String xpath, final String expected) throws XPathException, TeiidProcessingException, IOException {
final String actual = helpGetNode(xmlFilePath,xpath);
assertEquals(expected,actual);
return actual;
}
- public String helpGetNode(final String xmlFilePath, final String xpath ) throws XPathException, TeiidProcessingException {
+ public String helpGetNode(final String xmlFilePath, final String xpath ) throws XPathException, TeiidProcessingException, IOException {
final String xmlContent = getContentOfTestFile(xmlFilePath);
return XMLSystemFunctions.xpathValue(xmlContent,xpath);
}
14 years, 4 months
teiid SVN: r2349 - in trunk: runtime/src/main/java/org/teiid/services and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-14 21:21:21 -0400 (Wed, 14 Jul 2010)
New Revision: 2349
Modified:
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
Log:
correcting defaults and descriptions
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-07-14 21:39:14 UTC (rev 2348)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-07-15 01:21:21 UTC (rev 2349)
@@ -311,15 +311,15 @@
hiddenByDefault="false">
<c:simple-property name="maxBufferSpace"
displayName="Max Buffer Space"
- description="Max file storage space, in MB, to be used for buffer files (default 256G)"
+ description="Max file storage space, in MB, to be used for buffer files (default 50G)"
required="false" readOnly="false" />
<c:simple-property name="processorBatchSize"
displayName="Processor Batch Size"
- description="The max row count of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 256)"
+ description="The max row count of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 512)"
required="false" readOnly="false" />
<c:simple-property name="connectorBatchSize"
displayName="Connector Batch Size"
- description="The max row count of a batch from a connector. Should be even multiple of processorBatchSize. (default 512)"
+ description="The max row count of a batch from a connector. Should be even multiple of processorBatchSize. (default 1024)"
required="false" readOnly="false" />
<c:simple-property name="maxProcessingBatchesColumns"
displayName="Max Processing Batches Columns"
Modified: trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-07-14 21:39:14 UTC (rev 2348)
+++ trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-07-15 01:21:21 UTC (rev 2349)
@@ -219,7 +219,7 @@
return maxReserveBatchColumns;
}
- @ManagementProperty(description="Max file storage space, in MB, to be used for buffer files (default 256G)")
+ @ManagementProperty(description="Max file storage space, in MB, to be used for buffer files (default 50G)")
public long getMaxBufferSpace() {
return maxBufferSpace;
}
14 years, 5 months
teiid SVN: r2348 - in trunk/console/src/main: resources/META-INF and 1 other directory.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-07-14 17:39:14 -0400 (Wed, 14 Jul 2010)
New Revision: 2348
Modified:
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-958 - Added max buffer size property to Buffer Service properties on the Teiid Engine configuration panel
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-14 21:20:54 UTC (rev 2347)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-14 21:39:14 UTC (rev 2348)
@@ -61,8 +61,8 @@
public class PlatformComponent extends Facet {
private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- String[] PLATFORM_SERVICES_NAMES = { "org.teiid.jboss.deployers.RuntimeEngineDeployer",
- "org.teiid.services.BufferServiceImpl", "org.teiid.services.SessionServiceImpl", "org.teiid.transport.SocketConfiguration" };
+ String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer",
+ "BufferService", "SessionService", "AdminSocketConfiguration" };
/*
* (non-Javadoc)
@@ -168,7 +168,7 @@
PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
report.addData(new MeasurementDataNumeric(
request, (Double) metricReturnObject));
- }
+ }
}
}
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-07-14 21:20:54 UTC (rev 2347)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-07-14 21:39:14 UTC (rev 2348)
@@ -309,6 +309,10 @@
</c:group>
<c:group name="bufferServiceProperties" displayName="Buffer Service Properties"
hiddenByDefault="false">
+ <c:simple-property name="maxBufferSpace"
+ displayName="Max Buffer Space"
+ description="Max file storage space, in MB, to be used for buffer files (default 256G)"
+ required="false" readOnly="false" />
<c:simple-property name="processorBatchSize"
displayName="Processor Batch Size"
description="The max row count of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 256)"
14 years, 5 months
teiid SVN: r2347 - in trunk: test-integration/common/src/test/java/org/teiid/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-14 17:20:54 -0400 (Wed, 14 Jul 2010)
New Revision: 2347
Modified:
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
Log:
TEIID-908 fixing the type metadata
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 20:59:59 UTC (rev 2346)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 21:20:54 UTC (rev 2347)
@@ -416,7 +416,7 @@
records.add(row);
}
createResultSet(records, new String[] {"PLAN_TEXT", "PLAN_XML", "DEBUG_LOG"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.XML, JDBCSQLTypeInfo.STRING});
+ new String[] {JDBCSQLTypeInfo.CLOB, JDBCSQLTypeInfo.XML, JDBCSQLTypeInfo.CLOB});
return;
}
if (show.equalsIgnoreCase("ANNOTATIONS")) { //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-07-14 20:59:59 UTC (rev 2346)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-07-14 21:20:54 UTC (rev 2347)
@@ -28,6 +28,7 @@
import java.sql.ResultSet;
import java.sql.SQLXML;
import java.sql.Statement;
+import java.sql.Types;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -69,6 +70,7 @@
rs = s.executeQuery("show plan");
assertTrue(rs.next());
+ assertEquals(rs.getMetaData().getColumnType(1), Types.CLOB);
SQLXML plan = rs.getSQLXML(2);
assertTrue(plan.getString().startsWith("<?xml"));
assertNull(rs.getObject("DEBUG_LOG"));
14 years, 5 months
teiid SVN: r2346 - in trunk: build/kits/jboss-container and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-14 16:59:59 -0400 (Wed, 14 Jul 2010)
New Revision: 2346
Removed:
trunk/client-jdbc30/
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
trunk/pom.xml
Log:
TEIID-908 minor cleanups, updating release notes and docs on the show statement and ensuring that the set/show commands only affect execution properties.
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-14 20:59:59 UTC (rev 2346)
@@ -35,6 +35,7 @@
<li>Changed named procedure syntax to accept param=>value, rather than param=value.
</ul>
<LI><B>Parallel Source Queries</B> - reestablished parallel execution of source queries within a query plan along with a prioritized work system to help prevent resource contention.
+ <LI><B>SHOW Statement</B> - added client handling for the SHOW statement to retrieve query plan information and see parameter values.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-07-14 20:59:59 UTC (rev 2346)
@@ -65,9 +65,9 @@
import org.teiid.net.TeiidURL;
import org.teiid.net.socket.SocketServerConnection;
-
-
-
+/**
+ * Teiid's Connection implementation.
+ */
public class ConnectionImpl extends WrapperImpl implements Connection {
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
@@ -118,52 +118,60 @@
this.serverConn = serverConn;
this.url = url;
this.dqp = serverConn.getService(DQP.class);
+
+ logger.fine(JDBCPlugin.Util.getString("MMConnection.Session_success")); //$NON-NLS-1$
+ logConnectionProperties(url, info);
+
+ setExecutionProperties(info);
- // set default properties if not overridden
+ this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
+ }
+
+ private void setExecutionProperties(Properties info) {
+ this.propInfo = new Properties();
+
String overrideProp = info.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
if ( overrideProp == null || overrideProp.trim().length() == 0 ) {
- info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_DETECT);
+ propInfo.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_DETECT);
}
- // Get default fetch size
String defaultFetchSize = info.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
if (defaultFetchSize != null) {
- info.put(ExecutionProperties.PROP_FETCH_SIZE, defaultFetchSize);
+ propInfo.put(ExecutionProperties.PROP_FETCH_SIZE, defaultFetchSize);
} else {
- info.put(ExecutionProperties.PROP_FETCH_SIZE, ""+BaseDataSource.DEFAULT_FETCH_SIZE); //$NON-NLS-1$
+ propInfo.put(ExecutionProperties.PROP_FETCH_SIZE, String.valueOf(BaseDataSource.DEFAULT_FETCH_SIZE));
}
- // Get partial results mode
String partialResultsMode = info.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE);
if (partialResultsMode != null) {
- info.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, partialResultsMode);
+ propInfo.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, partialResultsMode);
} else {
- info.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, BaseDataSource.DEFAULT_PARTIAL_RESULTS_MODE);
+ propInfo.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, BaseDataSource.DEFAULT_PARTIAL_RESULTS_MODE);
}
- // Get result set cache mode
String resultSetCacheMode = info.getProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
if (resultSetCacheMode != null) {
- info.put(ExecutionProperties.RESULT_SET_CACHE_MODE, resultSetCacheMode);
+ propInfo.put(ExecutionProperties.RESULT_SET_CACHE_MODE, resultSetCacheMode);
} else {
- info.put(ExecutionProperties.RESULT_SET_CACHE_MODE, BaseDataSource.DEFAULT_RESULT_SET_CACHE_MODE);
+ propInfo.put(ExecutionProperties.RESULT_SET_CACHE_MODE, BaseDataSource.DEFAULT_RESULT_SET_CACHE_MODE);
}
String ansiQuotes = info.getProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS);
if (ansiQuotes != null) {
- info.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, ansiQuotes);
+ propInfo.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, ansiQuotes);
} else {
- info.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
+ propInfo.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
}
-
- logger.fine(JDBCPlugin.Util.getString("MMConnection.Session_success")); //$NON-NLS-1$
- logConnectionProperties(url, info);
-
- // properties object used in obtaining connection
- this.propInfo = info;
-
- this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
- }
+
+ for (String key : info.stringPropertyNames()) {
+ for (String prop : JDBCURL.EXECUTION_PROPERTIES) {
+ if (prop.equalsIgnoreCase(key)) {
+ propInfo.setProperty(key, info.getProperty(key));
+ break;
+ }
+ }
+ }
+ }
public Collection<Annotation> getAnnotations() {
return annotations;
@@ -189,7 +197,7 @@
this.currentPlanDescription = currentPlanDescription;
}
- protected Properties getConnectionProperties() {
+ protected Properties getExecutionProperties() {
return this.propInfo;
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-07-14 20:59:59 UTC (rev 2346)
@@ -24,10 +24,14 @@
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.teiid.net.TeiidURL;
@@ -43,27 +47,34 @@
private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
public static final String JDBC_PROTOCOL = "jdbc:teiid:"; //$NON-NLS-1$
private static final String OLD_JDBC_PROTOCOL = "jdbc:metamatrix:"; //$NON-NLS-1$
+
+ public static final Set<String> EXECUTION_PROPERTIES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
+ ExecutionProperties.PROP_TXN_AUTO_WRAP,
+ ExecutionProperties.PROP_PARTIAL_RESULTS_MODE,
+ ExecutionProperties.RESULT_SET_CACHE_MODE,
+ ExecutionProperties.ANSI_QUOTED_IDENTIFIERS,
+ ExecutionProperties.SQL_OPTION_SHOWPLAN,
+ ExecutionProperties.NOEXEC,
+ ExecutionProperties.PROP_FETCH_SIZE,
+ ExecutionProperties.PROP_XML_FORMAT,
+ ExecutionProperties.PROP_XML_VALIDATION,
+ ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)));
- public static final String[] KNOWN_PROPERTIES = {
- BaseDataSource.APP_NAME,
- BaseDataSource.VDB_NAME,
- BaseDataSource.VERSION,
- BaseDataSource.VDB_VERSION,
- BaseDataSource.USER_NAME,
- BaseDataSource.PASSWORD,
- ExecutionProperties.PROP_TXN_AUTO_WRAP,
- ExecutionProperties.PROP_PARTIAL_RESULTS_MODE,
- ExecutionProperties.RESULT_SET_CACHE_MODE,
- ExecutionProperties.ANSI_QUOTED_IDENTIFIERS,
- ExecutionProperties.SQL_OPTION_SHOWPLAN,
- ExecutionProperties.NOEXEC,
- ExecutionProperties.PROP_FETCH_SIZE,
- ExecutionProperties.PROP_XML_FORMAT,
- ExecutionProperties.PROP_XML_VALIDATION,
- ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
- TeiidURL.CONNECTION.AUTO_FAILOVER,
- TeiidURL.CONNECTION.DISCOVERY_STRATEGY
- };
+ public static final Set<String> KNOWN_PROPERTIES = getKnownProperties();
+
+ private static Set<String> getKnownProperties() {
+ Set<String> props = new HashSet<String>(Arrays.asList(
+ BaseDataSource.APP_NAME,
+ BaseDataSource.VDB_NAME,
+ BaseDataSource.VERSION,
+ BaseDataSource.VDB_VERSION,
+ BaseDataSource.USER_NAME,
+ BaseDataSource.PASSWORD,
+ TeiidURL.CONNECTION.AUTO_FAILOVER,
+ TeiidURL.CONNECTION.DISCOVERY_STRATEGY));
+ props.addAll(EXECUTION_PROPERTIES);
+ return Collections.unmodifiableSet(props);
+ }
private String vdbName;
private String connectionURL;
@@ -290,15 +301,14 @@
// now add the normalized key and value into the properties object.
target.put(validKey, value);
}
-
- public static String getValidKey(String key) {
- // figure out the valid key based on its case
- for (int i = 0; i < KNOWN_PROPERTIES.length; i++) {
- if (key.equalsIgnoreCase(KNOWN_PROPERTIES[i])) {
- return KNOWN_PROPERTIES[i];
- }
- }
- return key;
+
+ public static String getValidKey(String key) {
+ for (String prop : KNOWN_PROPERTIES) {
+ if (prop.equalsIgnoreCase(key)) {
+ return prop;
+ }
+ }
+ return key;
}
private static Object getValidValue(Object value) {
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 20:59:59 UTC (rev 2346)
@@ -166,7 +166,7 @@
this.driverConnection = driverConnection;
this.resultSetType = resultSetType;
this.resultSetConcurrency = resultSetConcurrency;
- this.execProps = new Properties(this.driverConnection.getConnectionProperties());
+ this.execProps = new Properties(this.driverConnection.getExecutionProperties());
// Set initial fetch size
String fetchSizeStr = this.execProps.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
@@ -395,7 +395,7 @@
}
String key = match.group(1);
String value = match.group(2);
- JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getConnectionProperties());
+ JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getExecutionProperties());
this.updateCounts = new int[] {0};
return;
}
@@ -436,17 +436,17 @@
}
if (show.equalsIgnoreCase("ALL")) { //$NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
- for (String key : driverConnection.getConnectionProperties().stringPropertyNames()) {
+ for (String key : driverConnection.getExecutionProperties().stringPropertyNames()) {
ArrayList<Object> row = new ArrayList<Object>(4);
row.add(key);
- row.add(driverConnection.getConnectionProperties().get(key));
+ row.add(driverConnection.getExecutionProperties().get(key));
records.add(row);
}
createResultSet(records, new String[] {"NAME", "VALUE"}, //$NON-NLS-1$ //$NON-NLS-2$
new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING});
return;
}
- List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getConnectionProperties().getProperty(JDBCURL.getValidKey(show))));
+ List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getExecutionProperties().getProperty(JDBCURL.getValidKey(show))));
createResultSet(records, new String[] {show}, new String[] {JDBCSQLTypeInfo.STRING});
return;
}
@@ -948,12 +948,6 @@
return this.annotations;
}
- public void setPartialResults(boolean isPartialResults){
- if(isPartialResults){
- this.execProps.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, "true"); //$NON-NLS-1$
- }
- }
-
public String getRequestIdentifier() {
if(this.currentRequestID >= 0) {
return Long.toString(this.currentRequestID);
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java 2010-07-14 20:59:59 UTC (rev 2346)
@@ -66,7 +66,7 @@
@Test public void testSetStatement() throws Exception {
ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
Properties p = new Properties();
- Mockito.stub(conn.getConnectionProperties()).toReturn(p);
+ Mockito.stub(conn.getExecutionProperties()).toReturn(p);
StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
assertFalse(statement.execute("set foo bar")); //$NON-NLS-1$
assertEquals("bar", p.get("foo")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -76,7 +76,7 @@
ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
Properties p = new Properties();
p.setProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
- Mockito.stub(conn.getConnectionProperties()).toReturn(p);
+ Mockito.stub(conn.getExecutionProperties()).toReturn(p);
StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
assertEquals(Boolean.TRUE.toString(), statement.getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS));
statement.setExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.FALSE.toString());
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml 2010-07-14 20:59:59 UTC (rev 2346)
@@ -175,7 +175,7 @@
</sect1>
<sect1 id="set_statement">
- <title>Set Statement</title>
+ <title>SET Statement</title>
<para>Execution properties may also be set on the connection by using the SET statement.
The SET statement is not yet a language feature of Teiid and is handled only in the JDBC client.</para>
@@ -208,18 +208,51 @@
</listitem>
</itemizedlist>
- <example>
+ <example id="plan_debug">
<title>Enabling Plan Debug</title>
<programlisting>Statement s = connection.createStatement();
s.execute("SET SHOWPLAN DEBUG");
...
Statement s1 = connection.createStatement();
ResultSet rs = s1.executeQuery("select col from table");
-TeiidStatement ts = s1.unwrap(TeiidStatement.class);
-String debugLog = ts.getDebugLog();
+
+ResultSet planRs = s1.exeuteQuery("SHOW PLAN");
+planRs.next();
+String debugLog = planRs.getString("DEBUG_LOG");
</programlisting>
</example>
</sect1>
+
+ <sect1 id="show_statement">
+ <title>SHOW Statement</title>
+
+ <para>The SHOW statement can be used to see a varitey of information.
+ The SHOW statement is not yet a language feature of Teiid and is handled only in the JDBC client.</para>
+
+ <itemizedlist>
+ <para>SHOW Usage:
+ </para>
+ <listitem>
+ <para>SHOW <emphasis>PLAN</emphasis> - returns a resultset with a clob column PLAN_TEXT, an xml column PLAN_XML, and a clob column DEBUG_LOG with a row containing the values from the previously executed query.
+ If SHOWPLAN is OFF or no plan is available, no rows are returned. If SHOWPLAN is not set to DEBUG, then DEBUG_LOG will return a null value.
+ </para>
+ </listitem>
+ <listitem>
+ <para>SHOW <emphasis>ANNOTATIONS</emphasis> - returns a resultset with string columns CATEGORY, PRIORITY, ANNOTATION, RESOLUTION and a row for each annotation on the previously executed query.
+ If SHOWPLAN is OFF or no plan is available, no rows are returned.
+ </para>
+ </listitem>
+ <listitem>
+ <para>SHOW property - the inverse of SET, shows the property value for the given property, returns a resultset with a single string column with a name matching the property key.
+ </para>
+ </listitem>
+ <listitem>
+ <para>SHOW <emphasis>ALL</emphasis> - returns a resultset with a NAME string column and a VALUE string column with a row entry for every property value.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>The SHOW statement is most commonly used to retrieve the query plan, see the plan <link linkend="plan_debug">debug example</link>.</para>
+ </sect1>
<sect1 id="partial_results">
<title>Partial Results Mode</title>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/pom.xml 2010-07-14 20:59:59 UTC (rev 2346)
@@ -469,11 +469,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>beanshell</groupId>
- <artifactId>bsh</artifactId>
- <version>2.0b4</version>
- </dependency>
- <dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
14 years, 5 months
teiid SVN: r2345 - trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-07-14 14:36:07 -0400 (Wed, 14 Jul 2010)
New Revision: 2345
Modified:
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
Log:
TEIID-1142 & TEIID-1055 These changes Teiid to work in a secured server (EAP 5.1) and provide access to the profile service
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-07-14 18:29:05 UTC (rev 2344)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-07-14 18:36:07 UTC (rev 2345)
@@ -93,6 +93,9 @@
private String userName;
private String password;
+ public ProfileConnection() throws AdminComponentException {
+ this.profileService = connect(null, null, null);
+ }
public ProfileConnection(final ProfileService profileService) {
this.profileService = profileService;
14 years, 5 months
teiid SVN: r2344 - in trunk/console: src/main/java/org/teiid/rhq/admin and 2 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-07-14 14:29:05 -0400 (Wed, 14 Jul 2010)
New Revision: 2344
Modified:
trunk/console/pom.xml
trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
TEIID-1152 - Changed to use the ProfileServiceConnection from the JBossAs5 plugin
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/pom.xml 2010-07-14 18:29:05 UTC (rev 2344)
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
@@ -18,10 +16,11 @@
<org.jboss.jopr.as4.version>1.2.0.GA</org.jboss.jopr.as4.version>
-->
<org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
+ <jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
<org.rhq.version>1.3.0.GA</org.rhq.version>
- <org.jboss.jopr.version>1.2.0.GA</org.jboss.jopr.version>
<apache.ant.version>1.7.0</apache.ant.version>
+
</properties>
<dependencies>
@@ -59,14 +58,14 @@
<artifactId>rhq-jmx-plugin</artifactId>
<version>${org.rhq.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-util</artifactId>
- <version>${org.rhq.version}</version>
- </dependency>
<dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${org.rhq.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>mc4j</groupId>
<artifactId>org-mc4j-ems</artifactId>
<version>1.2.6</version>
@@ -129,19 +128,18 @@
</dependency>
<dependency>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas5</artifactId>
- <type>war</type>
- <version>${org.jboss.jopr.as5.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.CR2</version>
</dependency>
<dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${jopr.jboss.as5.plugin.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
@@ -152,35 +150,31 @@
<version>1.3.2</version>
</dependency>
- <!-- <dependency>
- <groupId>org.jboss.on</groupId>
- <artifactId>jopr-jboss-as-5-plugin</artifactId>
- <version>2.3.0.EmbJopr.1.2.0-1</version>
- </dependency> -->
+
</dependencies>
-
+
<build>
- <outputDirectory>target/classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
</project>
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -1,3 +1,24 @@
+/*
+ * 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.rhq.admin;
import java.lang.reflect.Method;
@@ -22,6 +43,7 @@
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
import org.teiid.adminapi.Transaction;
@@ -36,7 +58,8 @@
public class DQPManagementView implements PluginConstants {
private static ManagedComponent mc = null;
- private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
private static final MetaValueFactory metaValueFactory = MetaValueFactory
.getInstance();
@@ -47,37 +70,38 @@
/*
* Metric methods
*/
- public Object getMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
+ public Object getMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(componentType, metric, valueMap);
+ resultObject = getPlatformMetric(connection, componentType, metric, valueMap);
} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(componentType, identifier, metric,
- valueMap);
+ resultObject = getVdbMetric(connection, componentType, identifier,
+ metric, valueMap);
}
return resultObject;
}
- private Object getPlatformMetric(String componentType, String metric,
+ private Object getPlatformMetric(ProfileServiceConnection connection, String componentType, String metric,
Map<String, Object> valueMap) {
Object resultObject = new Object();
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
+ resultObject = new Double(getQueryCount(connection).doubleValue());
} else {
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
+ resultObject = new Double(getSessionCount(connection).doubleValue());
} else {
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(),
+ getRequestCollectionValue(getLongRunningQueries(connection),
longRunningQueries);
resultObject = new Double(longRunningQueries.size());
}
@@ -87,29 +111,31 @@
return resultObject;
}
- private Object getVdbMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
+ private Object getVdbMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getErrorCount((String) valueMap.get(VDB.NAME));
+ resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getVDBStatus((String) valueMap.get(VDB.NAME), 1);
+ resultObject = getVDBStatus(connection, (String) valueMap
+ .get(VDB.NAME), 1);
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
+ resultObject = new Double(getQueryCount(connection).doubleValue());
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
+ resultObject = new Double(getSessionCount(connection).doubleValue());
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(),
+ getRequestCollectionValue(getLongRunningQueries(connection),
longRunningQueries);
resultObject = new Double(longRunningQueries.size());
@@ -122,48 +148,49 @@
* Operation methods
*/
- public void executeOperation(ExecutedResult operationResult,
- final Map<String, Object> valueMap) {
+ public void executeOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final Map<String, Object> valueMap) {
if (operationResult.getComponentType().equals(
PluginConstants.ComponentType.Platform.NAME)) {
- executePlatformOperation(operationResult, operationResult
- .getOperationName(), valueMap);
+ executePlatformOperation(connection, operationResult,
+ operationResult.getOperationName(), valueMap);
} else if (operationResult.getComponentType().equals(
PluginConstants.ComponentType.VDB.NAME)) {
- executeVdbOperation(operationResult, operationResult
+ executeVdbOperation(connection, operationResult, operationResult
.getOperationName(), valueMap);
}
}
- private void executePlatformOperation(ExecutedResult operationResult,
- final String operationName, final Map<String, Object> valueMap) {
+ private void executePlatformOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final String operationName,
+ final Map<String, Object> valueMap) {
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
Collection<Transaction> transactionsCollection = new ArrayList<Transaction>();
if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- getRequestCollectionValue(getLongRunningQueries(), resultObject);
+ getRequestCollectionValue(getLongRunningQueries(connection), resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.GET_SESSIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValue(sessionMetaValue,
activeSessionsCollection);
operationResult.setContent(createReportResultList(fieldNameList,
activeSessionsCollection.iterator()));
} else if (operationName.equals(Platform.Operations.GET_REQUESTS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue requestMetaValue = getRequests();
+ MetaValue requestMetaValue = getRequests(connection);
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.GET_TRANSACTIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue transactionMetaValue = getTransactions();
+ MetaValue transactionMetaValue = getTransactions(connection);
getTransactionCollectionValue(transactionMetaValue,
transactionsCollection);
operationResult.setContent(createReportResultList(fieldNameList,
@@ -174,7 +201,7 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(mc,
+ executeManagedOperation(connection, mc,
Platform.Operations.KILL_TRANSACTION, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.KILL_TRANSACTION; //$NON-NLS-1$
@@ -185,7 +212,7 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(mc, Platform.Operations.KILL_SESSION,
+ executeManagedOperation(connection, mc, Platform.Operations.KILL_SESSION,
args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.KILL_SESSION; //$NON-NLS-1$
@@ -198,7 +225,7 @@
metaValueFactory.create(requestID),
metaValueFactory.create(sessionID) };
try {
- executeManagedOperation(mc, Platform.Operations.KILL_REQUEST,
+ executeManagedOperation(connection, mc, Platform.Operations.KILL_REQUEST,
args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.KILL_REQUEST; //$NON-NLS-1$
@@ -207,30 +234,31 @@
}
}
- private void executeVdbOperation(ExecutedResult operationResult,
+ private void executeVdbOperation(ProfileServiceConnection connection, ExecutedResult operationResult,
final String operationName, final Map<String, Object> valueMap) {
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
String vdbName = (String) valueMap
.get(PluginConstants.ComponentType.VDB.NAME);
String vdbVersion = (String) valueMap
- .get(PluginConstants.ComponentType.VDB.VERSION);
+ .get(PluginConstants.ComponentType.VDB.VERSION);
if (operationName.equals(VDB.Operations.GET_PROPERTIES)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- getProperties(PluginConstants.ComponentType.VDB.NAME);
+ getProperties(connection, PluginConstants.ComponentType.VDB.NAME);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(VDB.Operations.GET_SESSIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValueForVDB(sessionMetaValue,
activeSessionsCollection, vdbName);
operationResult.setContent(createReportResultList(fieldNameList,
activeSessionsCollection.iterator()));
} else if (operationName.equals(VDB.Operations.GET_REQUESTS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue requestMetaValue = getRequestsForVDB(vdbName, Integer.parseInt(vdbVersion));
+ MetaValue requestMetaValue = getRequestsForVDB(connection, vdbName, Integer
+ .parseInt(vdbVersion));
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
@@ -242,13 +270,13 @@
* Helper methods
*/
- public MetaValue getProperties(final String component) {
+ public MetaValue getProperties(ProfileServiceConnection connection, final String component) {
MetaValue propertyValue = null;
MetaValue args = null;
try {
- propertyValue = executeManagedOperation(mc,
+ propertyValue = executeManagedOperation(connection, mc,
PluginConstants.Operation.GET_PROPERTIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_PROPERTIES; //$NON-NLS-1$
@@ -259,13 +287,14 @@
}
- protected MetaValue getRequests() {
+ protected MetaValue getRequests(ProfileServiceConnection connection) {
MetaValue requestsCollection = null;
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
+
PluginConstants.Operation.GET_REQUESTS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_REQUESTS; //$NON-NLS-1$
@@ -276,15 +305,15 @@
}
- protected MetaValue getRequestsForVDB(String vdbName, int vdbVersion) {
+ protected MetaValue getRequestsForVDB(ProfileServiceConnection connection, String vdbName, int vdbVersion) {
MetaValue requestsCollection = null;
MetaValue[] args = new MetaValue[] {
MetaValueFactory.getInstance().create(vdbName),
- MetaValueFactory.getInstance().create(vdbVersion)};
+ MetaValueFactory.getInstance().create(vdbVersion) };
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
PluginConstants.ComponentType.VDB.Operations.GET_REQUESTS,
args);
} catch (Exception e) {
@@ -296,13 +325,13 @@
}
- protected MetaValue getTransactions() {
+ protected MetaValue getTransactions(ProfileServiceConnection connection) {
MetaValue transactionsCollection = null;
MetaValue args = null;
try {
- transactionsCollection = executeManagedOperation(mc,
+ transactionsCollection = executeManagedOperation(connection, mc,
Platform.Operations.GET_TRANSACTIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_TRANSACTIONS; //$NON-NLS-1$
@@ -313,13 +342,13 @@
}
- public MetaValue getSessions() {
+ public MetaValue getSessions(ProfileServiceConnection connection) {
MetaValue sessionCollection = null;
MetaValue args = null;
try {
- sessionCollection = executeManagedOperation(mc,
+ sessionCollection = executeManagedOperation(connection, mc,
PluginConstants.Operation.GET_SESSIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_SESSIONS; //$NON-NLS-1$
@@ -329,12 +358,13 @@
}
- public static String getVDBStatus(String vdbName, int version) {
+ public static String getVDBStatus(ProfileServiceConnection connection,
+ String vdbName, int version) {
ManagedComponent mcVdb = null;
try {
mcVdb = ProfileServiceUtil
- .getManagedComponent(
+ .getManagedComponent(connection,
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -347,13 +377,14 @@
LOG.error(msg, e);
}
- return ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class);
+ return ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class); //$NON-NLS-1$
}
- public static MetaValue executeManagedOperation(ManagedComponent mc,
+ public static MetaValue executeManagedOperation(
+ ProfileServiceConnection connection, ManagedComponent mc,
String operation, MetaValue... args) throws Exception {
- mc = getDQPManagementView(mc);
+ mc = getDQPManagementView(connection, mc);
for (ManagedOperation mo : mc.getOperations()) {
String opName = mo.getName();
@@ -370,7 +401,7 @@
}
}
}
- throw new Exception("No operation found with given name =" + operation);
+ throw new Exception("No operation found with given name =" + operation); //$NON-NLS-1$
}
@@ -378,9 +409,10 @@
* @param mc
* @return
*/
- private static ManagedComponent getDQPManagementView(ManagedComponent mc) {
+ private static ManagedComponent getDQPManagementView(
+ ProfileServiceConnection connection, ManagedComponent mc) {
try {
- mc = ProfileServiceUtil.getDQPManagementView();
+ mc = ProfileServiceUtil.getDQPManagementView(connection);
} catch (NamingException e) {
final String msg = "NamingException getting the DQPManagementView"; //$NON-NLS-1$
LOG.error(msg, e);
@@ -391,10 +423,11 @@
return mc;
}
- public static MetaValue getManagedProperty(ManagedComponent mc,
+ public static MetaValue getManagedProperty(
+ ProfileServiceConnection connection, ManagedComponent mc,
String property, MetaValue... args) throws Exception {
- mc = getDQPManagementView(mc);
+ mc = getDQPManagementView(connection, mc);
try {
mc.getProperty(property);
@@ -403,17 +436,17 @@
LOG.error(msg, e);
}
- throw new Exception("No property found with given name =" + property);
+ throw new Exception("No property found with given name =" + property); //$NON-NLS-1$
}
- private Integer getQueryCount() {
+ private Integer getQueryCount(ProfileServiceConnection connection) {
Integer count = new Integer(0);
MetaValue requests = null;
Collection<Request> requestsCollection = new ArrayList<Request>();
- requests = getRequests();
+ requests = getRequests(connection);
getRequestCollectionValue(requests, requestsCollection);
@@ -424,10 +457,10 @@
return count;
}
- private Integer getSessionCount() {
+ private Integer getSessionCount(ProfileServiceConnection connection) {
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
return activeSessionsCollection.size();
}
@@ -437,12 +470,12 @@
* @return count
* @throws Exception
*/
- private int getErrorCount(String vdbName) {
+ private int getErrorCount(ProfileServiceConnection connection, String vdbName) {
ManagedComponent mcVdb = null;
try {
mcVdb = ProfileServiceUtil
- .getManagedComponent(
+ .getManagedComponent(connection,
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -457,7 +490,7 @@
// Get models from VDB
int count = 0;
- ManagedProperty property = mcVdb.getProperty("models");
+ ManagedProperty property = mcVdb.getProperty("models"); //$NON-NLS-1$
CollectionValueSupport valueSupport = (CollectionValueSupport) property
.getValue();
MetaValue[] metaValues = valueSupport.getElements();
@@ -468,7 +501,7 @@
.getValue();
// Get any model errors/warnings
- MetaValue errors = managedObject.getProperty("errors").getValue();
+ MetaValue errors = managedObject.getProperty("errors").getValue(); //$NON-NLS-1$
if (errors != null) {
CollectionValueSupport errorValueSupport = (CollectionValueSupport) errors;
MetaValue[] errorArray = errorValueSupport.getElements();
@@ -478,13 +511,13 @@
return count;
}
- protected MetaValue getLongRunningQueries() {
+ protected MetaValue getLongRunningQueries(ProfileServiceConnection connection) {
MetaValue requestsCollection = null;
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
Platform.Operations.GET_LONGRUNNINGQUERIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_LONGRUNNINGQUERIES; //$NON-NLS-1$
@@ -507,15 +540,15 @@
list.add(request);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
}
- private Collection<Session> getSessionsForVDB(String vdbName) {
+ private Collection<Session> getSessionsForVDB(ProfileServiceConnection connection, String vdbName) {
Collection<Session> activeSessionsCollection = Collections.emptyList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValueForVDB(sessionMetaValue,
activeSessionsCollection, vdbName);
return activeSessionsCollection;
@@ -533,8 +566,8 @@
list.add(transaction);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
+ + " is not a Composite type"); //$NON-NLS-1$
+ }
}
}
}
@@ -551,7 +584,7 @@
list.add(Session);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -571,7 +604,7 @@
}
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -71,6 +71,8 @@
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jbossas5.ProfileServiceComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
import org.teiid.rhq.plugin.objects.ExecutedResult;
@@ -82,7 +84,7 @@
* This class implements required RHQ interfaces and provides common logic used
* by all MetaMatrix components.
*/
-public abstract class Facet implements ResourceComponent, MeasurementFacet,
+public abstract class Facet implements ProfileServiceComponent<ResourceComponent>, MeasurementFacet,
OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
CreateChildResourceFacet {
@@ -146,6 +148,8 @@
deploymentName = context.getResourceKey();
}
+
+
/**
* This is called when the component is being stopped, usually due to the
* plugin container shutting down. You can perform some cleanup here; though
@@ -206,10 +210,10 @@
}
- protected void execute(final ExecutedResult result, final Map valueMap) {
+ protected void execute(final ProfileServiceConnection connection, final ExecutedResult result, final Map valueMap) {
DQPManagementView dqp = new DQPManagementView();
- dqp.executeOperation(result, valueMap);
+ dqp.executeOperation(connection, result, valueMap);
}
@@ -267,7 +271,7 @@
setOperationArguments(name, configuration, valueMap);
- execute(result, valueMap);
+ execute(getConnection(), result, valueMap);
return ((ExecutedOperationResultImpl) result).getOperationResult();
@@ -328,8 +332,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(this.name, componentType);
Map<String, ManagedProperty> managedProperties = managedComponent
.getProperties();
@@ -371,8 +374,7 @@
throws Exception {
log.trace("Updating " + this.name + " with component "
+ managedComponent.toString() + "...");
- ManagementView managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), false);
+ ManagementView managementView = getConnection().getManagementView();
managementView.updateComponent(managedComponent);
}
@@ -380,7 +382,7 @@
@Override
public void deleteResource() throws Exception {
- DeploymentManager deploymentManager = ProfileServiceUtil
+ DeploymentManager deploymentManager = getConnection()
.getDeploymentManager();
log.debug("Stopping deployment [" + this.deploymentName + "]...");
@@ -512,14 +514,9 @@
.getComponentType(resourceType);
ManagementView managementView = null;
;
- try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
- } catch (NamingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if (ProfileServiceUtil.isManagedComponent(managementView, resourceName,
+ managementView = getConnection().getManagementView();
+
+ if (ProfileServiceUtil.isManagedComponent(getConnection(), resourceName,
componentType)) {
createResourceReport.setStatus(CreateResourceStatus.FAILURE);
createResourceReport.setErrorMessage("A " + resourceType.getName()
@@ -593,7 +590,7 @@
}
- DeploymentManager deploymentManager = ProfileServiceUtil
+ DeploymentManager deploymentManager = getConnection()
.getDeploymentManager();
DeploymentUtils
.deployArchive(deploymentManager, archiveFile, false);
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -34,6 +34,7 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.RunState;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -42,7 +43,12 @@
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.ProfileServiceComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -86,7 +92,7 @@
RunState runState;
try {
- runState = ProfileServiceUtil.getDQPManagementView().getRunState();
+ runState = ProfileServiceUtil.getDQPManagementView(getConnection()).getRunState();
} catch (NamingException e) {
LOG
.error("Naming exception getting: "
@@ -138,7 +144,7 @@
// Initialize any parameters to be used in the retrieval of
// metric values
- Object metricReturnObject = view.getMetric(getComponentType(),
+ Object metricReturnObject = view.getMetric(getConnection(), getComponentType(),
this.getComponentIdentifier(), name, valueMap);
try {
@@ -210,8 +216,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
for (String serviceName : PLATFORM_SERVICES_NAMES) {
@@ -270,7 +275,7 @@
Set<ManagedComponent> mcSet = null;
try {
mcSet = ProfileServiceUtil
- .getManagedComponents(new org.jboss.managed.api.ComponentType(
+ .getManagedComponents(getConnection(),new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
} catch (NamingException e) {
@@ -307,4 +312,15 @@
}
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((ApplicationServerComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -34,6 +34,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -56,14 +58,20 @@
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
-
- ManagedComponent mc = ProfileServiceUtil.getManagedComponent(
+ ProfileServiceConnection connection = ((ApplicationServerComponent) discoveryContext.getParentResourceComponent()).getConnection();
+
+ ManagedComponent mc = ProfileServiceUtil.getManagedComponent(connection,
new ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE),
- PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
- String version = ProfileServiceUtil.getSimpleValue(mc, "runtimeVersion", String.class);
+ if (mc==null){
+ //No Teiid instance found
+ return discoveredResources;
+ }
+
+ String version = ProfileServiceUtil.getSimpleValue(mc, "runtimeVersion", String.class); //$NON-NLS-1$
/**
*
@@ -88,7 +96,7 @@
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Teiid instance: " + mc.getName());
+ log.info("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
return discoveredResources;
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -34,6 +34,7 @@
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
@@ -43,11 +44,12 @@
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
- * Component class for the MetaMatrix Host Controller process.
+ * Component class for the Teiid Translator.
*
*/
public class TranslatorComponent extends Facet {
@@ -131,7 +133,7 @@
ManagedComponent translator = null;
try {
translator = ProfileServiceUtil
- .getManagedComponent(new ComponentType(
+ .getManagedComponent(getConnection(), new ComponentType(
PluginConstants.ComponentType.Translator.TYPE,
PluginConstants.ComponentType.Translator.SUBTYPE), this.name);
} catch (NamingException e) {
@@ -183,4 +185,16 @@
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -41,6 +41,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -56,9 +58,11 @@
ResourceDiscoveryContext discoveryContext)
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
-
+ ProfileServiceConnection connection = ((PlatformComponent) discoveryContext
+ .getParentResourceComponent()).getConnection();
+
Set<ManagedComponent> translators = ProfileServiceUtil
- .getManagedComponents(new ComponentType(
+ .getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.Translator.TYPE,
PluginConstants.ComponentType.Translator.SUBTYPE));
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -50,6 +50,7 @@
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -64,7 +65,10 @@
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.adminapi.impl.PropertyMetadata;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -132,7 +136,7 @@
// TODO Remove vdb version after no longer viable in Teiid
String version = this.resourceConfiguration.getSimpleValue(
"version", null);
- String status = DQPManagementView.getVDBStatus(this.name, Integer.parseInt(version));
+ String status = DQPManagementView.getVDBStatus(getConnection(), this.name, Integer.parseInt(version));
if (status.equals("ACTIVE")) {
return AvailabilityType.UP;
}
@@ -162,7 +166,7 @@
String name = request.getName();
LOG.debug("Measurement name = " + name); //$NON-NLS-1$
- Object metricReturnObject = view.getMetric(getComponentType(), this
+ Object metricReturnObject = view.getMetric(getConnection(), getComponentType(), this
.getComponentIdentifier(), name, valueMap);
try {
@@ -255,8 +259,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(this.name,
componentType);
ManagedProperty mp = managedComponent.getProperty("models");//$NON-NLS-1$
@@ -343,7 +346,7 @@
ManagedComponent mcVdb = null;
try {
- mcVdb = ProfileServiceUtil.getManagedComponent(
+ mcVdb = ProfileServiceUtil.getManagedComponent( getConnection(),
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -643,4 +646,16 @@
}
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -34,6 +34,7 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -43,15 +44,18 @@
*/
public class VDBDiscoveryComponent implements ResourceDiscoveryComponent {
- private final Log log = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log log = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext discoveryContext)
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+ ProfileServiceConnection connection = ((PlatformComponent) discoveryContext
+ .getParentResourceComponent()).getConnection();
Set<ManagedComponent> vdbs = ProfileServiceUtil
- .getManagedComponents(new ComponentType(
+ .getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE));
@@ -104,6 +108,5 @@
return discoveredResources;
}
-
}
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -33,10 +33,6 @@
* getting a handle to a specific component related to Teiid.
*/
- // The system key is the value used to obtain a connection.
- // In embedded, its a predefined value
- // In enterprise, its the installation directory
- // public final static String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
/**
* These are global properties used by all components
*/
@@ -63,7 +59,7 @@
public final static String TEIID_SUB_TYPE = "dqp"; //$NON-NLS-1$
public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
- public final static String TEIID_RUNTIME_ENGINE = "org.teiid.jboss.deployers.RuntimeEngineDeployer"; //$NON-NLS-1$
+ public final static String TEIID_RUNTIME_ENGINE = "RuntimeEngineDeployer"; //$NON-NLS-1$
public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Services"; //$NON-NLS-1$
public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "Teiid Data Service Runtime Engine"; //$NON-NLS-1$
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-14 18:29:05 UTC (rev 2344)
@@ -36,7 +36,6 @@
import java.util.Map;
import java.util.Set;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.commons.logging.Log;
@@ -70,6 +69,7 @@
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.TranslatorComponent;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
@@ -79,15 +79,13 @@
public class ProfileServiceUtil {
protected final static Log LOG = LogFactory
- .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
- private static String DQPNAME = "org.teiid.jboss.deployers.RuntimeEngineDeployer";
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static String DQPNAME = "RuntimeEngineDeployer"; //$NON-NLS-1$
private static final Map<String, ComponentType> COMPONENT_TYPE_CACHE = new HashMap<String, ComponentType>();
- private static final Map<String, KnownDeploymentTypes> DEPLOYMENT_TYPE_CACHE = new HashMap<String, KnownDeploymentTypes>();
- private static final Map<String, Configuration> DEFAULT_PLUGIN_CONFIG_CACHE = new HashMap<String, Configuration>();
+
+ protected static final String PLUGIN = "ProfileService"; //$NON-NLS-1$
- protected static final String PLUGIN = "ProfileService";
-
public static ComponentType getComponentType(
@NotNull ResourceType resourceType) {
String resourceTypeName = resourceType.getName();
@@ -96,18 +94,18 @@
Configuration defaultPluginConfig = getDefaultPluginConfiguration(resourceType);
String type = defaultPluginConfig.getSimpleValue(
TranslatorComponent.Config.COMPONENT_TYPE, null);
- if (type == null || type.equals(""))
+ if (type == null || type.equals("")) //$NON-NLS-1$
throw new IllegalStateException(
- "Required plugin configuration property '"
+ "Required plugin configuration property '" //$NON-NLS-1$
+ TranslatorComponent.Config.COMPONENT_TYPE
- + "' is not defined in default template.");
+ + "' is not defined in default template."); //$NON-NLS-1$
String subtype = defaultPluginConfig.getSimpleValue(
TranslatorComponent.Config.COMPONENT_SUBTYPE, null);
- if (subtype == null || subtype.equals(""))
+ if (subtype == null || subtype.equals("")) //$NON-NLS-1$
throw new IllegalStateException(
- "Required plugin configuration property '"
- + TranslatorComponent.Config.COMPONENT_SUBTYPE
- + "' is not defined in default template.");
+ "Required plugin configuration property '" //$NON-NLS-1$
+ + TranslatorComponent.Config.COMPONENT_SUBTYPE
+ + "' is not defined in default template."); //$NON-NLS-1$
ComponentType componentType = new ComponentType(type, subtype);
COMPONENT_TYPE_CACHE.put(resourceTypeName, componentType);
return componentType;
@@ -127,13 +125,14 @@
* @param componentType
* @return
*/
- public static boolean isManagedComponent(ManagementView managementView,
- String name, ComponentType componentType) {
+ public static boolean isManagedComponent(
+ ProfileServiceConnection connection, String name,
+ ComponentType componentType) {
boolean isDeployed = false;
if (name != null) {
try {
- ManagedComponent component = getManagedComponent(componentType,
- name);
+ ManagedComponent component = getManagedComponent(connection,
+ componentType, name);
if (component != null)
isDeployed = true;
} catch (Exception e) {
@@ -154,13 +153,11 @@
* @throws Exception
*/
public static ManagedComponent getManagedComponent(
- ComponentType componentType, String componentName)
- throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+ ProfileServiceConnection connection, ComponentType componentType,
+ String componentName) throws NamingException, Exception {
+ ManagedComponent mc = connection.getManagementView().getComponent(
+ componentName, componentType);
- ManagedComponent mc = mv.getComponent(componentName, componentType);
-
return mc;
}
@@ -173,13 +170,11 @@
* , Exception
* @throws Exception
*/
- public static Set<ManagedComponent> getManagedComponents(
+ public static Set<ManagedComponent> getManagedComponents(ProfileServiceConnection connection,
ComponentType componentType) throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+
+ Set<ManagedComponent> mcSet = connection.getManagementView().getComponentsForType(componentType);
- Set<ManagedComponent> mcSet = mv.getComponentsForType(componentType);
-
return mcSet;
}
@@ -203,37 +198,21 @@
* @throws NamingException
* @throws Exception
*/
- public static DeploymentManager getDeploymentManager()
+ public static DeploymentManager getDeploymentManager(ProfileServiceConnection connection)
throws NamingException, Exception {
- ProfileService ps = getProfileService();
- DeploymentManager deploymentManager = ps.getDeploymentManager();
- return deploymentManager;
+ return connection.getDeploymentManager();
}
/**
- * @return {@link ProfileService}
- * @throws NamingException
- * , Exception
- */
- public static ProfileService getProfileService() throws NamingException {
- InitialContext ic = new InitialContext();
- ProfileService ps = (ProfileService) ic
- .lookup(PluginConstants.PROFILE_SERVICE);
- return ps;
- }
-
- /**
* @return {@link File}
* @throws NamingException
* , Exception
*/
- public static File getDeployDirectory() throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, false);
+ public static File getDeployDirectory(ProfileServiceConnection connection) throws NamingException, Exception {
Set<ManagedDeployment> warDeployments;
try {
- warDeployments = mv
+ warDeployments = connection.getManagementView()
.getDeploymentsForType(KnownDeploymentTypes.JavaEEWebApplication
.getType());
} catch (Exception e) {
@@ -261,10 +240,11 @@
return deployDir;
}
- public static ManagedComponent getDQPManagementView()
- throws NamingException, Exception {
+ public static ManagedComponent getDQPManagementView(
+ ProfileServiceConnection connection) throws NamingException,
+ Exception {
- return getManagedComponent(DQPTYPE, DQPNAME);
+ return getManagedComponent(connection, DQPTYPE, DQPNAME);
}
public static String stringValue(MetaValue v1) throws Exception {
@@ -274,7 +254,7 @@
SimpleValue simple = (SimpleValue) v1;
return simple.getValue().toString();
}
- throw new Exception("Failed to convert value to string value");
+ throw new Exception("Failed to convert value to string value"); //$NON-NLS-1$
}
return null;
}
@@ -286,7 +266,7 @@
SimpleValue simple = (SimpleValue) v1;
return Boolean.valueOf(simple.getValue().toString());
}
- throw new Exception("Failed to convert value to boolean value");
+ throw new Exception("Failed to convert value to boolean value"); //$NON-NLS-1$
}
return null;
}
@@ -305,41 +285,43 @@
return expectedType.cast((enumValue != null) ? enumValue
.getValue() : null);
}
- throw new IllegalStateException(prop + " is not a simple type");
+ throw new IllegalStateException(prop + " is not a simple type"); //$NON-NLS-1$
}
return null;
}
-
- public static <T> T getSimpleValue(ManagedCommon mc, String prop, Class<T> expectedType) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isSimple()) {
- SimpleValue simpleValue = (SimpleValue)mp.getValue();
- return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
- }
- else if (metaType.isEnum()) {
- EnumValue enumValue = (EnumValue)mp.getValue();
- return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
- }
- throw new IllegalArgumentException(prop+ " is not a simple type"); //$NON-NLS-1$
- }
- return null;
- }
+ public static <T> T getSimpleValue(ManagedCommon mc, String prop,
+ Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue) mp.getValue();
+ return expectedType.cast((simpleValue != null) ? simpleValue
+ .getValue() : null);
+ } else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue) mp.getValue();
+ return expectedType.cast((enumValue != null) ? enumValue
+ .getValue() : null);
+ }
+ throw new IllegalArgumentException(prop + " is not a simple type"); //$NON-NLS-1$
+ }
+ return null;
+ }
+
public static Map<String, PropertySimple> getCustomProperties(
Configuration pluginConfig) {
Map<String, PropertySimple> customProperties = new LinkedHashMap<String, PropertySimple>();
if (pluginConfig == null)
return customProperties;
- PropertyMap customPropsMap = pluginConfig.getMap("custom-properties");
+ PropertyMap customPropsMap = pluginConfig.getMap("custom-properties"); //$NON-NLS-1$
if (customPropsMap != null) {
Collection<Property> customProps = customPropsMap.getMap().values();
for (Property customProp : customProps) {
if (!(customProp instanceof PropertySimple)) {
LOG
- .error("Custom property definitions in plugin configuration must be simple properties - property "
- + customProp + " is not - ignoring...");
+ .error("Custom property definitions in plugin configuration must be simple properties - property " //$NON-NLS-1$
+ + customProp + " is not - ignoring..."); //$NON-NLS-1$
continue;
}
customProperties.put(customProp.getName(),
@@ -365,14 +347,14 @@
if (!managedProperty.hasViewUse(ViewUse.STATISTIC))
LOG
.debug(resourceType
- + " does not define a property corresponding to ManagedProperty '"
- + propName + "'.");
+ + " does not define a property corresponding to ManagedProperty '" //$NON-NLS-1$
+ + propName + "'."); //$NON-NLS-1$
continue;
}
if (managedProperty == null) {
// This should never happen, but don't let it blow us up.
- LOG.error("ManagedProperty '" + propName
- + "' has a null value in the ManagedProperties Map.");
+ LOG.error("ManagedProperty '" + propName //$NON-NLS-1$
+ + "' has a null value in the ManagedProperties Map."); //$NON-NLS-1$
continue;
}
MetaValue metaValue = managedProperty.getValue();
@@ -390,13 +372,13 @@
.getPropertyAdapter(metaValue);
if (propertyAdapter == null) {
LOG
- .error("Unable to find a PropertyAdapter for ManagedProperty '"
+ .error("Unable to find a PropertyAdapter for ManagedProperty '" //$NON-NLS-1$
+ propName
- + "' with MetaType ["
+ + "' with MetaType [" //$NON-NLS-1$
+ metaValue.getMetaType()
- + "] for ResourceType '"
- + resourceType.getName() + "'.");
- continue;
+ + "] for ResourceType '" //$NON-NLS-1$
+ + resourceType.getName() + "'."); //$NON-NLS-1$
+ continue;
}
Property property = propertyAdapter.convertToProperty(metaValue,
propertyDefinition);
@@ -414,19 +396,20 @@
String propertyName = managedProperty.getName();
PropertyDefinition propertyDefinition = configDefinition
.get(propertyName);
- if (propertyDefinition==null){
- //The managed property is not defined in the configuration
+ if (propertyDefinition == null) {
+ // The managed property is not defined in the configuration
continue;
}
populateManagedPropertyFromProperty(managedProperty,
- propertyDefinition, configuration);
- }
+ propertyDefinition, configuration);
+ }
return;
}
- public static void populateManagedPropertyFromProperty(ManagedProperty managedProperty,
+ public static void populateManagedPropertyFromProperty(
+ ManagedProperty managedProperty,
PropertyDefinition propertyDefinition, Configuration configuration) {
- // If the ManagedProperty defines a default value, assume it's more
+ // If the ManagedProperty defines a default value, assume it's more
// definitive than any default value that may
// have been defined in the plugin descriptor, and update the
// PropertyDefinition to use that as its default
@@ -438,29 +421,31 @@
MetaValue metaValue = managedProperty.getValue();
PropertyAdapter propertyAdapter = null;
if (metaValue != null) {
- LOG.trace("Populating existing MetaValue of type "
- + metaValue.getMetaType() + " from Teiid property "
- + propertyDefinition.getName() + " with definition " + propertyDefinition
- + "...");
+ LOG.trace("Populating existing MetaValue of type " //$NON-NLS-1$
+ + metaValue.getMetaType() + " from Teiid property " //$NON-NLS-1$
+ + propertyDefinition.getName() + " with definition " //$NON-NLS-1$
+ + propertyDefinition + "..."); //$NON-NLS-1$
propertyAdapter = PropertyAdapterFactory
- .getPropertyAdapter(metaValue);
-
- propertyAdapter.populateMetaValueFromProperty(configuration.getSimple(propertyDefinition.getName()), metaValue,
- propertyDefinition);
+ .getPropertyAdapter(metaValue);
+
+ propertyAdapter.populateMetaValueFromProperty(configuration
+ .getSimple(propertyDefinition.getName()), metaValue,
+ propertyDefinition);
managedProperty.setValue(metaValue);
} else {
- MetaType metaType = managedProperty.getMetaType();
+ MetaType metaType = managedProperty.getMetaType();
if (propertyAdapter == null)
propertyAdapter = PropertyAdapterFactory
.getPropertyAdapter(metaType);
- LOG.trace("Converting property " + propertyDefinition.getName() + " with definition "
- + propertyDefinition + " to MetaValue of type " + metaType
- + "...");
- metaValue = propertyAdapter.convertToMetaValue(configuration.getSimple(propertyDefinition.getName()),
- propertyDefinition, metaType);
+ LOG.trace("Converting property " + propertyDefinition.getName() //$NON-NLS-1$
+ + " with definition " + propertyDefinition //$NON-NLS-1$
+ + " to MetaValue of type " + metaType + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+ metaValue = propertyAdapter.convertToMetaValue(configuration
+ .getSimple(propertyDefinition.getName()),
+ propertyDefinition, metaType);
managedProperty.setValue(metaValue);
}
-
+
}
private static void updateDefaultValueOnPropertyDefinition(
@@ -468,17 +453,17 @@
@NotNull MetaValue defaultValue) {
if (!(propertyDefinition instanceof PropertyDefinitionSimple)) {
LOG
- .debug("Cannot update default value on non-simple property definition "
+ .debug("Cannot update default value on non-simple property definition " //$NON-NLS-1$
+ propertyDefinition
- + "(default value is "
- + defaultValue + ").");
+ + "(default value is " //$NON-NLS-1$
+ + defaultValue + ")."); //$NON-NLS-1$
return;
}
MetaType metaType = defaultValue.getMetaType();
if (!metaType.isSimple() && !metaType.isEnum()) {
- LOG.debug("Cannot update default value on " + propertyDefinition
- + ", because default value's type (" + metaType
- + ") is not simple or enum.");
+ LOG.debug("Cannot update default value on " + propertyDefinition //$NON-NLS-1$
+ + ", because default value's type (" + metaType //$NON-NLS-1$
+ + ") is not simple or enum."); //$NON-NLS-1$
return;
}
PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinition;
@@ -525,88 +510,91 @@
}
return memberMetaType;
}
-
- private static MetaType convertPropertySimpleTypeToSimpleMetaType(PropertySimpleType memberSimpleType)
- {
- MetaType memberMetaType;
- Class memberClass;
- switch (memberSimpleType)
- {
- case BOOLEAN:
- memberClass = Boolean.class;
- break;
- case INTEGER:
- memberClass = Integer.class;
- break;
- case LONG:
- memberClass = Long.class;
- break;
- case FLOAT:
- memberClass = Float.class;
- break;
- case DOUBLE:
- memberClass = Double.class;
- break;
- default:
- memberClass = String.class;
- break;
- }
- memberMetaType = SimpleMetaType.resolve(memberClass.getName());
- return memberMetaType;
- }
-
- public static SimpleValue wrap(MetaType type, String value) throws Exception {
- if (type instanceof SimpleMetaType) {
- SimpleMetaType st = (SimpleMetaType)type;
-
- if (SimpleMetaType.BIGDECIMAL.equals(st)) {
- return new SimpleValueSupport(st, new BigDecimal(value));
- } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
- return new SimpleValueSupport(st, new BigInteger(value));
- } else if (SimpleMetaType.BOOLEAN.equals(st)) {
- return new SimpleValueSupport(st, Boolean.valueOf(value));
- } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
- } else if (SimpleMetaType.BYTE.equals(st)) {
- return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
- } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, value.getBytes()[0]);
- } else if (SimpleMetaType.CHARACTER.equals(st)) {
- return new SimpleValueSupport(st, new Character(value.charAt(0)));
- } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st,value.charAt(0));
- } else if (SimpleMetaType.DATE.equals(st)) {
- try {
- return new SimpleValueSupport(st, SimpleDateFormat.getInstance().parse(value));
- } catch (ParseException e) {
- throw new Exception("Failed to convert value to SimpleValue", e); //$NON-NLS-1$
- }
- } else if (SimpleMetaType.DOUBLE.equals(st)) {
- return new SimpleValueSupport(st, Double.valueOf(value));
- } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Double.parseDouble(value));
- } else if (SimpleMetaType.FLOAT.equals(st)) {
- return new SimpleValueSupport(st, Float.parseFloat(value));
- } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Float.valueOf(value));
- } else if (SimpleMetaType.INTEGER.equals(st)) {
- return new SimpleValueSupport(st, Integer.valueOf(value));
- } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Integer.parseInt(value));
- } else if (SimpleMetaType.LONG.equals(st)) {
- return new SimpleValueSupport(st, Long.valueOf(value));
- } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Long.parseLong(value));
- } else if (SimpleMetaType.SHORT.equals(st)) {
- return new SimpleValueSupport(st, Short.valueOf(value));
- } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Short.parseShort(value));
- } else if (SimpleMetaType.STRING.equals(st)) {
- return new SimpleValueSupport(st,value);
+
+ private static MetaType convertPropertySimpleTypeToSimpleMetaType(
+ PropertySimpleType memberSimpleType) {
+ MetaType memberMetaType;
+ Class memberClass;
+ switch (memberSimpleType) {
+ case BOOLEAN:
+ memberClass = Boolean.class;
+ break;
+ case INTEGER:
+ memberClass = Integer.class;
+ break;
+ case LONG:
+ memberClass = Long.class;
+ break;
+ case FLOAT:
+ memberClass = Float.class;
+ break;
+ case DOUBLE:
+ memberClass = Double.class;
+ break;
+ default:
+ memberClass = String.class;
+ break;
+ }
+ memberMetaType = SimpleMetaType.resolve(memberClass.getName());
+ return memberMetaType;
+ }
+
+ public static SimpleValue wrap(MetaType type, String value)
+ throws Exception {
+ if (type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType) type;
+
+ if (SimpleMetaType.BIGDECIMAL.equals(st)) {
+ return new SimpleValueSupport(st, new BigDecimal(value));
+ } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
+ return new SimpleValueSupport(st, new BigInteger(value));
+ } else if (SimpleMetaType.BOOLEAN.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value));
+ } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value)
+ .booleanValue());
+ } else if (SimpleMetaType.BYTE.equals(st)) {
+ return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
+ } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.getBytes()[0]);
+ } else if (SimpleMetaType.CHARACTER.equals(st)) {
+ return new SimpleValueSupport(st,
+ new Character(value.charAt(0)));
+ } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.charAt(0));
+ } else if (SimpleMetaType.DATE.equals(st)) {
+ try {
+ return new SimpleValueSupport(st, SimpleDateFormat
+ .getInstance().parse(value));
+ } catch (ParseException e) {
+ throw new Exception(
+ "Failed to convert value to SimpleValue", e); //$NON-NLS-1$
}
+ } else if (SimpleMetaType.DOUBLE.equals(st)) {
+ return new SimpleValueSupport(st, Double.valueOf(value));
+ } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Double.parseDouble(value));
+ } else if (SimpleMetaType.FLOAT.equals(st)) {
+ return new SimpleValueSupport(st, Float.parseFloat(value));
+ } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Float.valueOf(value));
+ } else if (SimpleMetaType.INTEGER.equals(st)) {
+ return new SimpleValueSupport(st, Integer.valueOf(value));
+ } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Integer.parseInt(value));
+ } else if (SimpleMetaType.LONG.equals(st)) {
+ return new SimpleValueSupport(st, Long.valueOf(value));
+ } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Long.parseLong(value));
+ } else if (SimpleMetaType.SHORT.equals(st)) {
+ return new SimpleValueSupport(st, Short.valueOf(value));
+ } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Short.parseShort(value));
+ } else if (SimpleMetaType.STRING.equals(st)) {
+ return new SimpleValueSupport(st, value);
}
- throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
- }
+ }
+ throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
+ }
-
}
14 years, 5 months
teiid SVN: r2343 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-14 13:25:17 -0400 (Wed, 14 Jul 2010)
New Revision: 2343
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1157 fix for ruleplansorts with a table function
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-07-14 16:27:29 UTC (rev 2342)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-07-14 17:25:17 UTC (rev 2343)
@@ -42,7 +42,6 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
-import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.symbol.GroupSymbol;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-07-14 16:27:29 UTC (rev 2342)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-07-14 17:25:17 UTC (rev 2343)
@@ -41,7 +41,6 @@
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
-import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.lang.OrderByItem;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2010-07-14 16:27:29 UTC (rev 2342)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2010-07-14 17:25:17 UTC (rev 2343)
@@ -211,6 +211,9 @@
}
private boolean mergeSortWithDupRemoval(PlanNode node) {
+ if (node.getFirstChild() == null) {
+ return false;
+ }
switch (node.getFirstChild().getType()) {
case NodeConstants.Types.SET_OP:
if (node.getFirstChild().getProperty(NodeConstants.Info.SET_OPERATION) == SetQuery.Operation.UNION && !node.getFirstChild().hasBooleanProperty(NodeConstants.Info.USE_ALL)) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-07-14 16:27:29 UTC (rev 2342)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-07-14 17:25:17 UTC (rev 2343)
@@ -175,7 +175,17 @@
process(sql, expected);
}
+
+ @Test public void testTextTableGroupBy() throws Exception {
+ String sql = "select max(x) from texttable('a' || ',' || '1' COLUMNS x string, y integer) x group by y"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a"),
+ };
+ process(sql, expected);
+ }
+
public static void process(String sql, List[] expectedResults) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
14 years, 5 months
teiid SVN: r2342 - in trunk: client/src/main/java/org/teiid/jdbc and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-14 12:27:29 -0400 (Wed, 14 Jul 2010)
New Revision: 2342
Modified:
trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java
trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java
trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
Log:
TEIID-908 adding a show statement primarily to retrieve query plans.
Modified: trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -40,6 +40,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.ExternalizeUtil;
@@ -168,13 +169,18 @@
* document form.
* @return an XML document of this PlanNode
*/
- public String toXml() throws JAXBException {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE); //$NON-NLS-1$
- StringWriter writer = new StringWriter();
- marshaller.marshal(this, writer);
- return writer.toString();
+ public String toXml() {
+ try {
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
+ Marshaller marshaller = jc.createMarshaller();
+ marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE); //$NON-NLS-1$
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(this, writer);
+ return writer.toString();
+ } catch (JAXBException e) {
+ //shouldn't happen
+ throw new TeiidRuntimeException(e);
+ }
}
@Override
Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -27,15 +27,13 @@
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
+import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
-import java.sql.SQLClientInfoException;
-import java.sql.NClob;
import java.sql.SQLXML;
-
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
@@ -56,13 +54,15 @@
import javax.transaction.xa.Xid;
import org.teiid.client.DQP;
+import org.teiid.client.plan.Annotation;
+import org.teiid.client.plan.PlanNode;
import org.teiid.client.util.ResultsFuture;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
import org.teiid.core.util.SqlUtil;
import org.teiid.net.CommunicationException;
+import org.teiid.net.ServerConnection;
import org.teiid.net.TeiidURL;
-import org.teiid.net.ServerConnection;
import org.teiid.net.socket.SocketServerConnection;
@@ -94,7 +94,7 @@
// collection of all open statements on this connection
private Collection<StatementImpl> statements = new ArrayList<StatementImpl>();
// cached DatabaseMetadata
- private DatabaseMetaData dbmm;
+ private DatabaseMetaDataImpl dbmm;
//Xid for participating in TXN
private XidImpl transactionXid;
@@ -105,7 +105,14 @@
private boolean disableLocalTransactions = false;
private DQP dqp;
protected ServerConnection serverConn;
- private int transactionIsolation = DEFAULT_ISOLATION;
+ private int transactionIsolation = DEFAULT_ISOLATION;
+
+ // the last query plan description
+ private PlanNode currentPlanDescription;
+ // the last query debug log
+ private String debugLog;
+ // the last query annotations
+ private Collection<Annotation> annotations;
public ConnectionImpl(ServerConnection serverConn, Properties info, String url) {
this.serverConn = serverConn;
@@ -158,6 +165,30 @@
this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
}
+ public Collection<Annotation> getAnnotations() {
+ return annotations;
+ }
+
+ public void setAnnotations(Collection<Annotation> annotations) {
+ this.annotations = annotations;
+ }
+
+ public String getDebugLog() {
+ return debugLog;
+ }
+
+ public void setDebugLog(String debugLog) {
+ this.debugLog = debugLog;
+ }
+
+ public PlanNode getCurrentPlanDescription() {
+ return currentPlanDescription;
+ }
+
+ public void setCurrentPlanDescription(PlanNode currentPlanDescription) {
+ this.currentPlanDescription = currentPlanDescription;
+ }
+
protected Properties getConnectionProperties() {
return this.propInfo;
}
@@ -458,7 +489,7 @@
return this.serverConn.getLogonResult().getUserName();
}
- public DatabaseMetaData getMetaData() throws SQLException {
+ public DatabaseMetaDataImpl getMetaData() throws SQLException {
//Check to see the connection is open
checkConnection();
@@ -613,7 +644,7 @@
* @return a PreparedStatement object
* @throws SQLException if there is an error creating a prepared statement object
*/
- public PreparedStatement prepareStatement(String sql) throws SQLException {
+ public PreparedStatementImpl prepareStatement(String sql) throws SQLException {
return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
}
@@ -626,7 +657,7 @@
* @param intValue indicating the ResultSet's concurrency
* @return a PreparedStatement object
*/
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
//Check to see the connection is open
checkConnection();
Modified: trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -32,16 +32,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
-import org.teiid.client.ResultsMessage;
import org.teiid.client.metadata.ResultsMetadataConstants;
import org.teiid.client.metadata.ResultsMetadataDefaults;
import org.teiid.core.CoreConstants;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.JDBCSQLTypeInfo;
import org.teiid.core.util.SqlUtil;
@@ -392,43 +389,43 @@
Map[] metadataList = new Map[8];
// HardCoding metadata details for SCOPE column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.SCOPE,
- JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.SCOPE,
+ JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for COLUMN_NAME column
- metadataList[1] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.COLUMN_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[1] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.COLUMN_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for DATA_TYPE column
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.DATA_TYPE,
- JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[2] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.DATA_TYPE,
+ JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for TYPE_NAME column
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.TYPE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[3] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.TYPE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for COLUMN_SIZE column
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.COLUMN_SIZE,
- JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[4] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.COLUMN_SIZE,
+ JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for BUFFER_LENGTH column
- metadataList[5] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.BUFFER_LENGTH,
- JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[5] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.BUFFER_LENGTH,
+ JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for DECIMAL_DIGITS column
- metadataList[6] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.DECIMAL_DIGITS,
- JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[6] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.DECIMAL_DIGITS,
+ JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for PSEUDO_COLUMN column
- metadataList[7] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.PSEUDO_COLUMN,
- JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[7] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.BEST_ROW.PSEUDO_COLUMN,
+ JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.Best_row_sucess", table); //$NON-NLS-1$
logger.fine(logMsg);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
public ResultSet getCatalogs() throws SQLException {
@@ -442,57 +439,17 @@
Map[] metadataList = new Map[1];
// HardCoding metadata details for TABLE_CAT column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.CATALOGS.TABLE_CAT,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.CATALOGS.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.Catalog_success"); //$NON-NLS-1$
logger.fine(logMsg);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
- private ResultSet createResultSet(List records, Map[] columnMetadata) throws SQLException {
- ResultSetMetaData rsmd = new ResultSetMetaDataImpl(new MetadataProvider(columnMetadata));
-
- return createResultSet(records, rsmd);
- }
-
- private ResultSet createResultSet(List records, ResultSetMetaData rsmd) throws SQLException {
- rsmd.getScale(1); //force the load of the metadata
- ResultsMessage resultsMsg = createDummyResultsMessage(null, null, records);
- StatementImpl stmt = StatementImpl.newInstance(this.driverConnection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- return new ResultSetImpl(resultsMsg, stmt, rsmd, 0);
- }
-
- private ResultSet createEmptyResultSet(String[] columnNames, String[] dataTypes) throws SQLException {
- ResultsMessage resultsMsg = createDummyResultsMessage(columnNames, dataTypes, Collections.EMPTY_LIST);
- StatementImpl stmt = StatementImpl.newInstance(this.driverConnection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- try {
- stmt.setFetchSize(500);
- } catch(SQLException e) {
- // will never happen but throw a runtime if it does
- throw new TeiidRuntimeException(e);
- }
- Map[] metadata = new Map[columnNames.length];
- for (int i = 0; i < columnNames.length; i++) {
- metadata[i] = getColumnMetadata(null, columnNames[i], dataTypes[i], ResultsMetadataConstants.NULL_TYPES.UNKNOWN);
- }
- return new ResultSetImpl(resultsMsg, stmt, new ResultSetMetaDataImpl(new MetadataProvider(metadata)), 0);
- }
-
- private ResultsMessage createDummyResultsMessage(String[] columnNames, String[] dataTypes, List records) {
- ResultsMessage resultsMsg = new ResultsMessage();
- resultsMsg.setColumnNames(columnNames);
- resultsMsg.setDataTypes(dataTypes);
- resultsMsg.setFirstRow(1);
- resultsMsg.setLastRow(records.size());
- resultsMsg.setFinalRow(records.size());
- resultsMsg.setResults((List[])records.toArray(new List[records.size()]));
- return resultsMsg;
- }
-
/**
* <p>Gets the String object used to separate a catalog name and a table name
* @return String delimiter
@@ -526,24 +483,24 @@
***********************************************************************/
Map[] metadataList = new Map[8];
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_CAT,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[1] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.COLUMN_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTOR,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[5] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTEE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[6] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.PRIVILEGE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[7] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[1] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[2] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[3] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.COLUMN_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[4] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTOR,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[5] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTEE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[6] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.PRIVILEGE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[7] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
@@ -622,7 +579,7 @@
logger.fine(logMsg);
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch(Exception e) {
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCols_error", columnNamePattern, tableNamePattern, e.getMessage()); //$NON-NLS-1$
@@ -976,7 +933,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_success", table)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_error", table, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1201,7 +1158,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_error", table, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1262,7 +1219,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_success", columnNamePattern, procedureNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_error", columnNamePattern, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1323,7 +1280,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_success", procedureNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_error", procedureNamePattern, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1392,23 +1349,23 @@
Map[] metadataList = new Map[4];
// HardCoding metadata details for TABLE_CAT column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.TABLE_CAT,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TABLE_SCHEM column
- metadataList[1] = getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.TABLE_SCHEM,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[1] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.TABLE_SCHEM,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TABLE_NAME column
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.TABLE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[2] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.TABLE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for SUPERTABLE_NAME column
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.SUPERTABLE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[3] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TABLES.SUPERTABLE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
@@ -1430,31 +1387,31 @@
Map[] metadataList = new Map[6];
// HardCoding metadata details for TYPE_CAT column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_CAT,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_CAT,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TYPE_SCHEM column
- metadataList[1] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_SCHEM,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[1] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_SCHEM,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TYPE_NAME column
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[2] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for SUPERTYPE_CAT column
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.SUPERTYPE_CAT,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[3] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.SUPERTYPE_CAT,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for SUPERTYPE_SCHEM column
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.SUPERTYPE_SCHEM,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[4] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.SUPERTYPE_SCHEM,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for SUPERTYPE_NAME column
- metadataList[5] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.SUPERTYPE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[5] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.SUPERTYPE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
public String getSystemFunctions() throws SQLException {
@@ -1468,22 +1425,22 @@
***********************************************************************/
Map[] metadataList = new Map[7];
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_CAT,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[1] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_NAME,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTOR,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTEE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[5] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.PRIVILEGE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[6] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[1] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[2] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_NAME,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[3] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTOR,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[4] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTEE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[5] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.PRIVILEGE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[6] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
@@ -1569,7 +1526,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_success", tableNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_error", tableNamePattern, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1599,13 +1556,13 @@
Map[] metadataList = new Map[1];
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.TABLE_TYPES.TABLE_TYPE,
- JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[0] = StatementImpl.getColumnMetadata(null, JDBCColumnNames.TABLE_TYPES.TABLE_TYPE,
+ JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTableType_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
public String getTimeDateFunctions() throws SQLException {
@@ -1615,7 +1572,7 @@
public ResultSet getTypeInfo() throws SQLException {
// list which represent records containing data type info
- List records = new ArrayList ();
+ List<List<Object>> records = new ArrayList<List<Object>>();
records.add(Arrays.asList(createTypeInfoRow("boolean", "{b'", "}", Boolean.TRUE, Boolean.TRUE, 0))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
records.add(Arrays.asList(createTypeInfoRow("byte", null, null, Boolean.TRUE, Boolean.TRUE, 0))); //$NON-NLS-1$
@@ -1638,31 +1595,31 @@
Map[] metadataList = new Map[18];
- metadataList[0] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.TYPE_NAME, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[1] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.DATA_TYPE, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[2] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.PRECISION, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[3] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[4] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[5] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CREATE_PARAMS, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[6] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NULLABLE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[7] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE);//$NON-NLS-1$
- metadataList[8] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SEARCHABLE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[9] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[10] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[11] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.AUTOINCREMENT, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE);//$NON-NLS-1$
- metadataList[12] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[13] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[14] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[15] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[16] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[17] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[0] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.TYPE_NAME, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[1] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.DATA_TYPE, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[2] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.PRECISION, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[3] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[4] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[5] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CREATE_PARAMS, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[6] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NULLABLE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[7] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, driverConnection);//$NON-NLS-1$
+ metadataList[8] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SEARCHABLE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[9] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[10] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[11] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.AUTOINCREMENT, JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, driverConnection);//$NON-NLS-1$
+ metadataList[12] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME, JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[13] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[14] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE, JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[15] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[16] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[17] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, driverConnection);//$NON-NLS-1$
ResultSetMetaData rmetadata = new ResultSetMetaDataImpl(new MetadataProvider(metadataList));
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTypes_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
}
private Object[] createTypeInfoRow(String typeName, String prefix, String suffix, Boolean unsigned, Boolean fixedPrecScale, int radix){
@@ -1709,9 +1666,13 @@
JDBCSQLTypeInfo.STRING,
JDBCSQLTypeInfo.SHORT
};
- return createEmptyResultSet(columnNames, dataTypes);
+ return dummyStatement().createResultSet(Collections.EMPTY_LIST, columnNames, dataTypes);
}
+ private StatementImpl dummyStatement() {
+ return StatementImpl.newInstance(this.driverConnection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ }
+
public String getURL() throws SQLException {
return driverConnection.getUrl();
}
@@ -2312,41 +2273,9 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getRefKey_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
}
- private Map getColumnMetadata(String tableName, String columnName, String dataType, Integer nullable) throws SQLException {
- return getColumnMetadata(tableName, columnName, dataType, nullable, ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);
- }
-
- private Map getColumnMetadata(String tableName, String columnName, String dataType, Integer nullable, Integer searchable, Boolean writable, Boolean signed, Boolean caseSensitive) throws SQLException {
-
- // map that would contain metadata details
- Map metadataMap = new HashMap();
-
- /*******************************************************
- HardCoding Column metadata details for the given column
- ********************************************************/
-
- metadataMap.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, driverConnection.getVDBName());
- metadataMap.put(ResultsMetadataConstants.GROUP_NAME, tableName);
- metadataMap.put(ResultsMetadataConstants.ELEMENT_NAME, columnName);
- metadataMap.put(ResultsMetadataConstants.DATA_TYPE, dataType);
- metadataMap.put(ResultsMetadataConstants.PRECISION, ResultsMetadataDefaults.getDefaultPrecision(dataType));
- metadataMap.put(ResultsMetadataConstants.RADIX, new Integer(10));
- metadataMap.put(ResultsMetadataConstants.SCALE, new Integer(0));
- metadataMap.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
- metadataMap.put(ResultsMetadataConstants.CASE_SENSITIVE, caseSensitive);
- metadataMap.put(ResultsMetadataConstants.NULLABLE, nullable);
- metadataMap.put(ResultsMetadataConstants.SEARCHABLE, searchable);
- metadataMap.put(ResultsMetadataConstants.SIGNED, signed);
- metadataMap.put(ResultsMetadataConstants.WRITABLE, writable);
- metadataMap.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
- metadataMap.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.getMaxDisplaySize(dataType));
-
- return metadataMap;
- }
-
public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
return false;
}
@@ -2401,7 +2330,7 @@
ResultSetMetaData rmetadata = null;
ResultSetImpl results = null;
- PreparedStatement prepareQuery = null;
+ PreparedStatementImpl prepareQuery = null;
try {
prepareQuery = driverConnection.prepareStatement(QUERY_SCHEMAS);
prepareQuery.setObject(1, catalog.toUpperCase());
@@ -2427,7 +2356,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch(Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_error", e.getMessage())); //$NON-NLS-1$
} finally {
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -291,7 +291,7 @@
target.put(validKey, value);
}
- private static String getValidKey(String key) {
+ public static String getValidKey(String key) {
// figure out the valid key based on its case
for (int i = 0; i < KNOWN_PROPERTIES.length; i++) {
if (key.equalsIgnoreCase(KNOWN_PROPERTIES[i])) {
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -25,11 +25,13 @@
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -51,11 +53,15 @@
import org.teiid.client.RequestMessage.ResultsMode;
import org.teiid.client.RequestMessage.ShowPlan;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.client.metadata.ResultsMetadataConstants;
+import org.teiid.client.metadata.ResultsMetadataDefaults;
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.PlanNode;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.JDBCSQLTypeInfo;
+import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.util.SqlUtil;
@@ -139,7 +145,7 @@
protected Map outParamIndexMap = new HashMap();
private static Pattern SET_STATEMENT = Pattern.compile("\\s*set\\s*(\\w+)\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
-
+ private static Pattern SHOW_STATEMENT = Pattern.compile("\\s*show\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
/**
* Factory Constructor
* @param driverConnection
@@ -289,7 +295,7 @@
* throws an exception if it is closed. </p>
* @throws SQLException if the statement object is closed.
*/
- protected void checkStatement() throws SQLException {
+ protected void checkStatement() throws TeiidSQLException {
//Check to see the connection is closed and proceed if it is not
if ( isClosed ) {
throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Stmt_closed")); //$NON-NLS-1$
@@ -377,20 +383,73 @@
}
protected void executeSql(String[] commands, boolean isBatchedCommand, ResultsMode resultsMode)
- throws SQLException, TeiidSQLException {
+ throws SQLException {
checkStatement();
resetExecutionState();
- //handle set statement
- if (commands.length == 1 && resultsMode != ResultsMode.RESULTSET) {
+ if (commands.length == 1) {
Matcher match = SET_STATEMENT.matcher(commands[0]);
if (match.matches()) {
+ if (resultsMode == ResultsMode.RESULTSET) {
+ throw new TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.set_result_set")); //$NON-NLS-1$
+ }
String key = match.group(1);
String value = match.group(2);
JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getConnectionProperties());
this.updateCounts = new int[] {0};
return;
}
+ match = SHOW_STATEMENT.matcher(commands[0]);
+ if (match.matches()) {
+ if (resultsMode == ResultsMode.UPDATECOUNT) {
+ throw new TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.show_update_count")); //$NON-NLS-1$
+ }
+ String show = match.group(1);
+ if (show.equalsIgnoreCase("PLAN")) { //$NON-NLS-1$
+ List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
+ PlanNode plan = driverConnection.getCurrentPlanDescription();
+ if (plan != null) {
+ ArrayList<Object> row = new ArrayList<Object>(3);
+ row.add(DataTypeTransformer.getClob(plan.toString()));
+ row.add(new SQLXMLImpl(plan.toXml()));
+ row.add(DataTypeTransformer.getClob(driverConnection.getDebugLog()));
+ records.add(row);
+ }
+ createResultSet(records, new String[] {"PLAN_TEXT", "PLAN_XML", "DEBUG_LOG"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.XML, JDBCSQLTypeInfo.STRING});
+ return;
+ }
+ if (show.equalsIgnoreCase("ANNOTATIONS")) { //$NON-NLS-1$
+ List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
+ Collection<Annotation> annos = driverConnection.getAnnotations();
+ for (Annotation annotation : annos) {
+ ArrayList<Object> row = new ArrayList<Object>(4);
+ row.add(annotation.getCategory());
+ row.add(annotation.getPriority().name());
+ row.add(annotation.getAnnotation());
+ row.add(annotation.getResolution());
+ records.add(row);
+ }
+ createResultSet(records, new String[] {"CATEGORY", "PRIORITY", "ANNOTATION", "RESOLUTION"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING});
+ return;
+ }
+ if (show.equalsIgnoreCase("ALL")) { //$NON-NLS-1$
+ List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
+ for (String key : driverConnection.getConnectionProperties().stringPropertyNames()) {
+ ArrayList<Object> row = new ArrayList<Object>(4);
+ row.add(key);
+ row.add(driverConnection.getConnectionProperties().get(key));
+ records.add(row);
+ }
+ createResultSet(records, new String[] {"NAME", "VALUE"}, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING});
+ return;
+ }
+ List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getConnectionProperties().getProperty(JDBCURL.getValidKey(show))));
+ createResultSet(records, new String[] {show}, new String[] {JDBCSQLTypeInfo.STRING});
+ return;
+ }
}
RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, resultsMode);
@@ -913,7 +972,10 @@
protected void setAnalysisInfo(ResultsMessage resultsMsg) {
this.debugLog = resultsMsg.getDebugLog();
this.currentPlanDescription = resultsMsg.getPlanDescription();
- this.annotations = resultsMsg.getAnnotations();
+ this.annotations = resultsMsg.getAnnotations();
+ this.driverConnection.setDebugLog(debugLog);
+ this.driverConnection.setCurrentPlanDescription(currentPlanDescription);
+ this.driverConnection.setAnnotations(annotations);
}
Calendar getDefaultCalendar() {
@@ -988,4 +1050,69 @@
}
this.maxFieldSize = max;
}
+
+ ResultSetImpl createResultSet(List records, String[] columnNames, String[] dataTypes) throws SQLException {
+ Map[] metadata = new Map[columnNames.length];
+ for (int i = 0; i < columnNames.length; i++) {
+ metadata[i] = getColumnMetadata(null, columnNames[i], dataTypes[i], ResultsMetadataConstants.NULL_TYPES.UNKNOWN, driverConnection);
+ }
+ return createResultSet(records, metadata);
+ }
+
+ ResultSetImpl createResultSet(List records, Map[] columnMetadata) throws SQLException {
+ ResultSetMetaData rsmd = new ResultSetMetaDataImpl(new MetadataProvider(columnMetadata));
+
+ return createResultSet(records, rsmd);
+ }
+
+ ResultSetImpl createResultSet(List records, ResultSetMetaData rsmd) throws SQLException {
+ rsmd.getScale(1); //force the load of the metadata
+ ResultsMessage resultsMsg = createDummyResultsMessage(null, null, records);
+ resultSet = new ResultSetImpl(resultsMsg, this, rsmd, 0);
+ resultSet.setMaxFieldSize(this.maxFieldSize);
+ return resultSet;
+ }
+
+ static ResultsMessage createDummyResultsMessage(String[] columnNames, String[] dataTypes, List records) {
+ ResultsMessage resultsMsg = new ResultsMessage();
+ resultsMsg.setColumnNames(columnNames);
+ resultsMsg.setDataTypes(dataTypes);
+ resultsMsg.setFirstRow(1);
+ resultsMsg.setLastRow(records.size());
+ resultsMsg.setFinalRow(records.size());
+ resultsMsg.setResults((List[])records.toArray(new List[records.size()]));
+ return resultsMsg;
+ }
+
+ static Map<Integer, Object> getColumnMetadata(String tableName, String columnName, String dataType, Integer nullable, ConnectionImpl driverConnection) throws SQLException {
+ return getColumnMetadata(tableName, columnName, dataType, nullable, ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, driverConnection);
+ }
+
+ static Map<Integer, Object> getColumnMetadata(String tableName, String columnName, String dataType, Integer nullable, Integer searchable, Boolean writable, Boolean signed, Boolean caseSensitive, ConnectionImpl driverConnection) throws SQLException {
+
+ // map that would contain metadata details
+ Map<Integer, Object> metadataMap = new HashMap<Integer, Object>();
+
+ /*******************************************************
+ HardCoding Column metadata details for the given column
+ ********************************************************/
+
+ metadataMap.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, driverConnection.getVDBName());
+ metadataMap.put(ResultsMetadataConstants.GROUP_NAME, tableName);
+ metadataMap.put(ResultsMetadataConstants.ELEMENT_NAME, columnName);
+ metadataMap.put(ResultsMetadataConstants.DATA_TYPE, dataType);
+ metadataMap.put(ResultsMetadataConstants.PRECISION, ResultsMetadataDefaults.getDefaultPrecision(dataType));
+ metadataMap.put(ResultsMetadataConstants.RADIX, new Integer(10));
+ metadataMap.put(ResultsMetadataConstants.SCALE, new Integer(0));
+ metadataMap.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
+ metadataMap.put(ResultsMetadataConstants.CASE_SENSITIVE, caseSensitive);
+ metadataMap.put(ResultsMetadataConstants.NULLABLE, nullable);
+ metadataMap.put(ResultsMetadataConstants.SEARCHABLE, searchable);
+ metadataMap.put(ResultsMetadataConstants.SIGNED, signed);
+ metadataMap.put(ResultsMetadataConstants.WRITABLE, writable);
+ metadataMap.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
+ metadataMap.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.getMaxDisplaySize(dataType));
+
+ return metadataMap;
+ }
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -40,7 +40,7 @@
* Get the execution property value.
* @param name Execution property name
* @return Execution property value or null if not set
- * @deprecated
+ * @deprecated use show statement
*/
String getExecutionProperty(String name);
@@ -48,7 +48,7 @@
* Set the execution property value.
* @param name Execution property name
* @param value Execution property value
- * @deprecated use set property value
+ * @deprecated use set statement
*/
void setExecutionProperty(String name, String value);
@@ -67,6 +67,7 @@
* SHOWPLAN DEBUG. If no debug output was requested, this
* method will return null.
* @return Debug log or null if no log exists
+ * @deprecated use show statement
*/
String getDebugLog();
@@ -74,6 +75,7 @@
* Get collection of annotations from the query planner from
* the last command executed on the Statement
* @return Collection of {@link Annotation}s, may return null
+ * @deprecated use show statement
*/
Collection<Annotation> getAnnotations();
Modified: trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties 2010-07-14 16:27:29 UTC (rev 2342)
@@ -248,4 +248,7 @@
EmbeddedDataSource.The_configFile_property_is_null=The configFile property is null.
EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read=The configFile does not exist or cannot be read.
EmbeddedTransport.no_classpath=The Embedded Service Bootstrap does not contain a dqp.classpath property. Add the dqp.classpath property or specify unifiedClassLoader=true on the DQP JDBC URL.
-EmbeddedTransport.invalid_dqpproperties_path=The path {0} is invalid. Please check your file system and correct your JDBC URL.
\ No newline at end of file
+EmbeddedTransport.invalid_dqpproperties_path=The path {0} is invalid. Please check your file system and correct your JDBC URL.
+
+StatementImpl.show_update_count=SHOW does not return an update count
+StatementImpl.set_result_set=SET does not return a result set.
\ No newline at end of file
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml 2010-07-14 16:27:29 UTC (rev 2342)
@@ -9,8 +9,8 @@
<sect1 id="connecting">
<title>Connecting</title>
<para>An AdminAPI connection, which is represented by the <code>org.teiid.adminapi.Admin</code> interface, is obtained through the <code>org.teiid.adminapi.AdminFactory.createAdmin</code> methods.
- <code>AdminFactory</code> is a singleton, see <code>AdminFactory.getInstance()</code>, so there is no need to create instance. The <code>Admin</code> instance automatically tests its connection and reconnects to a server in the event of a failure. The <code>close</code> method should be called to terminate the connection.</para>
- <para>See your Teiid installation for the appropriate admin port, which by default 31443.</para>
+ <code>AdminFactory</code> is a singleton, see <code>AdminFactory.getInstance()</code>. The <code>Admin</code> instance automatically tests its connection and reconnects to a server in the event of a failure. The <code>close</code> method should be called to terminate the connection.</para>
+ <para>See your Teiid installation for the appropriate admin port - the default is 31443.</para>
</sect1>
<sect1 id="admin_methods">
<title>Admin Methods</title>
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-07-14 16:18:49 UTC (rev 2341)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-07-14 16:27:29 UTC (rev 2342)
@@ -26,9 +26,11 @@
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.SQLXML;
import java.sql.Statement;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
@@ -36,14 +38,18 @@
@SuppressWarnings("nls")
public class TestQueryPlans {
- private Connection conn;
+ private static Connection conn;
- @Before public void setUp() throws Exception {
+ @BeforeClass public static void setUp() throws Exception {
FakeServer server = new FakeServer();
server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @AfterClass public static void tearDown() throws Exception {
+ conn.close();
+ }
+
@Test public void testNoExec() throws Exception {
Statement s = conn.createStatement();
s.execute("set noexec on");
@@ -60,13 +66,39 @@
ResultSet rs = s.executeQuery("select * from all_tables");
assertNotNull(s.unwrap(TeiidStatement.class).getPlanDescription());
assertNull(s.unwrap(TeiidStatement.class).getDebugLog());
+
+ rs = s.executeQuery("show plan");
+ assertTrue(rs.next());
+ SQLXML plan = rs.getSQLXML(2);
+ assertTrue(plan.getString().startsWith("<?xml"));
+ assertNull(rs.getObject("DEBUG_LOG"));
+ assertNotNull(rs.getObject("PLAN_TEXT"));
+
s.execute("SET showplan debug");
rs = s.executeQuery("select * from all_tables");
assertNotNull(s.unwrap(TeiidStatement.class).getDebugLog());
+
+ rs = s.executeQuery("show plan");
+ assertTrue(rs.next());
+ assertNotNull(rs.getObject("DEBUG_LOG"));
+
s.execute("SET showplan off");
rs = s.executeQuery("select * from all_tables");
assertNull(s.unwrap(TeiidStatement.class).getPlanDescription());
assertTrue(rs.next());
}
+ @Test public void testShow() throws Exception {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("show all");
+ assertTrue(rs.next());
+ assertNotNull(rs.getString("NAME"));
+
+ s.execute("set showplan on");
+
+ rs = s.executeQuery("show showplan");
+ rs.next();
+ assertEquals("on", rs.getString(1));
+ }
+
}
14 years, 5 months
teiid SVN: r2341 - in trunk: jboss-integration/src/main/java/org/teiid/adminapi/jboss and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-07-14 12:18:49 -0400 (Wed, 14 Jul 2010)
New Revision: 2341
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1142 & TEIID-1055 These changes Teiid to work in a secured server (EAP 5.1) and provide access to the profile service
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-14 01:59:05 UTC (rev 2340)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-14 16:18:49 UTC (rev 2341)
@@ -1,21 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <interceptor xmlns="urn:jboss:aop-beans:1.0" name="JndiAspect" class="org.jboss.aop.microcontainer.aspects.jndi.JndiIntroduction">
- <property name="env">
- <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
- <entry><key>java.naming.factory.initial</key><value>org.jnp.interfaces.NamingContextFactory</value></entry>
- </map>
- </property>
- </interceptor>
-
- <introduction xmlns="urn:jboss:aop-beans:1.0" class="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">
- <interfaces>org.jboss.kernel.spi.dependency.KernelControllerContextAware</interfaces>
- </introduction>
-
- <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* $instanceof{org.jboss.kernel.spi.dependency.KernelControllerContextAware}->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
- <interceptor-ref name="JndiAspect"/>
- </bind>
<!-- Teiid Services -->
<bean name="SessionService" class="org.teiid.services.SessionServiceImpl">
@@ -63,7 +47,8 @@
</bean>
<bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
- <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/engine-deployer")</annotation>
+ <property name="jndiName">teiid/engine-deployer</property>
+ <property name="profileService"><inject bean="ProfileService"/></property>
<property name="jdbcSocketConfiguration"><inject bean="JdbcSocketConfiguration"/></property>
<property name="adminSocketConfiguration"><inject bean="AdminSocketConfiguration"/></property>
<property name="workManager"><inject bean="WorkManager"/></property>
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-07-14 01:59:05 UTC (rev 2340)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-07-14 16:18:49 UTC (rev 2341)
@@ -45,6 +45,11 @@
import org.teiid.adminapi.AdminComponentException;
public class AdminProvider {
+
+ public static Admin getLocal(final ProfileService profileService) {
+ ProfileConnection pc = new ProfileConnection(profileService);
+ return new Admin(pc.getManagementView(), pc.getDeploymentManager());
+ }
public static Admin getLocal() throws AdminComponentException {
ProfileConnection pc = new ProfileConnection();
@@ -89,9 +94,9 @@
private String password;
- public ProfileConnection() throws AdminComponentException {
- this.profileService = connect(null, null, null);
- }
+ public ProfileConnection(final ProfileService profileService) {
+ this.profileService = profileService;
+ }
public ProfileConnection(String providerURL, String user, String password) throws AdminComponentException {
this.userName = user;
@@ -113,7 +118,7 @@
// local connection
if (providerURL == null) {
InitialContext ic = new InitialContext();
- return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
+ return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
}
Properties env = new Properties();
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-07-14 01:59:05 UTC (rev 2340)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-07-14 16:18:49 UTC (rev 2341)
@@ -30,6 +30,8 @@
import java.util.Date;
import java.util.List;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkManager;
import javax.transaction.TransactionManager;
@@ -42,6 +44,8 @@
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.util.naming.Util;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
@@ -96,6 +100,9 @@
private transient ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
private transient VDBRepository vdbRepository;
+ private transient ProfileService profileService;
+ private transient String jndiName;
+
public RuntimeEngineDeployer() {
// TODO: this does not belong here
LogManager.setLogListener(new Log4jListener());
@@ -136,9 +143,27 @@
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "admin connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_started", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
+ if (jndiName != null) {
+ final InitialContext ic ;
+ try {
+ ic = new InitialContext() ;
+ Util.bind(ic, jndiName, this) ;
+ } catch (final NamingException ne) {
+ // Add jndi_failed to bundle
+ LogManager.logError(LogConstants.CTX_RUNTIME, ne, IntegrationPlugin.Util.getString("jndi_failed", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
+ }
+ }
}
public void stop() {
+ if (jndiName != null) {
+ final InitialContext ic ;
+ try {
+ ic = new InitialContext() ;
+ Util.unbind(ic, jndiName) ;
+ } catch (final NamingException ne) {
+ }
+ }
try {
this.dqpCore.stop();
@@ -164,11 +189,15 @@
this.dqpCore.start(this);
this.logon = new LogonImpl(this.sessionService, "teiid-cluster"); //$NON-NLS-1$
- try {
- this.admin = AdminProvider.getLocal();
- } catch (AdminComponentException e) {
- throw new TeiidRuntimeException(e.getCause());
- }
+ if (profileService != null) {
+ this.admin = AdminProvider.getLocal(profileService);
+ } else {
+ try {
+ this.admin = AdminProvider.getLocal();
+ } catch (AdminComponentException e) {
+ throw new TeiidRuntimeException(e.getCause());
+ }
+ }
}
/**
@@ -234,6 +263,14 @@
this.vdbRepository = repo;
}
+ public void setProfileService(final ProfileService profileService) {
+ this.profileService = profileService ;
+ }
+
+ public void setJndiName(final String jndiName) {
+ this.jndiName = jndiName ;
+ }
+
@Override
@ManagementOperation(description="Requests for perticular session", impact=Impact.ReadOnly,params={@ManagementParameter(name="sessionId",description="The session Identifier")})
public List<RequestMetadata> getRequestsForSession(String sessionId) {
14 years, 5 months