teiid SVN: r1870 - in branches/JCA: client/src/main/resources and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-23 17:22:21 -0500 (Tue, 23 Feb 2010)
New Revision: 1870
Removed:
branches/JCA/runtime/src/main/java/org/teiid/deployers/DefParser.java
Modified:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/JCA/client/src/main/resources/vdb-deployer.xsd
branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
Log:
TEIID-998: Replaced the DEF file parser with JAXB complient parser
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-02-23 22:22:21 UTC (rev 1870)
@@ -68,6 +68,9 @@
})
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="model"))
public class ModelMetaData extends AdminObjectImpl implements Model {
+
+ private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY = "supports-multi-source-bindings"; //$NON-NLS-1$
+ private static final String VISIBILITY_KEY = "visibility"; //$NON-NLS-1$
private static final long serialVersionUID = 3714234763056162230L;
@@ -77,12 +80,12 @@
@XmlElement(name = "connector-ref")
protected String connectorReference;
- private String modelType = ""; //$NON-NLS-1$
+ @XmlAttribute(name = "type", required = true)
+ private String modelType; //$NON-NLS-1$
+
private String modelURI = ""; //$NON-NLS-1$
- private boolean supportsMultiSourceBindings = false;
private String path;
private String uuid;
- private Visibility visibility;
@ManagementProperty(description="Model Name", readOnly=true)
@ManagementObjectID(type="model")
@@ -123,7 +126,7 @@
@Override
@ManagementProperty(description = "Is Model Visible", readOnly=true)
public boolean isVisible() {
- return visibility == Visibility.PUBLIC;
+ return getVisibility() == Visibility.PUBLIC;
}
@Override
@@ -141,7 +144,8 @@
@Override
@ManagementProperty(description = "Does Model supports multi-source bindings", readOnly=true)
public boolean isSupportsMultiSourceBindings() {
- return this.supportsMultiSourceBindings;
+ String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
+ return Boolean.parseBoolean(supports);
}
@Override
@@ -184,7 +188,7 @@
public void setSupportsMultiSourceBindings(boolean supports) {
- this.supportsMultiSourceBindings = supports;
+ addProperty(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY, Boolean.toString(supports));
}
public void setModelType(String modelType) {
@@ -208,10 +212,15 @@
}
public Visibility getVisibility(){
- return this.visibility;
+ String visibility = getPropertyValue(VISIBILITY_KEY);
+ if (visibility != null) {
+ Visibility v = Visibility.valueOf(visibility);
+ return v;
+ }
+ return Visibility.PUBLIC;
}
public void setVisibility(Visibility visibility) {
- this.visibility = visibility;
+ addProperty(VISIBILITY_KEY, visibility.name());
}
}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-02-23 22:22:21 UTC (rev 1870)
@@ -58,6 +58,8 @@
})
@XmlRootElement(name = "vdb")
public class VDBMetaData extends AdminObjectImpl implements VDB {
+ private static final String STATUS_KEY = "status"; //$NON-NLS-1$
+
private static final long serialVersionUID = -4723595252013356436L;
@XmlElement(name = "model", required = true, type = ModelMetaData.class)
@@ -80,7 +82,6 @@
private List<String> errors;
private String fileUrl = null;
- private Status status;
public VDBMetaData() {
// auto add sytem model.
@@ -110,11 +111,15 @@
@Override
@ManagementProperty(description="VDB Status", readOnly=true)
public Status getStatus() {
- return this.status;
+ String status = getPropertyValue(STATUS_KEY);
+ if (status != null) {
+ return VDB.Status.valueOf(status);
+ }
+ return VDB.Status.ACTIVE;
}
public void setStatus(Status s) {
- this.status = s;
+ addProperty(STATUS_KEY, s.name());
}
@Override
Modified: branches/JCA/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- branches/JCA/client/src/main/resources/vdb-deployer.xsd 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/client/src/main/resources/vdb-deployer.xsd 2010-02-23 22:22:21 UTC (rev 1870)
@@ -18,6 +18,7 @@
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="type" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="connector-mapping" type="reference-mapping" minOccurs="0" maxOccurs="unbounded"/>
Modified: branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-02-23 22:22:21 UTC (rev 1870)
@@ -58,6 +58,7 @@
ModelMetaData modelTwo = new ModelMetaData();
modelTwo.setName("model-two");
modelTwo.setConnectorReference("binding-two-ref");
+ modelTwo.setModelType("virtual");
modelTwo.addProperty("model-prop", "model-value");
vdb.addModel(modelTwo);
@@ -76,7 +77,7 @@
marshell.marshal(vdb, sw);
Unmarshaller un = jc.createUnmarshaller();
- //System.out.println(sw.toString());
+ System.out.println(sw.toString());
vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
@@ -92,7 +93,7 @@
modelOne = vdb.getModel("model-one");
assertEquals("model-one", modelOne.getName());
assertTrue(modelOne.getConnectorBindingNames().contains("java:mybinding"));
- assertEquals("", modelOne.getModelType()); // this is not persisted in the XML
+ assertEquals("physical", modelOne.getModelType());
assertEquals("model-value", modelOne.getPropertyValue("model-prop"));
@@ -100,7 +101,7 @@
assertEquals("model-two", modelTwo.getName());
assertTrue(modelTwo.getConnectorBindingNames().isEmpty());
assertEquals("binding-two-ref", modelTwo.getConnectorReference());
- assertEquals("", modelTwo.getModelType()); // this is not persisted in the XML
+ assertEquals("virtual", modelTwo.getModelType()); // this is not persisted in the XML
assertEquals("model-value", modelTwo.getPropertyValue("model-prop"));
Deleted: branches/JCA/runtime/src/main/java/org/teiid/deployers/DefParser.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/DefParser.java 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/DefParser.java 2010-02-23 22:22:21 UTC (rev 1870)
@@ -1,154 +0,0 @@
-package org.teiid.deployers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.Visibility;
-import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.VDBMetaData;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.xml.XMLReaderWriter;
-import com.metamatrix.common.xml.XMLReaderWriterImpl;
-
-public class DefParser {
-
- public static VDBMetaData load(InputStream defStream) throws IOException, MetaMatrixComponentException {
- VDBMetaData vdb = new VDBMetaData();
- try {
- XMLReaderWriter reader = new XMLReaderWriterImpl();
- Document doc = reader.readDocument(defStream);
- Element root = doc.getRootElement();
-
- // load VDBInfo section
- loadVDBInfoSection(vdb, root);
-
- // add Models section
- loadModelsSection(vdb, root);
-
- } catch (JDOMException e) {
- throw new MetaMatrixComponentException(e);//$NON-NLS-1$
- }
- return vdb;
- }
-
- private static void loadVDBInfoSection(VDBMetaData vdb, Element root) throws IOException {
-
- Element vdbInfoElement = root.getChild(VDBInfoFragment.ELEMENT);
- if (vdbInfoElement == null) {
- throw new IOException("VDBDefnXMLHelper.Invalid_xml_section"); //$NON-NLS-1$
- }
-
- Properties vdbProps = getElementProperties(vdbInfoElement);
- if (vdbProps == null || vdbProps.isEmpty()) {
- throw new IOException("VDBDefnXMLHelper.No_properties_defined_to_create_defn"); //$NON-NLS-1$
- }
-
- vdb.setName((String)vdbProps.remove(VDBInfoFragment.NAME));
- String version = (String)vdbProps.remove(VDBInfoFragment.VERSION);
- vdb.setVersion(version!=null?Integer.parseInt(version):1);//$NON-NLS-1$
- vdb.setDescription((String)vdbProps.remove(VDBInfoFragment.DESCRIPTION));
- if (TRUE.equals(vdbProps.remove(VDBInfoFragment.ACTIVE))) {
- vdb.setStatus(VDB.Status.ACTIVE);
- }
- else {
- vdb.setStatus(VDB.Status.INACTIVE);
- }
- vdb.setProperties(vdbProps);
- }
-
- private static void loadModelsSection(VDBMetaData vdb, Element root) {
- Collection<Element> modelsElements = root.getChildren(ModelFragment.ELEMENT);
- for(Element modelElement:modelsElements) {
- vdb.addModel(loadModel(modelElement));
- }
- }
-
- private static ModelMetaData loadModel(Element modelElement) {
- Properties props = getElementProperties(modelElement);
-
- ModelMetaData model = new ModelMetaData();
- model.setName(props.getProperty(ModelFragment.NAME));
- props.remove(ModelFragment.NAME);
-
- String visibility = props.getProperty(ModelFragment.VISIBILITY, Visibility.PUBLIC.toString());
- props.remove(ModelFragment.VISIBILITY);
- model.setVisibility(Visibility.valueOf(Visibility.class, visibility.toUpperCase()));
-
- model.setSupportsMultiSourceBindings(Boolean.parseBoolean(props.getProperty(ModelFragment.MULTI_SOURCE_ENABLED)));
- props.remove(ModelFragment.MULTI_SOURCE_ENABLED);
-
- model.setProperties(props);
-
- Element cbElement = modelElement.getChild(ModelFragment.CONNECTOR_BINDINGS_ELEMENT);
- if (cbElement != null) {
- Collection<Element> bindingElements = cbElement.getChildren(ModelFragment.CONNECTOR);
- for(Element bindingElement:bindingElements) {
- String connectorName = bindingElement.getAttributeValue(ModelFragment.CONNECTOR_ATTRIBUTE_NAME);
- model.addConnectorBinding(connectorName);
- }
- }
- return model;
- }
-
- protected static Properties getElementProperties(Element rootElement) {
- Properties properties = new Properties();
- if(rootElement == null) {
- return properties;
- }
- // obtain any defaults that are defined
- List propertyElements = rootElement.getChildren(PropertyFragment.ELEMENT);
- if (propertyElements != null) {
- Iterator iterator = propertyElements.iterator();
- for (int i = 1; iterator.hasNext(); i++) {
- Element element = (Element)iterator.next();
- String name = element.getAttributeValue(PropertyFragment.ATTRIBUTE_NAME);
- String value = element.getAttributeValue(PropertyFragment.ATTRIBUTE_VALUE);
- if (name != null && name.length() > 0) {
- properties.setProperty(name, value);
- }
- }
- }
- return properties;
- }
-
- static final String ROOT_ELEMENT = "VDB"; //$NON-NLS-1$
- private static final String TRUE = "true"; //$NON-NLS-1$
- private static class VDBInfoFragment {
- public static final String ELEMENT = "VDBInfo"; //$NON-NLS-1$
- public static final String NAME = "Name"; //$NON-NLS-1$
- public static final String VERSION = "Version"; //$NON-NLS-1$
-
- // Optional - defaults to VDB Name
- public static final String DESCRIPTION = "Description"; //$NON-NLS-1$
- public static final String ACTIVE = "Active"; //$NON-NLS-1$
- }
-
- private static class PropertyFragment {
- public static final String ELEMENT = "Property"; //$NON-NLS-1$
- public static final String ATTRIBUTE_NAME = "Name"; //$NON-NLS-1$
- public static final String ATTRIBUTE_VALUE = "Value"; //$NON-NLS-1$
- }
-
- private static class ModelFragment {
- public static final String ELEMENT = "Model"; //$NON-NLS-1$
- public static final String NAME = "Name"; //$NON-NLS-1$
-
- // Optional - Default - physical=false, virtual=true
- public static final String VISIBILITY = "Visibility"; //$NON-NLS-1$
- public static final String MULTI_SOURCE_ENABLED = "MultiSourceEnabled"; //$NON-NLS-1$
-
- // Optional - no binding set
- public static final String CONNECTOR_BINDINGS_ELEMENT = "ConnectorBindings"; //$NON-NLS-1$
- public static final String CONNECTOR = "Connector"; //$NON-NLS-1$
- public static final String CONNECTOR_ATTRIBUTE_NAME = "Name"; //$NON-NLS-1$
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-02-23 22:22:21 UTC (rev 1870)
@@ -25,11 +25,13 @@
import java.io.IOException;
import java.util.ArrayList;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.virtual.VirtualFile;
-import org.teiid.adminapi.Visibility;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.api.ConnectorException;
@@ -39,7 +41,6 @@
import org.teiid.metadata.CompositeMetadataStore;
import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.vdb.ModelType;
public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
private VDBRepository vdbRepository;
@@ -53,15 +54,10 @@
@Override
protected VDBMetaData parse(VFSDeploymentUnit unit, VirtualFile file, VDBMetaData root) throws Exception {
- VDBMetaData def = DefParser.load(file.openStream());
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
+ Unmarshaller un = jc.createUnmarshaller();
+ VDBMetaData def = (VDBMetaData)un.unmarshal(file.openStream());
- // Set the additional model properties which are traditionally on the VDB based Models.
- for(ModelMetaData model:def.getModels()) {
- model.setModelType(ModelType.getString(ModelType.PHYSICAL));
- model.setVisibility(Visibility.PUBLIC);
- model.setSupportsMultiSourceBindings(false);
- }
-
def.setUrl(unit.getRoot().toURL().toExternalForm());
log.debug("VDB "+unit.getRoot().getName()+" has been parsed.");
Modified: branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-02-23 20:56:05 UTC (rev 1869)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-02-23 22:22:21 UTC (rev 1870)
@@ -27,6 +27,9 @@
import java.util.List;
import java.util.Map;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.virtual.VirtualFile;
@@ -66,7 +69,10 @@
@Override
protected <U> U parse(VFSDeploymentUnit unit, Class<U> expectedType, VirtualFile file, Object root) throws Exception {
if (expectedType.equals(VDBMetaData.class)) {
- VDBMetaData def = DefParser.load(file.openStream());
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
+ Unmarshaller un = jc.createUnmarshaller();
+ VDBMetaData def = (VDBMetaData)un.unmarshal(file.openStream());
+
return expectedType.cast(def);
}
else if (expectedType.equals(ManifestMetaData.class)) {
14 years, 10 months
teiid SVN: r1869 - branches/JCA/console.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-23 15:56:05 -0500 (Tue, 23 Feb 2010)
New Revision: 1869
Modified:
branches/JCA/console/pom.xml
Log:
Misc: Fixing the compilation error in the IDE
Modified: branches/JCA/console/pom.xml
===================================================================
--- branches/JCA/console/pom.xml 2010-02-23 20:38:54 UTC (rev 1868)
+++ branches/JCA/console/pom.xml 2010-02-23 20:56:05 UTC (rev 1869)
@@ -239,6 +239,12 @@
<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>mc4j</groupId>
14 years, 10 months
teiid SVN: r1868 - in branches/JCA: build/kit-jboss-container/deploy/teiid and 15 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-23 15:38:54 -0500 (Tue, 23 Feb 2010)
New Revision: 1868
Removed:
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-engine.rar/
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-runtime-ds.xml
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPManagementView.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/configuration/
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/authorization/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/spi/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/
branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidResourceAdapter.java
branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java
branches/JCA/runtime/src/main/java/org/teiid/adminapi/
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/spi/
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/
Modified:
branches/JCA/build/assembly/jboss-container/dist.xml
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/JCA/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
Log:
TEIID-862: Teiid engine is exposed as simple bean to avoid the unnecessary dependency issues during the start up. The work manager and Txn manager are grabbed from the Jboss container directly
Modified: branches/JCA/build/assembly/jboss-container/dist.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-23 20:38:54 UTC (rev 1868)
@@ -85,7 +85,7 @@
<binaries>
<includeDependencies>false</includeDependencies>
<unpack>false</unpack>
- <outputDirectory>deploy/teiid-connectors</outputDirectory>
+ <outputDirectory>deploy/teiid/connectors</outputDirectory>
</binaries>
</moduleSet>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-02-23 20:38:54 UTC (rev 1868)
@@ -16,8 +16,6 @@
<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>
-
- <bean name="SecurityHelper" class="org.teiid.jboss.JBossSecurityHelper"/>
<!-- Teiid Services -->
<bean name="AuthorizationService" class="org.teiid.services.AuthorizationServiceImpl">
@@ -63,17 +61,40 @@
<bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
<annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/engine-deployer")</annotation>
- <property name="securityHelper"><inject bean="ContainerHelper"/></property>
- <property name="containerHelper"><inject bean="ContainerHelper"/></property>
<property name="jdbcSocketConfiguration"><inject bean="JdbcSocketConfiguration"/></property>
<property name="adminSocketConfiguration"><inject bean="AdminSocketConfiguration"/></property>
- <property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="workManager"><inject bean="WorkManager"/></property>
+ <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
<property name="authorizationService"><inject bean="AuthorizationService"/></property>
<property name="sessionService"><inject bean="SessionService"/></property>
<property name="bufferService"><inject bean="BufferService"/></property>
<property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
- <property name="DQPManager"><inject bean="DQPManager"/></property>
+ <property name="securityHelper"><inject bean="SecurityHelper"/></property>
+
+ <!-- Name of the process that uniquely identifies this process -->
+ <property name="processName">localhost</property>
+ <!-- Process pool maximum thread count. (default 16) Increase this value if your load includes a large number of XQueries or if the system's available processors is larger than 8. -->
+ <property name="maxThreads">16</property>
+ <!-- Query processor time slice, in milliseconds. (default 2000) -->
+ <property name="timeSliceInMilli">2000</property>
+ <!-- Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20480) -->
+ <property name="maxRowsFetchSize">20480</property>
+ <!-- The max lob chunk size in KB transferred each time when processing blobs, clobs(100KB default) -->
+ <property name="lobChunkSizeInKB">10</property>
+ <!-- The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250) -->
+ <property name="preparedPlanCacheMaxCount">250</property>
+ <!-- Maximum number of cached lookup tables. Note: this is a memory based cache and should be set to a value of at least 10 to accomidate system usage. (default 200) -->
+ <property name="codeTablesMaxCount">200</property>
+ <!-- Maximum number of records in a single lookup table (default 10000) -->
+ <property name="codeTablesMaxRowsPerTable">10000</property>
+ <!-- Maximum number of records in all lookup tables (default 200000) -->
+ <property name="codeTablesMaxRows">200000</property>
+ <!-- Max Entries allowed for ResultSet Cache -->
+ <property name="resultSetCacheMaxEntries">1024</property>
+ <!-- Enable Resultset Caching -->
+ <property name="resultSetCacheEnabled">true</property>
</bean>
+
<bean name="JdbcSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
Deleted: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-runtime-ds.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-runtime-ds.xml 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-runtime-ds.xml 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<connection-factories>
-
- <no-tx-connection-factory>
- <jndi-name>teiid/runtime-engine</jndi-name>
- <rar-name>teiid-engine.rar</rar-name>
- <connection-definition>com.metamatrix.common.comm.api.ServerConnectionFactory</connection-definition>
- <max-pool-size>20</max-pool-size>
- </no-tx-connection-factory>
-
-</connection-factories>
Modified: branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-02-23 20:38:54 UTC (rev 1868)
@@ -6,6 +6,7 @@
<bean name="VDBStructure" class="org.teiid.deployers.VDBStructure" />
<bean name="VDBRepository" class="org.teiid.deployers.VDBRepository"/>
<bean name="ConnectorManagerRepository" class="org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository"/>
+ <bean name="SecurityHelper" class="org.teiid.jboss.JBossSecurityHelper"/>
<bean name="VDBParserDeployer" class="org.teiid.deployers.VDBParserDeployer">
<property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
@@ -55,9 +56,6 @@
<property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
</bean>
- <bean name="DQPManager" class="org.teiid.dqp.internal.process.DQPManagementView">
- <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
- </bean>
<!-- JBOSS Cache -->
<!-- Uncomment for JBoss Cache -->
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -51,4 +51,19 @@
//list.add(manager.getProcess());
return list;
}
+
+ @Override
+ public void restart() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ }
+
+ @Override
+ public void shutdown(int millisToWait) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ }
+
+ @Override
+ public void setRuntimeProperty(String propertyName, String propertyValue) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ }
}
Modified: branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -48,7 +48,7 @@
import com.metamatrix.platform.security.api.SessionToken;
public class LocalServerConnection implements ServerConnection {
- private static final String TEIID_RUNTIME = "java:teiid/engine-deployer";
+ private static final String TEIID_RUNTIME = "teiid/engine-deployer";
private final LogonResult result;
private boolean shutdown;
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -23,7 +23,7 @@
import com.metamatrix.dqp.message.RequestMessage;
-public class DQPConfiguration {
+public class DQPConfiguration{
//Constants
static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
@@ -51,7 +51,6 @@
private boolean resultSetCacheEnabled = false;
private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
-
public String getProcessName() {
return processName;
}
@@ -64,7 +63,7 @@
return maxThreads;
}
- public void setMaxThreads(Integer maxThreads) {
+ public void setMaxThreads(int maxThreads) {
this.maxThreads = maxThreads;
}
@@ -72,14 +71,14 @@
return timeSliceInMilli;
}
- public void setTimeSliceInMilli(Integer timeSliceInMilli) {
+ public void setTimeSliceInMilli(int timeSliceInMilli) {
this.timeSliceInMilli = timeSliceInMilli;
}
public boolean isProcessDebugAllowed() {
return processDebugAllowed;
}
-
+
public void setProcessDebugAllowed(boolean processDebugAllowed) {
this.processDebugAllowed = processDebugAllowed;
}
@@ -88,7 +87,7 @@
return maxRowsFetchSize;
}
- public void setMaxRowsFetchSize(Integer maxRowsFetchSize) {
+ public void setMaxRowsFetchSize(int maxRowsFetchSize) {
this.maxRowsFetchSize = maxRowsFetchSize;
}
@@ -96,7 +95,7 @@
return lobChunkSizeInKB;
}
- public void setLobChunkSizeInKB(Integer lobChunkSizeInKB) {
+ public void setLobChunkSizeInKB(int lobChunkSizeInKB) {
this.lobChunkSizeInKB = lobChunkSizeInKB;
}
@@ -104,7 +103,7 @@
return preparedPlanCacheMaxCount;
}
- public void setPreparedPlanCacheMaxCount(Integer preparedPlanCacheMaxCount) {
+ public void setPreparedPlanCacheMaxCount(int preparedPlanCacheMaxCount) {
this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
}
@@ -112,7 +111,7 @@
return codeTablesMaxCount;
}
- public void setCodeTablesMaxCount(Integer codeTablesMaxCount) {
+ public void setCodeTablesMaxCount(int codeTablesMaxCount) {
this.codeTablesMaxCount = codeTablesMaxCount;
}
@@ -120,7 +119,7 @@
return codeTablesMaxRowsPerTable;
}
- public void setCodeTablesMaxRowsPerTable(Integer codeTablesMaxRowsPerTable) {
+ public void setCodeTablesMaxRowsPerTable(int codeTablesMaxRowsPerTable) {
this.codeTablesMaxRowsPerTable = codeTablesMaxRowsPerTable;
}
@@ -128,7 +127,7 @@
return codeTablesMaxRows;
}
- public void setCodeTablesMaxRows(Integer codeTablesMaxRows) {
+ public void setCodeTablesMaxRows(int codeTablesMaxRows) {
this.codeTablesMaxRows = codeTablesMaxRows;
}
@@ -144,7 +143,7 @@
return portNumber;
}
- public void setPortNumber(Integer portNumber) {
+ public void setPortNumber(int portNumber) {
this.portNumber = portNumber;
}
@@ -152,7 +151,7 @@
return this.maxResultSetCacheEntries;
}
- public void setResultSetCacheMaxEntries(Integer value) {
+ public void setResultSetCacheMaxEntries(int value) {
this.maxResultSetCacheEntries = value;
}
@@ -160,7 +159,7 @@
return this.resultSetCacheEnabled;
}
- public void setResultSetCacheEnabled(Boolean value) {
+ public void setResultSetCacheEnabled(boolean value) {
this.resultSetCacheEnabled = value;
- }
+ }
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -443,10 +443,6 @@
}
}
contextCache.removeSessionScopedCache(sessionId);
-
- if (this.sessionService != null) {
- this.sessionService.terminateSession(terminateeId, terminatorId);
- }
}
public boolean cancelRequest(long sessionId, long requestId) throws MetaMatrixComponentException {
@@ -841,6 +837,10 @@
this.connectorManagerRepository = repo;
}
+ public ConnectorManagerRepository getConnectorManagerRepository() {
+ return this.connectorManagerRepository;
+ }
+
public void setSessionService(SessionService service) {
this.sessionService = service;
service.setDqp(this);
Deleted: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPManagementView.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPManagementView.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPManagementView.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.dqp.internal.process;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.managed.api.ManagedOperation.Impact;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementOperation;
-import org.jboss.managed.api.annotation.ManagementParameter;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.impl.RequestMetadata;
-import org.teiid.adminapi.impl.SessionMetadata;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.dqp.client.DQPManagement;
-
-/**
- * Since DQPCore can not be made into a management bean itself as it has life cycle dependencies associated with
- * runtime connector. Even though we can intercept the deployer for runtime, injection of management bean was not occurring
- * through "ManagedObjectCreator" interface. This is brute force way to introduce a management bean then this can delegate calls to
- * what ever objects it has access to.
- */
-@ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
-public class DQPManagementView implements DQPManagement {
-
- private DQPCore dqp;
- private ConnectorManagerRepository connectorManagerRepository;
-
- public DQPCore getDQP() {
- return this.dqp;
- }
-
- public void setDQP(DQPCore dqp) {
- this.dqp = dqp;
- }
-
- public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
- this.connectorManagerRepository = repo;
- }
-
- @Override
- @ManagementOperation(description="Requests for perticular session", impact=Impact.ReadOnly,params={@ManagementParameter(name="sessionId",description="The session Identifier")})
- public List<RequestMetadata> getRequestsForSession(long sessionId) {
- return this.dqp.getRequestsForSession(sessionId);
- }
-
- @Override
- @ManagementOperation(description="Active requests", impact=Impact.ReadOnly)
- public List<RequestMetadata> getRequests() {
- return this.dqp.getRequests();
- }
-
- @Override
- @ManagementOperation(description="Get Runtime workmanager statistics", impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Use \"runtime\" for engine, or connector name for connector")})
- public WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier) {
- if ("runtime".equalsIgnoreCase(identifier)) {
- return this.dqp.getWorkManagerStatistics();
- }
- ConnectorManager cm = this.connectorManagerRepository.getConnectorManager(identifier);
- if (cm != null) {
- return cm.getWorkManagerStatistics();
- }
- return null;
- }
-
- @Override
- @ManagementOperation(description="Terminate a Session",params={@ManagementParameter(name="terminateeId",description="The session to be terminated")})
- public void terminateSession(long terminateeId) {
- this.dqp.terminateSession(terminateeId);
- }
-
- @Override
- @ManagementOperation(description="Cancel a Request",params={@ManagementParameter(name="sessionId",description="The session Identifier"), @ManagementParameter(name="requestId",description="The request Identifier")})
- public boolean cancelRequest(long sessionId, long requestId) throws AdminException {
- try {
- return this.dqp.cancelRequest(sessionId, requestId);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- @ManagementOperation(description="Get Cache types in the system", impact=Impact.ReadOnly)
- public Collection<String> getCacheTypes(){
- return this.dqp.getCacheTypes();
- }
-
- @Override
- @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
- public void clearCache(String cacheType) {
- this.dqp.clearCache(cacheType);
- }
-
- @Override
- @ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
- public Collection<SessionMetadata> getActiveSessions() throws AdminException {
- try {
- return this.dqp.getActiveSessions();
- } catch (SessionServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- @ManagementProperty(description="Active session count", use={ViewUse.STATISTIC}, readOnly=true)
- public int getActiveSessionsCount() throws AdminException{
- try {
- return this.dqp.getActiveSessionsCount();
- } catch (SessionServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- @ManagementOperation(description="Active Transactions", impact=Impact.ReadOnly)
- public Collection<org.teiid.adminapi.Transaction> getTransactions() {
- return this.dqp.getTransactions();
- }
-
- @Override
- @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
- public void terminateTransaction(String xid) throws AdminException {
- this.dqp.terminateTransaction(xid);
- }
-}
Modified: branches/JCA/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -44,17 +44,20 @@
public CompositeMetadataStore(MetadataStore metadataStore) {
- this.schemas.putAll(metadataStore.getSchemas());
- this.datatypes.addAll(metadataStore.getDatatypes());
+ addMetadataStore(metadataStore);
}
public CompositeMetadataStore(List<MetadataStore> metadataStores) {
for (MetadataStore metadataStore : metadataStores) {
- this.schemas.putAll(metadataStore.getSchemas());
- this.datatypes.addAll(metadataStore.getDatatypes());
+ addMetadataStore(metadataStore);
}
}
+ public void addMetadataStore(MetadataStore metadataStore) {
+ this.schemas.putAll(metadataStore.getSchemas());
+ this.datatypes.addAll(metadataStore.getDatatypes());
+ }
+
public Schema getSchema(String fullName)
throws QueryMetadataException {
Schema result = getSchemas().get(fullName);
Modified: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -79,6 +79,7 @@
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.TransactionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.jboss.deployers.RuntimeEngineDeployer;
import com.metamatrix.core.CoreConstants;
@@ -86,7 +87,6 @@
protected Logger log = Logger.getLogger(getClass());
private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
- private static final String TEIID_RUNTIME_ENGINE = "teiid/runtime-engine";
private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate";
private static final long serialVersionUID = 7081309086056911304L;
private static ComponentType VDBTYPE = new ComponentType("teiid", "vdb");
@@ -95,7 +95,7 @@
private static ComponentType TXTYPE = new ComponentType("ConnectionFactory", "Tx");
private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
private static ComponentType DSTYPE = new ComponentType("DataSource", "XA");
- private static String DQPNAME = "org.teiid.dqp.internal.process.DQPManagementView";
+ private static String DQPNAME = RuntimeEngineDeployer.class.getName();
private ManagementView view;
private DeploymentManager deploymentMgr;
@@ -301,13 +301,8 @@
throw new AdminComponentException(e);
}
}
-
+
@Override
- public void setRuntimeProperty(String propertyName, String propertyValue) throws AdminException {
- setConnectorBindingProperty(TEIID_RUNTIME_ENGINE, propertyName, propertyValue);
- }
-
- @Override
public void deleteConnectorBinding(String deployedName) throws AdminException {
ManagedComponent mc = getConnectorBindingComponent(deployedName);
if (mc != null) {
@@ -623,19 +618,7 @@
return null;
}
- @Override
- public void restart() throws AdminException {
- ConnectorBinding binding = getConnectorBinding(TEIID_RUNTIME_ENGINE);
- stopConnectorBinding(binding);
- startConnectorBinding(binding);
- }
- @Override
- public void shutdown(int millisToWait) throws AdminException {
- // TODO: implement the wait.
- ConnectorBinding binding = getConnectorBinding(TEIID_RUNTIME_ENGINE);
- stopConnectorBinding(binding);
- }
@Override
public Collection<String> getCacheTypes() throws AdminException {
Modified: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -21,32 +21,39 @@
*/
package org.teiid.jboss.deployers;
+import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.Collection;
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 org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
import org.teiid.SecurityHelper;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.adminapi.jboss.AdminProvider;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.ContainerServiceProvider;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPManagementView;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
@@ -58,180 +65,104 @@
import org.teiid.transport.SocketTransport;
import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.client.ExceptionUtil;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQPManagement;
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.BufferService;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.jdbc.LogConfigurationProvider;
+import com.metamatrix.jdbc.LogListernerProvider;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
-public class RuntimeEngineDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ClientServiceRegistry {
- private static final String TEIID_RUNTIME = "java:teiid/runtime-engine"; //$NON-NLS-1$
+@ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
+public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry {
+
protected Logger log = Logger.getLogger(getClass());
- //injected state
- private AuthorizationService authorizationService;
- private SecurityHelper securityHelper;
- private SessionService sessionService;
- private BufferService bufferService;
- private ConnectorManagerRepository connectorManagerRepository;
- private DQPManagementView dqpManagementView;
- private SocketTransport jdbcSocketTransport;
- private SocketConfiguration jdbcSocketConfiguration;
- private SocketTransport adminSocketTransport;
- private SocketConfiguration adminSocketConfiguration;
- //locally constructed client services
- private DQPCore dqp;
- private ILogon logon;
- private Admin admin;
- private ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
- public RuntimeEngineDeployer() {
- super(ManagedConnectionFactoryDeploymentGroup.class);
- setRelativeOrder(3000);
- }
+ private transient SocketConfiguration jdbcSocketConfiguration;
+ private transient SocketConfiguration adminSocketConfiguration;
+ private transient SocketTransport jdbcSocket;
+ private transient SocketTransport adminSocket;
+ private transient SecurityHelper securityHelper;
+
+ private transient DQPCore dqpCore = new DQPCore();
+ private transient ILogon logon;
+ private transient Admin admin;
+ private transient ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
+
+ public RuntimeEngineDeployer() {
+ // TODO: this does not belong here
+ LogManager.setLogConfiguration(new LogConfigurationProvider().get());
+ LogManager.setLogListener(new LogListernerProvider().get());
+ }
+
@Override
public <T> T getClientService(Class<T> iface)
throws ComponentNotFoundException {
return this.csr.getClientService(iface);
}
-
- @Override
- public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
- List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
-
- for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
- String connectorDefinition = data.getConnectionDefinition();
- if (connectorDefinition.equals(ServerConnectionFactory.class.getName())) {
- startEngine();
- log.info("Teiid Engine Started = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
- }
- }
- }
-
- @Override
- public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
- super.undeploy(unit, group);
- List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
-
- for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
- String connectorDefinition = data.getConnectionDefinition();
- if (connectorDefinition.equals(ServerConnectionFactory.class.getName())) {
- stopEngine();
- log.info("Teiid Engine Stopped = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
- }
- }
- }
- public void setSecurityHelper(SecurityHelper securityHelper) {
- this.securityHelper = securityHelper;
- }
-
- public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
- this.jdbcSocketConfiguration = socketConfig;
- }
-
- public void setAdminSocketConfiguration(SocketConfiguration socketConfig) {
- this.adminSocketConfiguration = socketConfig;
- }
-
- public void setAuthorizationService(AuthorizationService service) {
- this.authorizationService = service;
- }
-
- public void setSessionService(SessionService service) {
- this.sessionService = service;
- }
-
- public void setBufferService(BufferService service) {
- this.bufferService = service;
- }
-
- public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
- this.connectorManagerRepository = repo;
- }
-
- public void setDQPManager(DQPManagementView holder) {
- this.dqpManagementView = holder;
- }
-
- private void startEngine() throws DeploymentException {
- ContainerServiceProvider scf = null;
- try {
- InitialContext ic = new InitialContext();
- scf = (ContainerServiceProvider)ic.lookup(TEIID_RUNTIME);
- } catch (NamingException e) {
- throw new DeploymentException(e.getMessage());
- }
+ public void start() {
// create the necessary services
- createClientServices(scf);
-
- // Start the socket transport
- DQPConfiguration config = scf.getDQPConfiguration();
- if (config.getBindAddress() != null) {
- this.jdbcSocketConfiguration.setBindAddress(config.getBindAddress());
- }
- if (config.getPortNumber() > 0) {
- this.jdbcSocketConfiguration.setPortNumber(config.getPortNumber());
- }
-
- csr.registerClientService(ILogon.class, proxyService(ILogon.class, logon), com.metamatrix.common.util.LogConstants.CTX_SERVER);
- csr.registerClientService(ClientSideDQP.class, proxyService(ClientSideDQP.class, dqp), LogConstants.CTX_QUERY_SERVICE);
- csr.registerClientService(Admin.class, proxyService(Admin.class, admin), LogConstants.CTX_ADMIN_API);
+ createClientServices();
- this.jdbcSocketTransport = new SocketTransport(this.jdbcSocketConfiguration, csr);
- this.jdbcSocketTransport.start();
+ this.csr.registerClientService(ILogon.class, proxyService(ILogon.class, logon), com.metamatrix.common.util.LogConstants.CTX_SERVER);
+ this.csr.registerClientService(ClientSideDQP.class, proxyService(ClientSideDQP.class, this.dqpCore), LogConstants.CTX_QUERY_SERVICE);
+ this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin), LogConstants.CTX_ADMIN_API);
+
+ this.jdbcSocket = new SocketTransport(this.jdbcSocketConfiguration, csr);
+ this.jdbcSocket.start();
log.info("Teiid JDBC = " + (this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()); //$NON-NLS-1$
-
- this.adminSocketTransport = new SocketTransport(this.adminSocketConfiguration, csr);
- this.adminSocketTransport.start();
+
+ this.adminSocket = new SocketTransport(this.adminSocketConfiguration, csr);
+ this.adminSocket.start();
log.info("Teiid Admin = " + (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()); //$NON-NLS-1$
+ log.info("Teiid Engine Started = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
}
- private void stopEngine() {
- if (dqp != null) {
- dqp.stop();
- dqp = null;
+ public void stop() {
+
+ try {
+ this.dqpCore.stop();
+ } catch(MetaMatrixRuntimeException e) {
+ // this bean is already shutdown
}
// Stop socket transport(s)
- if (this.jdbcSocketTransport != null) {
- this.jdbcSocketTransport.stop();
- this.jdbcSocketTransport = null;
+ if (this.jdbcSocket != null) {
+ this.jdbcSocket.stop();
+ this.jdbcSocket = null;
}
- if (this.adminSocketTransport != null) {
- this.adminSocketTransport.stop();
- this.adminSocketTransport = null;
+ if (this.adminSocket != null) {
+ this.adminSocket.stop();
+ this.adminSocket = null;
}
+
+ log.info("Teiid Engine Stopped = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
}
- private void createClientServices(ContainerServiceProvider scf) throws DeploymentException {
- dqp = new DQPCore();
- dqp.setTransactionService(getTransactionService("localhost", scf.getXATerminator())); //$NON-NLS-1$
- dqp.setWorkManager(scf.getWorkManager());
- dqp.setAuthorizationService(authorizationService);
- dqp.setBufferService(bufferService);
- dqp.setSessionService(sessionService);
- dqp.setConnectorManagerRepository(connectorManagerRepository);
- dqp.setSecurityHelper(this.securityHelper);
- dqp.start(scf.getDQPConfiguration());
+ private void createClientServices() {
- dqpManagementView.setDQP(dqp);
+ this.dqpCore.start(this);
- this.logon = new LogonImpl(dqp.getSessionService(), "teiid-cluster"); //$NON-NLS-1$
+ this.logon = new LogonImpl(this.dqpCore.getSessionService(), "teiid-cluster"); //$NON-NLS-1$
try {
this.admin = AdminProvider.getLocal();
} catch (AdminComponentException e) {
- throw new DeploymentException(e.getCause());
- }
+ throw new MetaMatrixRuntimeException(e.getCause());
+ }
}
private TransactionService getTransactionService(String processName, XATerminator terminator) {
@@ -241,7 +172,7 @@
txnService.setXidFactory(new XidFactory());
return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
}
-
+
private <T> T proxyService(final Class<T> iface, final T instance) {
return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
@@ -284,6 +215,127 @@
if (context.getSubject() != null) {
securityHelper.clearSecurityContext(context.getSecurityDomain());
}
+ }
+
+ public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
+ this.jdbcSocketConfiguration = socketConfig;
+ }
+
+ public void setAdminSocketConfiguration(SocketConfiguration socketConfig) {
+ this.adminSocketConfiguration = socketConfig;
+ }
+
+ public void setXATerminator(XATerminator xaTerminator){
+ this.dqpCore.setTransactionService(getTransactionService("localhost", xaTerminator));
+ }
+
+ public void setWorkManager(WorkManager mgr) {
+ this.dqpCore.setWorkManager(mgr);
+ }
+
+ public void setAuthorizationService(AuthorizationService service) {
+ this.dqpCore.setAuthorizationService(service);
+ }
+
+ public void setSessionService(SessionService service) {
+ this.dqpCore.setSessionService(service);
+ }
+
+ public void setBufferService(BufferService service) {
+ this.dqpCore.setBufferService(service);
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.dqpCore.setConnectorManagerRepository(repo);
+ }
+
+ public void setSecurityHelper(SecurityHelper helper) {
+ this.securityHelper = helper;
+ this.dqpCore.setSecurityHelper(helper);
+ }
+
+ @Override
+ @ManagementOperation(description="Requests for perticular session", impact=Impact.ReadOnly,params={@ManagementParameter(name="sessionId",description="The session Identifier")})
+ public List<RequestMetadata> getRequestsForSession(long sessionId) {
+ return this.dqpCore.getRequestsForSession(sessionId);
+ }
+
+ @Override
+ @ManagementOperation(description="Active requests", impact=Impact.ReadOnly)
+ public List<RequestMetadata> getRequests() {
+ return this.dqpCore.getRequests();
+ }
+
+ @Override
+ @ManagementOperation(description="Get Runtime workmanager statistics", impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Use \"runtime\" for engine, or connector name for connector")})
+ public WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier) {
+ if ("runtime".equalsIgnoreCase(identifier)) {
+ return this.dqpCore.getWorkManagerStatistics();
+ }
+ ConnectorManager cm = this.dqpCore.getConnectorManagerRepository().getConnectorManager(identifier);
+ if (cm != null) {
+ return cm.getWorkManagerStatistics();
+ }
+ return null;
+ }
+
+ @Override
+ @ManagementOperation(description="Terminate a Session",params={@ManagementParameter(name="terminateeId",description="The session to be terminated")})
+ public void terminateSession(long terminateeId) {
+ this.dqpCore.getSessionService().terminateSession(terminateeId, SessionToken.getSession().getSessionID());
+ }
+
+ @Override
+ @ManagementOperation(description="Cancel a Request",params={@ManagementParameter(name="sessionId",description="The session Identifier"), @ManagementParameter(name="requestId",description="The request Identifier")})
+ public boolean cancelRequest(long sessionId, long requestId) throws AdminException {
+ try {
+ return this.dqpCore.cancelRequest(sessionId, requestId);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementOperation(description="Get Cache types in the system", impact=Impact.ReadOnly)
+ public Collection<String> getCacheTypes(){
+ return this.dqpCore.getCacheTypes();
+ }
+
+ @Override
+ @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
+ public void clearCache(String cacheType) {
+ this.dqpCore.clearCache(cacheType);
+ }
+
+ @Override
+ @ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
+ public Collection<SessionMetadata> getActiveSessions() throws AdminException {
+ try {
+ return this.dqpCore.getActiveSessions();
+ } catch (SessionServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementProperty(description="Active session count", use={ViewUse.STATISTIC}, readOnly=true)
+ public int getActiveSessionsCount() throws AdminException{
+ try {
+ return this.dqpCore.getActiveSessionsCount();
+ } catch (SessionServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementOperation(description="Active Transactions", impact=Impact.ReadOnly)
+ public Collection<org.teiid.adminapi.Transaction> getTransactions() {
+ return this.dqpCore.getTransactions();
+ }
+
+ @Override
+ @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
+ public void terminateTransaction(String xid) throws AdminException {
+ this.dqpCore.terminateTransaction(xid);
}
-
}
Deleted: branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,35 +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;
-
-import java.util.Properties;
-
-import javax.resource.spi.ConnectionRequestInfo;
-
-public class ConnectionInfo implements ConnectionRequestInfo {
- Properties properties;
-
- public ConnectionInfo(Properties properties) {
- this.properties = properties;
- }
-}
Deleted: branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,126 +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;
-
-import java.util.Properties;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionManager;
-import javax.resource.spi.XATerminator;
-import javax.resource.spi.work.WorkManager;
-
-import org.teiid.dqp.internal.process.ContainerServiceProvider;
-import org.teiid.dqp.internal.process.DQPConfiguration;
-
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.jdbc.LogConfigurationProvider;
-import com.metamatrix.jdbc.LogListernerProvider;
-
-
-/**
- * A factory class which creates the connections to the embedded DQP instance.
- * This is also responsible for initializing the DQP if the DQP instance is not
- * already alive.
- */
-public class TeiidConnectionFactory implements ServerConnectionFactory, ContainerServiceProvider {
-
- private TeiidResourceAdapter ra;
- private TeiidManagedConnectionFactory mcf;
- private ConnectionManager cxManager;
-
- public TeiidConnectionFactory(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
- this.ra = ra;
- this.mcf = mcf;
- this.cxManager = cxmanager;
- // TODO: this does not belong here
- LogManager.setLogConfiguration(new LogConfigurationProvider().get());
- LogManager.setLogListener(new LogListernerProvider().get());
- }
-
- @Override
- public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
- try {
- // this code will not be invoked as teiid does not use managed connection.
- return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties));
- } catch (ResourceException e) {
- throw new ConnectionException(e);
- }
- }
-
- @Override
- public WorkManager getWorkManager() {
- return this.ra.getWorkManager();
- }
-
- @Override
- public XATerminator getXATerminator() {
- return this.ra.getXATerminator();
- }
-
- @Override
- public DQPConfiguration getDQPConfiguration() {
- return mcf;
- }
-
-// public MMProcess getProcess() {
-//
-// Properties props = this.bootProperties;
-//
-// String hostName = getAddress().getHostName();
-// String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
-//
-// String[] identifierParts = new String[] {hostName, processName};
-// MMProcess process = new MMProcess(identifierParts);
-//
-// Runtime rt = Runtime.getRuntime();
-//
-// process.setEnabled(true);
-// process.setCreated(new Date(getStartTime()));
-// process.setInetAddress(getAddress());
-// process.setFreeMemory(rt.freeMemory());
-// process.setTotalMemory(rt.totalMemory());
-// process.setProperties(PropertiesUtils.clone(props));
-// process.setStartTime(new Date(this.starttime));
-//
-// if (this.socketTransport != null) {
-// SocketListenerStats socketStats = this.socketTransport.getStats();
-// if (socketStats != null) {
-// process.setSockets(socketStats.sockets);
-// process.setMaxSockets(socketStats.maxSockets);
-// process.setObjectsRead(socketStats.objectsRead);
-// process.setObjectsWritten(socketStats.objectsWritten);
-// }
-//
-// WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
-// process.setQueueWorkerPool(workerStats);
-//
-// process.setPort(this.socketTransport.getPort());
-// }
-// return process;
-// return null;
-// }
-}
Deleted: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,138 +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;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionEvent;
-import javax.resource.spi.ConnectionEventListener;
-import javax.resource.spi.ConnectionRequestInfo;
-import javax.resource.spi.LocalTransaction;
-import javax.resource.spi.ManagedConnection;
-import javax.resource.spi.ManagedConnectionMetaData;
-import javax.security.auth.Subject;
-import javax.transaction.xa.XAResource;
-
-import org.teiid.connector.api.ConnectorException;
-
-public class TeiidManagedConnection implements ManagedConnection {
- protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
- private PrintWriter log;
- private WrappedConnection conn;
-
- public TeiidManagedConnection() {
-
- }
-
- @Override
- public void associateConnection(Object handle) throws ResourceException {
- if (!(handle instanceof WrappedConnection)) {
- throw new ConnectorException("Wrong connection supplied to assosiate");
- }
- conn = (WrappedConnection)handle;
- conn.setManagedConnection(this);
- }
-
- @Override
- public void cleanup() throws ResourceException {
- if (this.conn != null) {
- this.conn.close();
- this.conn = null;
- }
- }
-
- @Override
- public void destroy() throws ResourceException {
- cleanup();
- }
-
- @Override
- public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
- ConnectionInfo ci = (ConnectionInfo)arg1;
- // This code will not be invoked as managed connection is not used anywhere.
- this.conn = new WrappedConnection(null);
- this.conn.setManagedConnection(this);
- return this.conn;
- }
-
- @Override
- public LocalTransaction getLocalTransaction() throws ResourceException {
- return null;
- }
-
- @Override
- public ManagedConnectionMetaData getMetaData() throws ResourceException {
- return null;
- }
-
- @Override
- public XAResource getXAResource() throws ResourceException {
- return null;
- }
-
- @Override
- public void addConnectionEventListener(ConnectionEventListener arg0) {
- synchronized (listeners) {
- listeners.add(arg0);
- }
- }
-
- @Override
- public void removeConnectionEventListener(ConnectionEventListener arg0) {
- synchronized (listeners) {
- listeners.remove(arg0);
- }
- }
-
- @Override
- public PrintWriter getLogWriter() throws ResourceException {
- return this.log;
- }
-
- @Override
- public void setLogWriter(PrintWriter arg0) throws ResourceException {
- this.log = arg0;
- }
-
- /**
- * This method called by wrapped Connection when the connection is closed by the user, which will in turn
- * remove the managed connection from the pool
- */
- void connectionClosed() {
- ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
- ce.setConnectionHandle(this.conn);
-
- ArrayList<ConnectionEventListener> copy = null;
- synchronized (this.listeners) {
- copy = new ArrayList<ConnectionEventListener>(this.listeners);
- }
-
- for(ConnectionEventListener l: copy) {
- l.connectionClosed(ce);
- }
- }
-
-}
Deleted: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,86 +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;
-
-import java.io.PrintWriter;
-import java.util.Set;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionManager;
-import javax.resource.spi.ConnectionRequestInfo;
-import javax.resource.spi.ManagedConnection;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.ResourceAdapter;
-import javax.resource.spi.ResourceAdapterAssociation;
-import javax.security.auth.Subject;
-
-import org.teiid.dqp.internal.process.DQPConfiguration;
-
-public class TeiidManagedConnectionFactory extends DQPConfiguration implements ManagedConnectionFactory,ResourceAdapterAssociation {
- private static final long serialVersionUID = -3728121947515526429L;
-
- private TeiidResourceAdapter ra;
- private PrintWriter log;
- private TeiidConnectionFactory connFactory;
-
- @Override
- public Object createConnectionFactory() throws ResourceException {
- return new ResourceException("Resource Adapter does not currently support running in a non-managed environment.");
- }
-
- @Override
- public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
- this.connFactory = new TeiidConnectionFactory(this.ra, this, arg0);
- return this.connFactory;
- }
-
- @Override
- public ManagedConnection createManagedConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
- return new TeiidManagedConnection();
- }
-
- @Override
- public PrintWriter getLogWriter() throws ResourceException {
- return this.log;
- }
-
- @Override
- public ManagedConnection matchManagedConnections(Set arg0, Subject arg1, ConnectionRequestInfo arg2) throws ResourceException {
- return null;
- }
-
- @Override
- public void setLogWriter(PrintWriter arg0) throws ResourceException {
- this.log = arg0;
- }
-
- @Override
- public ResourceAdapter getResourceAdapter() {
- return this.ra;
- }
-
- @Override
- public void setResourceAdapter(ResourceAdapter arg0) throws ResourceException {
- this.ra = (TeiidResourceAdapter)arg0;
- }
-}
Deleted: branches/JCA/runtime/src/main/java/org/teiid/TeiidResourceAdapter.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidResourceAdapter.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidResourceAdapter.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This 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 software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.teiid;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ActivationSpec;
-import javax.resource.spi.BootstrapContext;
-import javax.resource.spi.ResourceAdapter;
-import javax.resource.spi.ResourceAdapterInternalException;
-import javax.resource.spi.XATerminator;
-import javax.resource.spi.endpoint.MessageEndpointFactory;
-import javax.resource.spi.work.WorkManager;
-import javax.transaction.xa.XAResource;
-
-public class TeiidResourceAdapter implements ResourceAdapter {
- BootstrapContext ctx;
-
- @Override
- public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException {
- }
-
- @Override
- public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
- }
-
- @Override
- public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
- return new XAResource[0];
- }
-
- @Override
- public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
- this.ctx = ctx;
- }
-
- @Override
- public void stop() {
- // TODO: hook up to shutdown.
- }
-
- public WorkManager getWorkManager() {
- return ctx.getWorkManager();
- }
-
- public XATerminator getXATerminator() {
- return ctx.getXATerminator();
- }
-}
Deleted: branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -1,72 +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;
-
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.platform.security.api.LogonResult;
-
-public class WrappedConnection implements ServerConnection {
-
- private ServerConnection delegate;
- private TeiidManagedConnection mc;
- private boolean closed = false;
-
- public WrappedConnection(ServerConnection conn) {
- this.delegate = conn;
- }
-
- @Override
- public LogonResult getLogonResult() {
- return delegate.getLogonResult();
- }
-
- @Override
- public <T> T getService(Class<T> iface) {
- return delegate.getService(iface);
- }
-
- @Override
- public boolean isOpen() {
- return delegate.isOpen();
- }
-
- @Override
- public boolean isSameInstance(ServerConnection conn)
- throws CommunicationException {
- return delegate.isSameInstance(conn);
- }
-
- @Override
- public void close() {
- if (!this.closed && this.mc != null) {
- this.closed = true;
- this.mc.connectionClosed();
- this.mc = null;
- }
- }
-
- void setManagedConnection(TeiidManagedConnection teiidManagedConnection) {
- this.mc = teiidManagedConnection;
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-02-23 16:07:13 UTC (rev 1867)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-02-23 20:38:54 UTC (rev 1868)
@@ -128,6 +128,8 @@
throw new DeploymentException("System.vdb needs to be loaded before any other VDBs.");
}
+ store.addMetadataStore(systemStore);
+
Collection <FunctionMethod> methods = null;
if (udf != null) {
methods = udf.getMethods();
14 years, 10 months
teiid SVN: r1867 - in branches/JCA: build/kit-jboss-container/deploy/teiid/teiid-engine.rar/META-INF and 31 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-23 11:07:13 -0500 (Tue, 23 Feb 2010)
New Revision: 1867
Added:
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
branches/JCA/client/src/main/java/org/teiid/transport/ClientServiceRegistry.java
branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java
branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
branches/JCA/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/JCA/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
Removed:
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java
branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java
branches/JCA/common-internal/src/main/java/org/teiid/ContainerHelper.java
branches/JCA/common-internal/src/main/java/org/teiid/ContainerUtil.java
branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeWorkManager.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossContainerHelper.java
branches/JCA/runtime/src/main/java/org/teiid/services/MembershipServiceImpl.java
Modified:
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-engine.rar/META-INF/ra.xml
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java
branches/JCA/client/src/main/java/org/teiid/adminapi/Request.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java
branches/JCA/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java
branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
branches/JCA/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
branches/JCA/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java
branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java
branches/JCA/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
Log:
TEIID-833 refactoring of transaction processing methods so that there is no need for the server work pool (there is still a separate pool for admin calls). Also removed most lookups and minimized the info in request/response messages.
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-engine.rar/META-INF/ra.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-engine.rar/META-INF/ra.xml 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-engine.rar/META-INF/ra.xml 2010-02-23 16:07:13 UTC (rev 1867)
@@ -59,11 +59,6 @@
<config-property-value>2000</config-property-value>
</config-property>
<config-property>
- <description>Plan debug messages allowed. see option debug.</description>
- <config-property-name>OptionDebugAllowed</config-property-name>
- <config-property-type>java.lang.Boolean</config-property-type>
- </config-property>
- <config-property>
<description>Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20480)</description>
<config-property-name>MaxRowsFetchSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-02-23 16:07:13 UTC (rev 1867)
@@ -17,15 +17,7 @@
<interceptor-ref name="JndiAspect"/>
</bind>
- <bean name="ContainerHelper" class="org.teiid.jboss.JBossContainerHelper">
- <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/container-helper")</annotation>
- <property name="VDBRepository"><inject bean="VDBRepository"/></property>
- <property name="authorizationService"><inject bean="AuthorizationService"/></property>
- <property name="sessionService"><inject bean="SessionService"/></property>
- <property name="bufferService"><inject bean="BufferService"/></property>
- <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
- <property name="DQPManager"><inject bean="DQPManager"/></property>
- </bean>
+ <bean name="SecurityHelper" class="org.teiid.jboss.JBossSecurityHelper"/>
<!-- Teiid Services -->
<bean name="AuthorizationService" class="org.teiid.services.AuthorizationServiceImpl">
@@ -35,6 +27,7 @@
<bean name="SessionService" class="org.teiid.services.SessionServiceImpl">
<property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="securityHelper"><inject bean="SecurityHelper"/></property>
<!-- Comma separated list of domains to be used -->
<property name="securityDomains">teiid-security</property>
<property name="adminSecurityDomain">jmx-console</property>
@@ -47,12 +40,10 @@
<property name="cacheFactory"><inject bean="TeiidCache"/></property>
<property name="useDisk">true</property>
<property name="diskDirectory">${jboss.server.temp.dir}/teiid</property>
- <property name="bufferMemorySizeInMB">64</property>
- <!-- The max row count of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 256) -->
+ <!-- The max row count of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 512) -->
<property name="processorBatchSize">512</property>
- <!-- The max row count of a batch from a connector. Should be even multiple of processorBatchSize. (default 512) -->
+ <!-- The max row count of a batch from a connector. Should be even multiple of processorBatchSize. (default 1024) -->
<property name="connectorBatchSize">1024</property>
- <property name="maxProcessingBatches">8</property>
<!--
The number of batch columns to allow in memory (default 16384).
This value should be set lower or higher depending on the available memory to Teiid in the VM.
@@ -60,20 +51,28 @@
-->
<property name="maxReserveBatchColumns">16384</property>
<!--
- The number of batch columns guarenteed to a processing operation. Set this value lower if the workload typically
+ The number of batch columns guaranteed to a processing operation. Set this value lower if the workload typically
processes larger numbers of concurrent queries with large intermediate results from operations such as sorting,
grouping, etc. (default 124)
-->
<property name="maxProcessingBatchesColumns">128</property>
- <!-- Max File size in GB -->
- <property name="maxFileSize">2</property>
+ <!-- Max File size in MB -->
+ <property name="maxFileSize">2024</property>
<property name="maxOpenFiles">256</property>
</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="securityHelper"><inject bean="ContainerHelper"/></property>
<property name="containerHelper"><inject bean="ContainerHelper"/></property>
<property name="jdbcSocketConfiguration"><inject bean="JdbcSocketConfiguration"/></property>
<property name="adminSocketConfiguration"><inject bean="AdminSocketConfiguration"/></property>
+ <property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="authorizationService"><inject bean="AuthorizationService"/></property>
+ <property name="sessionService"><inject bean="SessionService"/></property>
+ <property name="bufferService"><inject bean="BufferService"/></property>
+ <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
+ <property name="DQPManager"><inject bean="DQPManager"/></property>
</bean>
<bean name="JdbcSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
Modified: branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-02-23 16:07:13 UTC (rev 1867)
@@ -50,6 +50,7 @@
</bean>
<bean name="ConnectorBindingDeployer" class="org.teiid.jboss.deployers.ConnectorBindingDeployer">
+ <property name="securityHelper"><inject bean="SecurityHelper"/></property>
<property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
<property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
</bean>
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -45,24 +45,21 @@
private BatchSerializer() {} // Uninstantiable
- private static final Map serializers = new HashMap(18, 1.0f);
+ private static ColumnSerializer defaultSerializer = new ColumnSerializer();
+
+ private static final Map<String, ColumnSerializer> serializers = new HashMap<String, ColumnSerializer>();
static {
serializers.put(DataTypeManager.DefaultDataTypes.BIG_DECIMAL, new BigDecimalColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.BIG_INTEGER, new BigIntegerColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.BLOB, new ObjectColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.BOOLEAN, new BooleanColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.BYTE, new ByteColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.CHAR, new CharColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.CLOB, new ObjectColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.XML, new ObjectColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.DATE, new DateColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.DOUBLE, new DoubleColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.FLOAT, new FloatColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.INTEGER, new IntColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.LONG, new LongColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.OBJECT, new ObjectColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.SHORT, new ShortColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.STRING, new StringColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.TIME, new TimeColumnSerializer());
serializers.put(DataTypeManager.DefaultDataTypes.TIMESTAMP, new TimestampColumnSerializer());
}
@@ -123,19 +120,10 @@
}
/**
- * An interface representing a stateless serializer of a batch column
- * @since 4.2
- */
- private static interface ColumnSerializer {
- void writeColumn(ObjectOutput out, int col, List[] results) throws IOException;
- void readColumn(ObjectInput in, int col, List[] batch, byte[] isNullNuffer) throws IOException, ClassNotFoundException;
- }
-
- /**
* An abstract serializer for native types
* @since 4.2
*/
- private static abstract class AbstractNativeColumnSerializer implements ColumnSerializer {
+ private static class ColumnSerializer {
public void writeColumn(ObjectOutput out, int col, List[] batch) throws IOException {
writeIsNullData(out, col, batch);
Object obj = null;
@@ -156,11 +144,15 @@
}
}
- protected abstract void writeObject(ObjectOutput out, Object obj) throws IOException;
- protected abstract Object readObject(ObjectInput in) throws IOException;
+ protected void writeObject(ObjectOutput out, Object obj) throws IOException {
+ out.writeObject(obj);
+ }
+ protected Object readObject(ObjectInput in) throws IOException, ClassNotFoundException {
+ return in.readObject();
+ }
}
- private static class IntColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class IntColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeInt(((Integer)obj).intValue());
}
@@ -169,7 +161,7 @@
}
}
- private static class LongColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class LongColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeLong(((Long)obj).longValue());
}
@@ -178,7 +170,7 @@
}
}
- private static class FloatColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class FloatColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeFloat(((Float)obj).floatValue());
}
@@ -187,7 +179,7 @@
}
}
- private static class DoubleColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class DoubleColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeDouble(((Double)obj).doubleValue());
}
@@ -196,7 +188,7 @@
}
}
- private static class ShortColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class ShortColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeShort(((Short)obj).shortValue());
}
@@ -205,7 +197,7 @@
}
}
- private static class BooleanColumnSerializer implements ColumnSerializer {
+ private static class BooleanColumnSerializer extends ColumnSerializer {
/* This implementation compacts the isNull and boolean data for non-null values into a byte[]
* by using a 8 bit mask that is bit-shifted to mask each value.
*/
@@ -270,7 +262,7 @@
}
}
- private static class ByteColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class ByteColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeByte(((Byte)obj).byteValue());
}
@@ -279,7 +271,7 @@
}
}
- private static class CharColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class CharColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeChar(((Character)obj).charValue());
}
@@ -288,61 +280,8 @@
}
}
- private static class StringColumnSerializer extends AbstractNativeColumnSerializer {
- /*
- * This implementation writes single-byte chars until it reaches a non-ascii char in the string,
- * at which point it starts writing two-byte characters. This implementation never writes more
- * than two bytes per char.
- */
+ private static class BigIntegerColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
- String val = (String)obj;
- int length = val.length();
- out.writeInt(length);
- boolean writingShort = true;
- char c;
- for (int i = 0 ; i < length; i++) {
- if (writingShort) {
- /* charAt() simply gets the char out of the underlying array. The assumption is that this would be quicker
- * calling getChars() which makes a copy of the underlying char[].
- */
- c = val.charAt(i);
- if (c < 0x80) {
- out.write(c);
- } else {
- out.write(0x80);
- writingShort = false;
- out.writeChar(c);
- }
- } else {
- out.writeChar(val.charAt(i));
- }
- }
- }
- protected Object readObject(ObjectInput in) throws IOException {
- int b;
- boolean readingShort;
- int length = in.readInt();
- char[] chars = new char[length];
- readingShort = true;
- for (int i = 0; i < length; i++) {
- if (readingShort) {
- b = in.read();
- if (b == 0x80) {
- readingShort = false;
- chars[i] = in.readChar();
- } else {
- chars[i] = ((char)b);
- }
- } else {
- chars[i] = in.readChar();
- }
- }
- return new String(chars);
- }
- }
-
- private static class BigIntegerColumnSerializer extends AbstractNativeColumnSerializer {
- protected void writeObject(ObjectOutput out, Object obj) throws IOException {
BigInteger val = (BigInteger)obj;
byte[] bytes = val.toByteArray();
out.writeInt(bytes.length);
@@ -356,7 +295,7 @@
}
}
- private static class BigDecimalColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class BigDecimalColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
BigDecimal val = (BigDecimal)obj;
out.writeInt(val.scale());
@@ -374,7 +313,7 @@
}
}
- private static class DateColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class DateColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeLong(((java.sql.Date)obj).getTime());
}
@@ -383,7 +322,7 @@
}
}
- private static class TimeColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class TimeColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
out.writeLong(((Time)obj).getTime());
}
@@ -392,7 +331,7 @@
}
}
- private static class TimestampColumnSerializer extends AbstractNativeColumnSerializer {
+ private static class TimestampColumnSerializer extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
Timestamp ts = (Timestamp)obj;
out.writeLong(ts.getTime());
@@ -404,24 +343,12 @@
return ts;
}
}
-
- private static class ObjectColumnSerializer implements ColumnSerializer {
- public void writeColumn(ObjectOutput out, int col, List[] results) throws IOException {
- for (int i = 0; i < results.length; i++) {
- out.writeObject(results[i].get(col));
- }
- }
- public void readColumn(ObjectInput in, int col, List[] batch, byte[] isNull) throws IOException, ClassNotFoundException {
- for (int i = 0; i < batch.length; i++) {
- batch[i].set(col, in.readObject());
- }
- }
- }
-
private static ColumnSerializer getSerializer(String type) {
- ColumnSerializer cs = (ColumnSerializer)serializers.get((type == null) ? DataTypeManager.DefaultDataTypes.OBJECT : type);
- assert cs != null;
+ ColumnSerializer cs = serializers.get((type == null) ? DataTypeManager.DefaultDataTypes.OBJECT : type);
+ if (cs == null) {
+ return defaultSerializer;
+ }
return cs;
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -28,6 +28,7 @@
public interface ServerConnection {
public static final int PING_INTERVAL = 120000;
+ public static final String LOCAL_CONNECTION = "localConnection";
<T> T getService(Class<T> iface);
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -39,9 +39,4 @@
* problems with the connection properties (bad user name, bad password, bad host name, etc)
*/
ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException;
-
- <T> T getService(Class<T> clazz);
-
- <T> void registerClientService(Class<T> type, T instance, String loggingContext);
- <T> String getLoggingContextForService(Class<T> type);
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -287,15 +287,4 @@
this.maxCachedInstances = maxCachedInstances;
}
- @Override
- public <T> T getService(Class<T> clazz) {
- return null;
- }
- @Override
- public <T> void registerClientService(Class<T> type, T instance, String loggingContext){
- }
- @Override
- public <T> String getLoggingContextForService(Class<T> type) {
- return null;
- }
}
Deleted: branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.client;
-
-import java.util.List;
-
-import javax.transaction.xa.Xid;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.lob.LobChunk;
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-
-public interface ClientSideDQP {
-
- ResultsFuture<ResultsMessage> executeRequest(long reqID, RequestMessage message) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-
- ResultsFuture<ResultsMessage> processCursorRequest(long reqID, int batchFirst, int fetchSize) throws MetaMatrixProcessingException;
-
- ResultsFuture<?> closeRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-
- boolean cancelRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-
- ResultsFuture<?> closeLobChunkStream(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-
- ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-
- List getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException;
-
- MetadataResult getMetadata(long requestID) throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
- MetadataResult getMetadata(long requestID, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
- void terminateSession() throws MetaMatrixComponentException;
-
- // local transaction
- void begin() throws XATransactionException;
-
- void commit() throws XATransactionException;
-
- void rollback() throws XATransactionException;
-
- // XA
- int prepare(MMXid xid) throws XATransactionException;
-
- void commit(MMXid xid, boolean onePhase) throws XATransactionException;
-
- void rollback(MMXid xid) throws XATransactionException;
-
- Xid[] recover(int flag) throws XATransactionException;
-
- void forget(MMXid xid) throws XATransactionException;
-
- void start(MMXid xid,
- int flags,
- int timeout) throws XATransactionException;
-
- void end(MMXid xid,
- int flags) throws XATransactionException;
-
-}
Added: branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java (rev 0)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.client;
+
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+
+public interface ClientSideDQP {
+
+ ResultsFuture<ResultsMessage> executeRequest(long reqID, RequestMessage message) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+
+ ResultsFuture<ResultsMessage> processCursorRequest(long reqID, int batchFirst, int fetchSize) throws MetaMatrixProcessingException;
+
+ ResultsFuture<?> closeRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+
+ boolean cancelRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+
+ ResultsFuture<?> closeLobChunkStream(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+
+ ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+
+ List<String> getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException;
+
+ MetadataResult getMetadata(long requestID) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+
+ MetadataResult getMetadata(long requestID, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+
+ // local transaction
+
+ ResultsFuture<?> begin() throws XATransactionException;
+
+ ResultsFuture<?> commit() throws XATransactionException;
+
+ ResultsFuture<?> rollback() throws XATransactionException;
+
+ // XA
+
+ ResultsFuture<?> start(MMXid xid,
+ int flags,
+ int timeout) throws XATransactionException;
+
+ ResultsFuture<?> end(MMXid xid,
+ int flags) throws XATransactionException;
+
+ ResultsFuture<Integer> prepare(MMXid xid) throws XATransactionException;
+
+ ResultsFuture<?> commit(MMXid xid, boolean onePhase) throws XATransactionException;
+
+ ResultsFuture<?> rollback(MMXid xid) throws XATransactionException;
+
+ ResultsFuture<?> forget(MMXid xid) throws XATransactionException;
+
+ ResultsFuture<Xid[]> recover(int flag) throws XATransactionException;
+
+}
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,58 +22,54 @@
package com.metamatrix.dqp.message;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.CommonCommPlugin;
+import com.metamatrix.core.util.ExternalizeUtil;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
* Request Message, used by MMXStatement for submitting queries.
*/
-public class RequestMessage implements Serializable {
+public class RequestMessage implements Externalizable {
- static final long serialVersionUID = 2258063872049251854L;
-
public static final int DEFAULT_FETCH_SIZE = 2048;
+
+ public enum StatementType {
+ PREPARED, CALLABLE, STATEMENT
+ }
+
+ public enum ResultsMode {
+ RESULTSET, UPDATECOUNT, EITHER
+ }
private String[] commands;
private boolean isBatchedUpdate;
private int fetchSize = DEFAULT_FETCH_SIZE;
private int cursorType;
private boolean partialResultsFlag;
- private boolean isPreparedStatement;
- private boolean isCallableStatement;
- private boolean isPreparedBatchUpdate;
- private List parameterValues;
+ private StatementType statementType = StatementType.STATEMENT;
+ private List<?> parameterValues;
private boolean validationMode;
private String txnAutoWrapMode;
private String XMLFormat;
private String styleSheet;
- private Boolean requireResultSet;
-
- /**The time when the command was created by the client.*/
- private Date submittedTimestamp;
-
- /**The time when command begins processing on the server.*/
- private Date processingTimestamp;
-
+ private ResultsMode resultsMode = ResultsMode.EITHER;
//whether to use ResultSet cache if there is one
private boolean useResultSetCache;
-
// Treat the double quoted strings as variables in the command
private boolean ansiQuotedIdentifiers = true;
-
- private boolean showPlan = false;
-
+ private boolean showPlan;
private int rowLimit;
-
private Serializable executionPayload;
-
private long executionId;
public RequestMessage() {
@@ -110,34 +106,24 @@
* @return True if this request includes a prepared statement.
*/
public boolean isPreparedStatement() {
- return isPreparedStatement;
+ return this.statementType == StatementType.PREPARED;
}
/**
* @return True if this request includes a callable statement.
*/
public boolean isCallableStatement() {
- return isCallableStatement;
+ return this.statementType == StatementType.CALLABLE;
}
-
- /**
- * @param isPreparedStatement
- */
- public void setPreparedStatement(boolean isPreparedStatement) {
- this.isPreparedStatement = isPreparedStatement;
- }
-
- /**
- * @param isCallableStatement
- */
- public void setCallableStatement(boolean isCallableStatement) {
- this.isCallableStatement = isCallableStatement;
- }
-
- /**
+
+ public void setStatementType(StatementType statementType) {
+ this.statementType = statementType;
+ }
+
+ /**
* @return A list of parameter values. May be null.
*/
- public List getParameterValues() {
+ public List<?> getParameterValues() {
if (parameterValues == null) {
return Collections.EMPTY_LIST;
}
@@ -147,7 +133,7 @@
/**
* @param values
*/
- public void setParameterValues(List values) {
+ public void setParameterValues(List<?> values) {
parameterValues = values;
}
@@ -238,55 +224,6 @@
this.styleSheet = styleSheet;
}
- /**
- * Get time that the time when the command was created by the client.
- * @return timestamp in millis
- */
- public Date getSubmittedTimestamp() {
- return submittedTimestamp;
- }
-
- /**
- * Set time that the time when the command was created by the client.
- * NOTE: By default, this gets set to the current time by the constructor.
- * @param submittedTimestamp Time submitted to server.
- */
- public void setSubmittedTimestamp(Date submittedTimestamp) {
- this.submittedTimestamp = submittedTimestamp;
- }
-
- /**
- * Start the clock on submission start - this should be called when the request is originally created.
- */
- public void markSubmissionStart() {
- setSubmittedTimestamp(new Date());
- }
-
-
- /**
- * Get time that the request was assigned a unique ID by the server.
- * @return timestamp in millis
- */
- public Date getProcessingTimestamp() {
- return processingTimestamp;
- }
-
- /**
- * Set time that the request is submitted on the server.
- * @param processingTimestamp Time submitted to server.
- */
- public void setProcessingTimestamp(Date processingTimestamp) {
- this.processingTimestamp = processingTimestamp;
- }
-
- /**
- * Start the clock on processing times - this should be called when the query
- * hits the QueryService or SubscriptionService.
- */
- public void markProcessingStart() {
- setProcessingTimestamp(new Date());
- }
-
public boolean useResultSetCache() {
//not use caching when there is a txn
return useResultSetCache;
@@ -354,14 +291,6 @@
this.commands = batchedCommands;
}
- public boolean isPreparedBatchUpdate() {
- return isPreparedBatchUpdate;
- }
-
- public void setPreparedBatchUpdate(boolean isPreparedBatchUpdate) {
- this.isPreparedBatchUpdate = isPreparedBatchUpdate;
- }
-
public void setExecutionPayload(Serializable executionPayload) {
this.executionPayload = executionPayload;
}
@@ -377,7 +306,7 @@
public void setExecutionId(long executionId) {
this.executionId = executionId;
}
-
+
public void setBatchedUpdate(boolean isBatchedUpdate) {
this.isBatchedUpdate = isBatchedUpdate;
}
@@ -385,13 +314,58 @@
public boolean isBatchedUpdate() {
return isBatchedUpdate;
}
-
- public Boolean getRequireResultSet() {
- return requireResultSet;
+
+ public ResultsMode getResultsMode() {
+ return resultsMode;
}
- public void setRequireResultSet(Boolean requireResultSet) {
- this.requireResultSet = requireResultSet;
+ public void setResultsMode(ResultsMode resultsMode) {
+ this.resultsMode = resultsMode;
}
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ this.commands = ExternalizeUtil.readStringArray(in);
+ this.isBatchedUpdate = in.readBoolean();
+ this.fetchSize = in.readInt();
+ this.cursorType = in.readInt();
+ this.partialResultsFlag = in.readBoolean();
+ this.statementType = StatementType.values()[in.readByte()];
+ this.parameterValues = ExternalizeUtil.readList(in);
+ this.validationMode = in.readBoolean();
+ this.txnAutoWrapMode = (String)in.readObject();
+ this.XMLFormat = (String)in.readObject();
+ this.styleSheet = (String)in.readObject();
+ this.resultsMode = ResultsMode.values()[in.readByte()];
+ this.useResultSetCache = in.readBoolean();
+ this.ansiQuotedIdentifiers = in.readBoolean();
+ this.showPlan = in.readBoolean();
+ this.rowLimit = in.readInt();
+ this.executionPayload = (Serializable)in.readObject();
+ this.executionId = in.readLong();
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ ExternalizeUtil.writeArray(out, commands);
+ out.writeBoolean(isBatchedUpdate);
+ out.writeInt(fetchSize);
+ out.writeInt(cursorType);
+ out.writeBoolean(partialResultsFlag);
+ out.writeByte(statementType.ordinal());
+ ExternalizeUtil.writeList(out, parameterValues);
+ out.writeBoolean(validationMode);
+ out.writeObject(txnAutoWrapMode);
+ out.writeObject(XMLFormat);
+ out.writeObject(styleSheet);
+ out.writeByte(resultsMode.ordinal());
+ out.writeBoolean(useResultSetCache);
+ out.writeBoolean(ansiQuotedIdentifiers);
+ out.writeBoolean(showPlan);
+ out.writeInt(rowLimit);
+ out.writeObject(executionPayload);
+ out.writeLong(executionId);
+ }
+
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -28,7 +28,6 @@
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -69,12 +68,6 @@
/** The parameters of a Stored Procedure */
private List parameters;
- /** This object represents the time when command is submitted to the server. */
- private Date processingTimestamp;
-
- /** This object represents the time when results are produced on the server. */
- private Date completedTimestamp;
-
/** OPTION DEBUG log if OPTION DEBUG was used */
private String debugLog;
@@ -100,10 +93,6 @@
* @since 4.2
*/
public ResultsMessage(RequestMessage requestMsg){
- if(requestMsg != null){
- this.processingTimestamp = requestMsg.getProcessingTimestamp();
- this.completedTimestamp = new Date();
- }
this.results = new ArrayList[0];
}
@@ -236,13 +225,6 @@
parameters = list;
}
- public Date getProcessingTimestamp() {
- return this.processingTimestamp;
- }
-
- public Date getCompletedTimestamp() {
- return this.completedTimestamp;
- }
/**
* @param strings
*/
@@ -284,8 +266,6 @@
//Parameters
parameters = ExternalizeUtil.readList(in);
- processingTimestamp = (Date)in.readObject();
- completedTimestamp = (Date)in.readObject();
debugLog = (String)in.readObject();
annotations = (Collection)in.readObject();
isUpdateResult = in.readBoolean();
@@ -320,8 +300,6 @@
// Parameters
ExternalizeUtil.writeList(out, parameters);
- out.writeObject(processingTimestamp);
- out.writeObject(completedTimestamp);
out.writeObject(debugLog);
out.writeObject(annotations);
out.writeBoolean(isUpdateResult);
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Request.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Request.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -35,11 +35,6 @@
*/
public interface Request extends AdminObject {
- /**
- * @return time when the request was created
- */
- public long getCreatedTime();
-
/**
* Get the ExecutionId for a Request
* @return ExecutionId
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,7 +22,6 @@
package org.teiid.adminapi.impl;
-import java.io.Serializable;
import java.util.Date;
import org.jboss.managed.api.annotation.ManagementProperty;
@@ -33,7 +32,7 @@
@MetaMapping(RequestMetadataMapper.class)
-public class RequestMetadata extends AdminObjectImpl implements Request, Serializable {
+public class RequestMetadata extends AdminObjectImpl implements Request {
private static final long serialVersionUID = -2779106368517784259L;
@@ -70,16 +69,6 @@
}
@Override
- @ManagementProperty(description="Time when request submitted", readOnly=true)
- public long getCreatedTime() {
- return this.createdTime;
- }
-
- public void setCreatedTiime(long time) {
- this.createdTime = time;
- }
-
- @Override
@ManagementProperty(description="Processing time for the request", readOnly=true)
public long getProcessingTime() {
return this.processTime;
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -71,7 +71,6 @@
request.set("executionId", SimpleValueSupport.wrap(object.getExecutionId()));
request.set("sessionId", SimpleValueSupport.wrap(object.getSessionId()));
- request.set("createdTime", SimpleValueSupport.wrap(object.getCreatedTime()));
request.set("processingTime", SimpleValueSupport.wrap(object.getProcessingTime()));
request.set("command", SimpleValueSupport.wrap(object.getCommand()));
request.set("sourceRequest", SimpleValueSupport.wrap(object.sourceRequest()));
@@ -94,7 +93,6 @@
RequestMetadata request = new RequestMetadata();
request.setExecutionId((Long) metaValueFactory.unwrap(compositeValue.get("executionId")));
request.setSessionId((Long) metaValueFactory.unwrap(compositeValue.get("sessionId")));
- request.setCreatedTiime((Long) metaValueFactory.unwrap(compositeValue.get("createdTime")));
request.setProcessingTime((Long) metaValueFactory.unwrap(compositeValue.get("processingTime")));
request.setCommand((String) metaValueFactory.unwrap(compositeValue.get("command")));
request.setSourceRequest((Boolean) metaValueFactory.unwrap(compositeValue.get("sourceRequest")));
Added: branches/JCA/client/src/main/java/org/teiid/transport/ClientServiceRegistry.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/transport/ClientServiceRegistry.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,31 @@
+/*
+ * 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.transport;
+
+import com.metamatrix.api.exception.ComponentNotFoundException;
+
+public interface ClientServiceRegistry {
+
+ <T> T getClientService(Class<T> iface) throws ComponentNotFoundException;
+
+}
Property changes on: branches/JCA/client/src/main/java/org/teiid/transport/ClientServiceRegistry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -40,7 +40,6 @@
import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.comm.CommonCommPlugin;
import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
@@ -49,7 +48,7 @@
import com.metamatrix.platform.security.api.SessionToken;
public class LocalServerConnection implements ServerConnection {
- private static final String TEIID_RUNTIME = "java:teiid/runtime-engine";
+ private static final String TEIID_RUNTIME = "java:teiid/engine-deployer";
private final LogonResult result;
private boolean shutdown;
@@ -60,7 +59,7 @@
public synchronized LogonResult authenticate(Properties connProps) throws ConnectionException, CommunicationException {
try {
- connProps.setProperty("localConnection", "true");
+ connProps.setProperty(ServerConnection.LOCAL_CONNECTION, Boolean.TRUE.toString());
LogonResult logonResult = this.getService(ILogon.class).logon(connProps);
return logonResult;
} catch (LogonException e) {
@@ -75,18 +74,16 @@
}
}
-
- @SuppressWarnings("unchecked")
public <T> T getService(final Class<T> iface) {
- return (T) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
+ return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
if (!isOpen()) {
throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(CommonCommPlugin.Util.getString("LocalTransportHandler.Transport_shutdown"))); //$NON-NLS-1$
}
try {
- ServerConnectionFactory scf = lookup(TEIID_RUNTIME);
- T service = scf.getService(iface);
+ ClientServiceRegistry scf = lookup(TEIID_RUNTIME);
+ T service = scf.getClientService(iface);
if (!(iface.equals(ILogon.class))) {
SessionToken.setSession(result.getSessionToken());
@@ -99,8 +96,7 @@
SessionToken.setSession(null);
}
}
- });
-
+ }));
}
public boolean isOpen() {
@@ -145,7 +141,7 @@
return (conn instanceof LocalServerConnection);
}
- public static <T> T lookup(String jndiName) throws NamingException {
+ protected <T> T lookup(String jndiName) throws NamingException {
InitialContext ic = new InitialContext();
return (T)ic.lookup(jndiName);
}
Modified: branches/JCA/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java
===================================================================
--- branches/JCA/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -23,13 +23,13 @@
package com.metamatrix.dqp.message;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.jdbc.api.ExecutionProperties;
public class TestRequestMessage extends TestCase {
@@ -44,7 +44,7 @@
public static RequestMessage example() {
RequestMessage message = new RequestMessage();
- message.setCallableStatement(true);
+ message.setStatementType(StatementType.CALLABLE);
message.setFetchSize(100);
List params = new ArrayList();
params.add(new Integer(100));
@@ -54,9 +54,6 @@
message.setParameterValues(params);
message.setPartialResults(true);
- message.setPreparedStatement(false);
- message.setSubmittedTimestamp(new Date(11111111L));
- message.setProcessingTimestamp(new Date(12345678L));
message.setStyleSheet("myStyleSheet"); //$NON-NLS-1$
message.setExecutionPayload("myExecutionPayload"); //$NON-NLS-1$
try {
@@ -85,8 +82,6 @@
assertEquals(new Integer(400), copy.getParameterValues().get(3));
assertFalse(copy.isPreparedStatement());
- assertEquals(new Date(11111111L), copy.getSubmittedTimestamp());
- assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
assertEquals("myStyleSheet", copy.getStyleSheet()); //$NON-NLS-1$
assertEquals("myExecutionPayload", copy.getExecutionPayload()); //$NON-NLS-1$
assertEquals(ExecutionProperties.TXN_WRAP_ON, copy.getTxnAutoWrapMode()); //$NON-NLS-1$
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -51,6 +51,8 @@
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
/**
* <p> This class inherits Statement methods, which deal with SQL statements in
@@ -91,10 +93,9 @@
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
- RequestMessage message = super.createRequestMessage(commands, isBatchedCommand, requiresResultSet);
- message.setCallableStatement(true);
- message.setPreparedStatement(false);
+ boolean isBatchedCommand, ResultsMode resultsMode) {
+ RequestMessage message = super.createRequestMessage(commands, isBatchedCommand, resultsMode);
+ message.setStatementType(StatementType.CALLABLE);
return message;
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -65,6 +65,7 @@
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -347,8 +348,9 @@
private void directCommit() throws SQLException {
try {
- this.dqp.commit();
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.commit();
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
logger.fine(JDBCPlugin.Util.getString("MMConnection.Commit_success")); //$NON-NLS-1$
@@ -716,8 +718,9 @@
if (!autoCommitFlag) {
try {
try {
- this.dqp.rollback();
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.rollback();
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
logger.fine(JDBCPlugin.Util.getString("MMConnection.Rollback_success")); //$NON-NLS-1$
@@ -802,8 +805,9 @@
transactionXid = null;
this.autoCommitFlag = true;
try {
- this.dqp.commit(arg0, arg1);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.commit(arg0, arg1);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -812,8 +816,9 @@
checkConnection();
this.autoCommitFlag = true;
try {
- this.dqp.end(arg0, arg1);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.end(arg0, arg1);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -821,8 +826,9 @@
protected void forgetTransaction(MMXid arg0) throws SQLException {
checkConnection();
try {
- this.dqp.forget(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.forget(arg0);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -831,8 +837,9 @@
checkConnection();
transactionXid = null;
try {
- return this.dqp.prepare(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<Integer> future = this.dqp.prepare(arg0);
+ return future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -840,8 +847,9 @@
protected Xid[] recoverTransaction(int arg0) throws SQLException {
checkConnection();
try {
- return this.dqp.recover(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<Xid[]> future = this.dqp.recover(arg0);
+ return future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -851,8 +859,9 @@
transactionXid = null;
this.autoCommitFlag = true;
try {
- this.dqp.rollback(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.rollback(arg0);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -860,8 +869,9 @@
protected void startTransaction(MMXid arg0, int arg1, int timeout) throws SQLException {
checkConnection();
try {
- this.dqp.start(arg0, arg1, timeout);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.start(arg0, arg1, timeout);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
transactionXid = arg0;
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -60,6 +60,8 @@
import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -186,7 +188,7 @@
@Override
//## JDBC4.0-end ##
public boolean execute() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, null);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER);
return hasResultSet();
}
@@ -196,7 +198,7 @@
return new int[0];
}
try{
- executeSql(new String[] {this.prepareSql}, true, false);
+ executeSql(new String[] {this.prepareSql}, true, ResultsMode.UPDATECOUNT);
}finally{
batchParameterList.clear();
}
@@ -207,7 +209,7 @@
@Override
//## JDBC4.0-end ##
public ResultSet executeQuery() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, true);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.RESULTSET);
return resultSet;
}
@@ -215,17 +217,17 @@
@Override
//## JDBC4.0-end ##
public int executeUpdate() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, false);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.UPDATECOUNT);
return this.updateCounts[0];
}
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
- RequestMessage message = super.createRequestMessage(commands, false, requiresResultSet);
- message.setPreparedStatement(true);
+ boolean isBatchedCommand, ResultsMode resultsMode) {
+ RequestMessage message = super.createRequestMessage(commands, false, resultsMode);
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(isBatchedCommand?getParameterValuesList(): getParameterValues());
- message.setPreparedBatchUpdate(isBatchedCommand);
+ message.setBatchedUpdate(isBatchedCommand);
return message;
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -126,7 +126,7 @@
this.statement = statement;
this.parameters = parameters;
// server latency-related timestamp
- this.processingTimestamp = resultsMsg.getProcessingTimestamp();
+ this.processingTimestamp = statement.getProcessingTimestamp();
this.requestID = statement.getCurrentRequestID();
this.cursorType = statement.getResultSetType();
this.batchResults = new BatchResults(this, getCurrentBatch(resultsMsg), this.cursorType == ResultSet.TYPE_FORWARD_ONLY ? 1 : BatchResults.DEFAULT_SAVED_BATCHES);
@@ -1116,7 +1116,7 @@
}
protected void setResultsData(ResultsMessage resultsMsg) {
- this.completedTimestamp = resultsMsg.getCompletedTimestamp();
+ this.completedTimestamp = new java.util.Date();
this.statement.accumulateWarnings(resultsMsg.getWarnings());
}
@@ -1186,9 +1186,9 @@
}
/**
- * Gets the time command execution is compleated on the server.
+ * Gets the time command execution is completed on the server.
*
- * @return Date object representing time the commond finished execution.
+ * @return Date object representing time the command finished execution.
*/
public java.util.Date getCompletedTimestamp() throws SQLException {
checkClosed();
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -53,10 +54,12 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.util.SqlUtil;
+import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.jdbc.api.Annotation;
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.jdbc.api.PlanNode;
@@ -157,6 +160,8 @@
private Pattern setStatement = Pattern.compile("\\s*set\\s*(\\w+)\\s*=\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private Date processingTimestamp;
+
/**
* Factory Constructor
* @param driverConnection
@@ -318,7 +323,7 @@
@Override
//## JDBC4.0-end ##
public boolean execute(String sql) throws SQLException {
- executeSql(new String[] {sql}, false, null);
+ executeSql(new String[] {sql}, false, ResultsMode.EITHER);
return hasResultSet();
}
@@ -330,7 +335,7 @@
return new int[0];
}
String[] commands = (String[])batchedUpdates.toArray(new String[batchedUpdates.size()]);
- executeSql(commands, true, false);
+ executeSql(commands, true, ResultsMode.UPDATECOUNT);
return updateCounts;
}
@@ -338,7 +343,7 @@
@Override
//## JDBC4.0-end ##
public ResultSet executeQuery(String sql) throws SQLException {
- executeSql(new String[] {sql}, false, true);
+ executeSql(new String[] {sql}, false, ResultsMode.RESULTSET);
return resultSet;
}
@@ -347,7 +352,7 @@
//## JDBC4.0-end ##
public int executeUpdate(String sql) throws SQLException {
String[] commands = new String[] {sql};
- executeSql(commands, false, false);
+ executeSql(commands, false, ResultsMode.UPDATECOUNT);
return this.updateCounts[0];
}
@@ -402,13 +407,13 @@
resultSet.setMaxFieldSize(this.maxFieldSize);
}
- protected void executeSql(String[] commands, boolean isBatchedCommand, Boolean requiresResultSet)
+ protected void executeSql(String[] commands, boolean isBatchedCommand, ResultsMode resultsMode)
throws SQLException, MMSQLException {
checkStatement();
resetExecutionState();
//handle set statement
- if (commands.length == 1 && requiresResultSet != Boolean.TRUE) {
+ if (commands.length == 1 && resultsMode != ResultsMode.RESULTSET) {
Matcher match = setStatement.matcher(commands[0]);
if (match.matches()) {
String key = match.group(1);
@@ -419,7 +424,7 @@
}
}
- RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, requiresResultSet);
+ RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, resultsMode);
ResultsMessage resultsMsg = null;
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
@@ -466,11 +471,11 @@
}
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
+ boolean isBatchedCommand, ResultsMode resultsMode) {
RequestMessage reqMessage = new RequestMessage();
reqMessage.setCommands(commands);
reqMessage.setBatchedUpdate(isBatchedCommand);
- reqMessage.setRequireResultSet(requiresResultSet);
+ reqMessage.setResultsMode(resultsMode);
return reqMessage;
}
@@ -761,6 +766,15 @@
// Get result set cache mode
String rsCache = getExecutionProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
res.setUseResultSetCache(Boolean.valueOf(rsCache).booleanValue());
+
+ res.setAnsiQuotedIdentifiers(Boolean.valueOf(
+ getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS))
+ .booleanValue());
+ String sqlOptions = getExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS);
+ if (sqlOptions != null &&
+ sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
+ res.setShowPlan(true);
+ }
}
/**
@@ -821,34 +835,13 @@
/**
* Send out request message with necessary states.
- * @param transaction UsertTransaction
- * @param sql String of command or prepared string
- * @param listener Message Listener
- * @param timeout Maybe 0
- * @param isPreparedStatement flag indicating whether this statement is a PreparedStatement
- * @param isCallableStatement flag indicating whether this statement is a CallableStatement
- * @param params Parameters values of either PreparedStatement or CallableStatement
- * @param isBatchedCommand flag indicating whether the statements are being executed as a batch
- * @throws SQLException
- * @throws TimeoutException
- * @throws InterruptedException
- * @throws CommunicationException
*/
protected ResultsMessage sendRequestMessageAndWait(RequestMessage reqMsg)
throws SQLException, InterruptedException, TimeoutException {
-
+ this.processingTimestamp = new Date();
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
- reqMsg.markSubmissionStart();
reqMsg.setExecutionPayload(this.payload);
- reqMsg.setAnsiQuotedIdentifiers(Boolean.valueOf(
- getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS))
- .booleanValue());
- String sqlOptions = getExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS);
- if (sqlOptions != null &&
- sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
- reqMsg.setShowPlan(true);
- }
reqMsg.setCursorType(this.resultSetType);
reqMsg.setFetchSize(this.fetchSize);
reqMsg.setStyleSheet(this.styleSheet);
@@ -905,23 +898,7 @@
* @throws IOException if unable to read the style sheet from the Reader object.
*/
public void attachStylesheet(Reader reader) throws IOException {
- BufferedReader bufferedReader = null;
- StringBuffer buffer = new StringBuffer();
- try {
- bufferedReader = new BufferedReader(reader);
- while(true) {
- String line = bufferedReader.readLine();
- if(line == null) {
- break;
- }
- buffer.append( line );
- }
- } finally {
- if(bufferedReader != null) {
- bufferedReader.close();
- }
- }
- this.styleSheet = buffer.toString();
+ this.styleSheet = ObjectConverterUtil.convertToString(reader);
}
/**
@@ -981,6 +958,10 @@
public Collection getAnnotations() {
return this.annotations;
}
+
+ public Date getProcessingTimestamp() {
+ return processingTimestamp;
+ }
public void setPartialResults(boolean isPartialResults){
if(isPartialResults){
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
@@ -675,35 +674,6 @@
rs.close();
}
-
- /**
- * Case 4293 - timestamps for begin and end processing should both be set
- * server-side (from the same system clock)
- */
- @Test public void testProcessingTime() throws Exception {
- RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(12345678L));
- ResultsMessage resultsMsg = new ResultsMessage(request);
-
- // these two lines not important to the test
- resultsMsg.setColumnNames(new String[] { "IntNum" }); //$NON-NLS-1$
- resultsMsg.setDataTypes(new String[] { MMJDBCSQLTypeInfo.INTEGER });
-
- // expected results
- long expectedProcessingTime = resultsMsg.getCompletedTimestamp()
- .getTime()
- - resultsMsg.getProcessingTimestamp().getTime();
-
- // sleep for a couple milliseconds
- Thread.sleep(200);
-
- MMResultSet rs = new MMResultSet(resultsMsg, statement);
-
- long actualProcessingTime = rs.getProcessingTime();
-
- assertEquals(expectedProcessingTime, actualProcessingTime);
-
- }
/**
* 3 batches
@@ -850,7 +820,6 @@
private static ResultsMessage exampleResultsMsg4(int begin, int length, int fetchSize, boolean lastBatch) {
RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
List[] results = exampleResults1(length, begin);
@@ -879,7 +848,6 @@
@Test public void testDateType() throws SQLException {
RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
resultsMsg.setResults(new List[] {Arrays.asList(new Timestamp(0))});
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -41,6 +41,7 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.platform.security.api.LogonResult;
/**
@@ -113,8 +114,7 @@
// Now verify the statement's RequestMessage is what we expect
assertEquals("Command does not match", sqlCommand, statement.requestMessage.getCommandString()); //$NON-NLS-1$
assertEquals("Parameter values do not match", expectedParameterValues, statement.requestMessage.getParameterValues()); //$NON-NLS-1$
- assertTrue("RequestMessage.isPreparedBatchUpdate should be true", statement.requestMessage.isPreparedBatchUpdate()); //$NON-NLS-1$
- assertFalse("RequestMessage.isBatchedUpdate should be false", statement.requestMessage.isBatchedUpdate()); //$NON-NLS-1$
+ assertTrue("RequestMessage.isBatchedUpdate should be true", statement.requestMessage.isBatchedUpdate()); //$NON-NLS-1$
assertFalse("RequestMessage.isCallableStatement should be false", statement.requestMessage.isCallableStatement()); //$NON-NLS-1$
assertTrue("RequestMessage.isPreparedStatement should be true", statement.requestMessage.isPreparedStatement()); //$NON-NLS-1$
}
@@ -323,9 +323,9 @@
public RequestMessage requestMessage;
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
+ boolean isBatchedCommand, ResultsMode resultsMode) {
this.requestMessage = super
- .createRequestMessage(commands, isBatchedCommand, requiresResultSet);
+ .createRequestMessage(commands, isBatchedCommand, resultsMode);
return this.requestMessage;
}
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -673,7 +673,7 @@
/** test getProcessingTime() -- include test for getProcessingTimestamp() and getCompletedTimestamp() */
@Test public void testGetProcessingTime() throws SQLException {
MMResultSet cs = helpExecuteQuery();
- assertTrue(cs.getProcessingTime() == cs.getCompletedTimestamp().getTime() - 1);
+ assertNotNull(cs.getCompletedTimestamp());
cs.close();
}
Modified: branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
===================================================================
--- branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,17 +22,21 @@
package com.metamatrix.common.queue;
-import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.LinkedList;
-import java.util.List;
+import java.util.Map;
import java.util.Queue;
import java.util.Set;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.resource.spi.work.ExecutionContext;
import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkException;
import javax.resource.spi.work.WorkListener;
import javax.resource.spi.work.WorkManager;
@@ -44,8 +48,104 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.NamedThreadFactory;
+/**
+ * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to
+ * capture statistics and implement an unbounded queue of work.
+ */
public class StatsCapturingWorkManager {
+
+ private static class WorkContext {
+ ExecutionContext context;
+ long startTimeout;
+ long submitted = System.currentTimeMillis();
+
+ public WorkContext(ExecutionContext context, long startTimeout) {
+ this.context = context;
+ this.startTimeout = startTimeout;
+ }
+
+ long getStartTimeout() {
+ if (startTimeout == 0) {
+ return 0;
+ }
+ return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
+ }
+
+ }
+
+ private final class WorkWrapper implements Work {
+ private final WorkManager delegate;
+ private final Work work;
+ private final WorkContext workContext;
+
+ private WorkWrapper(WorkManager delegate, Work work, WorkContext workContext) {
+ this.delegate = delegate;
+ this.work = work;
+ this.workContext = workContext;
+ }
+
+ @Override
+ public void run() {
+ Thread t = Thread.currentThread();
+ synchronized (poolLock) {
+ threads.add(t);
+ }
+ String name = t.getName();
+ t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
+ }
+ boolean success = false;
+ try {
+ work.run();
+ success = true;
+ } finally {
+ synchronized (poolLock) {
+ WorkWrapper next = null;
+ if (success) {
+ completedCount++;
+ next = queue.poll();
+ }
+ threads.remove(t);
+ if (next == null) {
+ activeCount--;
+ if (activeCount == 0 && terminated) {
+ poolLock.notifyAll();
+ }
+ } else {
+ try {
+ if (next.workContext == null) {
+ delegate.scheduleWork(next);
+ } else {
+ delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
+ }
+ } catch (WorkException e) {
+ handleException(next.work, e);
+ }
+ }
+ }
+ t.setName(name);
+ }
+ }
+
+ @Override
+ public void release() {
+ this.work.release();
+ }
+ }
+
+ private static void handleException(Work work, WorkException e) {
+ if (work instanceof WorkListener) {
+ ((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
+ } else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_POOLING, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$
+ }
+ }
+
+ private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
+
private volatile int activeCount;
private volatile int highestActiveCount;
private volatile int highestQueueSize;
@@ -56,104 +156,79 @@
private AtomicInteger threadCounter = new AtomicInteger();
private String poolName;
private int maximumPoolSize;
- private Queue<Work> queue = new LinkedList<Work>();
+ private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
-
+ private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
+ private int idCounter;
+
public StatsCapturingWorkManager(String name, int maximumPoolSize) {
this.maximumPoolSize = maximumPoolSize;
this.poolName = name;
}
- public void doWork(WorkManager delegate, Work arg0) throws WorkException {
- delegate.doWork(new StatuscapableWork(arg0));
+ public void scheduleWork(final WorkManager delegate, final Work arg0) throws WorkException {
+ scheduleWork(delegate, arg0, (WorkContext)null);
}
- public void doWork(WorkManager delegate, Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- delegate.doWork(new StatuscapableWork(arg0), arg1, arg2, arg3);
- }
-
- public void scheduleWork(WorkManager delegate, Work arg0) throws WorkException {
- delegate.scheduleWork(new StatuscapableWork(arg0));
- }
-
- public void scheduleWork(WorkManager delegate, Work arg0, long arg1, ExecutionContext arg2,WorkListener arg3) throws WorkException {
- delegate.scheduleWork(new StatuscapableWork(arg0), arg1, arg2, arg3);
- }
-
- public long startWork(WorkManager delegate,Work arg0) throws WorkException {
- return delegate.startWork(new StatuscapableWork(arg0));
- }
-
- public long startWork(WorkManager delegate, Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- return delegate.startWork(new StatuscapableWork(arg0), arg1, arg2, arg3);
- }
-
-
- class StatuscapableWork implements Work{
-
- public StatuscapableWork(Work work) throws WorkRejectedException {
- boolean atMaxThreads = false;
- boolean newMaxQueueSize = false;
- synchronized (poolLock) {
- checkForTermination();
- submittedCount++;
- atMaxThreads = activeCount == maximumPoolSize;
- queue.add(work);
- if (atMaxThreads) {
- int queueSize = queue.size();
- if (queueSize > highestQueueSize) {
- atMaxThreads = true;
- highestQueueSize = queueSize;
- }
- } else {
- activeCount++;
- highestActiveCount = Math.max(activeCount, highestActiveCount);
+ private void scheduleWork(final WorkManager delegate, final Work work, WorkContext workContext)
+ throws WorkRejectedException, WorkException {
+ boolean atMaxThreads = false;
+ boolean newMaxQueueSize = false;
+ synchronized (poolLock) {
+ checkForTermination();
+ submittedCount++;
+ atMaxThreads = activeCount == maximumPoolSize;
+ if (atMaxThreads) {
+ queue.add(new WorkWrapper(delegate, work, workContext));
+ int queueSize = queue.size();
+ if (queueSize > highestQueueSize) {
+ newMaxQueueSize = true;
+ highestQueueSize = queueSize;
}
+ } else {
+ activeCount++;
+ highestActiveCount = Math.max(activeCount, highestActiveCount);
}
- if (atMaxThreads) {
- if (newMaxQueueSize && maximumPoolSize > 1) {
- throw new WorkRejectedException( CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
- }
- }
}
-
- @Override
- public void release() {
+ if (atMaxThreads) {
+ if (newMaxQueueSize && maximumPoolSize > 1) {
+ LogManager.logWarning(LogConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
+ }
+ return;
}
+ if (workContext == null) {
+ delegate.scheduleWork(new WorkWrapper(delegate, work, null));
+ } else {
+ delegate.scheduleWork(new WorkWrapper(delegate, work, null), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
+ }
+ }
- @Override
- public void run() {
- Thread t = Thread.currentThread();
- threads.add(t);
- String name = t.getName();
- t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
- LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
- }
-
- Work r = queue.poll();
- if (r != null) {
- boolean success = false;
- try {
- r.run();
- success = true;
- } finally {
- synchronized (poolLock) {
- if (success) {
- completedCount++;
+ public void scheduleWork(final WorkManager delegate, final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
+ if (delay < 1) {
+ scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
+ } else {
+ synchronized (futures) {
+ final int id = idCounter++;
+ ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ futures.remove(id);
+ scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
+ } catch (WorkException e) {
+ handleException(arg0, e);
}
- threads.remove(t);
- activeCount--;
}
- t.setName(name);
- }
- }
+ }, delay, TimeUnit.MILLISECONDS);
+ this.futures.put(id, sf);
+ }
}
}
-
+
private void checkForTermination() throws WorkRejectedException {
if (terminated) {
- throw new WorkRejectedException();
+ throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
}
}
@@ -174,21 +249,40 @@
this.terminated = true;
}
- public List<Runnable> shutdownNow() {
+ public void shutdownNow() {
this.shutdown();
synchronized (poolLock) {
- synchronized (threads) {
- for (Thread t : threads) {
- t.interrupt();
- }
+ for (Thread t : threads) {
+ t.interrupt();
}
- List<Runnable> result = Collections.EMPTY_LIST;
- if (!queue.isEmpty()) {
- new ArrayList<Runnable>(queue);
- queue.clear();
+ queue.clear();
+ }
+ synchronized (futures) {
+ for (ScheduledFuture<?> future : futures.values()) {
+ future.cancel(true);
}
- return result;
+ futures.clear();
}
}
+
+ public boolean isTerminated() {
+ return terminated;
+ }
+
+ public boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ long timeoutMillis = unit.toMillis(timeout);
+ long finalMillis = System.currentTimeMillis() + timeoutMillis;
+ synchronized (poolLock) {
+ while (this.activeCount > 0 || !terminated) {
+ if (timeoutMillis < 1) {
+ return false;
+ }
+ poolLock.wait(timeoutMillis);
+ timeoutMillis = finalMillis - System.currentTimeMillis();
+ }
+ }
+ return true;
+ }
}
Deleted: branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java
===================================================================
--- branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPool.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.queue;
-
-import java.util.List;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-public interface WorkerPool extends Executor {
-
- void shutdown();
-
- List<Runnable> shutdownNow();
-
- boolean awaitTermination(long timeout, TimeUnit unit)
- throws InterruptedException;
-
- boolean isTerminated();
-
- WorkerPoolStatisticsMetadata getStats();
-
- boolean hasWork();
-
- ScheduledFuture<?> schedule(Runnable command,
- long delay,
- TimeUnit unit);
-
- ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
- long initialDelay,
- long period,
- TimeUnit unit);
-
-}
\ No newline at end of file
Deleted: branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java
===================================================================
--- branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/WorkerPoolFactory.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,373 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.queue;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.Delayed;
-import java.util.concurrent.Executor;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.NamedThreadFactory;
-
-/**
- * Creates named, queued, daemon Thread pools.
- * <br/>
- * The requirements are:
- * <ol>
- * <li>minimize thread creation</li>
- * <li>allow for proper timeout of idle threads</li>
- * <li>allow for queuing</li>
- * </ol>
- * <br/>
- * A non-fifo (lifo) {@link SynchronousQueue} based {@link ThreadPoolExecutor} satisfies 1 and 2, but not 3.
- * A bounded or unbound queue based {@link ThreadPoolExecutor} allows for 3, but will tend to create
- * up to the maximum number of threads and makes no guarantee on thread scheduling.
- * <br/>
- * So the approach here is to use virtual thread pools off of single shared {@link SynchronousQueue}
- * backed {@link ThreadPoolExecutor}.
- * <br/>
- * There is also only a single master scheduling thread with actual executions deferred to the calling
- * WorkerPool.
- *
- * TODO: this probably needs to be re-thought, especially since the lifo ordering of a {@link SynchronousQueue}
- * is not guaranteed behavior. also there's a race condition between previously retiring threads and new work -
- * prior to being returned to the shared pool we can create extra threads if the shared pool is exhausted.
- * TODO: bounded queuing - we never bothered bounding in the past with our worker pools, but reasonable
- * defaults would be a good idea.
- */
-public class WorkerPoolFactory {
-
- private static ThreadPoolExecutor tpe = new ThreadPoolExecutor(0,
- Integer.MAX_VALUE, 2, TimeUnit.MINUTES,
- new SynchronousQueue<Runnable>(), new NamedThreadFactory("Worker")) { //$NON-NLS-1$
- @Override
- protected void afterExecute(Runnable r, Throwable t) {
- if (t != null) {
- LogManager.logError(LogConstants.CTX_POOLING, t, CommonPlugin.Util.getString("WorkerPool.uncaughtException")); //$NON-NLS-1$
- }
- }
- };
-
- private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
-
- static class StatsCapturingSharedThreadPoolExecutor implements WorkerPool {
-
- class ScheduledFutureTask extends FutureTask<Void> implements ScheduledFuture<Void> {
- private ScheduledFuture<?> scheduledFuture;
- private boolean periodic;
- private volatile boolean running;
-
- public ScheduledFutureTask(Runnable runnable, boolean periodic) {
- super(runnable, null);
- this.periodic = periodic;
- }
-
- public void setScheduledFuture(ScheduledFuture<?> scheduledFuture) {
- scheduledTasks.add(this);
- this.scheduledFuture = scheduledFuture;
- }
-
- @Override
- public long getDelay(TimeUnit unit) {
- return this.scheduledFuture.getDelay(unit);
- }
-
- @Override
- public int compareTo(Delayed o) {
- return this.scheduledFuture.compareTo(o);
- }
-
- @Override
- public boolean cancel(boolean mayInterruptIfRunning) {
- this.scheduledFuture.cancel(false);
- scheduledTasks.remove(this);
- return super.cancel(mayInterruptIfRunning);
- }
-
- public Runnable getParent() {
- return new Runnable() {
- @Override
- public void run() {
- if (running || terminated) {
- return;
- }
- running = periodic;
- execute(ScheduledFutureTask.this);
- }
- };
- }
-
- @Override
- public void run() {
- if (periodic) {
- if (!this.runAndReset()) {
- this.scheduledFuture.cancel(false);
- scheduledTasks.remove(this);
- }
- running = false;
- } else {
- scheduledTasks.remove(this);
- super.run();
- }
- }
- }
-
- private volatile int activeCount;
- private volatile int highestActiveCount;
- private volatile int highestQueueSize;
- private volatile boolean terminated;
- private volatile int submittedCount;
- private volatile int completedCount;
- private Object poolLock = new Object();
- private AtomicInteger threadCounter = new AtomicInteger();
- private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
- private Set<ScheduledFutureTask> scheduledTasks = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<ScheduledFutureTask, Boolean>()));
-
- private String poolName;
- private int maximumPoolSize;
- private Queue<Runnable> queue = new LinkedList<Runnable>();
- private Executor thread;
-
- public StatsCapturingSharedThreadPoolExecutor(String name, int maximumPoolSize, Executor thread) {
- this.maximumPoolSize = maximumPoolSize;
- this.poolName = name;
- this.thread = thread;
- }
-
- @Override
- public void execute(final Runnable command) {
- boolean atMaxThreads = false;
- boolean newMaxQueueSize = false;
- synchronized (poolLock) {
- checkForTermination();
- submittedCount++;
- atMaxThreads = activeCount == maximumPoolSize;
- if (atMaxThreads) {
- queue.add(command);
- int queueSize = queue.size();
- if (queueSize > highestQueueSize) {
- atMaxThreads = true;
- highestQueueSize = queueSize;
- }
- } else {
- activeCount++;
- highestActiveCount = Math.max(activeCount, highestActiveCount);
- }
- }
- if (atMaxThreads) {
- if (newMaxQueueSize && maximumPoolSize > 1) {
- LogManager.logWarning(LogConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
- }
- return;
- }
- this.thread.execute(new Runnable() {
- @Override
- public void run() {
- Thread t = Thread.currentThread();
- threads.add(t);
- String name = t.getName();
- t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
- LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
- }
- Runnable r = command;
- while (r != null) {
- boolean success = false;
- try {
- r.run();
- success = true;
- } finally {
- synchronized (poolLock) {
- if (success) {
- completedCount++;
- r = queue.poll();
- }
- if (!success || r == null) {
- threads.remove(t);
- activeCount--;
- if (activeCount == 0 && terminated) {
- poolLock.notifyAll();
- }
- }
- }
- t.setName(name);
- }
- }
- };
- });
- }
-
- private void checkForTermination() {
- if (terminated) {
- throw new RejectedExecutionException();
- }
- }
-
- public int getActiveCount() {
- return activeCount;
- }
-
- public int getSubmittedCount() {
- return submittedCount;
- }
-
- public int getCompletedCount() {
- return completedCount;
- }
-
- public int getPoolSize() {
- return activeCount;
- }
-
- public boolean isTerminated() {
- return terminated;
- }
-
- public void shutdown() {
- this.terminated = true;
- synchronized (scheduledTasks) {
- for (ScheduledFuture<?> future : new ArrayList<ScheduledFuture<?>>(scheduledTasks)) {
- future.cancel(false);
- }
- scheduledTasks.clear();
- }
- }
-
- public int getLargestPoolSize() {
- return this.highestActiveCount;
- }
-
- @Override
- public WorkerPoolStatisticsMetadata getStats() {
- WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
- stats.setName(poolName);
- stats.setQueued(queue.size());
- stats.setHighestQueued(highestQueueSize);
- stats.setActiveThreads(getActiveCount());
- stats.setMaxThreads(this.maximumPoolSize);
- stats.setTotalSubmitted(getSubmittedCount());
- stats.setHighestActiveThreads(getLargestPoolSize());
- stats.setTotalCompleted(getCompletedCount());
- return stats;
- }
-
- @Override
- public boolean hasWork() {
- synchronized (poolLock) {
- return this.getSubmittedCount() - this.getCompletedCount() > 0 && !this.isTerminated();
- }
- }
-
- @Override
- public List<Runnable> shutdownNow() {
- this.shutdown();
- synchronized (poolLock) {
- synchronized (threads) {
- for (Thread t : threads) {
- t.interrupt();
- }
- }
- List<Runnable> result = new ArrayList<Runnable>(queue);
- queue.clear();
- return result;
- }
- }
-
- @Override
- public boolean awaitTermination(long timeout, TimeUnit unit)
- throws InterruptedException {
- long timeoutMillis = unit.toMillis(timeout);
- long finalMillis = System.currentTimeMillis() + timeoutMillis;
- synchronized (poolLock) {
- while (this.activeCount > 0 || !terminated) {
- if (timeoutMillis < 1) {
- return false;
- }
- poolLock.wait(timeoutMillis);
- timeoutMillis = finalMillis - System.currentTimeMillis();
- }
- }
- return true;
- }
-
- @Override
- public ScheduledFuture<?> schedule(final Runnable command, long delay,
- TimeUnit unit) {
- checkForTermination();
- ScheduledFutureTask sft = new ScheduledFutureTask(command, false);
- synchronized (scheduledTasks) {
- ScheduledFuture<?> future = stpe.schedule(sft.getParent(), delay, unit);
- sft.setScheduledFuture(future);
- return sft;
- }
- }
-
- @Override
- public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command,
- long initialDelay, long period, TimeUnit unit) {
- checkForTermination();
- ScheduledFutureTask sft = new ScheduledFutureTask(command, true);
- synchronized (scheduledTasks) {
- ScheduledFuture<?> future = stpe.scheduleAtFixedRate(sft.getParent(), initialDelay, period, unit);
- sft.setScheduledFuture(future);
- return sft;
- }
- }
- }
-
- /**
- * Creates a WorkerPool that prefers thread reuse over thread creation based upon the given parameters
- *
- * @param name
- * @param numThreads the maximum number of worker threads allowed
- * @return
- */
- public static WorkerPool newWorkerPool(String name, int numThreads) {
- return new StatsCapturingSharedThreadPoolExecutor(name, numThreads, tpe);
- }
-
-
- public static WorkerPool newWorkerPool(String name, int numThreads, final Executor executor) {
- return new StatsCapturingSharedThreadPoolExecutor(name, numThreads, executor);
- }
-
-}
Deleted: branches/JCA/common-internal/src/main/java/org/teiid/ContainerHelper.java
===================================================================
--- branches/JCA/common-internal/src/main/java/org/teiid/ContainerHelper.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/main/java/org/teiid/ContainerHelper.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,40 +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;
-
-import java.security.Principal;
-
-import javax.security.auth.Subject;
-
-
-public interface ContainerHelper {
-
- boolean assosiateSecurityContext(String securityDomain, Object context);
-
- void clearSecurityContext(String securityDomain);
-
- Object getSecurityContext(String securityDomain);
-
- Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject);
-
- <T> T getService(Class<T> clazz);
-}
Deleted: branches/JCA/common-internal/src/main/java/org/teiid/ContainerUtil.java
===================================================================
--- branches/JCA/common-internal/src/main/java/org/teiid/ContainerUtil.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/main/java/org/teiid/ContainerUtil.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,48 +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;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-public class ContainerUtil {
-
- public static <T> T lookup(String jndiName) {
- try {
- InitialContext ic = new InitialContext();
- return (T)ic.lookup(jndiName);
- } catch (NamingException e) {
- throw new MetaMatrixRuntimeException("Object with JNDI name "+jndiName+" not found");
- }
- }
-
- public static boolean exists(String jndiName) {
- try {
- lookup(jndiName);
- return true;
- }catch(MetaMatrixRuntimeException e) {
- return false;
- }
- }
-}
Added: branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java
===================================================================
--- branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java (rev 0)
+++ branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+public interface SecurityHelper {
+
+ boolean assosiateSecurityContext(String securityDomain, Object context);
+
+ void clearSecurityContext(String securityDomain);
+
+ Object getSecurityContext(String securityDomain);
+
+ Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject);
+
+}
Property changes on: branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
===================================================================
--- branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -24,9 +24,11 @@
import java.sql.Timestamp;
+import javax.resource.spi.work.Work;
+
/**
*/
-public class FakeWorkItem implements Runnable {
+public class FakeWorkItem implements Work {
private static boolean DEBUG = false;
@@ -68,4 +70,9 @@
}
}
+ @Override
+ public void release() {
+
+ }
+
}
Copied: branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java (from rev 1854, branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeWorkManager.java)
===================================================================
--- branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java (rev 0)
+++ branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,73 @@
+package com.metamatrix.common.queue;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+
+import org.mockito.Mockito;
+
+public class FakeWorkManager implements WorkManager {
+ private Thread t;
+
+ @Override
+ public void doWork(Work arg0) throws WorkException {
+ execute(arg0, null, true);
+ }
+
+ @Override
+ public void doWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+ execute(arg0, arg3, true);
+ }
+
+ @Override
+ public void scheduleWork(Work arg0) throws WorkException {
+ execute(arg0, null, false);
+ }
+
+ @Override
+ public void scheduleWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+ execute(arg0, arg3, false);
+ }
+
+ @Override
+ public long startWork(Work arg0) throws WorkException {
+ execute(arg0, null, false);
+ return 0;
+ }
+
+ @Override
+ public long startWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+ execute(arg0, arg3, false);
+ return 0;
+ }
+
+ void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
+ if (arg3 != null) {
+ arg3.workAccepted(Mockito.mock(WorkEvent.class));
+ arg3.workStarted(Mockito.mock(WorkEvent.class));
+ }
+
+ t = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ arg0.run();
+ if (arg3 != null) {
+ arg3.workCompleted(Mockito.mock(WorkEvent.class));
+ }
+ }
+ });
+ t.start();
+ if (join) {
+ try {
+ t.join();
+ } catch (InterruptedException e) {
+ throw new WorkException(e);
+ }
+ }
+ }
+
+}
Property changes on: branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
===================================================================
--- branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,173 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.queue;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.junit.Test;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-/**
- */
-public class TestQueueWorkerPool {
-
- @Test public void testQueuing() throws Exception {
- final long SINGLE_WAIT = 50;
- final int WORK_ITEMS = 10;
- final int MAX_THREADS = 5;
-
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", MAX_THREADS); //$NON-NLS-1$
-
- for(int i=0; i<WORK_ITEMS; i++) {
- pool.execute(new FakeWorkItem(SINGLE_WAIT));
- }
-
- pool.shutdown();
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- assertTrue(pool.isTerminated());
- WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals(10, stats.getTotalCompleted());
- assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
- }
-
- @Test public void testThreadReuse() throws Exception {
- final long SINGLE_WAIT = 50;
- final long NUM_THREADS = 5;
-
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
-
- for(int i=0; i<NUM_THREADS; i++) {
- pool.execute(new FakeWorkItem(SINGLE_WAIT));
-
- try {
- Thread.sleep(SINGLE_WAIT*2);
- } catch(InterruptedException e) {
- }
- }
-
- pool.shutdown();
-
- WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
-
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- }
-
- @Test(expected=RejectedExecutionException.class) public void testShutdown() throws Exception {
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
- pool.shutdown();
- pool.execute(new FakeWorkItem(1));
- }
-
- @Test public void testScheduleCancel() throws Exception {
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
- ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- }
- }, 0, 5, TimeUnit.MILLISECONDS);
- future.cancel(true);
- assertFalse(future.cancel(true));
- }
-
- @Test public void testSchedule() throws Exception {
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
- final ArrayList<String> result = new ArrayList<String>();
- ScheduledFuture<?> future = pool.schedule(new Runnable() {
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- }
- }, 5, TimeUnit.MILLISECONDS);
- future.cancel(true);
- Thread.sleep(10);
- assertEquals(0, result.size());
- future = pool.schedule(new Runnable() {
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- }
- }, 5, TimeUnit.MILLISECONDS);
- Thread.sleep(10);
- pool.shutdown();
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- assertEquals(1, result.size());
- }
-
- @Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
- ScheduledFuture<?> future = pool.schedule(new Runnable() {
- @Override
- public void run() {
- throw new RuntimeException();
- }
- }, 0, TimeUnit.MILLISECONDS);
- future.get();
- }
-
- /**
- * Here each execution exceeds the period
- */
- @Test public void testScheduleRepeated() throws Exception {
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
- final ArrayList<String> result = new ArrayList<String>();
- ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- try {
- Thread.sleep(75);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- }, 0, 10, TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- future.cancel(true);
- assertEquals(2, result.size());
- }
-
- @Test public void testFailingWork() throws Exception {
- final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5); //$NON-NLS-1$
- final AtomicInteger count = new AtomicInteger();
- pool.execute(new Runnable() {
- @Override
- public void run() {
- count.getAndIncrement();
- throw new RuntimeException();
- }
- });
- Thread.sleep(100);
- assertEquals(1, count.get());
- }
-
-}
Copied: branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java (from rev 1835, branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java)
===================================================================
--- branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java (rev 0)
+++ branches/JCA/common-internal/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.queue;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.junit.Test;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+/**
+ */
+public class TestStatsCapturingWorkManager {
+
+ private WorkManager manager = new FakeWorkManager();
+
+ @Test public void testQueuing() throws Exception {
+ final long SINGLE_WAIT = 50;
+ final int WORK_ITEMS = 10;
+ final int MAX_THREADS = 5;
+
+ final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS); //$NON-NLS-1$
+
+ for(int i=0; i<WORK_ITEMS; i++) {
+ pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+ }
+
+ pool.shutdown();
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ assertTrue(pool.isTerminated());
+ WorkerPoolStatisticsMetadata stats = pool.getStats();
+ assertEquals(10, stats.getTotalCompleted());
+ assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
+ }
+
+ @Test public void testThreadReuse() throws Exception {
+ final long SINGLE_WAIT = 50;
+ final long NUM_THREADS = 5;
+
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+
+ for(int i=0; i<NUM_THREADS; i++) {
+ pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+
+ try {
+ Thread.sleep(SINGLE_WAIT*2);
+ } catch(InterruptedException e) {
+ }
+ }
+
+ pool.shutdown();
+
+ WorkerPoolStatisticsMetadata stats = pool.getStats();
+ assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
+
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ }
+
+ @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ pool.shutdown();
+ pool.scheduleWork(manager, new FakeWorkItem(1));
+ }
+
+ /*@Test public void testScheduleCancel() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ }
+ }, 0, 5, TimeUnit.MILLISECONDS);
+ future.cancel(true);
+ assertFalse(future.cancel(true));
+ }*/
+
+ @Test public void testSchedule() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ final ArrayList<String> result = new ArrayList<String>();
+ pool.scheduleWork(manager, new Work() {
+
+ @Override
+ public void run() {
+ result.add("hello"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void release() {
+
+ }
+ }, null, 5);
+ Thread.sleep(10);
+ pool.shutdown();
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ assertEquals(1, result.size());
+ }
+
+ /*(a)Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ ScheduledFuture<?> future = pool.schedule(new Runnable() {
+ @Override
+ public void run() {
+ throw new RuntimeException();
+ }
+ }, 0, TimeUnit.MILLISECONDS);
+ future.get();
+ }*/
+
+ /**
+ * Here each execution exceeds the period
+ */
+ /*@Test public void testScheduleRepeated() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ final ArrayList<String> result = new ArrayList<String>();
+ ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ result.add("hello"); //$NON-NLS-1$
+ try {
+ Thread.sleep(75);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }, 0, 10, TimeUnit.MILLISECONDS);
+ Thread.sleep(100);
+ future.cancel(true);
+ assertEquals(2, result.size());
+ }*/
+
+ @Test public void testFailingWork() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ final AtomicInteger count = new AtomicInteger();
+ pool.scheduleWork(manager, new Work() {
+ @Override
+ public void run() {
+ count.getAndIncrement();
+ throw new RuntimeException();
+ }
+
+ @Override
+ public void release() {
+
+ }
+ });
+ Thread.sleep(100);
+ assertEquals(1, count.get());
+ }
+
+}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -25,7 +25,6 @@
package com.metamatrix.dqp.message;
import java.io.Serializable;
-import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -69,11 +68,8 @@
// results fetch size
private int fetchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
- // The time when the command was created by the client
- private Date submittedTimestamp;
-
// The time when command begins processing on the server.
- private Date processingTimestamp;
+ private long processingTimestamp = System.currentTimeMillis();
// whether to use ResultSet cache if there is one
private boolean useResultSetCache;
@@ -148,54 +144,13 @@
}
/**
- * Get time that the time when the command was created by the client.
- * @return timestamp in millis
- */
- public Date getSubmittedTimestamp() {
- return submittedTimestamp;
- }
-
- /**
- * Set time that the time when the command was created by the client.
- * NOTE: By default, this gets set to the current time by the constructor.
- * @param submittedTimestamp Time submitted to server.
- */
- public void setSubmittedTimestamp(Date submittedTimestamp) {
- this.submittedTimestamp = submittedTimestamp;
- }
-
- /**
- * Start the clock on submission start - this should be called when the request is originally created.
- */
- public void markSubmissionStart() {
- setSubmittedTimestamp(new Date());
- }
-
-
- /**
* Get time that the request was assigned a unique ID by the server.
* @return timestamp in millis
*/
- public Date getProcessingTimestamp() {
+ public long getProcessingTimestamp() {
return processingTimestamp;
}
- /**
- * Set time that the request is submitted on the server.
- * @param processingTimestamp Time submitted to server.
- */
- public void setProcessingTimestamp(Date processingTimestamp) {
- this.processingTimestamp = processingTimestamp;
- }
-
- /**
- * Start the clock on processing times - this should be called when the query
- * hits the QueryService or SubscriptionService.
- */
- public void markProcessingStart() {
- setProcessingTimestamp(new Date());
- }
-
public boolean useResultSetCache() {
//not use caching when there is a txn
return useResultSetCache
Modified: branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -28,6 +28,7 @@
import javax.security.auth.login.LoginException;
import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.dqp.internal.process.DQPCore;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.security.AuthorizationException;
@@ -141,4 +142,7 @@
public void setLocalSession(long sessionID);
SessionMetadata getActiveSession(long sessionID);
+
+ void setDqp(DQPCore dqp);
+
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -41,6 +41,7 @@
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.annotation.ViewUse;
+import org.teiid.SecurityHelper;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
@@ -84,6 +85,8 @@
private String connectorName;
private StatsCapturingWorkManager workManager;
+ private SecurityHelper securityHelper;
+
protected ConnectorWorkItemFactory workItemFactory;
private volatile ConnectorStatus state = ConnectorStatus.NOT_INITIALIZED;
@@ -97,10 +100,10 @@
private SourceCapabilities cachedCapabilities;
public ConnectorManager(String name) {
- this(name, DEFAULT_MAX_THREADS);
+ this(name, DEFAULT_MAX_THREADS, null);
}
- public ConnectorManager(String name, int maxThreads) {
+ public ConnectorManager(String name, int maxThreads, SecurityHelper securityHelper) {
if (name == null) {
throw new IllegalArgumentException("Connector name can not be null");
}
@@ -109,8 +112,13 @@
}
this.connectorName = name;
this.workManager = new StatsCapturingWorkManager(this.connectorName, maxThreads);
+ this.securityHelper = securityHelper;
}
+ SecurityHelper getSecurityHelper() {
+ return securityHelper;
+ }
+
public String getName() {
return this.connectorName;
}
@@ -173,7 +181,6 @@
ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver, workManager);
Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
- message.markProcessingStart();
enqueueRequest(workManager, item);
}
@@ -181,7 +188,7 @@
try {
// if connector is immutable, then we do not want pass-on the transaction context.
if (work.securityContext.isTransactional()) {
- this.workManager.scheduleWork(workManager, work, 0, work.requestMsg.getTransactionContext(), work);
+ this.workManager.scheduleWork(workManager, work, work.requestMsg.getTransactionContext(), 0);
}
else {
this.workManager.scheduleWork(workManager, work);
@@ -241,7 +248,7 @@
public void release() {
}
- }, delay, null, null);
+ }, null, delay);
} catch (WorkException e) {
throw new ConnectorException(e);
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -29,8 +29,6 @@
import javax.resource.spi.work.WorkEvent;
-import org.teiid.ContainerHelper;
-import org.teiid.ContainerUtil;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
@@ -542,7 +540,7 @@
try {
asynchCancel();
} catch (ConnectorException e) {
- LogManager.logError(LogConstants.CTX_CONNECTOR, event.getException(), this.id.toString()); //$NON-NLS-1$
+ LogManager.logError(LogConstants.CTX_CONNECTOR, event.getException(), this.id.toString());
}
}
@@ -550,8 +548,7 @@
protected boolean assosiateSecurityContext() {
DQPWorkContext context = requestMsg.getWorkContext();
if (context.getSubject() != null) {
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
- return helper.assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
+ return manager.getSecurityHelper().assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
}
return false;
}
@@ -560,8 +557,7 @@
protected void clearSecurityContext() {
DQPWorkContext context = requestMsg.getWorkContext();
if (context.getSubject() != null) {
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
- helper.clearSecurityContext(context.getSecurityDomain());
+ manager.getSecurityHelper().clearSecurityContext(context.getSecurityDomain());
}
}
}
\ No newline at end of file
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -34,7 +34,7 @@
* Represents a task that performs work that may take more than one processing pass to complete.
* During processing the WorkItem may receive events asynchronously through the moreWork method.
*/
-public abstract class AbstractWorkItem implements Work, WorkListener{
+public abstract class AbstractWorkItem implements Work, WorkListener {
enum ThreadState {
MORE_WORK, WORKING, IDLE, DONE
Added: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+
+public interface ContainerServiceProvider {
+
+ XATerminator getXATerminator();
+
+ WorkManager getWorkManager();
+
+ DQPConfiguration getDQPConfiguration();
+
+}
Property changes on: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -39,7 +39,7 @@
private String processName = "localhost";
private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
- private boolean optionDebugAllowed = true;
+ private boolean processDebugAllowed;
private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
private int lobChunkSizeInKB = 100;
private int preparedPlanCacheMaxCount = SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL;
@@ -75,13 +75,13 @@
public void setTimeSliceInMilli(Integer timeSliceInMilli) {
this.timeSliceInMilli = timeSliceInMilli;
}
-
- public boolean isOptionDebugAllowed() {
- return optionDebugAllowed;
+
+ public boolean isProcessDebugAllowed() {
+ return processDebugAllowed;
}
-
- public void setOptionDebugAllowed(Boolean optionDebugAllowed) {
- this.optionDebugAllowed = optionDebugAllowed;
+
+ public void setProcessDebugAllowed(boolean processDebugAllowed) {
+ this.processDebugAllowed = processDebugAllowed;
}
public int getMaxRowsFetchSize() {
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -29,13 +29,18 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
+import org.teiid.SecurityHelper;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.impl.RequestMetadata;
@@ -49,6 +54,7 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.lob.LobChunk;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.queue.StatsCapturingWorkManager;
@@ -82,6 +88,51 @@
*/
public class DQPCore implements ClientSideDQP {
+ private final static class FutureWork<T> implements Work, WorkListener {
+ private final ResultsReceiver<T> receiver;
+ private final Callable<T> toCall;
+
+ private FutureWork(ResultsReceiver<T> receiver,
+ Callable<T> processor) {
+ this.receiver = receiver;
+ this.toCall = processor;
+ }
+
+ @Override
+ public void run() {
+ try {
+ receiver.receiveResults(toCall.call());
+ } catch (Throwable t) {
+ receiver.exceptionOccurred(t);
+ }
+ }
+
+ @Override
+ public void release() {
+
+ }
+
+ @Override
+ public void workAccepted(WorkEvent arg0) {
+
+ }
+
+ @Override
+ public void workCompleted(WorkEvent arg0) {
+
+ }
+
+ @Override
+ public void workRejected(WorkEvent arg0) {
+ receiver.exceptionOccurred(arg0.getException());
+ }
+
+ @Override
+ public void workStarted(WorkEvent arg0) {
+
+ }
+ }
+
static class ClientState {
List<RequestID> requests;
TempTableStoreImpl tempTableStoreImpl;
@@ -142,11 +193,17 @@
private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();
private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
private DQPContextCache contextCache;
+ private SecurityHelper securityHelper;
/**
* perform a full shutdown and wait for 10 seconds for all threads to finish
*/
public void stop() {
+ processWorkerPool.shutdownNow();
+ try {
+ processWorkerPool.awaitTermination(10, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ }
// TODO: Should we be doing more cleanup here??
LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
}
@@ -192,8 +249,7 @@
req.setExecutionId(holder.requestID.getExecutionID());
req.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
req.setCommand(holder.requestMsg.getCommandString());
- req.setCreatedTiime(holder.requestMsg.getSubmittedTimestamp().getTime());
- req.setProcessingTime(holder.requestMsg.getProcessingTimestamp().getTime());
+ req.setProcessingTime(holder.getProcessingTimestamp());
if (holder.getTransactionContext() != null && holder.getTransactionContext().getXid() != null) {
req.setTransactionId(holder.getTransactionContext().getXid().toString());
@@ -213,8 +269,7 @@
info.setExecutionId(arm.getRequestID().getExecutionID());
info.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
info.setCommand(arm.getCommand().toString());
- info.setCreatedTiime(arm.getSubmittedTimestamp().getTime());
- info.setProcessingTime(arm.getProcessingTimestamp().getTime());
+ info.setProcessingTime(arm.getProcessingTimestamp());
info.setSourceRequest(true);
info.setNodeId(arm.getAtomicRequestID().getNodeID());
@@ -229,7 +284,6 @@
public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage requestMsg) {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID requestID = workContext.getRequestID(reqID);
- requestMsg.markProcessingStart();
requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), maxFetchSize));
Request request = null;
if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
@@ -282,8 +336,8 @@
try {
this.processWorkerPool.scheduleWork(this.workManager, work);
} catch (WorkException e) {
- //TODO: how can be turn this into result?
- e.printStackTrace();
+ //TODO: cancel? close?
+ throw new MetaMatrixRuntimeException(e);
}
}
@@ -291,6 +345,14 @@
this.workManager = mgr;
}
+ SecurityHelper getSecurityHelper() {
+ return this.securityHelper;
+ }
+
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
+ }
+
public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
long requestId, String streamId)
throws MetaMatrixProcessingException {
@@ -353,17 +415,6 @@
return processWorkerPool.getStats();
}
- /**
- * Cancel and close all requests associated with the clientConnection/session. Also runs a final cleanup any caches within
- * the session's scope.
- */
- @Override
- public void terminateSession() throws MetaMatrixComponentException {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- terminateSession(context.getSessionId());
- }
-
-
public void terminateSession(long terminateeId) {
DQPWorkContext context = DQPWorkContext.getWorkContext();
@@ -492,7 +543,7 @@
public Collection<SessionMetadata> getActiveSessions() throws SessionServiceException {
if (this.sessionService == null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return this.sessionService.getActiveSessions();
}
@@ -506,7 +557,7 @@
public Collection<org.teiid.adminapi.Transaction> getTransactions() {
if (this.transactionService == null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return this.transactionService.getTransactions();
}
@@ -600,7 +651,7 @@
this.processorTimeslice = config.getTimeSliceInMilli();
this.maxFetchSize = config.getMaxRowsFetchSize();
- this.processorDebugAllowed = config.isOptionDebugAllowed();
+ this.processorDebugAllowed = config.isProcessDebugAllowed();
this.maxCodeTableRecords = config.getCodeTablesMaxRowsPerTable();
this.maxCodeTables = config.getCodeTablesMaxCount();
this.maxCodeRecords = config.getCodeTablesMaxRows();
@@ -651,7 +702,7 @@
this.transactionService = service;
}
- public List getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException {
+ public List<String> getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
QueryMetadataInterface metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
@@ -667,55 +718,108 @@
}
// local txn
- public void begin() throws XATransactionException {
+ public ResultsFuture<?> begin() throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().begin(threadId);
+ return null;
}
// local txn
- public void commit() throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().commit(threadId);
+ public ResultsFuture<?> commit() throws XATransactionException {
+ final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().commit(threadId);
+ return null;
+ }
+ };
+ return addWork(processor);
}
// local txn
- public void rollback() throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().rollback(threadId);
+ public ResultsFuture<?> rollback() throws XATransactionException {
+ final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().rollback(threadId);
+ return null;
+ }
+ };
+ return addWork(processor);
}
// global txn
- public void commit(MMXid xid, boolean onePhase) throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().commit(threadId, xid, onePhase, false);
+ public ResultsFuture<?> commit(final MMXid xid, final boolean onePhase) throws XATransactionException {
+ final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().commit(threadId, xid, onePhase, false);
+ return null;
+ }
+ };
+ return addWork(processor);
}
// global txn
- public void end(MMXid xid, int flags) throws XATransactionException {
+ public ResultsFuture<?> end(MMXid xid, int flags) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().end(threadId, xid, flags, false);
+ return null;
}
// global txn
- public void forget(MMXid xid) throws XATransactionException {
+ public ResultsFuture<?> forget(MMXid xid) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().forget(threadId, xid, false);
+ return null;
}
+
// global txn
- public int prepare(MMXid xid) throws XATransactionException {
- return this.getTransactionService().prepare(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+ public ResultsFuture<Integer> prepare(final MMXid xid) throws XATransactionException {
+ Callable<Integer> processor = new Callable<Integer>() {
+ @Override
+ public Integer call() throws Exception {
+ return getTransactionService().prepare(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+ }
+ };
+ return addWork(processor);
}
+
+ private <T> ResultsFuture<T> addWork(Callable<T> processor) {
+ ResultsFuture<T> result = new ResultsFuture<T>();
+ ResultsReceiver<T> receiver = result.getResultsReceiver();
+ try {
+ this.workManager.scheduleWork(new FutureWork<T>(receiver, processor));
+ } catch (WorkException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return result;
+ }
+
// global txn
- public Xid[] recover(int flag) throws XATransactionException {
- return this.getTransactionService().recover(flag, false);
+ public ResultsFuture<Xid[]> recover(int flag) throws XATransactionException {
+ ResultsFuture<Xid[]> result = new ResultsFuture<Xid[]>();
+ result.getResultsReceiver().receiveResults(this.getTransactionService().recover(flag, false));
+ return result;
}
// global txn
- public void rollback(MMXid xid) throws XATransactionException {
- this.getTransactionService().rollback(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+ public ResultsFuture<?> rollback(final MMXid xid) throws XATransactionException {
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().rollback(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+ return null;
+ }
+ };
+ return addWork(processor);
}
// global txn
- public void start(MMXid xid, int flags, int timeout)
+ public ResultsFuture<?> start(MMXid xid, int flags, int timeout)
throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().start(threadId, xid, flags, timeout, false);
+ return null;
}
public MetadataResult getMetadata(long requestID)
@@ -739,6 +843,7 @@
public void setSessionService(SessionService service) {
this.sessionService = service;
+ service.setDqp(this);
}
public SessionService getSessionService() {
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -332,7 +332,6 @@
RequestMessage request = workItem.requestMsg;
// build the atomic request based on original request + context info
AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID);
- aqr.markSubmissionStart();
aqr.setCommand(command);
aqr.setModelName(modelName);
aqr.setUseResultSetCache(request.useResultSetCache());
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -103,7 +103,7 @@
List<SPParameter> spParams = proc.getParameters();
proc.clearParameters();
int inParameterCount = values.size();
- if (this.requestMsg.isPreparedBatchUpdate() && values.size() > 0) {
+ if (this.requestMsg.isBatchedUpdate() && values.size() > 0) {
inParameterCount = ((List)values.get(0)).size();
}
int index = 1;
@@ -161,7 +161,7 @@
createCommandContext();
}
- if (requestMsg.isPreparedBatchUpdate()) {
+ if (requestMsg.isBatchedUpdate()) {
handlePreparedBatchUpdate();
} else {
List<Reference> params = prepPlan.getReferences();
@@ -186,7 +186,7 @@
*/
private void handlePreparedBatchUpdate() throws QueryMetadataException,
MetaMatrixComponentException, QueryResolverException, QueryPlannerException, QueryValidatorException {
- List<List<?>> paramValues = requestMsg.getParameterValues();
+ List<List<?>> paramValues = (List<List<?>>) requestMsg.getParameterValues();
if (paramValues.isEmpty()) {
throw new QueryValidatorException("No batch values sent for prepared batch update"); //$NON-NLS-1$
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -52,6 +52,7 @@
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
@@ -214,8 +215,9 @@
StoredProcedure proc = (StoredProcedure)userCommand;
returnsResultSet = proc.returnsResultSet();
}
- if (this.requestMsg.getRequireResultSet() != null && this.requestMsg.getRequireResultSet() != returnsResultSet) {
- throw new QueryValidatorException(DQPPlugin.Util.getString(this.requestMsg.getRequireResultSet()?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
+ if ((this.requestMsg.getResultsMode() == ResultsMode.UPDATECOUNT && !returnsUpdateCount)
+ || (this.requestMsg.getResultsMode() == ResultsMode.RESULTSET && !returnsResultSet)) {
+ throw new QueryValidatorException(DQPPlugin.Util.getString(this.requestMsg.getResultsMode()==ResultsMode.RESULTSET?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
}
// Create command context, used in rewriting, planning, and processing
@@ -288,7 +290,7 @@
private Command parseCommand() throws QueryParserException {
String[] commands = requestMsg.getCommands();
ParseInfo parseInfo = createParseInfo(this.requestMsg);
- if (!requestMsg.isBatchedUpdate()) {
+ if (requestMsg.isPreparedStatement() || requestMsg.isCallableStatement() || !requestMsg.isBatchedUpdate()) {
String commandStr = commands[0];
return QueryParser.getQueryParser().parseCommand(commandStr, parseInfo);
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -33,8 +33,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.teiid.ContainerHelper;
-import org.teiid.ContainerUtil;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -122,6 +120,9 @@
private TupleBatch savedBatch;
private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
+ /**The time when command begins processing on the server.*/
+ private long processingTimestamp = System.currentTimeMillis();
+
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
this.requestMsg = requestMsg;
this.requestID = requestID;
@@ -691,11 +692,14 @@
return dqpWorkContext;
}
+ public long getProcessingTimestamp() {
+ return processingTimestamp;
+ }
+
@Override
protected boolean assosiateSecurityContext() {
if (dqpWorkContext.getSubject() != null) {
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
- return helper.assosiateSecurityContext(dqpWorkContext.getSecurityDomain(),dqpWorkContext.getSecurityContext());
+ return dqpCore.getSecurityHelper().assosiateSecurityContext(dqpWorkContext.getSecurityDomain(),dqpWorkContext.getSecurityContext());
}
return false;
}
@@ -703,8 +707,7 @@
@Override
protected void clearSecurityContext() {
if (dqpWorkContext.getSubject() != null) {
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
- helper.clearSecurityContext(dqpWorkContext.getSecurityDomain());
+ dqpCore.getSecurityHelper().clearSecurityContext(dqpWorkContext.getSecurityDomain());
}
}
}
\ No newline at end of file
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -194,12 +194,11 @@
return new Xid[0];
}
- return new Xid[0];
-// try {
-// return this.provider.getXATerminator().recover(flag);
-// } catch (XAException e) {
-// throw new XATransactionException(e);
-// }
+ try {
+ return this.provider.getXATerminator().recover(flag);
+ } catch (XAException e) {
+ throw new XATransactionException(e);
+ }
}
/**
Modified: branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,8 +22,6 @@
package com.metamatrix.dqp.message;
-import java.util.Date;
-
import junit.framework.TestCase;
import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
@@ -50,7 +48,6 @@
message.setCommand(TestQueryImpl.helpExample());
message.setFetchSize(100);
message.setPartialResults(true);
- message.setProcessingTimestamp(new Date(12345678L));
message.setRequestID(new RequestID(5000L));
//AtomicRequestMessage-specific stuff
@@ -59,12 +56,13 @@
}
public void testSerialize() throws Exception {
- AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example());
+ AtomicRequestMessage example = example();
+ AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example);
assertEquals(TestQueryImpl.helpExample(), copy.getCommand());
assertEquals(100, copy.getFetchSize());
- assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
+ assertEquals(example.getProcessingTimestamp(), copy.getProcessingTimestamp());
assertEquals(new RequestID(5000L), copy.getRequestID());
assertEquals("2", copy.getWorkContext().getConnectionID()); //$NON-NLS-1$
//AtomicRequestMessage-specific stuff
Deleted: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeWorkManager.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeWorkManager.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeWorkManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,62 +0,0 @@
-package org.teiid.dqp.internal.datamgr.impl;
-
-import javax.resource.spi.work.ExecutionContext;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
-
-import org.mockito.Mockito;
-
-public class FakeWorkManager implements WorkManager {
- Thread t;
- @Override
- public void doWork(Work arg0) throws WorkException {
- execute(arg0);
- }
-
- @Override
- public void doWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- execute(arg0);
- }
-
- @Override
- public void scheduleWork(Work arg0) throws WorkException {
- execute(arg0);
- }
-
- @Override
- public void scheduleWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- execute(arg0);
- }
-
- @Override
- public long startWork(Work arg0) throws WorkException {
- execute(arg0);
- return 0;
- }
-
- @Override
- public long startWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- execute(arg0);
- return 0;
- }
-
- void execute(Work arg0) {
- if (arg0 instanceof WorkListener) {
- WorkListener wl = (WorkListener)arg0;
- wl.workAccepted(Mockito.mock(WorkEvent.class));
- wl.workStarted(Mockito.mock(WorkEvent.class));
- }
-
- t = new Thread(arg0);
- t.start();
-
- if (arg0 instanceof WorkListener) {
- WorkListener wl = (WorkListener)arg0;
- wl.workCompleted(Mockito.mock(WorkEvent.class));
- }
- }
-
-}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -39,6 +39,7 @@
import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.message.AtomicRequestMessage;
/**
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -37,6 +37,7 @@
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -49,6 +49,7 @@
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -144,7 +145,7 @@
// processing will close
assertFalse(state.isDoneProcessing());
- wm.doWork(state);
+ wm.doWork(state, 0, null, state);
AtomicResultsMessage arm = resultsFuture.get(1000, TimeUnit.MILLISECONDS);
@@ -273,9 +274,7 @@
state.requestClose();
assertFalse(resultsFuture.isDone());
- wm.doWork(state);
-
- wm.t.join();
+ wm.doWork(state, 0, null, state);
AtomicResultsMessage arm = resultsFuture.get(1000,
TimeUnit.MILLISECONDS);
@@ -292,18 +291,14 @@
FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
- wm.doWork(state);
-
- wm.t.join();
+ wm.doWork(state, 0, null, state);
assertFalse(state.isDoneProcessing());
connector.setReturnsFinalBatch(true);
state.requestMore();
- wm.doWork(state);
+ wm.doWork(state, 0, null, state);
- wm.t.join();
-
assertTrue(state.isDoneProcessing());
assertEquals(3, resultsReceiver.results.size());
@@ -318,9 +313,7 @@
FakeWorkManager wm = new FakeWorkManager();
FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
- wm.doWork(state);
-
- wm.t.join();
+ wm.doWork(state, 0, null, state);
assertFalse(state.isDoneProcessing());
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -38,9 +38,9 @@
import org.teiid.adminapi.Visibility;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import org.teiid.dqp.internal.datamgr.impl.FakeWorkManager;
import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
@@ -49,14 +49,13 @@
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-
public class TestDQPCore {
private DQPCore core;
@Before public void setUp() throws Exception {
DQPWorkContext context = FakeMetadataFactory.buildWorkContext(FakeMetadataFactory.exampleBQTCached(), FakeMetadataFactory.exampleBQTVDB());
- context.getVDB().getModel("BQT3").setVisibility(Visibility.PRIVATE);
+ context.getVDB().getModel("BQT3").setVisibility(Visibility.PRIVATE); //$NON-NLS-1$
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
@@ -77,7 +76,6 @@
public RequestMessage exampleRequestMessage(String sql) {
RequestMessage msg = new RequestMessage(sql);
- msg.setCallableStatement(false);
msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
msg.setFetchSize(10);
msg.setPartialResults(false);
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -86,8 +86,6 @@
private RequestID addRequest(DQPCore rm, String sessionId, int executionId) {
RequestMessage r0 = new RequestMessage("test command"); //$NON-NLS-1$
RequestID id = new RequestID(sessionId, executionId);
- r0.markSubmissionStart();
- r0.markProcessingStart();
addRequest(rm, r0, id, null, null);
return id;
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -33,10 +33,10 @@
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import org.teiid.dqp.internal.datamgr.impl.FakeWorkManager;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -42,6 +42,7 @@
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -232,11 +233,14 @@
//Create Request
RequestMessage request = new RequestMessage(preparedSql);
- request.setPreparedStatement(true);
- request.setCallableStatement(callableStatement);
+ if (callableStatement) {
+ request.setStatementType(StatementType.CALLABLE);
+ } else {
+ request.setStatementType(StatementType.PREPARED);
+ }
request.setParameterValues(values);
if (values != null && values.size() > 0 && values.get(0) instanceof List) {
- request.setPreparedBatchUpdate(true);
+ request.setBatchedUpdate(true);
}
if (limitResults) {
request.setRowLimit(1);
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -39,6 +39,7 @@
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -190,7 +191,7 @@
RequestMessage message = new RequestMessage(QUERY);
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
- message.setPreparedStatement(true);
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(new ArrayList());
helpProcessMessage(message, cache, workContext);
@@ -198,7 +199,7 @@
//Try again, now that plan is already cached.
//If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
- message.setPreparedStatement(true);
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(new ArrayList());
helpProcessMessage(message, cache, workContext);
Deleted: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossContainerHelper.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossContainerHelper.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossContainerHelper.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,126 +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.jboss;
-
-import java.io.Serializable;
-import java.security.Principal;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.security.auth.Subject;
-
-import org.jboss.security.SecurityContext;
-import org.teiid.ContainerHelper;
-import org.teiid.deployers.VDBRepository;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.DQPManagementView;
-
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.platform.security.api.service.SessionService;
-
-public class JBossContainerHelper implements ContainerHelper, Serializable{
- private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
-
- private static final long serialVersionUID = 1318670652523708608L;
-
- @Override
- public boolean assosiateSecurityContext(String securityDomain, Object newContext) {
- SecurityContext context = SecurityActions.getSecurityContext();
- if (context == null || (!context.getSecurityDomain().equals(securityDomain) && newContext != null)) {
- SecurityActions.setSecurityContext((SecurityContext)newContext);
- return true;
- }
- return false;
- }
-
- @Override
- public void clearSecurityContext(String securityDomain) {
- SecurityContext sc = SecurityActions.getSecurityContext();
- if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
- SecurityActions.clearSecurityContext();
- }
- }
-
- @Override
- public Object getSecurityContext(String securityDomain) {
- SecurityContext sc = SecurityActions.getSecurityContext();
- if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
- return sc;
- }
- return null;
- }
-
- @Override
- public Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject) {
- SecurityActions.pushSecurityContext(p, credentials, subject, securityDomain);
- return getSecurityContext(securityDomain);
- }
-
- public <T> T getService(Class<T> type) {
- if (type == null) {
- throw new IllegalArgumentException("Null type");
- }
- Object result = this.attachments.get(type.getName());
- if (result == null) {
- return null;
- }
- return type.cast(result);
- }
-
- protected <T> T addAttchment(Class<T> type, T attachment) {
- if (type == null) {
- throw new IllegalArgumentException("Null type");
- }
- Object result = this.attachments.put(type.getName(), attachment);
- if (result == null) {
- return null;
- }
- return type.cast(result);
-
- }
-
- public void setVDBRepository(VDBRepository repo) {
- addAttchment(VDBRepository.class, repo);
- }
-
- public void setAuthorizationService(AuthorizationService service) {
- addAttchment(AuthorizationService.class, service);
- }
-
- public void setSessionService(SessionService service) {
- addAttchment(SessionService.class, service);
- }
-
- public void setBufferService(BufferService service) {
- addAttchment(BufferService.class, service);
- }
-
- public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
- addAttchment(ConnectorManagerRepository.class, repo);
- }
-
- public void setDQPManager(DQPManagementView holder) {
- addAttchment(DQPManagementView.class, holder);
- }
-}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,68 @@
+/*
+ * 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.jboss;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.jboss.security.SecurityContext;
+import org.teiid.SecurityHelper;
+
+public class JBossSecurityHelper implements SecurityHelper, Serializable {
+
+ @Override
+ public boolean assosiateSecurityContext(String securityDomain, Object newContext) {
+ SecurityContext context = SecurityActions.getSecurityContext();
+ if (context == null || (!context.getSecurityDomain().equals(securityDomain) && newContext != null)) {
+ SecurityActions.setSecurityContext((SecurityContext)newContext);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void clearSecurityContext(String securityDomain) {
+ SecurityContext sc = SecurityActions.getSecurityContext();
+ if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
+ SecurityActions.clearSecurityContext();
+ }
+ }
+
+ @Override
+ public Object getSecurityContext(String securityDomain) {
+ SecurityContext sc = SecurityActions.getSecurityContext();
+ if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
+ return sc;
+ }
+ return null;
+ }
+
+ @Override
+ public Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject) {
+ SecurityActions.pushSecurityContext(p, credentials, subject, securityDomain);
+ return getSecurityContext(securityDomain);
+ }
+
+}
Property changes on: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -34,6 +34,7 @@
import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.teiid.SecurityHelper;
import org.teiid.connector.api.ConnectorException;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
@@ -41,6 +42,7 @@
public class ConnectorBindingDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
protected Logger log = Logger.getLogger(getClass());
private ManagedObjectFactory mof;
+ private SecurityHelper securityHelper;
private ConnectorManagerRepository connectorManagerRepository;
@@ -83,7 +85,7 @@
ConnectorManager createConnectorManger(String deployedConnectorName, int maxThreads) {
- ConnectorManager mgr = new ConnectorManager(deployedConnectorName, maxThreads);
+ ConnectorManager mgr = new ConnectorManager(deployedConnectorName, maxThreads, securityHelper);
return mgr;
}
@@ -130,4 +132,8 @@
public void setManagedObjectFactory(ManagedObjectFactory mof) {
this.mof = mof;
}
+
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
+ }
}
Modified: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -21,11 +21,16 @@
*/
package org.teiid.jboss.deployers;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
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 org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
@@ -33,25 +38,29 @@
import org.jboss.logging.Logger;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
-import org.teiid.ContainerHelper;
-import org.teiid.ContainerUtil;
+import org.teiid.SecurityHelper;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.jboss.AdminProvider;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.ContainerServiceProvider;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.internal.process.DQPManagementView;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
import org.teiid.dqp.internal.transaction.XidFactory;
+import org.teiid.transport.ClientServiceRegistry;
+import org.teiid.transport.ClientServiceRegistryImpl;
import org.teiid.transport.LogonImpl;
import org.teiid.transport.SocketConfiguration;
import org.teiid.transport.SocketTransport;
+import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.service.AuthorizationService;
@@ -59,21 +68,39 @@
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.platform.security.api.ILogon;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
-public class RuntimeEngineDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> {
- private static final String TEIID_RUNTIME = "java:teiid/runtime-engine";
+public class RuntimeEngineDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ClientServiceRegistry {
+ private static final String TEIID_RUNTIME = "java:teiid/runtime-engine"; //$NON-NLS-1$
protected Logger log = Logger.getLogger(getClass());
- private ContainerHelper containerHelper;
+ //injected state
+ private AuthorizationService authorizationService;
+ private SecurityHelper securityHelper;
+ private SessionService sessionService;
+ private BufferService bufferService;
+ private ConnectorManagerRepository connectorManagerRepository;
+ private DQPManagementView dqpManagementView;
private SocketTransport jdbcSocketTransport;
private SocketConfiguration jdbcSocketConfiguration;
private SocketTransport adminSocketTransport;
private SocketConfiguration adminSocketConfiguration;
+ //locally constructed client services
+ private DQPCore dqp;
+ private ILogon logon;
+ private Admin admin;
+ private ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
public RuntimeEngineDeployer() {
super(ManagedConnectionFactoryDeploymentGroup.class);
setRelativeOrder(3000);
}
+
+ @Override
+ public <T> T getClientService(Class<T> iface)
+ throws ComponentNotFoundException {
+ return this.csr.getClientService(iface);
+ }
@Override
public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
@@ -81,13 +108,12 @@
for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
String connectorDefinition = data.getConnectionDefinition();
- if (connectorDefinition.equals("com.metamatrix.common.comm.api.ServerConnectionFactory")) {
+ if (connectorDefinition.equals(ServerConnectionFactory.class.getName())) {
startEngine();
log.info("Teiid Engine Started = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
}
}
}
-
@Override
public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
@@ -96,15 +122,15 @@
for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
String connectorDefinition = data.getConnectionDefinition();
- if (connectorDefinition.equals("com.metamatrix.common.comm.api.ServerConnectionFactory")) {
+ if (connectorDefinition.equals(ServerConnectionFactory.class.getName())) {
stopEngine();
log.info("Teiid Engine Stopped = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
}
}
}
- public void setContainerHelper(ContainerHelper helper) {
- this.containerHelper = helper;
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
}
public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
@@ -115,11 +141,32 @@
this.adminSocketConfiguration = socketConfig;
}
+ public void setAuthorizationService(AuthorizationService service) {
+ this.authorizationService = service;
+ }
+
+ public void setSessionService(SessionService service) {
+ this.sessionService = service;
+ }
+
+ public void setBufferService(BufferService service) {
+ this.bufferService = service;
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.connectorManagerRepository = repo;
+ }
+
+ public void setDQPManager(DQPManagementView holder) {
+ this.dqpManagementView = holder;
+ }
+
private void startEngine() throws DeploymentException {
- ServerConnectionFactory scf = null;
+ ContainerServiceProvider scf = null;
try {
- scf = ContainerUtil.lookup(TEIID_RUNTIME);
- } catch (MetaMatrixRuntimeException e) {
+ InitialContext ic = new InitialContext();
+ scf = (ContainerServiceProvider)ic.lookup(TEIID_RUNTIME);
+ } catch (NamingException e) {
throw new DeploymentException(e.getMessage());
}
@@ -127,33 +174,31 @@
createClientServices(scf);
// Start the socket transport
- DQPConfiguration config = scf.getService(DQPConfiguration.class);
+ DQPConfiguration config = scf.getDQPConfiguration();
if (config.getBindAddress() != null) {
this.jdbcSocketConfiguration.setBindAddress(config.getBindAddress());
}
if (config.getPortNumber() > 0) {
this.jdbcSocketConfiguration.setPortNumber(config.getPortNumber());
}
+
+ csr.registerClientService(ILogon.class, proxyService(ILogon.class, logon), com.metamatrix.common.util.LogConstants.CTX_SERVER);
+ csr.registerClientService(ClientSideDQP.class, proxyService(ClientSideDQP.class, dqp), LogConstants.CTX_QUERY_SERVICE);
+ csr.registerClientService(Admin.class, proxyService(Admin.class, admin), LogConstants.CTX_ADMIN_API);
- this.jdbcSocketTransport = new SocketTransport(this.jdbcSocketConfiguration);
- this.jdbcSocketTransport.setWorkManager(scf.getService(WorkManager.class));
+ this.jdbcSocketTransport = new SocketTransport(this.jdbcSocketConfiguration, csr);
this.jdbcSocketTransport.start();
log.info("Teiid JDBC = " + (this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()); //$NON-NLS-1$
-
- this.adminSocketTransport = new SocketTransport(this.adminSocketConfiguration);
- this.adminSocketTransport.setWorkManager(scf.getService(WorkManager.class));
+
+ this.adminSocketTransport = new SocketTransport(this.adminSocketConfiguration, csr);
this.adminSocketTransport.start();
log.info("Teiid Admin = " + (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()); //$NON-NLS-1$
}
private void stopEngine() {
-
- try {
- ServerConnectionFactory scf = ContainerUtil.lookup(TEIID_RUNTIME);
- ClientSideDQP dqp = scf.getService(ClientSideDQP.class);
- ((DQPCore)dqp).stop();
- } catch(MetaMatrixRuntimeException e) {
- // this bean is already shutdown
+ if (dqp != null) {
+ dqp.stop();
+ dqp = null;
}
// Stop socket transport(s)
@@ -168,29 +213,25 @@
}
}
- private void createClientServices(ServerConnectionFactory scf) throws DeploymentException {
- DQPCore dqp = new DQPCore();
- dqp.setTransactionService(getTransactionService("localhost", scf.getService(XATerminator.class)));
- dqp.setWorkManager(scf.getService(WorkManager.class));
- dqp.setAuthorizationService(this.containerHelper.getService(AuthorizationService.class));
- dqp.setBufferService(this.containerHelper.getService(BufferService.class));
- dqp.setSessionService(this.containerHelper.getService(SessionService.class));
- dqp.setConnectorManagerRepository(this.containerHelper.getService(ConnectorManagerRepository.class));
- dqp.start(scf.getService(DQPConfiguration.class));
+ private void createClientServices(ContainerServiceProvider scf) throws DeploymentException {
+ dqp = new DQPCore();
+ dqp.setTransactionService(getTransactionService("localhost", scf.getXATerminator())); //$NON-NLS-1$
+ dqp.setWorkManager(scf.getWorkManager());
+ dqp.setAuthorizationService(authorizationService);
+ dqp.setBufferService(bufferService);
+ dqp.setSessionService(sessionService);
+ dqp.setConnectorManagerRepository(connectorManagerRepository);
+ dqp.setSecurityHelper(this.securityHelper);
+ dqp.start(scf.getDQPConfiguration());
- DQPManagementView holder = this.containerHelper.getService(DQPManagementView.class);
- holder.setDQP(dqp);
+ dqpManagementView.setDQP(dqp);
- scf.registerClientService(ILogon.class, new LogonImpl(dqp.getSessionService(), "teiid-cluster"), com.metamatrix.common.util.LogConstants.CTX_SERVER);
- scf.registerClientService(ClientSideDQP.class, dqp, LogConstants.CTX_QUERY_SERVICE);
-
+ this.logon = new LogonImpl(dqp.getSessionService(), "teiid-cluster"); //$NON-NLS-1$
try {
- scf.registerClientService(Admin.class, AdminProvider.getLocal(), LogConstants.CTX_ADMIN_API);
- } catch (AdminComponentException e) {
- throw new DeploymentException(e.getCause());
- }
-
- scf.registerClientService(ContainerHelper.class, this.containerHelper, LogConstants.CTX_DQP);
+ this.admin = AdminProvider.getLocal();
+ } catch (AdminComponentException e) {
+ throw new DeploymentException(e.getCause());
+ }
}
private TransactionService getTransactionService(String processName, XATerminator terminator) {
@@ -201,4 +242,48 @@
return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
}
+ private <T> T proxyService(final Class<T> iface, final T instance) {
+
+ return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
+
+ public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
+
+ Throwable exception = null;
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ try {
+ if (!(iface.equals(ILogon.class))) {
+ logon.assertIdentity(SessionToken.getSession());
+ assosiateSecurityContext();
+ }
+
+ return arg1.invoke(instance, arg2);
+ } catch (InvocationTargetException e) {
+ exception = e.getTargetException();
+ } catch(Throwable t){
+ exception = t;
+ } finally {
+ clearSecurityContext();
+ DQPWorkContext.releaseWorkContext();
+ Thread.currentThread().setContextClassLoader(current);
+ }
+ throw ExceptionUtil.convertException(arg1, exception);
+ }
+ }));
+ }
+
+ private boolean assosiateSecurityContext() {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ if (context.getSubject() != null) {
+ return securityHelper.assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
+ }
+ return false;
+ }
+
+ private void clearSecurityContext() {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ if (context.getSubject() != null) {
+ securityHelper.clearSecurityContext(context.getSecurityDomain());
+ }
+ }
+
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -26,14 +26,10 @@
import javax.resource.spi.ConnectionRequestInfo;
-import com.metamatrix.common.comm.ClientServiceRegistry;
-
public class ConnectionInfo implements ConnectionRequestInfo {
Properties properties;
- ClientServiceRegistry clientServices;
- public ConnectionInfo(Properties properties,ClientServiceRegistry clientServices) {
+ public ConnectionInfo(Properties properties) {
this.properties = properties;
- this.clientServices = clientServices;
}
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,33 +22,23 @@
package org.teiid;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkManager;
-import org.teiid.adminapi.Admin;
+import org.teiid.dqp.internal.process.ContainerServiceProvider;
import org.teiid.dqp.internal.process.DQPConfiguration;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.jdbc.LogConfigurationProvider;
import com.metamatrix.jdbc.LogListernerProvider;
-import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.SessionToken;
/**
@@ -56,14 +46,11 @@
* This is also responsible for initializing the DQP if the DQP instance is not
* already alive.
*/
-public class TeiidConnectionFactory implements ServerConnectionFactory {
+public class TeiidConnectionFactory implements ServerConnectionFactory, ContainerServiceProvider {
private TeiidResourceAdapter ra;
private TeiidManagedConnectionFactory mcf;
private ConnectionManager cxManager;
- private ConcurrentHashMap<Class, Object> clientServices = new ConcurrentHashMap<Class, Object>();
- private ConcurrentHashMap<Class, String> loggingContext = new ConcurrentHashMap<Class, String>();
-
public TeiidConnectionFactory(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
this.ra = ra;
@@ -78,99 +65,27 @@
public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
try {
// this code will not be invoked as teiid does not use managed connection.
- return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, null));
+ return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties));
} catch (ResourceException e) {
throw new ConnectionException(e);
}
}
- public <T> T getService(Class<T> type) {
- if (type.equals(WorkManager.class)) {
- return type.cast(this.ra.getWorkManager());
- }
-
- if (type.equals(XATerminator.class)) {
- return type.cast(this.ra.getXATerminator());
- }
-
- if (type.equals(DQPConfiguration.class)) {
- return type.cast(mcf);
- }
-
- // see if there are any client services.
- Object service = this.clientServices.get(type);
- if (service != null) {
- return type.cast(proxyService(type, type.cast(service)));
- }
-
- return null;
+ @Override
+ public WorkManager getWorkManager() {
+ return this.ra.getWorkManager();
}
@Override
- public <T> void registerClientService(Class<T> type, T instance, String loggingContext) {
- this.clientServices.put(type, instance);
- this.loggingContext.put(type, loggingContext);
+ public XATerminator getXATerminator() {
+ return this.ra.getXATerminator();
}
-
- @Override
- public <T> String getLoggingContextForService(Class<T> type) {
- return this.loggingContext.get(type);
- }
- private <T> T proxyService(final Class<T> iface, final T instance) {
-
- return (T) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
-
- public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
-
- Throwable exception = null;
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try {
- if (!(iface.equals(ILogon.class))) {
- ((ILogon)clientServices.get(ILogon.class)).assertIdentity(SessionToken.getSession());
- assosiateSecurityContext();
- }
-
- // if this is admin session, do not allow any interface other then "Admin"
- if (DQPWorkContext.getWorkContext().isAdmin()) {
- if (!(iface.equals(Admin.class)) && !arg1.getName().equals("ping")) {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- throw new IllegalAccessException(DQPEmbeddedPlugin.Util.getString("Illegal_access_on_admin", context.getSubject(), context.getClientAddress()));
- }
- }
-
- return arg1.invoke(instance, arg2);
- } catch (InvocationTargetException e) {
- exception = e.getTargetException();
- } catch(Throwable t){
- exception = t;
- } finally {
- clearSecurityContext();
- DQPWorkContext.releaseWorkContext();
- Thread.currentThread().setContextClassLoader(current);
- }
- throw ExceptionUtil.convertException(arg1, exception);
- }
- });
- }
-
- private boolean assosiateSecurityContext() {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- if (context.getSubject() != null) {
- ContainerHelper helper = (ContainerHelper)this.clientServices.get(ContainerHelper.class);
- return helper.assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
- }
- return false;
- }
+ @Override
+ public DQPConfiguration getDQPConfiguration() {
+ return mcf;
+ }
- private void clearSecurityContext() {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- if (context.getSubject() != null) {
- ContainerHelper helper = (ContainerHelper)this.clientServices.get(ContainerHelper.class);
- helper.clearSecurityContext(context.getSecurityDomain());
- }
- }
-
// public MMProcess getProcess() {
//
// Properties props = this.bootProperties;
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -37,11 +37,7 @@
import javax.transaction.xa.XAResource;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.transport.LocalServerConnection;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.comm.exception.ConnectionException;
-
public class TeiidManagedConnection implements ManagedConnection {
protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
private PrintWriter log;
Deleted: branches/JCA/runtime/src/main/java/org/teiid/services/MembershipServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/services/MembershipServiceImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/services/MembershipServiceImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -1,222 +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.services;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.teiid.ContainerHelper;
-import org.teiid.ContainerUtil;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.platform.security.api.Credentials;
-
-/**
- * This class serves as the primary implementation of the
- * Membership Service. Based on the security domains specified this class delegates the responsibility of
- * authenticating user to those security domains in the order they are defined.
- */
-public class MembershipServiceImpl {
- public static final String AT = "@"; //$NON-NLS-1$
- private LoginContext loginContext;
- private String userName;
- private String securitydomain;
- private Object credentials;
-
- public void authenticateUser(String username, Credentials credential, String applicationName, List<String> domains) throws LoginException {
-
- LogManager.logTrace(LogConstants.CTX_MEMBERSHIP, new Object[] {"authenticateUser", username, applicationName}); //$NON-NLS-1$
-
- final String baseUsername = getBaseUsername(username);
- final char[] password = credential.getCredentialsAsCharArray();
-
- // If username specifies a domain (user@domain) only that domain is authenticated against.
- // If username specifies no domain, then all domains are tried in order.
- for (String domain:getDomainsForUser(domains, username)) {
-
- try {
- CallbackHandler handler = new CallbackHandler() {
- @Override
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- NameCallback nc = (NameCallback)callbacks[i];
- nc.setName(baseUsername);
- } else if (callbacks[i] instanceof PasswordCallback) {
- PasswordCallback pc = (PasswordCallback)callbacks[i];
- pc.setPassword(password);
- credentials = password;
- } else {
- throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
- }
- }
- }
- };
-
- // this is the configured login for teiid
- this.loginContext = createLoginContext(domain,handler);
- this.loginContext.login();
- this.userName = baseUsername+AT+domain;
- this.securitydomain = domain;
-
- return;
- } catch (LoginException e) {
- LogManager.logDetail(LogConstants.CTX_MEMBERSHIP,e.getMessage());
- }
- }
- throw new LoginException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.The_username_0_and/or_password_are_incorrect", username ));
- }
-
- protected LoginContext createLoginContext(String domain, CallbackHandler handler) throws LoginException {
- return new LoginContext(domain, handler);
- }
-
- public LoginContext getLoginContext() {
- return this.loginContext;
- }
-
- public String getUserName() {
- return this.userName;
- }
-
- public String getSecurityDomain() {
- return this.securitydomain;
- }
-
- public Object getSecurityContext() {
- Object sc = null;
- if (this.loginContext != null) {
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
- sc = helper.getSecurityContext(this.securitydomain);
- if ( sc == null){
- Subject subject = this.loginContext.getSubject();
- Principal principal = null;
- for(Principal p:subject.getPrincipals()) {
- if (this.userName.startsWith(p.getName())) {
- principal = p;
- break;
- }
- }
- return helper.createSecurityContext(this.securitydomain, principal, credentials, subject);
- }
- }
- return sc;
- }
-
- static String getBaseUsername(String username) {
- if (username == null) {
- return username;
- }
-
- int index = getQualifierIndex(username);
-
- String result = username;
-
- if (index != -1) {
- result = username.substring(0, index);
- }
-
- //strip the escape character from the remaining ats
- return result.replaceAll("\\\\"+AT, AT); //$NON-NLS-1$
- }
-
- static String escapeName(String name) {
- if (name == null) {
- return name;
- }
-
- return name.replaceAll(AT, "\\\\"+AT); //$NON-NLS-1$
- }
-
- static String getDomainName(String username) {
- if (username == null) {
- return username;
- }
-
- int index = getQualifierIndex(username);
-
- if (index != -1) {
- return username.substring(index + 1);
- }
-
- return null;
- }
-
- static int getQualifierIndex(String username) {
- int index = username.length();
- while ((index = username.lastIndexOf(AT, --index)) != -1) {
- if (index > 0 && username.charAt(index - 1) != '\\') {
- return index;
- }
- }
-
- return -1;
- }
-
- private Collection<String> getDomainsForUser(List<String> domains, String username) {
- // If username is null, return all domains
- if (username == null) {
- return domains;
- }
-
- String domain = getDomainName(username);
-
- if (domain == null) {
- return domains;
- }
-
- // ------------------------------------------
- // Handle usernames having @ sign
- // ------------------------------------------
- String domainHolder = null;
- for (String d:domains) {
- if(d.equalsIgnoreCase(domain)) {
- domainHolder = d;
- break;
- }
- }
-
- if (domainHolder == null) {
- return Collections.EMPTY_LIST;
- }
-
- LinkedList result = new LinkedList();
- result.add(domainHolder);
- return result;
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,11 +22,9 @@
package org.teiid.services;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -39,9 +37,11 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
+import org.teiid.SecurityHelper;
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.deployers.VDBRepository;
+import org.teiid.dqp.internal.process.DQPCore;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.security.SessionServiceException;
@@ -50,7 +50,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.platform.security.api.Credentials;
@@ -60,9 +59,7 @@
/**
* This class serves as the primary implementation of the Session Service.
*/
-public class SessionServiceImpl implements SessionService, Serializable {
- private static final long serialVersionUID = 3366022966048148299L;
-
+public class SessionServiceImpl implements SessionService {
public static final String SECURITY_DOMAINS = "securitydomains"; //$NON-NLS-1$
/*
@@ -70,10 +67,16 @@
*/
private long sessionMaxLimit = DEFAULT_MAX_SESSIONS;
private long sessionExpirationTimeLimit = DEFAULT_SESSION_EXPIRATION;
+ /*
+ * Injected state
+ */
private VDBRepository vdbRepository;
+ private SecurityHelper securityHelper;
+ private DQPCore dqp;
+
private Map<Long, SessionMetadata> sessionCache = new ConcurrentHashMap<Long, SessionMetadata>();
- private transient Timer sessionMonitor = new Timer("SessionMonitor", true);
+ private Timer sessionMonitor = new Timer("SessionMonitor", true); //$NON-NLS-1$
private AtomicLong idSequence = new AtomicLong();
private LinkedList<String> securityDomains = new LinkedList<String>();
private LinkedList<String> adminSecurityDomains = new LinkedList<String>();
@@ -107,6 +110,13 @@
if (info == null) {
throw new InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
}
+ if (info.getVDBName() != null) {
+ try {
+ dqp.terminateSession(info.getSessionId());
+ } catch (Exception e) {
+ LogManager.logWarning(LogConstants.CTX_SESSION,e,"Exception terminitating session"); //$NON-NLS-1$
+ }
+ }
// try to log out of the context.
try {
@@ -128,7 +138,7 @@
Properties productInfo = new Properties();
LoginContext loginContext = null;
- String securityDomain = "none";
+ String securityDomain = "none"; //$NON-NLS-1$
Object securityContext = null;
List<String> domains = this.securityDomains;
if (adminConnection) {
@@ -138,11 +148,11 @@
if (!domains.isEmpty()) {
// Authenticate user...
// if not authenticated, this method throws exception
- MembershipServiceImpl membership = authenticate(userName, credentials, applicationName, domains);
+ TeiidLoginContext membership = authenticate(userName, credentials, applicationName, domains);
loginContext = membership.getLoginContext();
userName = membership.getUserName();
securityDomain = membership.getSecurityDomain();
- securityContext = membership.getSecurityContext();
+ securityContext = membership.getSecurityContext(securityHelper);
}
// Validate VDB and version if logging on to server product...
@@ -197,9 +207,9 @@
return newSession;
}
- protected MembershipServiceImpl authenticate(String userName, Credentials credentials, String applicationName, List<String> domains)
+ protected TeiidLoginContext authenticate(String userName, Credentials credentials, String applicationName, List<String> domains)
throws LoginException {
- MembershipServiceImpl membership = new MembershipServiceImpl();
+ TeiidLoginContext membership = new TeiidLoginContext();
membership.authenticateUser(userName, credentials, applicationName, domains);
return membership;
}
@@ -281,10 +291,8 @@
if (domainNameOrder != null && domainNameOrder.trim().length()>0) {
LogManager.logDetail(LogConstants.CTX_MEMBERSHIP, "Security Enabled: true"); //$NON-NLS-1$
- List domainNames = StringUtil.split(domainNameOrder, ","); //$NON-NLS-1$
- Iterator domainNameItr = domainNames.iterator();
- while ( domainNameItr.hasNext() ) {
- String domainName = ((String) domainNameItr.next()).trim();
+ String[] domainNames = domainNameOrder.split(","); //$NON-NLS-1$
+ for (String domainName : domainNames) {
this.securityDomains.addLast(domainName);
}
}
@@ -320,4 +328,12 @@
public void setVDBRepository(VDBRepository repo) {
this.vdbRepository = repo;
}
+
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
+ }
+
+ public void setDqp(DQPCore dqp) {
+ this.dqp = dqp;
+ }
}
Copied: branches/JCA/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java (from rev 1854, branches/JCA/runtime/src/main/java/org/teiid/services/MembershipServiceImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,220 @@
+/*
+ * 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.services;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.teiid.SecurityHelper;
+
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.platform.security.api.Credentials;
+
+/**
+ * This class serves as the primary implementation of the
+ * Membership Service. Based on the security domains specified this class delegates the responsibility of
+ * authenticating user to those security domains in the order they are defined.
+ */
+public class TeiidLoginContext {
+ public static final String AT = "@"; //$NON-NLS-1$
+ private LoginContext loginContext;
+ private String userName;
+ private String securitydomain;
+ private Object credentials;
+
+ public void authenticateUser(String username, Credentials credential, String applicationName, List<String> domains) throws LoginException {
+
+ LogManager.logTrace(LogConstants.CTX_MEMBERSHIP, new Object[] {"authenticateUser", username, applicationName}); //$NON-NLS-1$
+
+ final String baseUsername = getBaseUsername(username);
+ final char[] password = credential.getCredentialsAsCharArray();
+
+ // If username specifies a domain (user@domain) only that domain is authenticated against.
+ // If username specifies no domain, then all domains are tried in order.
+ for (String domain:getDomainsForUser(domains, username)) {
+
+ try {
+ CallbackHandler handler = new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof NameCallback) {
+ NameCallback nc = (NameCallback)callbacks[i];
+ nc.setName(baseUsername);
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback)callbacks[i];
+ pc.setPassword(password);
+ credentials = password;
+ } else {
+ throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); //$NON-NLS-1$
+ }
+ }
+ }
+ };
+
+ // this is the configured login for teiid
+ this.loginContext = createLoginContext(domain,handler);
+ this.loginContext.login();
+ this.userName = baseUsername+AT+domain;
+ this.securitydomain = domain;
+
+ return;
+ } catch (LoginException e) {
+ LogManager.logDetail(LogConstants.CTX_MEMBERSHIP,e.getMessage());
+ }
+ }
+ throw new LoginException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.The_username_0_and/or_password_are_incorrect", username )); //$NON-NLS-1$
+ }
+
+ protected LoginContext createLoginContext(String domain, CallbackHandler handler) throws LoginException {
+ return new LoginContext(domain, handler);
+ }
+
+ public LoginContext getLoginContext() {
+ return this.loginContext;
+ }
+
+ public String getUserName() {
+ return this.userName;
+ }
+
+ public String getSecurityDomain() {
+ return this.securitydomain;
+ }
+
+ public Object getSecurityContext(SecurityHelper helper) {
+ Object sc = null;
+ if (this.loginContext != null) {
+ sc = helper.getSecurityContext(this.securitydomain);
+ if ( sc == null){
+ Subject subject = this.loginContext.getSubject();
+ Principal principal = null;
+ for(Principal p:subject.getPrincipals()) {
+ if (this.userName.startsWith(p.getName())) {
+ principal = p;
+ break;
+ }
+ }
+ return helper.createSecurityContext(this.securitydomain, principal, credentials, subject);
+ }
+ }
+ return sc;
+ }
+
+ static String getBaseUsername(String username) {
+ if (username == null) {
+ return username;
+ }
+
+ int index = getQualifierIndex(username);
+
+ String result = username;
+
+ if (index != -1) {
+ result = username.substring(0, index);
+ }
+
+ //strip the escape character from the remaining ats
+ return result.replaceAll("\\\\"+AT, AT); //$NON-NLS-1$
+ }
+
+ static String escapeName(String name) {
+ if (name == null) {
+ return name;
+ }
+
+ return name.replaceAll(AT, "\\\\"+AT); //$NON-NLS-1$
+ }
+
+ static String getDomainName(String username) {
+ if (username == null) {
+ return username;
+ }
+
+ int index = getQualifierIndex(username);
+
+ if (index != -1) {
+ return username.substring(index + 1);
+ }
+
+ return null;
+ }
+
+ static int getQualifierIndex(String username) {
+ int index = username.length();
+ while ((index = username.lastIndexOf(AT, --index)) != -1) {
+ if (index > 0 && username.charAt(index - 1) != '\\') {
+ return index;
+ }
+ }
+
+ return -1;
+ }
+
+ private Collection<String> getDomainsForUser(List<String> domains, String username) {
+ // If username is null, return all domains
+ if (username == null) {
+ return domains;
+ }
+
+ String domain = getDomainName(username);
+
+ if (domain == null) {
+ return domains;
+ }
+
+ // ------------------------------------------
+ // Handle usernames having @ sign
+ // ------------------------------------------
+ String domainHolder = null;
+ for (String d:domains) {
+ if(d.equalsIgnoreCase(domain)) {
+ domainHolder = d;
+ break;
+ }
+ }
+
+ if (domainHolder == null) {
+ return Collections.emptyList();
+ }
+
+ LinkedList<String> result = new LinkedList<String>();
+ result.add(domainHolder);
+ return result;
+ }
+}
Property changes on: branches/JCA/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -0,0 +1,75 @@
+/*
+ * 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.transport;
+
+import java.util.HashMap;
+
+import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.core.util.ReflectionHelper;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+
+public class ClientServiceRegistryImpl {
+
+ public static class ClientService {
+ private Object instance;
+ private String loggingContext;
+ private ReflectionHelper reflectionHelper;
+
+ public ClientService(Object instance, String loggingContext,
+ ReflectionHelper reflectionHelper) {
+ this.instance = instance;
+ this.loggingContext = loggingContext;
+ this.reflectionHelper = reflectionHelper;
+ }
+
+ public Object getInstance() {
+ return instance;
+ }
+ public String getLoggingContext() {
+ return loggingContext;
+ }
+ public ReflectionHelper getReflectionHelper() {
+ return reflectionHelper;
+ }
+ }
+
+ private HashMap<String, ClientService> clientServices = new HashMap<String, ClientService>();
+
+ public <T> T getClientService(Class<T> iface) throws ComponentNotFoundException {
+ ClientService cs = getClientService(iface.getName());
+ return iface.cast(cs.getInstance());
+ }
+
+ public ClientService getClientService(String iface) throws ComponentNotFoundException {
+ ClientService cs = clientServices.get(iface);
+ if (cs == null) {
+ throw new ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("ServerWorkItem.Component_Not_Found", iface)); //$NON-NLS-1$
+ }
+ return cs;
+ }
+
+ public <T> void registerClientService(Class<T> iface, T instance, String loggingContext) {
+ this.clientServices.put(iface.getName(), new ClientService(instance, loggingContext, new ReflectionHelper(iface)));
+ }
+
+}
Property changes on: branches/JCA/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -37,6 +37,7 @@
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
@@ -70,13 +71,13 @@
credential = new Credentials(password.toCharArray());
}
- boolean adminConnection = Boolean.parseBoolean(connProps.getProperty(MMURL.CONNECTION.ADMIN, "false"));
+ boolean adminConnection = Boolean.parseBoolean(connProps.getProperty(MMURL.CONNECTION.ADMIN));
try {
- SessionMetadata sessionInfo = service.createSession(user,credential, applicationName, connProps, adminConnection);;
+ SessionMetadata sessionInfo = service.createSession(user,credential, applicationName, connProps, adminConnection);
long sessionID = updateDQPContext(sessionInfo, adminConnection);
LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"Logon successful for \"", user, "\" - created SessionID \"", "" + sessionID, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (connProps.getProperty("localConnection", "false").equalsIgnoreCase("true")) {
+ if (Boolean.parseBoolean(connProps.getProperty(ServerConnection.LOCAL_CONNECTION))) {
service.setLocalSession(sessionID);
}
return new LogonResult(sessionInfo.getAttachment(SessionToken.class), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -34,21 +34,18 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.transport.ClientServiceRegistryImpl.ClientService;
-import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.ExceptionHolder;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.api.Message;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.platform.socket.client.ServiceInvocationStruct;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.SessionToken;
public class ServerWorkItem {
@@ -56,43 +53,36 @@
private final ClientInstance socketClientInstance;
private final Serializable messageKey;
private final Message message;
- private ServerConnectionFactory scf;
+ private final ClientServiceRegistryImpl csr;
- public ServerWorkItem(ClientInstance socketClientInstance, Serializable messageKey, Message message, ServerConnectionFactory server) {
+ public ServerWorkItem(ClientInstance socketClientInstance, Serializable messageKey, Message message, ClientServiceRegistryImpl server) {
this.socketClientInstance = socketClientInstance;
this.messageKey = messageKey;
this.message = message;
- this.scf = server;
+ this.csr = server;
}
/**
- * main entry point for remote method calls. encryption/decryption is
- * handled here so that it won't be done by the io thread
+ * main entry point for remote method calls.
*/
public void process() {
Message result = null;
+ String loggingContext = null;
DQPWorkContext.setWorkContext(this.socketClientInstance.getWorkContext());
final boolean encrypt = message.getContents() instanceof SealedObject;
try {
message.setContents(this.socketClientInstance.getCryptor().unsealObject(message.getContents()));
-
if (!(message.getContents() instanceof ServiceInvocationStruct)) {
throw new AssertionError("unknown message contents"); //$NON-NLS-1$
}
final ServiceInvocationStruct serviceStruct = (ServiceInvocationStruct)message.getContents();
- final Class type = Class.forName(serviceStruct.targetClass);
- Object instance = this.scf.getService(type);
- if (instance == null) {
- throw new ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("ServerWorkItem.Component_Not_Found", serviceStruct.targetClass)); //$NON-NLS-1$
- }
- if (!(instance instanceof ILogon)) {
- SessionToken.setSession(this.socketClientInstance.getWorkContext().getSessionToken());
- }
- ReflectionHelper helper = new ReflectionHelper(instance.getClass());
- Method m = helper.findBestMethodOnTarget(serviceStruct.methodName, serviceStruct.args);
+ final ClientService clientService = this.csr.getClientService(serviceStruct.targetClass);
+ loggingContext = clientService.getLoggingContext();
+ SessionToken.setSession(this.socketClientInstance.getWorkContext().getSessionToken());
+ Method m = clientService.getReflectionHelper().findBestMethodOnTarget(serviceStruct.methodName, serviceStruct.args);
Object methodResult;
try {
- methodResult = m.invoke(instance, serviceStruct.args);
+ methodResult = m.invoke(clientService.getInstance(), serviceStruct.args);
} catch (InvocationTargetException e) {
throw e.getCause();
}
@@ -106,9 +96,9 @@
try {
asynchResult.setContents(completedFuture.get());
} catch (InterruptedException e) {
- asynchResult.setContents(processException(e, scf.getLoggingContextForService(type)));
+ asynchResult.setContents(processException(e, clientService.getLoggingContext()));
} catch (ExecutionException e) {
- asynchResult.setContents(processException(e.getCause(), scf.getLoggingContextForService(type)));
+ asynchResult.setContents(processException(e.getCause(), clientService.getLoggingContext()));
}
sendResult(asynchResult, encrypt);
}
@@ -121,10 +111,11 @@
}
} catch (Throwable t) {
Message holder = new Message();
- holder.setContents(processException(t, null));
+ holder.setContents(processException(t, loggingContext));
result = holder;
} finally {
DQPWorkContext.releaseWorkContext();
+ SessionToken.setSession(null);
}
if (result != null) {
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -29,7 +29,6 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.comm.api.Message;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
import com.metamatrix.common.comm.platform.socket.Handshake;
@@ -54,14 +53,14 @@
private final ObjectChannel objectSocket;
private Cryptor cryptor;
- private ServerConnectionFactory server;
+ private ClientServiceRegistryImpl csr;
private boolean usingEncryption;
private DhKeyGenerator keyGen;
private DQPWorkContext workContext = new DQPWorkContext();
- public SocketClientInstance(ObjectChannel objectSocket, ServerConnectionFactory server, boolean isClientEncryptionEnabled) {
+ public SocketClientInstance(ObjectChannel objectSocket, ClientServiceRegistryImpl csr, boolean isClientEncryptionEnabled) {
this.objectSocket = objectSocket;
- this.server = server;
+ this.csr = csr;
this.usingEncryption = isClientEncryptionEnabled;
SocketAddress address = this.objectSocket.getRemoteAddress();
if (address instanceof InetSocketAddress) {
@@ -139,7 +138,7 @@
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_SERVER, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_SERVER, "processing message:" + packet); //$NON-NLS-1$
}
- ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet, this.server);
+ ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet, this.csr);
work.process();
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -23,67 +23,57 @@
package org.teiid.transport;
import java.net.InetSocketAddress;
-import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.net.ssl.SSLEngine;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkManager;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.transport.ChannelListener.ChannelListenerFactory;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.platform.socket.ObjectChannel;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.NamedThreadFactory;
/**
* Server-side class to listen for new connection requests and create a SocketClientConnection for each connection request.
*/
public class SocketListener implements ChannelListenerFactory {
- private static final String TEIID_RUNTIME = "java:teiid/runtime-engine";
private SSLAwareChannelHandler channelHandler;
private Channel serverChanel;
private boolean isClientEncryptionEnabled;
- private WorkerPool workerPool;
- private Executor executor;
+ private ExecutorService nettyPool;
+ private ClientServiceRegistryImpl csr;
/**
*
* @param port
- * @param bindaddress
- * @param server
* @param inputBufferSize
* @param outputBufferSize
- * @param workerPool
* @param engine null if SSL is disabled
+ * @param bindaddress
+ * @param server
*/
public SocketListener(int port, String bindAddress, int inputBufferSize,
- int outputBufferSize, int maxWorkers, SSLEngine engine, boolean isClientEncryptionEnabled, WorkManager workManager) {
+ int outputBufferSize, int maxWorkers, SSLEngine engine, boolean isClientEncryptionEnabled, ClientServiceRegistryImpl csr) {
this.isClientEncryptionEnabled = isClientEncryptionEnabled;
+ this.csr = csr;
if (port < 0 || port > 0xFFFF) {
throw new IllegalArgumentException("port out of range:" + port); //$NON-NLS-1$
}
- this.executor = new WorkManagerExecutor(workManager);
- this.workerPool = WorkerPoolFactory.newWorkerPool("SocketWorker", maxWorkers, this.executor); //$NON-NLS-1$
+ this.nettyPool = Executors.newCachedThreadPool(new NamedThreadFactory("NIO")); //$NON-NLS-1$
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_SERVER, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_SERVER, "server = " + bindAddress + "binding to port:" + port); //$NON-NLS-1$ //$NON-NLS-2$
}
- ChannelFactory factory = new NioServerSocketChannelFactory(this.executor, this.executor, Math.min(Runtime.getRuntime().availableProcessors(), maxWorkers));
+ ChannelFactory factory = new NioServerSocketChannelFactory(this.nettyPool, this.nettyPool, Math.min(Runtime.getRuntime().availableProcessors(), maxWorkers));
ServerBootstrap bootstrap = new ServerBootstrap(factory);
this.channelHandler = new SSLAwareChannelHandler(this, engine, Thread.currentThread().getContextClassLoader());
@@ -99,10 +89,6 @@
this.serverChanel = bootstrap.bind(new InetSocketAddress(bindAddress, port));
}
- public WorkerPoolStatisticsMetadata getProcessPoolStats() {
- return this.workerPool.getStats();
- }
-
public int getPort() {
return ((InetSocketAddress)this.serverChanel.getLocalAddress()).getPort();
}
@@ -113,7 +99,7 @@
public void stop() {
this.serverChanel.close();
- this.workerPool.shutdownNow();
+ this.nettyPool.shutdownNow();
}
public SocketListenerStats getStats() {
@@ -126,41 +112,7 @@
}
public ChannelListener createChannelListener(ObjectChannel channel) {
- return new SocketClientInstance(channel, getServer(), this.isClientEncryptionEnabled);
+ return new SocketClientInstance(channel, csr, this.isClientEncryptionEnabled);
}
-
- static class WorkManagerExecutor implements Executor{
- WorkManager workManager;
-
- public WorkManagerExecutor(WorkManager workManager){
- this.workManager = workManager;
- }
-
- @Override
- public void execute(final Runnable command) {
- try {
- workManager.scheduleWork(new Work() {
- @Override
- public void run() {
- command.run();
- }
-
- @Override
- public void release() {
- }
- });
- } catch (WorkException e) {
- LogManager.logError(LogConstants.CTX_POOLING, e, CommonPlugin.Util.getString("WorkerPool.uncaughtException")); //$NON-NLS-1$
- }
- }
- }
- protected ServerConnectionFactory getServer() {
- try {
- InitialContext ic = new InitialContext();
- return (ServerConnectionFactory)ic.lookup(TEIID_RUNTIME);
- } catch (NamingException e) {
- return null;
- }
- }
}
\ No newline at end of file
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -25,10 +25,6 @@
import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
-import javax.resource.spi.work.WorkManager;
-
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -41,11 +37,12 @@
public class SocketTransport {
private SocketListener listener;
- private WorkManager workManager;
private SocketConfiguration config;
+ private ClientServiceRegistryImpl csr;
- public SocketTransport(SocketConfiguration config) {
+ public SocketTransport(SocketConfiguration config, ClientServiceRegistryImpl csr) {
this.config = config;
+ this.csr = csr;
}
public void start() {
@@ -54,7 +51,8 @@
try {
if (this.config.isEnabled()) {
LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.1", new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
- this.listener = new SocketListener(this.config.getPortNumber(), bindAddress, this.config.getInputBufferSize(), this.config.getOutputBufferSize(), this.config.getMaxSocketThreads(), this.config.getSSLConfiguration().getServerSSLEngine(), this.config.getSSLConfiguration().isClientEncryptionEnabled(), this.workManager);
+ this.listener = new SocketListener(this.config.getPortNumber(), bindAddress, this.config.getInputBufferSize(), this.config.getOutputBufferSize(), this.config.getMaxSocketThreads(), this.config.getSSLConfiguration().getServerSSLEngine(), this.config.getSSLConfiguration().isClientEncryptionEnabled(), csr);
+
}
else {
LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
@@ -73,10 +71,6 @@
this.listener.stop();
}
- public WorkerPoolStatisticsMetadata getProcessPoolStats() {
- return listener.getProcessPoolStats();
- }
-
public int getPort() {
return this.listener.getPort();
}
@@ -85,7 +79,4 @@
return this.listener.getStats();
}
- public void setWorkManager(WorkManager mgr) {
- this.workManager = mgr;
- }
}
Modified: branches/JCA/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -32,7 +32,7 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.services.MembershipServiceImpl;
+import org.teiid.services.TeiidLoginContext;
import com.metamatrix.platform.security.api.Credentials;
@@ -41,17 +41,17 @@
public void testBaseUsername() throws Exception {
- assertEquals("foo(a)bar.com", MembershipServiceImpl.getBaseUsername("foo\\@bar.com(a)foo")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("foo(a)bar.com", TeiidLoginContext.getBaseUsername("foo\\@bar.com(a)foo")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("foo", MembershipServiceImpl.getDomainName("me\\@bar.com(a)foo")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("foo", TeiidLoginContext.getDomainName("me\\@bar.com(a)foo")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(null, MembershipServiceImpl.getDomainName("@")); //$NON-NLS-1$
+ assertEquals(null, TeiidLoginContext.getDomainName("@")); //$NON-NLS-1$
- assertEquals("@", MembershipServiceImpl.getBaseUsername("@")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("@", TeiidLoginContext.getBaseUsername("@")); //$NON-NLS-1$ //$NON-NLS-2$
}
- private MembershipServiceImpl createMembershipService() throws Exception {
- MembershipServiceImpl membershipService = new MembershipServiceImpl() {
+ private TeiidLoginContext createMembershipService() throws Exception {
+ TeiidLoginContext membershipService = new TeiidLoginContext() {
public LoginContext createLoginContext(String domain, CallbackHandler handler) throws LoginException {
LoginContext context = Mockito.mock(LoginContext.class);
return context;
@@ -62,7 +62,7 @@
public void testAuthenticate() throws Exception {
- MembershipServiceImpl ms = createMembershipService();
+ TeiidLoginContext ms = createMembershipService();
List<String> domains = new ArrayList<String>();
domains.add("testFile");
ms.authenticateUser("user1", new Credentials("pass1".toCharArray()), null, domains); //$NON-NLS-1$ //$NON-NLS-2$
Modified: branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -13,7 +13,7 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.adminapi.impl.SessionMetadata;
-import org.teiid.services.MembershipServiceImpl;
+import org.teiid.services.TeiidLoginContext;
import org.teiid.services.SessionServiceImpl;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
@@ -22,7 +22,7 @@
public class TestSessionServiceImpl {
public void validateSession(boolean securityEnabled) throws Exception {
- final MembershipServiceImpl impl = Mockito.mock(MembershipServiceImpl.class);
+ final TeiidLoginContext impl = Mockito.mock(TeiidLoginContext.class);
Mockito.stub(impl.getUserName()).toReturn("steve@somedomain");
Mockito.stub(impl.getLoginContext()).toReturn(Mockito.mock(LoginContext.class));
final ArrayList<String> domains = new ArrayList<String>();
@@ -30,7 +30,7 @@
SessionServiceImpl ssi = new SessionServiceImpl() {
@Override
- protected MembershipServiceImpl authenticate(String userName, Credentials credentials, String applicationName, List<String> domains)
+ protected TeiidLoginContext authenticate(String userName, Credentials credentials, String applicationName, List<String> domains)
throws LoginException {
impl.authenticateUser(userName, credentials, applicationName, domains);
return impl;
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,10 +22,8 @@
*/
package org.teiid.transport;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.net.InetSocketAddress;
import java.util.Properties;
@@ -36,13 +34,10 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.dqp.internal.datamgr.impl.FakeWorkManager;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.comm.ClientServiceRegistry;
-import com.metamatrix.common.comm.ClientServiceRegistryImpl;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
@@ -72,10 +67,7 @@
}
@Test public void testFailedConnect() throws Exception {
- ClientServiceRegistry csr = new ClientServiceRegistryImpl();
- SessionService sessionService = mock(SessionService.class);
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
- listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),1024, 1024, 1, null, true, new FakeWorkManager());
+ listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),1024, 1024, 1, null, true, null);
try {
Properties p = new Properties();
@@ -142,19 +134,16 @@
SSLEngine serverSSL, boolean isClientEncryptionEnabled, Properties socketConfig) throws CommunicationException,
ConnectionException {
if (listener == null) {
- listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(), 1024, 1024, 1, serverSSL, isClientEncryptionEnabled, new FakeWorkManager()) {
- protected ServerConnectionFactory getServer() {
- ServerConnectionFactory server = Mockito.mock(ServerConnectionFactory.class);
- Mockito.stub(server.getService(ILogon.class)).toReturn(new LogonImpl(mock(SessionService.class), "fakeCluster") { //$NON-NLS-1$
- @Override
- public LogonResult logon(Properties connProps)
- throws LogonException, ComponentNotFoundException {
- return new LogonResult();
- }
- });
- return server;
+ ClientServiceRegistryImpl server = new ClientServiceRegistryImpl();
+ server.registerClientService(ILogon.class, new LogonImpl(mock(SessionService.class), "fakeCluster") { //$NON-NLS-1$
+ @Override
+ public LogonResult logon(Properties connProps)
+ throws LogonException, ComponentNotFoundException {
+ return new LogonResult();
}
- };
+
+ }, null);
+ listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(), 1024, 1024, 1, serverSSL, isClientEncryptionEnabled, server);
SocketListenerStats stats = listener.getStats();
assertEquals(0, stats.maxSockets);
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-02-22 18:48:13 UTC (rev 1866)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-02-23 16:07:13 UTC (rev 1867)
@@ -22,10 +22,7 @@
package org.teiid.transport;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.io.Serializable;
@@ -34,13 +31,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import javax.resource.spi.ConnectionManager;
-
import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.TeiidConnectionFactory;
-import org.teiid.TeiidManagedConnectionFactory;
-import org.teiid.TeiidResourceAdapter;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
@@ -51,7 +42,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.Message;
import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
import com.metamatrix.common.comm.platform.socket.client.SocketServerConnection;
@@ -61,7 +51,6 @@
import com.metamatrix.common.comm.platform.socket.client.UrlServerDiscovery;
import com.metamatrix.common.util.crypto.Cryptor;
import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.ILogon;
@@ -94,10 +83,10 @@
private static class FakeClientServerInstance extends SocketServerInstanceImpl implements ClientInstance {
- ServerConnectionFactory server;
+ ClientServiceRegistryImpl server;
private ResultsReceiver<Object> listener;
- public FakeClientServerInstance(ServerConnectionFactory server) {
+ public FakeClientServerInstance(ClientServiceRegistryImpl server) {
super();
this.server = server;
}
@@ -153,7 +142,7 @@
@Test
public void testMethodInvocation() throws Exception {
- TeiidConnectionFactory csr = new TeiidConnectionFactory(new TeiidResourceAdapter(), new TeiidManagedConnectionFactory(), Mockito.mock(ConnectionManager.class));
+ ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
csr.registerClientService(ILogon.class, new ILogon() {
public ResultsFuture<?> logoff()
@@ -205,10 +194,11 @@
}
ClientSideDQP dqp = connection.getService(ClientSideDQP.class);
try {
- dqp.begin();
+ ResultsFuture<?> future = dqp.begin();
+ future.get();
fail("exception expected"); //$NON-NLS-1$
- } catch (XATransactionException e) {
- assertEquals("Component not found: com.metamatrix.dqp.client.ClientSideDQP", e.getMessage()); //$NON-NLS-1$
+ } catch (Exception e) {
+ assertTrue(e.getMessage().endsWith("Component not found: com.metamatrix.dqp.client.ClientSideDQP")); //$NON-NLS-1$
}
}
14 years, 10 months
teiid SVN: r1866 - trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-22 13:48:13 -0500 (Mon, 22 Feb 2010)
New Revision: 1866
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
Log:
Teiid-773 - (reversing for the time being) Per Warrens request, the error file generated using the xml file option will use the same logic to write an error file that the text file option uses.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-02-19 23:36:36 UTC (rev 1865)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-02-22 18:48:13 UTC (rev 1866)
@@ -203,7 +203,7 @@
// Begin New from Impl
- public String generateErrorFile(final String querySetID,
+ public String generateErrorFile_keep(final String querySetID,
final String queryID, final String sql, final ResultSet resultSet,
final Throwable queryError, final Object results)
throws QueryTestFailedException {
@@ -285,18 +285,8 @@
PrintStream filePrintStream = new PrintStream(actualOut);
TestResultSetUtil.printResultSet(actualResult, sql, MAX_COL_WIDTH, true, filePrintStream);
+
-// if (results != null) {
-// for (Iterator<String> it=results.iterator(); it.hasNext();) {
-// String line = it.next();
-// filePrintStream.print(line);
-// }
-// } else {
-//
-// ResultSetUtil.printResultSet(actualResult, MAX_COL_WIDTH, true, filePrintStream);
-// }
-
-
} catch (Exception e) {
e.printStackTrace();
throw new QueryTestFailedException(e);
@@ -313,7 +303,7 @@
}
// End of copy from impl
- public String generateErrorFilex(final String querySetID,
+ public String generateErrorFile(final String querySetID,
final String queryID, final String sql, final ResultSet resultSet,
final Throwable queryError, final Object expectedResultsFile)
throws QueryTestFailedException {
14 years, 10 months
teiid SVN: r1865 - in branches/JCA: client/src/main/resources and 14 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-19 18:36:36 -0500 (Fri, 19 Feb 2010)
New Revision: 1865
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
branches/JCA/client/src/main/resources/vdb-deployer.xsd
branches/JCA/client/src/test/java/org/teiid/adminapi/
branches/JCA/client/src/test/java/org/teiid/adminapi/impl/
branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
Removed:
branches/JCA/client/src/test/java/com/metamatrix/admin/api/objects/
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/client/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/authorization/service/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/service/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/spi/file/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/spi/ldap/
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/services/
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/service/
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/spi/file/
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/spi/ldap/
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/
Modified:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
Log:
TEIID-998: Adding the schema file, and XML annotations to the vdb metadata objects to confirm to new VDB deployment XML file
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -22,18 +22,27 @@
package org.teiid.adminapi.impl;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
import org.teiid.adminapi.AdminObject;
-public class AdminObjectImpl implements AdminObject, Serializable {
+(a)XmlAccessorType(XmlAccessType.NONE)
+public abstract class AdminObjectImpl implements AdminObject, Serializable {
private static final long serialVersionUID = -6381303538713462682L;
- String name;
- Properties properties;
+
+ private String name;
+
+ private List<PropertyMetadata> properties;
+
private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
@Override
@@ -47,23 +56,50 @@
@Override
public Properties getProperties() {
+ if (this.properties == null) {
+ return null;
+ }
+
+ Properties props = new Properties();
+ for (PropertyMetadata p:this.properties) {
+ props.setProperty(p.getName(), p.getValue());
+ }
+ return props;
+ }
+
+ protected List<PropertyMetadata> getPropertiesDirect(){
return this.properties;
}
+
+ protected void setPropertiesDirect(List<PropertyMetadata> props){
+ this.properties = props;
+ }
@Override
public String getPropertyValue(String name) {
- return this.properties.getProperty(name);
+ if (this.properties == null) {
+ return null;
+ }
+
+ for (PropertyMetadata p:this.properties) {
+ if (p.getName().equals(name)) {
+ return p.getValue();
+ }
+ }
+ return null;
}
- public void setProperties(Properties properties) {
- this.properties = new Properties(properties);
+ public void setProperties(Properties props) {
+ for (String key:props.stringPropertyNames()) {
+ addProperty(key, props.getProperty(key));
+ }
}
public void addProperty(String key, String value) {
if (this.properties == null) {
- this.properties = new Properties();
+ this.properties = new ArrayList<PropertyMetadata>();
}
- this.properties.setProperty(key, value);
+ this.properties.add(new PropertyMetadata(key, value));
}
/**
@@ -144,5 +180,6 @@
if (result == null)
return null;
return result;
- }
+ }
+
}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java 2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -60,6 +60,6 @@
}
public String toString() {
- return name;
+ return getName();
}
}
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+
+
+/**
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="resource-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="allow-create" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * <element name="allow-read" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * <element name="allow-update" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * <element name="allow-delete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * <choice minOccurs="0">
+ * <element name="security-role-name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ * <element name="security-role-ref" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * </choice>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "description",
+ "resourceName",
+ "allowCreate",
+ "allowRead",
+ "allowUpdate",
+ "allowDelete",
+ "securityRoleNames",
+ "securityRoleRef"
+})
+@ManagementObject
+public class DataRoleMetadata {
+
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlElement(name = "description")
+ protected String description;
+ @XmlElement(name = "resource-name", required = true)
+ protected String resourceName;
+ @XmlElement(name = "allow-create")
+ protected Boolean allowCreate;
+ @XmlElement(name = "allow-read")
+ protected Boolean allowRead;
+ @XmlElement(name = "allow-update")
+ protected Boolean allowUpdate;
+ @XmlElement(name = "allow-delete")
+ protected Boolean allowDelete;
+ @XmlElement(name = "security-role-name")
+ protected List<String> securityRoleNames;
+ @XmlElement(name = "security-role-ref")
+ protected String securityRoleRef;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String value) {
+ this.description = value;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
+
+ public Boolean isAllowCreate() {
+ return allowCreate;
+ }
+
+ public void setAllowCreate(Boolean value) {
+ this.allowCreate = value;
+ }
+
+ public Boolean isAllowRead() {
+ return allowRead;
+ }
+
+ public void setAllowRead(Boolean value) {
+ this.allowRead = value;
+ }
+
+ public Boolean isAllowUpdate() {
+ return allowUpdate;
+ }
+
+ public void setAllowUpdate(Boolean value) {
+ this.allowUpdate = value;
+ }
+
+ public Boolean isAllowDelete() {
+ return allowDelete;
+ }
+
+ public void setAllowDelete(Boolean value) {
+ this.allowDelete = value;
+ }
+
+ public List<String> getSecurityRoleNames() {
+ if (this.securityRoleNames == null) {
+ this.securityRoleNames = new ArrayList<String>();
+ }
+ return this.securityRoleNames;
+ }
+
+ public String getSecurityRoleRef() {
+ return securityRoleRef;
+ }
+
+ public void setSecurityRoleRef(String value) {
+ this.securityRoleRef = value;
+ }
+}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -26,6 +26,12 @@
import java.util.List;
import java.util.Properties;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
import org.jboss.managed.api.annotation.ManagementComponent;
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementObjectID;
@@ -35,12 +41,43 @@
import com.metamatrix.core.vdb.ModelType;
+/**
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="property" type="{}property" maxOccurs="unbounded" minOccurs="0"/>
+ * <choice minOccurs="0">
+ * <element name="connector-name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ * <element name="connector-ref" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * </choice>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "propertiesDirect",
+ "connectorBindings",
+ "connectorReference"
+})
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="model"))
public class ModelMetaData extends AdminObjectImpl implements Model {
private static final long serialVersionUID = 3714234763056162230L;
+
+ @XmlElement(name = "connector-name")
private List<String> connectorBindings = new ArrayList<String>();
- private String modelType = ""; //$NON-NLS-1$
+
+ @XmlElement(name = "connector-ref")
+ protected String connectorReference;
+
+ private String modelType = ""; //$NON-NLS-1$
private String modelURI = ""; //$NON-NLS-1$
private boolean supportsMultiSourceBindings = false;
private String path;
@@ -49,16 +86,31 @@
@ManagementProperty(description="Model Name", readOnly=true)
@ManagementObjectID(type="model")
+ @XmlAttribute(name = "name", required = true)
public String getName() {
return super.getName();
}
+ // This is needed by JAXB
+ public void setName(String name) {
+ super.setName(name);
+ }
@ManagementProperty(description="Connector Bindings for model")
public List<String> getConnectorBindingNames(){
return this.connectorBindings;
}
+
+ @ManagementProperty(description="Connector Binding Reference")
+ public String getConnectorReference() {
+ return connectorReference;
+ }
+
+ public void setConnectorReference(String connectorReference) {
+ this.connectorReference = connectorReference;
+ }
+
@Override
@ManagementProperty(description = "Is Model Source model", readOnly=true)
public boolean isSource() {
@@ -110,6 +162,17 @@
return new Properties(super.getProperties());
}
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ protected List<PropertyMetadata> getPropertiesDirect(){
+ return super.getPropertiesDirect();
+ }
+
+ // This is needed by the JAXB
+ protected void setPropertiesDirect(List<PropertyMetadata> props){
+ super.setPropertiesDirect(props);
+ }
+
public void addConnectorBinding(String binding) {
this.connectorBindings.add(binding);
}
@@ -141,7 +204,7 @@
}
public String toString() {
- return name + connectorBindings;
+ return getName() + connectorBindings;
}
public Visibility getVisibility(){
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <pre>
+ * <complexType name="property">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "property")
+public class PropertyMetadata {
+
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "value", required = true)
+ protected String value;
+
+ public PropertyMetadata() {
+ }
+
+ public PropertyMetadata(String key, String value) {
+ this.name = key;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
\ No newline at end of file
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+
+
+/**
+ * <pre>
+ * <complexType name="reference-mapping">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="ref-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "reference-mapping", propOrder = {
+ "refName",
+ "names"
+})
+@ManagementObject
+public class ReferenceMappingMetadata {
+
+ @XmlElement(name = "ref-name", required = true)
+ protected String refName;
+
+ @XmlElement(name = "name", required = true)
+ protected List<String> names;
+
+ public String getRefName() {
+ return refName;
+ }
+
+ public void setRefName(String value) {
+ this.refName = value;
+ }
+
+ public List<String> getNames() {
+ if (this.names == null) {
+ this.names = new ArrayList<String>();
+ }
+ return this.names;
+ }
+
+ public void addName(String name) {
+ getNames().add(name);
+ }
+}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -25,8 +25,16 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
import org.jboss.managed.api.annotation.ManagementComponent;
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementObjectID;
@@ -39,16 +47,41 @@
import com.metamatrix.core.vdb.ModelType;
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="vdb"))
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "propertiesDirect",
+ "models",
+ "connectorMappings",
+ "dataRoles",
+ "securityRoleMappings"
+})
+@XmlRootElement(name = "vdb")
public class VDBMetaData extends AdminObjectImpl implements VDB {
-
private static final long serialVersionUID = -4723595252013356436L;
+
+ @XmlElement(name = "model", required = true, type = ModelMetaData.class)
private HashSet<ModelMetaData> models = new HashSet<ModelMetaData>();
- private String fileUrl = null;
+
+ @XmlAttribute(name = "version", required = true)
private int version = 1;
- private Status status;
+
+ @XmlElement(name = "description")
private String description;
- private List<String> errors;
+ @XmlElement(name = "connector-mapping")
+ protected List<ReferenceMappingMetadata> connectorMappings;
+
+ @XmlElement(name = "data-role")
+ protected List<DataRoleMetadata> dataRoles;
+
+ @XmlElement(name = "security-role-mapping")
+ protected List<ReferenceMappingMetadata> securityRoleMappings;
+
+ private List<String> errors;
+ private String fileUrl = null;
+ private Status status;
+
public VDBMetaData() {
// auto add sytem model.
ModelMetaData system = new ModelMetaData();
@@ -64,10 +97,16 @@
@ManagementProperty(description="Name of the VDB", readOnly=true)
@ManagementObjectID(type="vdb")
+ @XmlAttribute(name = "name", required = true)
public String getName() {
return super.getName();
}
+ // This needed by JAXB marshaling
+ public void setName(String name) {
+ super.setName(name);
+ }
+
@Override
@ManagementProperty(description="VDB Status", readOnly=true)
public Status getStatus() {
@@ -158,7 +197,7 @@
}
public String toString() {
- return this.name + models;
+ return getName() + models;
}
@ManagementOperation(description = "Get the model with given name")
@@ -180,4 +219,46 @@
}
return list;
}
+
+ @ManagementProperty(description="Connector reference mappings", managed=true)
+ public List<ReferenceMappingMetadata> getConnectorMappings() {
+ return this.connectorMappings;
+ }
+
+ public void addConnectorMapping(ReferenceMappingMetadata data) {
+ if (this.connectorMappings == null) {
+ this.connectorMappings = new ArrayList<ReferenceMappingMetadata>();
+ }
+ this.connectorMappings.add(data);
+ }
+
+ @ManagementProperty(description="Security refrence mappings", managed=true)
+ public List<ReferenceMappingMetadata> getSecurityRoleMappings() {
+ return securityRoleMappings;
+ }
+
+ public void addSecurityRoleMapping(ReferenceMappingMetadata data) {
+ if (this.securityRoleMappings == null) {
+ this.securityRoleMappings = new ArrayList<ReferenceMappingMetadata>();
+ }
+ this.securityRoleMappings.add(data);
+ }
+
+ @Override
+ @ManagementProperty(description = "Properties", readOnly=true)
+ public Properties getProperties() {
+ return new Properties(super.getProperties());
+ }
+
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ protected List<PropertyMetadata> getPropertiesDirect(){
+ return super.getPropertiesDirect();
+ }
+
+ // This is needed by the JAXB
+ protected void setPropertiesDirect(List<PropertyMetadata> props){
+ super.setPropertiesDirect(props);
+ }
+
}
Added: branches/JCA/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- branches/JCA/client/src/main/resources/vdb-deployer.xsd (rev 0)
+++ branches/JCA/client/src/main/resources/vdb-deployer.xsd 2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+ <xs:element name="vdb">
+ <xs:annotation>
+ <xs:documentation>Describes the configuration for a VDB</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="description" type="xs:string" minOccurs="0"/>
+ <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="model" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:choice minOccurs="0">
+ <xs:element name="connector-name" type="xs:string" maxOccurs="unbounded"/>
+ <xs:element name="connector-ref" type="xs:string"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="connector-mapping" type="reference-mapping" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="data-role" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="description" type="xs:string" minOccurs="0"/>
+ <xs:element name="resource-name" type="xs:string"/>
+ <xs:element name="allow-create" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="allow-read" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="allow-update" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="allow-delete" type="xs:boolean" minOccurs="0"/>
+ <xs:choice minOccurs="0">
+ <xs:element name="security-role-name" type="xs:string" maxOccurs="unbounded"/>
+ <xs:element name="security-role-ref" type="xs:string"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="security-role-mapping" type="reference-mapping" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="version" type="xs:int" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="property">
+ <xs:annotation>
+ <xs:documentation> property</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="value" type="xs:string" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="reference-mapping">
+ <xs:sequence>
+ <xs:element name="ref-name" type="xs:string"/>
+ <xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
Added: branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java (rev 0)
+++ branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.Test;
+
+
+public class TestVDBMetaData {
+
+ @Test
+ public void testMarshellUnmarshell() throws Exception {
+
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("myVDB");
+ vdb.setDescription("vdb description");
+ vdb.setVersion(1);
+ vdb.addProperty("vdb-property", "vdb-value");
+
+ ModelMetaData modelOne = new ModelMetaData();
+ modelOne.setName("model-one");
+ modelOne.addConnectorBinding("java:mybinding");
+ modelOne.setModelType("physical");
+ modelOne.addProperty("model-prop", "model-value");
+
+ vdb.addModel(modelOne);
+
+ ModelMetaData modelTwo = new ModelMetaData();
+ modelTwo.setName("model-two");
+ modelTwo.setConnectorReference("binding-two-ref");
+ modelTwo.addProperty("model-prop", "model-value");
+
+ vdb.addModel(modelTwo);
+
+ ReferenceMappingMetadata ref = new ReferenceMappingMetadata();
+ ref.setRefName("binding-two-ref");
+ ref.addName("java:binding-one");
+ ref.addName("java:binding-two");
+ vdb.addConnectorMapping(ref);
+
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
+ Marshaller marshell = jc.createMarshaller();
+ marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
+
+ StringWriter sw = new StringWriter();
+ marshell.marshal(vdb, sw);
+ Unmarshaller un = jc.createUnmarshaller();
+
+ //System.out.println(sw.toString());
+
+ vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
+
+ assertEquals("myVDB", vdb.getName());
+ assertEquals("vdb description", vdb.getDescription());
+ assertEquals(1, vdb.getVersion());
+ assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"));
+
+ assertNotNull(vdb.getModel("model-one"));
+ assertNotNull(vdb.getModel("model-two"));
+ assertNull(vdb.getModel("model-unknown"));
+
+ modelOne = vdb.getModel("model-one");
+ assertEquals("model-one", modelOne.getName());
+ assertTrue(modelOne.getConnectorBindingNames().contains("java:mybinding"));
+ assertEquals("", modelOne.getModelType()); // this is not persisted in the XML
+ assertEquals("model-value", modelOne.getPropertyValue("model-prop"));
+
+
+ modelTwo = vdb.getModel("model-two");
+ assertEquals("model-two", modelTwo.getName());
+ assertTrue(modelTwo.getConnectorBindingNames().isEmpty());
+ assertEquals("binding-two-ref", modelTwo.getConnectorReference());
+ assertEquals("", modelTwo.getModelType()); // this is not persisted in the XML
+ assertEquals("model-value", modelTwo.getPropertyValue("model-prop"));
+
+
+ assertTrue(vdb.getConnectorMappings().size()==1);
+ ref = vdb.getConnectorMappings().get(0);
+
+ assertEquals("binding-two-ref", ref.getRefName());
+ assertTrue(ref.getNames().contains("java:binding-one"));
+ assertTrue(ref.getNames().contains("java:binding-two"));
+ }
+}
14 years, 10 months
teiid SVN: r1864 - branches/JCA/console/src/test/java/org/teiid/rhq.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 16:57:25 -0500 (Fri, 19 Feb 2010)
New Revision: 1864
Removed:
branches/JCA/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java
Log:
Remove legacy code
Deleted: branches/JCA/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java
===================================================================
--- branches/JCA/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java 2010-02-19 21:56:58 UTC (rev 1863)
+++ branches/JCA/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java 2010-02-19 21:57:25 UTC (rev 1864)
@@ -1,56 +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.rhq;
-
-
-
-/**
- * @since 4.3
- */
-public interface StartingEnvironmentConstants {
-
- public static final String INSTALL_DIR = "D:/apps/MetaMatrix/enterpriseserver/5.5.3/073008"; //$NON-NLS-1$
- public static final String PORT = "31000"; //$NON-NLS-1$
- public static final String USERNAME = "metamatrixadmin"; //$NON-NLS-1$
- public static final String PASSWORD = "mm"; //$NON-NLS-1$
-
- public static final String INSTALL_DIR2 = "D:/metamatrix/5.5.3/server_0721b"; //$NON-NLS-1$
- public static final String PORT2 = "32000"; //$NON-NLS-1$
-
-
-
-
- public static final String SINGLE_SYSTEM_PARM =
- INSTALL_DIR + "," + //$NON-NLS-1$
- PORT + "," + //$NON-NLS-1$
- USERNAME + "," + //$NON-NLS-1$
- PASSWORD;
-
- public static final String TWO_SYSTEM_PARM = SINGLE_SYSTEM_PARM + ";" + //$NON-NLS-1$
- INSTALL_DIR2 + "," + //$NON-NLS-1$
- PORT2 + "," + //$NON-NLS-1$
- USERNAME + "," + //$NON-NLS-1$
- PASSWORD;
-
-
-
-}
14 years, 10 months
teiid SVN: r1863 - branches/JCA/console/src/main/java/org/teiid/rhq/enterprise.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 16:56:58 -0500 (Fri, 19 Feb 2010)
New Revision: 1863
Removed:
branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java
Log:
Remove legacy code
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java 2010-02-19 21:56:34 UTC (rev 1862)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java 2010-02-19 21:56:58 UTC (rev 1863)
@@ -1,219 +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.rhq.enterprise;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-public class AdminUtil {
-
- private final static String[] CLASSLOADERPREFIXVALUES = new String[] {
- "/jbedsp-teiid", "/teiid-client-", "/log4j-", "/commons-logging", "/teiid-common-core", "netty-" }; //$NON-NLS-1$, //$NON-NLS-2$, //$NON-NLS-3$, //$NON-NLS-4$
-
- public static ClassLoader createClassloader(String installDir, ClassLoader parentClassLoader) {
- if (true) {
- return parentClassLoader;
- }
- LinkedList p = new LinkedList();
- String[] classLoaderValues = getJarsForPrefixes(installDir + "/lib"); //$NON-NLS-1$
- String[] patches = getPatchJars(installDir + "/lib/patches"); //$NON-NLS-1$
- int cnt = classLoaderValues.length;
- if (patches != null) {
- p.addAll(Arrays.asList(patches));
- cnt += patches.length;
- }
-
- p.add(installDir + "/lib/"); //$NON-NLS-1$
- cnt++;
-
- if (classLoaderValues != null){
- p.addAll(Arrays.asList(classLoaderValues));
- }
-
- URL[] urls = new URL[cnt];
- try {
-
-
- for (int i = 0; i < cnt; i++) {
- String f = (String) p.get(i);
- urls[i] = new File(f).toURL();
- }
- ClassLoader classLoader = new URLClassLoader(urls, parentClassLoader);
- return classLoader;
-
- } catch (Exception e) {
- e.printStackTrace();
- // TODO: handle exception
- }
-
- return null;
- }
-
- private static String[] getJarsForPrefixes(String dir) {
- ArrayList<String> jarArrayList = new ArrayList<String>();
- File[] jarFiles = findAllFilesInDirectoryHavingExtension(dir, ".jar"); //$NON-NLS-1$
- if (jarFiles != null && jarFiles.length > 0) {
- for (int i = 0; i < jarFiles.length; i++) {
- try {
- String fileName = jarFiles[i].getCanonicalPath();
- for (int j = 0; j < CLASSLOADERPREFIXVALUES.length; j++){
- if (fileName.contains(CLASSLOADERPREFIXVALUES[j].toString())){
- jarArrayList.add(fileName);
- break;
- }
- }
- } catch (Exception e) {
- //TODO
- }
- }
-
- }
- String[] jars = new String[jarArrayList.size()];
- int i = 0;
- Iterator<String> jarIter = jarArrayList.iterator();
- while(jarIter.hasNext()){
- jars[i++] = jarIter.next();
- }
-
- return jars;
- }
-
- private static String[] getPatchJars(String dir) {
- String[] jars = null;
- File[] jarFiles = findAllFilesInDirectoryHavingExtension(dir, ".jar"); //$NON-NLS-1$
- if (jarFiles != null && jarFiles.length > 0) {
- jars = new String[jarFiles.length];
- for (int i = 0; i < jarFiles.length; i++) {
- try {
- jars[i] = jarFiles[i].getCanonicalPath();
- } catch (Exception e) {
- //TODO
- }
- }
-
- }
- return jars;
- }
-
- /**
- * Returns a <code>File</code> array that will contain all the files that
- * exist in the directory that have the specified extension.
- * @return File[] of files having a certain extension
- */
- private static File[] findAllFilesInDirectoryHavingExtension(String dir, final String extension) {
-
- // Find all files in that directory that end in XML and attempt to
- // load them into the runtime metadata database.
- File modelsDirFile = new File(dir);
- FileFilter fileFilter = new FileFilter() {
- public boolean accept(File file) {
- if(file.isDirectory()) {
- return false;
- }
-
-
- String fileName = file.getName();
-
- if (fileName==null || fileName.length()==0) {
- return false;
- }
-
- // here we check to see if the file is an .xml file...
- int index = fileName.lastIndexOf("."); //$NON-NLS-1$
-
- if (index<0 || index==fileName.length()) {
- return false;
- }
-
- if (fileName.substring(index, fileName.length()).equalsIgnoreCase(extension)) {
- return true;
- }
- return false;
- }
- };
-
- File[] modelFiles = modelsDirFile.listFiles(fileFilter);
-
- return modelFiles;
-
- }
-
- /**
- * Return the tokens in a string in a list. This is particularly
- * helpful if the tokens need to be processed in reverse order. In that case,
- * a list iterator can be acquired from the list for reverse order traversal.
- *
- * @param str String to be tokenized
- * @param delimiter Characters which are delimit tokens
- * @return List of string tokens contained in the tokenized string
- */
- public static List getTokens(String str, String delimiter) {
- ArrayList l = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(str, delimiter);
- while(tokens.hasMoreTokens()) {
- l.add(tokens.nextToken());
- }
- return l;
- }
-
- /*
- * Replace all occurrences of the search string with the replace string
- * in the source string. If any of the strings is null or the search string
- * is zero length, the source string is returned.
- * @param source the source string whose contents will be altered
- * @param search the string to search for in source
- * @param replace the string to substitute for search if present
- * @return source string with *all* occurrences of the search string
- * replaced with the replace string
- */
- public static String replaceAll(String source, String search, String replace) {
- if (source != null && search != null && search.length() > 0 && replace != null) {
- int start = source.indexOf(search);
- if (start > -1) {
- StringBuffer newString = new StringBuffer(source);
- replaceAll(newString, search, replace);
- return newString.toString();
- }
- }
- return source;
- }
-
- public static void replaceAll(StringBuffer source, String search, String replace) {
- if (source != null && search != null && search.length() > 0 && replace != null) {
- int start = source.toString().indexOf(search);
- while (start > -1) {
- int end = start + search.length();
- source.replace(start, end, replace);
- start = source.toString().indexOf(search, start + replace.length());
- }
- }
- }
-
-}
14 years, 10 months
teiid SVN: r1862 - branches/JCA/console/src/main/java/org/teiid/rhq/comm.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 16:56:34 -0500 (Fri, 19 Feb 2010)
New Revision: 1862
Removed:
branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java
Log:
Remove legacy code
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java 2010-02-19 21:56:15 UTC (rev 1861)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java 2010-02-19 21:56:34 UTC (rev 1862)
@@ -1,50 +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.rhq.comm;
-
-
-/**
- * @since 4.3
- */
-public class ConnectionException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = -3342409142882071873L;
-
-
- public ConnectionException() {
- super();
- }
-
-
- public ConnectionException(final String msg) {
- super(msg);
- }
-
-
- public ConnectionException(final Exception e) {
- super(e);
- }
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java 2010-02-19 21:56:15 UTC (rev 1861)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java 2010-02-19 21:56:34 UTC (rev 1862)
@@ -1,73 +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.rhq.comm;
-
-
-
-/**
- * These are the properties are used by the {@link ConnectionPool) to create and manage
- * connections. These properties are passed into the pool when at initialization time.
- * @since 1.0
- */
-public interface ConnectionPoolConstants {
-
- /**
- * Indicates the connection factory to use in the connection pool.
- */
- public static final String CONNECTION_FACTORY = "pool.connection.factory"; //$NON-NLS-1$
-
- /**
- * Maximum connections for this pool. Default to 0, which means there is no limit.
- */
-// public static final String MAX_CONNECTIONS = "pool.max_connections"; //$NON-NLS-1$
-
- /**
- * Idle time of the connection before it should be closed in seconds. Default to 60 seconds.
- */
- public static final String LIVE_AND_UNUSED_TIME = "pool.live_and_unused_time"; //$NON-NLS-1$
-
- /**
- * Time to wait if the connection is not available in milliseconds. Default to 2 seconds.
- */
- public static final String WAIT_FOR_SOURCE_TIME = "pool.wait_for_source_time"; //$NON-NLS-1$
-
- /**
- * Interval for running the cleaning thread in seconds. Default to 60 seconds.
- */
- public static final String CLEANING_INTERVAL = "pool.cleaning_interval"; //$NON-NLS-1$
-
- /**
- * Whether to enable pool shrinking. Default to true.
- */
- public static final String ENABLE_SHRINKING = "pool.enable_shrinking"; //$NON-NLS-1$
-
- /**
- * This property is used to specify the length of time between JDBC Source test connections
- * How often (in seconds) to test that the data source is available by establishing a new connection. Default to 600 seconds.
- */
-// public static final String CONNECTION_TEST_INTERVAL = "pool.connection.test.interval"; //$NON-NLS-1$
-
-
-
-
-
-}
14 years, 10 months