[teiid-commits] teiid SVN: r3559 - in branches/as7: admin/src/main/java/org/teiid/adminapi/impl and 11 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Tue Oct 18 11:56:09 EDT 2011
Author: rareddy
Date: 2011-10-18 11:56:08 -0400 (Tue, 18 Oct 2011)
New Revision: 3559
Added:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/CSRReferenceFactoryService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidOperations.java
branches/as7/jboss-integration/src/test/resources/bqt.vdb
Removed:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ClientServiceRegistryReferenceFactoryService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidAdminOperations.java
Modified:
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
branches/as7/admin/src/test/resources/vdb-describe.txt
branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java
branches/as7/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStoreCache.java
branches/as7/jboss-integration/pom.xml
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescribe.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
branches/as7/jboss-integration/src/test/resources/teiid-model-json.txt
branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/as7/test-integration/common/pom.xml
Log:
TEIID-1720: Minor updates
Modified: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -332,6 +332,7 @@
return builder.buildRequest();
}
+ //add
ModelNode composite = new ModelNode();
composite.get("operation").set("composite");
composite.get("address").setEmptyList();
Modified: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -56,7 +56,6 @@
if (vdb == null) {
return null;
}
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
node.get(VDBNAME).set(vdb.getName());
node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
@@ -182,7 +181,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, VDBNAME, ModelType.STRING, true);
ModelNode connectionsAllowed = new ModelNode();
@@ -239,7 +237,6 @@
if (model == null) {
return null;
}
- node.get(TYPE).set(ModelType.OBJECT);
node.get(MODEL_NAME).set(model.getName());
if (model.getDescription() != null) {
@@ -332,8 +329,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
-
ModelNode modelTypes = new ModelNode();
modelTypes.add(Model.Type.PHYSICAL.toString());
modelTypes.add(Model.Type.VIRTUAL.toString());
@@ -378,7 +373,6 @@
return null;
}
- node.get(TYPE).set(ModelType.OBJECT);
if (error.getPath() != null) {
node.get(ERROR_PATH).set(error.getPath());
}
@@ -407,7 +401,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, ERROR_PATH, ModelType.STRING, false);
addAttribute(node, SEVERITY, ModelType.STRING, true);
addAttribute(node, MESSAGE, ModelType.STRING, true);
@@ -430,8 +423,6 @@
return null;
}
- node.get(TYPE).set(ModelType.OBJECT);
-
node.get(SOURCE_NAME).set(source.getName());
node.get(JNDI_NAME).set(source.getConnectionJndiName());
node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
@@ -456,7 +447,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, SOURCE_NAME, ModelType.STRING, true);
addAttribute(node, JNDI_NAME, ModelType.STRING, true);
addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
@@ -481,7 +471,6 @@
if (translator == null) {
return null;
}
- node.get(TYPE).set(ModelType.OBJECT);
node.get(TRANSLATOR_NAME).set(translator.getName());
if (translator.getType() != null) {
@@ -536,7 +525,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
addAttribute(node, BASETYPE, ModelType.STRING, true);
addAttribute(node, DESCRIPTION, ModelType.STRING, false);
@@ -562,7 +550,6 @@
if (property == null) {
return null;
}
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
node.get(PROPERTY_NAME).set(property.getName());
node.get(PROPERTY_VALUE).set(property.getValue());
@@ -585,7 +572,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, PROPERTY_NAME, ModelType.STRING, true);
addAttribute(node, PROPERTY_VALUE, ModelType.STRING, true);
return node;
@@ -614,8 +600,7 @@
if (policy == null) {
return null;
}
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
+
node.get(POLICY_NAME).set(policy.getName());
if (policy.getDescription() != null) {
node.get(DESCRIPTION).set(policy.getDescription());
@@ -684,7 +669,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, POLICY_NAME, ModelType.STRING, true);
addAttribute(node, DESCRIPTION, ModelType.STRING, false);
addAttribute(node, ALLOW_CREATE_TEMP_TABLES, ModelType.BOOLEAN, false);
@@ -736,8 +720,6 @@
return null;
}
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
node.get(RESOURCE_NAME).set(permission.getResourceName());
if (permission.getAllowCreate() != null) {
node.get(ALLOW_CREATE).set(permission.getAllowCreate().booleanValue());
@@ -812,8 +794,6 @@
if (object == null)
return null;
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
node.get(TOTAL_ENTRIES).set(object.getTotalEntries());
node.get(HITRATIO).set(object.getHitRatio());
node.get(REQUEST_COUNT).set(object.getRequestCount());
@@ -833,7 +813,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, TOTAL_ENTRIES, ModelType.STRING, true);
addAttribute(node, HITRATIO, ModelType.STRING, true);
addAttribute(node, REQUEST_COUNT, ModelType.STRING, true);
@@ -858,7 +837,6 @@
if (request == null) {
return null;
}
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
node.get(EXECUTION_ID).set(request.getExecutionId());
node.get(SESSION_ID).set(request.getSessionId());
@@ -898,7 +876,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, EXECUTION_ID, ModelType.LONG, true);
addAttribute(node, SESSION_ID, ModelType.STRING, true);
addAttribute(node, START_TIME, ModelType.LONG, true);
@@ -931,7 +908,6 @@
if (session == null) {
return null;
}
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
if (session.getApplicationName() != null) {
node.get(APPLICATION_NAME).set(session.getApplicationName());
@@ -979,7 +955,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, APPLICATION_NAME, ModelType.STRING, false);
addAttribute(node, CREATED_TIME, ModelType.LONG, true);
addAttribute(node, CLIENT_HOST_NAME, ModelType.LONG, true);
@@ -1006,7 +981,6 @@
if (object == null)
return null;
- transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
transaction.get(CREATED_TIME).set(object.getCreatedTime());
transaction.get(SCOPE).set(object.getScope());
@@ -1028,7 +1002,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, ASSOCIATED_SESSION, ModelType.STRING, true);
addAttribute(node, CREATED_TIME, ModelType.LONG, true);
addAttribute(node, SCOPE, ModelType.LONG, true);
@@ -1052,7 +1025,6 @@
public ModelNode wrap(WorkerPoolStatisticsMetadata stats, ModelNode node) {
if (stats == null)
return null;
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
node.get(ACTIVE_THREADS).set(stats.getActiveThreads());
node.get(HIGHEST_ACTIVE_THREADS).set(stats.getHighestActiveThreads());
@@ -1083,7 +1055,6 @@
}
public ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
addAttribute(node, ACTIVE_THREADS, ModelType.INT, true);
addAttribute(node, HIGHEST_ACTIVE_THREADS, ModelType.INT, true);
addAttribute(node, TOTAL_COMPLETED, ModelType.LONG, true);
Modified: branches/as7/admin/src/test/resources/vdb-describe.txt
===================================================================
--- branches/as7/admin/src/test/resources/vdb-describe.txt 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/admin/src/test/resources/vdb-describe.txt 2011-10-18 15:56:08 UTC (rev 3559)
@@ -1,7 +1,4 @@
{
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"vdb-name" : {
"type" : {
@@ -60,9 +57,6 @@
"children" : {
"properties" : {
"description" : "properties",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"property-name" : {
"type" : {
@@ -81,9 +75,6 @@
}
},
"models" : {
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"model-name" : {
"type" : {
@@ -130,9 +121,6 @@
"children" : {
"properties" : {
"description" : "properties",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"property-name" : {
"type" : {
@@ -152,9 +140,6 @@
},
"source-mappings" : {
"description" : "Model to source mapping",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"source-name" : {
"type" : {
@@ -181,9 +166,6 @@
},
"validity-errors" : {
"description" : "Model validation errors",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"error-path" : {
"type" : {
@@ -214,9 +196,6 @@
},
"override-translators" : {
"description" : "Overridden translators for the Virtual Database",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"translator-name" : {
"type" : {
@@ -249,9 +228,6 @@
},
"children" : {"properties" : {
"description" : "properties",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"property-name" : {
"type" : {
@@ -272,9 +248,6 @@
},
"data-policies" : {
"description" : "Data access policies defined for the Virtual Database",
- "type" : {
- "TYPE_MODEL_VALUE" : "OBJECT"
- },
"attributes" : {
"policy-name" : {
"type" : {
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -101,7 +101,7 @@
* @return The collection of MetaMatrixSessionInfo objects of active users on
* the system - possibly empty, never null.
*/
- Collection<SessionMetadata> getActiveSessions() throws SessionServiceException;
+ Collection<SessionMetadata> getActiveSessions();
/**
* Get the number of active user sessions on the system.
Modified: branches/as7/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStoreCache.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStoreCache.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStoreCache.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -74,7 +74,7 @@
fsc.setStorageManager(ssm);
fsc.initialize();
- UnitTestUtil.enableTraceLogging("org.teiid"); //$NON-NLS-1$
+ //UnitTestUtil.enableTraceLogging("org.teiid"); //$NON-NLS-1$
CacheEntry ce = new CacheEntry(2l);
Serializer<Integer> s = new SimpleSerializer();
Modified: branches/as7/jboss-integration/pom.xml
===================================================================
--- branches/as7/jboss-integration/pom.xml 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/pom.xml 2011-10-18 15:56:08 UTC (rev 3559)
@@ -209,6 +209,13 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
Copied: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/CSRReferenceFactoryService.java (from rev 3548, branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ClientServiceRegistryReferenceFactoryService.java)
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/CSRReferenceFactoryService.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/CSRReferenceFactoryService.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., 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.jboss;
+
+import org.jboss.as.naming.ManagedReference;
+import org.jboss.as.naming.ManagedReferenceFactory;
+import org.jboss.as.naming.ValueManagedReference;
+import org.jboss.msc.inject.Injector;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+import org.jboss.msc.value.ImmediateValue;
+import org.jboss.msc.value.InjectedValue;
+import org.teiid.transport.ClientServiceRegistry;
+
+
+class CSRReferenceFactoryService implements Service<ManagedReferenceFactory>, ManagedReferenceFactory {
+ private final InjectedValue<ClientServiceRegistry> csrInjector = new InjectedValue<ClientServiceRegistry>();
+
+ private ManagedReference reference;
+
+ public synchronized void start(StartContext startContext) throws StartException {
+ reference = new ValueManagedReference(new ImmediateValue<Object>(csrInjector.getValue()));
+ }
+
+ public synchronized void stop(StopContext stopContext) {
+ reference = null;
+ }
+
+ public synchronized ManagedReferenceFactory getValue() throws IllegalStateException, IllegalArgumentException {
+ return this;
+ }
+
+ public synchronized ManagedReference getReference() {
+ return reference;
+ }
+
+ public Injector<ClientServiceRegistry> getCSRInjector() {
+ return csrInjector;
+ }
+}
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/CSRReferenceFactoryService.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ClientServiceRegistryReferenceFactoryService.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ClientServiceRegistryReferenceFactoryService.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ClientServiceRegistryReferenceFactoryService.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., 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.jboss;
-
-import org.jboss.as.naming.ManagedReference;
-import org.jboss.as.naming.ManagedReferenceFactory;
-import org.jboss.as.naming.ValueManagedReference;
-import org.jboss.msc.inject.Injector;
-import org.jboss.msc.service.Service;
-import org.jboss.msc.service.StartContext;
-import org.jboss.msc.service.StartException;
-import org.jboss.msc.service.StopContext;
-import org.jboss.msc.value.ImmediateValue;
-import org.jboss.msc.value.InjectedValue;
-import org.teiid.transport.ClientServiceRegistry;
-
-
-class ClientServiceRegistryReferenceFactoryService implements Service<ManagedReferenceFactory>, ManagedReferenceFactory {
- private final InjectedValue<ClientServiceRegistry> csrInjector = new InjectedValue<ClientServiceRegistry>();
-
- private ManagedReference reference;
-
- public synchronized void start(StartContext startContext) throws StartException {
- reference = new ValueManagedReference(new ImmediateValue<Object>(csrInjector.getValue()));
- }
-
- public synchronized void stop(StopContext stopContext) {
- reference = null;
- }
-
- public synchronized ManagedReferenceFactory getValue() throws IllegalStateException, IllegalArgumentException {
- return this;
- }
-
- public synchronized ManagedReference getReference() {
- return reference;
- }
-
- public Injector<ClientServiceRegistry> getCSRInjector() {
- return csrInjector;
- }
-}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -78,7 +78,6 @@
PREPAREDPLAN_CACHE_ELEMENT("preparedplan-cache"),
PPC_MAX_ENTRIES_ATTRIBUTE("max-entries", "preparedplan-cache-max-entries", ModelType.INT, false, "512"),
PPC_MAX_AGE_IN_SECS_ATTRIBUTE("max-age-in-seconds", "preparedplan-cache-max-age-in-seconds", ModelType.INT, false, "28800"),
- PPC_MAX_STALENESS_ATTRIBUTE("max-staleness", "preparedplan-cache-max-staleness", ModelType.INT, false, "0"),
// Object Replicator
OBJECT_REPLICATOR_ELEMENT("object-replicator"),
Deleted: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -1,1194 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., 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.jboss;
-
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REPLY_PROPERTIES;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.PathAddress;
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-import org.jboss.msc.service.ServiceController;
-import org.jboss.msc.service.ServiceName;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.impl.*;
-import org.teiid.adminapi.impl.VDBMetadataMapper.TransactionMetadataMapper;
-import org.teiid.adminapi.impl.VDBMetadataMapper.VDBTranslatorMetaDataMapper;
-import org.teiid.client.RequestMessage;
-import org.teiid.client.ResultsMessage;
-import org.teiid.client.security.SessionToken;
-import org.teiid.client.util.ResultsFuture;
-import org.teiid.core.TeiidComponentException;
-import org.teiid.deployers.VDBRepository;
-import org.teiid.dqp.internal.datamgr.TranslatorRepository;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.SessionAwareCache;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-
-abstract class QueryEngineOperationHandler extends BaseOperationHandler<DQPCore> {
- List<Transport> transports = new ArrayList<Transport>();
- protected VDBRepository vdbRepo;
- protected DQPCore engine;
-
- protected QueryEngineOperationHandler(String operationName){
- super(operationName);
- }
-
- @Override
- protected DQPCore getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- List<ServiceName> services = context.getServiceRegistry(false).getServiceNames();
- for (ServiceName name:services) {
- if (name.isParentOf(TeiidServiceNames.TRANSPORT_BASE)) {
- ServiceController<?> transport = context.getServiceRegistry(false).getService(name);
- if (transport != null) {
- this.transports.add(Transport.class.cast(transport.getValue()));
- }
- }
- }
- ServiceController<?> repo = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
- if (repo != null) {
- this.vdbRepo = VDBRepository.class.cast(repo.getValue());
- }
-
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.ENGINE);
- if (sc != null) {
- this.engine = DQPCore.class.cast(sc.getValue());
- }
- return this.engine;
- }
-}
-
-abstract class TranslatorOperationHandler extends BaseOperationHandler<TranslatorRepository> {
-
- protected TranslatorOperationHandler(String operationName){
- super(operationName);
- }
-
- @Override
- public TranslatorRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.TRANSLATOR_REPO);
- return TranslatorRepository.class.cast(sc.getValue());
- }
-}
-
-class GetRuntimeVersion extends QueryEngineOperationHandler{
- protected GetRuntimeVersion(String operationName) {
- super(operationName);
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- context.getResult().set(engine.getRuntimeVersion());
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).set(ModelType.STRING);
- }
-}
-
-class GetActiveSessionsCount extends QueryEngineOperationHandler{
- protected GetActiveSessionsCount(String operationName) {
- super(operationName);
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- try {
- int count = 0;
- for (Transport t: this.transports) {
- count += t.getActiveSessionsCount();
- }
- context.getResult().set(String.valueOf(count));
- } catch (AdminException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).set(ModelType.INT);
- }
-}
-
-class ListSessions extends QueryEngineOperationHandler{
- protected ListSessions() {
- super("list-sessions"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- try {
- ModelNode result = context.getResult();
- for (Transport t: this.transports) {
- Collection<SessionMetadata> sessions = t.getActiveSessions();
- for (SessionMetadata session:sessions) {
- VDBMetadataMapper.SessionMetadataMapper.INSTANCE.wrap(session, result.add());
- }
- }
- } catch (AdminException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.SessionMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class RequestsPerSession extends QueryEngineOperationHandler{
- protected RequestsPerSession() {
- super("requests-per-session"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- if (!operation.hasDefined(OperationsConstants.SESSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
- }
- ModelNode result = context.getResult();
- List<RequestMetadata> requests = engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
- for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
-
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class ListRequests extends QueryEngineOperationHandler{
- protected ListRequests() {
- super("list-requests"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- ModelNode result = context.getResult();
- List<RequestMetadata> requests = engine.getRequests();
- for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
- }
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class RequestsPerVDB extends QueryEngineOperationHandler{
- protected RequestsPerVDB() {
- super("requests-per-vdb"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- try {
-
- if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
- }
-
- ModelNode result = context.getResult();
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- for (Transport t: this.transports) {
- List<RequestMetadata> requests = t.getRequestsUsingVDB(vdbName,vdbVersion);
- for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
- }
- }
- } catch (AdminException e) {
- throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.INT);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
-
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class GetLongRunningQueries extends QueryEngineOperationHandler{
- protected GetLongRunningQueries() {
- super("long-running-queries"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- ModelNode result = context.getResult();
- List<RequestMetadata> requests = engine.getLongRunningRequests();
- for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
- }
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class TerminateSession extends QueryEngineOperationHandler{
- protected TerminateSession() {
- super("terminate-session"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- if (!operation.hasDefined(OperationsConstants.SESSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
- }
- for (Transport t: this.transports) {
- t.terminateSession(operation.get(OperationsConstants.SESSION).asString());
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
- }
-}
-
-class CancelRequest extends QueryEngineOperationHandler{
- protected CancelRequest() {
- super("cancel-request"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
- try {
- if (!operation.hasDefined(OperationsConstants.SESSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.EXECUTION_ID)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.EXECUTION_ID+MISSING)));
- }
- boolean pass = engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(), operation.get(OperationsConstants.EXECUTION_ID).asLong());
- ModelNode result = context.getResult();
- result.set(pass);
- } catch (TeiidComponentException e) {
- throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, TYPE).set(ModelType.LONG);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.EXECUTION_ID));
-
- operationNode.get(REPLY_PROPERTIES).set(ModelType.BOOLEAN);
- }
-}
-
-abstract class BaseCachehandler extends BaseOperationHandler<SessionAwareCache>{
- BaseCachehandler(String operationName){
- super(operationName);
- }
-
- @Override
- protected SessionAwareCache getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- String cacheType = Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.name();
-
- if (operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
- cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
- //throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
- }
-
- ServiceController<?> sc;
- if (SessionAwareCache.isResultsetCache(cacheType)) {
- sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.CACHE_RESULTSET);
- }
- else {
- sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.CACHE_PREPAREDPLAN);
- }
-
- return SessionAwareCache.class.cast(sc.getValue());
- }
-}
-
-
-class CacheTypes extends BaseCachehandler {
- protected CacheTypes() {
- super("cache-types"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, SessionAwareCache cache, ModelNode operation) throws OperationFailedException {
- ModelNode result = context.getResult();
- Collection<String> types = SessionAwareCache.getCacheTypes();
- for (String type:types) {
- result.add(type);
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- ModelNode node = new ModelNode();
- node.get(OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
- node.get(OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
- node.get(OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
- operationNode.get(REPLY_PROPERTIES).add(node);
- }
-}
-
-class ClearCache extends BaseCachehandler {
-
- protected ClearCache() {
- super("clear-cache"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, SessionAwareCache cache, ModelNode operation) throws OperationFailedException {
- if (operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
- }
-
- String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
- if (operation.hasDefined(OperationsConstants.VDB_NAME) && operation.hasDefined(OperationsConstants.VDB_VERSION)) {
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- LogManager.logInfo(LogConstants.CTX_DQP, IntegrationPlugin.Util.getString("clearing_cache_vdb", cacheType, vdbName, vdbVersion)); //$NON-NLS-1$
- cache.clearForVDB(vdbName, vdbVersion);
- }
- else {
- LogManager.logInfo(LogConstants.CTX_DQP, IntegrationPlugin.Util.getString("clearing_cache", cacheType)); //$NON-NLS-1$
- cache.clearAll();
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(false);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.INT);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(false);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
-
- }
-}
-
-class CacheStatistics extends BaseCachehandler {
-
- protected CacheStatistics() {
- super("cache-statistics"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, SessionAwareCache cache, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
- }
- ModelNode result = context.getResult();
- String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
- CacheStatisticsMetadata stats = buildCacheStats(cacheType, cache);
- VDBMetadataMapper.CacheStatisticsMetadataMapper.INSTANCE.wrap(stats, result);
- }
-
- private CacheStatisticsMetadata buildCacheStats(String name, SessionAwareCache cache) {
- CacheStatisticsMetadata stats = new CacheStatisticsMetadata();
- stats.setName(name);
- stats.setHitRatio(cache.getRequestCount() == 0?0:((double)cache.getCacheHitCount()/cache.getRequestCount())*100);
- stats.setTotalEntries(cache.getTotalCacheEntries());
- stats.setRequestCount(cache.getRequestCount());
- return stats;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
-
- ModelNode node = new ModelNode();
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.CacheStatisticsMetadataMapper.INSTANCE.describe(node));
- }
-}
-
-class WorkerPoolStatistics extends QueryEngineOperationHandler{
-
- protected WorkerPoolStatistics() {
- super("workerpool-statistics"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
- ModelNode result = context.getResult();
- WorkerPoolStatisticsMetadata stats = engine.getWorkerPoolStatistics();
- VDBMetadataMapper.WorkerPoolStatisticsMetadataMapper.INSTANCE.wrap(stats, result);
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.WorkerPoolStatisticsMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class ListTransactions extends QueryEngineOperationHandler{
-
- protected ListTransactions() {
- super("list-transactions"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
- ModelNode result = context.getResult();
- Collection<TransactionMetadata> txns = engine.getTransactions();
- for (TransactionMetadata txn:txns) {
- VDBMetadataMapper.TransactionMetadataMapper.INSTANCE.wrap(txn, result.add());
- }
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- ModelNode node = new ModelNode();
- operationNode.get(REPLY_PROPERTIES).add(TransactionMetadataMapper.INSTANCE.describe(node));
- }
-}
-
-class TerminateTransaction extends QueryEngineOperationHandler{
-
- protected TerminateTransaction() {
- super("terminate-transaction"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
-
- if (!operation.hasDefined(OperationsConstants.XID)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.XID+MISSING)));
- }
-
- String xid = operation.get(OperationsConstants.XID).asString();
- try {
- engine.terminateTransaction(xid);
- } catch (AdminException e) {
- throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
- }
-}
-
-class MergeVDBs extends BaseOperationHandler<VDBRepository>{
-
- protected MergeVDBs() {
- super("merge-vdbs"); //$NON-NLS-1$
- }
-
- @Override
- protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
- return VDBRepository.class.cast(sc.getValue());
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.SOURCE_VDBNAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBNAME+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.SOURCE_VDBVERSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBVERSION+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.TARGET_VDBNAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBNAME+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.TARGET_VDBVERSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBVERSION+MISSING)));
- }
-
- String sourceVDBName = operation.get(OperationsConstants.SOURCE_VDBNAME).asString();
- int sourceVDBversion = operation.get(OperationsConstants.SOURCE_VDBVERSION).asInt();
- String targetVDBName = operation.get(OperationsConstants.TARGET_VDBNAME).asString();
- int targetVDBversion = operation.get(OperationsConstants.TARGET_VDBVERSION).asInt();
- try {
- repo.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
- } catch (AdminException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBNAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBVERSION));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBNAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBVERSION));
- }
-}
-
-class ExecuteQuery extends QueryEngineOperationHandler{
-
- protected ExecuteQuery() {
- super("execute-query"); //$NON-NLS-1$
- }
- @Override
- protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
-
- if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.SQL_QUERY)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SQL_QUERY+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.TIMEOUT_IN_MILLI)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TIMEOUT_IN_MILLI+MISSING)));
- }
-
- ModelNode result = context.getResult();
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- String sql = operation.get(OperationsConstants.SQL_QUERY).asString();
- int timeout = operation.get(OperationsConstants.TIMEOUT_IN_MILLI).asInt();
-
- result.set(executeQuery(vdbName, vdbVersion, sql, timeout, new ModelNode()));
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SQL_QUERY));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TIMEOUT_IN_MILLI));
-
- operationNode.get(REPLY_PROPERTIES).set(ModelType.LIST);
- }
-
- public ModelNode executeQuery(final String vdbName, final int version, final String command, final long timoutInMilli, final ModelNode resultsNode) throws OperationFailedException {
- String user = "CLI ADMIN"; //$NON-NLS-1$
- LogManager.logDetail(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("admin_executing", user, command)); //$NON-NLS-1$
-
- SessionMetadata session = createTemporarySession(vdbName, version, user);
-
- final long requestID = 0L;
-
- DQPWorkContext context = new DQPWorkContext();
- context.setSession(session);
-
- try {
- return context.runInContext(new Callable<ModelNode>() {
- @Override
- public ModelNode call() throws Exception {
-
- long start = System.currentTimeMillis();
- RequestMessage request = new RequestMessage(command);
- request.setExecutionId(0L);
- request.setRowLimit(engine.getMaxRowsFetchSize()); // this would limit the number of rows that are returned.
- Future<ResultsMessage> message = engine.executeRequest(requestID, request);
- ResultsMessage rm = null;
- if (timoutInMilli < 0) {
- rm = message.get();
- } else {
- rm = message.get(timoutInMilli, TimeUnit.MILLISECONDS);
- }
- if (rm.getException() != null) {
- throw new AdminProcessingException(rm.getException());
- }
-
- if (rm.isUpdateResult()) {
- writeResults(resultsNode, Arrays.asList("update-count"), rm.getResultsList()); //$NON-NLS-1$
- }
- else {
- writeResults(resultsNode, Arrays.asList(rm.getColumnNames()), rm.getResultsList());
-
- while (rm.getFinalRow() == -1 || rm.getLastRow() < rm.getFinalRow()) {
- long elapsed = System.currentTimeMillis() - start;
- message = engine.processCursorRequest(requestID, rm.getLastRow()+1, 1024);
- rm = message.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
- writeResults(resultsNode, Arrays.asList(rm.getColumnNames()), rm.getResultsList());
- }
- }
-
- long elapsed = System.currentTimeMillis() - start;
- ResultsFuture<?> response = engine.closeRequest(requestID);
- response.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
- return resultsNode;
- }
- });
- } catch (Throwable t) {
- throw new OperationFailedException(new ModelNode().set(t.getMessage()));
- }
- }
-
- private void writeResults(ModelNode resultsNode, List<String> columns, List<? extends List<?>> results) throws SQLException {
- for (List<?> row:results) {
- ModelNode rowNode = new ModelNode();
-
- for (int colNum = 0; colNum < columns.size(); colNum++) {
-
- Object aValue = row.get(colNum);
- if (aValue != null) {
- if (aValue instanceof Integer) {
- rowNode.get(columns.get(colNum)).set((Integer)aValue);
- }
- else if (aValue instanceof Long) {
- rowNode.get(columns.get(colNum)).set((Long)aValue);
- }
- else if (aValue instanceof Double) {
- rowNode.get(columns.get(colNum)).set((Double)aValue);
- }
- else if (aValue instanceof Boolean) {
- rowNode.get(columns.get(colNum)).set((Boolean)aValue);
- }
- else if (aValue instanceof BigInteger) {
- rowNode.get(columns.get(colNum)).set((BigInteger)aValue);
- }
- else if (aValue instanceof BigDecimal) {
- rowNode.get(columns.get(colNum)).set((BigDecimal)aValue);
- }
- else if (aValue instanceof String) {
- rowNode.get(columns.get(colNum), TYPE).set(ModelType.STRING);
- rowNode.get(columns.get(colNum)).set((String)aValue);
- }
- else if (aValue instanceof Blob) {
- rowNode.get(columns.get(colNum), TYPE).set(ModelType.OBJECT);
- rowNode.get(columns.get(colNum)).set("blob"); //$NON-NLS-1$
- }
- else if (aValue instanceof Clob) {
- rowNode.get(columns.get(colNum), TYPE).set(ModelType.OBJECT);
- rowNode.get(columns.get(colNum)).set("clob"); //$NON-NLS-1$
- }
- else if (aValue instanceof SQLXML) {
- SQLXML xml = (SQLXML)aValue;
- rowNode.get(columns.get(colNum), TYPE).set(ModelType.STRING);
- rowNode.get(columns.get(colNum)).set(xml.getString());
- }
- else {
- rowNode.get(columns.get(colNum), TYPE).set(ModelType.STRING);
- rowNode.get(columns.get(colNum)).set(aValue.toString());
- }
- }
- }
- resultsNode.add(rowNode);
- }
- }
-
- private SessionMetadata createTemporarySession(final String vdbName, final int version, final String userName) {
-
- long creationTime = System.currentTimeMillis();
-
- // Return a new session info object
- SessionMetadata newSession = new SessionMetadata();
- newSession.setSessionToken(new SessionToken(userName));
- newSession.setSessionId(newSession.getSessionToken().getSessionID());
- newSession.setUserName(userName);
- newSession.setCreatedTime(creationTime);
- newSession.setApplicationName("admin-console"); //$NON-NLS-1$
- newSession.setVDBName(vdbName);
- newSession.setVDBVersion(version);
-
- newSession.setVdb(this.vdbRepo.getVDB(vdbName, version));
- return newSession;
- }
-}
-
-class GetVDB extends BaseOperationHandler<VDBRepository>{
-
- protected GetVDB() {
- super("get-vdb"); //$NON-NLS-1$
- }
-
- @Override
- protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
- return VDBRepository.class.cast(sc.getValue());
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
- }
- if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
- }
-
- ModelNode result = context.getResult();
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
-
- VDBMetaData vdb = repo.getVDB(vdbName, vdbVersion);
- VDBMetadataMapper.INSTANCE.wrap(vdb, result);
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
-
- operationNode.get(REPLY_PROPERTIES).set(VDBMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class ListVDBs extends BaseOperationHandler<VDBRepository>{
-
- protected ListVDBs() {
- super("list-vdbs"); //$NON-NLS-1$
- }
-
- @Override
- protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
- return VDBRepository.class.cast(sc.getValue());
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
- ModelNode result = context.getResult();
- List<VDBMetaData> vdbs = repo.getVDBs();
- for (VDBMetaData vdb:vdbs) {
- VDBMetadataMapper.INSTANCE.wrap(vdb, result.add());
- }
- }
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class ListTranslators extends TranslatorOperationHandler{
-
- protected ListTranslators() {
- super("list-translators"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, TranslatorRepository repo, ModelNode operation) throws OperationFailedException {
- ModelNode result = context.getResult();
- List<VDBTranslatorMetaData> translators = repo.getTranslators();
- for (VDBTranslatorMetaData t:translators) {
- VDBMetadataMapper.VDBTranslatorMetaDataMapper.INSTANCE.wrap(t, result.add());
- }
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.VDBTranslatorMetaDataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-class GetTranslator extends TranslatorOperationHandler{
-
- protected GetTranslator() {
- super("get-translator"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, TranslatorRepository repo, ModelNode operation) throws OperationFailedException {
-
- if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
- }
-
- ModelNode result = context.getResult();
- String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
- VDBTranslatorMetaData translator = repo.getTranslatorMetaData(translatorName);
- VDBMetadataMapper.VDBTranslatorMetaDataMapper.INSTANCE.wrap(translator, result);
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
-
- operationNode.get(REPLY_PROPERTIES).set(VDBTranslatorMetaDataMapper.INSTANCE.describe(new ModelNode()));
- }
-}
-
-abstract class VDBOperations extends BaseOperationHandler<VDBMetaData>{
- private ObjectSerializer serializer;
-
- public VDBOperations(String operationName) {
- super(operationName);
- }
-
- @Override
- public VDBMetaData getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
- }
-
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
-
- ServiceController<?> osSvc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.OBJECT_SERIALIZER);
- this.serializer = ObjectSerializer.class.cast(osSvc.getValue());
-
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.vdbServiceName(vdbName, vdbVersion));
- return VDBMetaData.class.cast(sc.getValue());
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
- }
-
- protected void save(VDBMetaData vdb) throws AdminProcessingException{
- try {
- VDBMetadataParser.marshell(vdb, this.serializer.getVdbXmlOutputStream(vdb));
- } catch (IOException e) {
- throw new AdminProcessingException(e);
- } catch (XMLStreamException e) {
- throw new AdminProcessingException(e);
- }
- }
-}
-
-class AddDataRole extends VDBOperations {
-
- public AddDataRole() {
- super("add-data-role"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.MAPPED_ROLE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MAPPED_ROLE+MISSING)));
- }
-
- String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
- String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE).asString();
-
- try {
- DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
- if (policy == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
-
- policy.addMappedRoleName(mappedRole);
- save(vdb);
- } catch (AdminProcessingException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- @Override
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- super.describeParameters(operationNode, bundle);
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MAPPED_ROLE));
- }
-}
-
-class RemoveDataRole extends VDBOperations {
-
- public RemoveDataRole() {
- super("remove-data-role"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.MAPPED_ROLE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MAPPED_ROLE+MISSING)));
- }
-
- String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
- String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE).asString();
-
- try {
- DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
- if (policy == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
-
- policy.removeMappedRoleName(mappedRole);
- save(vdb);
- } catch (AdminProcessingException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- @Override
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- super.describeParameters(operationNode, bundle);
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MAPPED_ROLE));
- }
-}
-
-class AddAnyAuthenticatedDataRole extends VDBOperations {
-
- public AddAnyAuthenticatedDataRole() {
- super("add-anyauthenticated-role"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
- }
-
- String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
-
- try {
- DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
- if (policy == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
-
- policy.setAnyAuthenticated(true);
- save(vdb);
- } catch (AdminProcessingException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- @Override
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- super.describeParameters(operationNode, bundle);
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
- }
-
-}
-
-class RemoveAnyAuthenticatedDataRole extends VDBOperations {
-
- public RemoveAnyAuthenticatedDataRole() {
- super("remove-anyauthenticated-role"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
- }
-
- String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
-
- try {
- DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
- if (policy == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
-
- policy.setAnyAuthenticated(false);
- save(vdb);
- } catch (AdminProcessingException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- @Override
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- super.describeParameters(operationNode, bundle);
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
- }
-}
-
-class ChangeVDBConnectionType extends VDBOperations {
-
- public ChangeVDBConnectionType() {
- super("change-vdb-connection-type"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.CONNECTION_TYPE)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CONNECTION_TYPE+MISSING)));
- }
-
- String connectionType = operation.get(OperationsConstants.CONNECTION_TYPE).asString();
- try {
- vdb.setConnectionType(connectionType);
- save(vdb);
- } catch (AdminProcessingException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- @Override
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- super.describeParameters(operationNode, bundle);
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CONNECTION_TYPE, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CONNECTION_TYPE, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CONNECTION_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CONNECTION_TYPE));
- }
-}
-
-class AssignDataSource extends VDBOperations {
-
- public AssignDataSource() {
- super("assign-datasource"); //$NON-NLS-1$
- }
-
- @Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
- if (!operation.hasDefined(OperationsConstants.MODEL_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MODEL_NAME+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.SOURCE_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_NAME+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
- }
-
- if (!operation.hasDefined(OperationsConstants.DS_NAME)) {
- throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DS_NAME+MISSING)));
- }
-
-
- String modelName = operation.get(OperationsConstants.MODEL_NAME).asString();
- String sourceName = operation.get(OperationsConstants.SOURCE_NAME).asString();
- String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
- String dsName = operation.get(OperationsConstants.DS_NAME).asString();
-
- try {
- ModelMetaData model = vdb.getModel(modelName);
-
- if (model == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("model_not_found", modelName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
-
- SourceMappingMetadata source = model.getSourceMapping(sourceName);
- if(source == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("source_not_found", sourceName, modelName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
- source.setTranslatorName(translatorName);
- source.setConnectionJndiName(dsName);
- save(vdb);
- } catch (AdminProcessingException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- }
-
- @Override
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- super.describeParameters(operationNode, bundle);
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MODEL_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MODEL_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MODEL_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MODEL_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MODEL_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DS_NAME, TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DS_NAME, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DS_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DS_NAME));
-
- }
-}
\ No newline at end of file
Copied: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java (from rev 3548, branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java)
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -0,0 +1,470 @@
+/*
+ * 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 static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.ServiceLoader;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.TransactionManager;
+
+import org.jboss.as.clustering.jgroups.ChannelFactory;
+import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.server.AbstractDeploymentChainStep;
+import org.jboss.as.server.DeploymentProcessorTarget;
+import org.jboss.as.server.deployment.Phase;
+import org.jboss.as.server.services.path.RelativePathService;
+import org.jboss.dmr.ModelNode;
+import org.jboss.modules.Module;
+import org.jboss.modules.ModuleIdentifier;
+import org.jboss.modules.ModuleLoadException;
+import org.jboss.msc.service.ServiceBuilder;
+import org.jboss.msc.service.ServiceBuilder.DependencyType;
+import org.jboss.msc.service.ServiceContainer;
+import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.ServiceTarget;
+import org.jboss.msc.service.ValueService;
+import org.jboss.msc.value.InjectedValue;
+import org.teiid.PolicyDecider;
+import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.CacheConfiguration.Policy;
+import org.teiid.cache.DefaultCacheFactory;
+import org.teiid.cache.jboss.ClusterableCacheFactory;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.deployers.SystemVDBDeployer;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
+import org.teiid.dqp.internal.process.AuthorizationValidator;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DataRolePolicyDecider;
+import org.teiid.dqp.internal.process.DefaultAuthorizationValidator;
+import org.teiid.dqp.internal.process.PreparedPlan;
+import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.jboss.deployers.RuntimeEngineDeployer;
+import org.teiid.query.ObjectReplicator;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.replication.jboss.JGroupsObjectReplicator;
+import org.teiid.services.BufferServiceImpl;
+
+class TeiidAdd extends AbstractAddStepHandler implements DescriptionProvider {
+
+ private static Element[] attributes = {
+ Element.ALLOW_ENV_FUNCTION_ELEMENT,
+ Element.ASYNC_THREAD_POOL_ELEMENT,
+ Element.MAX_THREADS_ELEMENT,
+ Element.MAX_ACTIVE_PLANS_ELEMENT,
+ Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT,
+ Element.TIME_SLICE_IN_MILLI_ELEMENT,
+ Element.MAX_ROWS_FETCH_SIZE_ELEMENT,
+ Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT,
+ Element.QUERY_THRESHOLD_IN_SECS_ELEMENT,
+ Element.MAX_SOURCE_ROWS_ELEMENT,
+ Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT,
+ Element.DETECTING_CHANGE_EVENTS_ELEMENT,
+ Element.AUTHORIZATION_VALIDATOR_MODULE_ATTRIBUTE,
+ Element.POLICY_DECIDER_MODULE_ATTRIBUTE,
+
+ // object replicator
+ Element.OR_STACK_ATTRIBUTE,
+ Element.OR_CLUSTER_NAME_ATTRIBUTE,
+
+ // Buffer Service
+ Element.USE_DISK_ATTRIBUTE,
+ Element.PROCESSOR_BATCH_SIZE_ATTRIBUTE,
+ Element.CONNECTOR_BATCH_SIZE_ATTRIBUTE,
+ Element.MAX_PROCESSING_KB_ATTRIBUTE,
+ Element.MAX_RESERVED_KB_ATTRIBUTE,
+ Element.MAX_FILE_SIZE_ATTRIBUTE,
+ Element.MAX_BUFFER_SPACE_ATTRIBUTE,
+ Element.MAX_OPEN_FILES_ATTRIBUTE,
+
+ // prepared plan cache
+ Element.PPC_MAX_ENTRIES_ATTRIBUTE,
+ Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE,
+
+ // resultset cache
+ Element.RSC_NAME_ELEMENT,
+ Element.RSC_CONTAINER_NAME_ELEMENT,
+ Element.RSC_MAX_STALENESS_ELEMENT,
+ Element.RSC_ENABLE_ATTRIBUTE
+ };
+
+ @Override
+ public ModelNode getModelDescription(Locale locale) {
+ final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
+ final ModelNode node = new ModelNode();
+ node.get(OPERATION_NAME).set(ADD);
+ node.get(DESCRIPTION).set(bundle.getString("teiid.add")); //$NON-NLS-1$
+
+ describeTeiid(node, REQUEST_PROPERTIES, bundle);
+
+ return node;
+ }
+
+ static void describeTeiid(final ModelNode node, String type, final ResourceBundle bundle) {
+ for (int i = 0; i < attributes.length; i++) {
+ attributes[i].describe(node, type, bundle);
+ }
+ }
+
+ @Override
+ protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
+ populate(operation, model);
+ }
+
+ static void populate(ModelNode operation, ModelNode model) {
+ for (int i = 0; i < attributes.length; i++) {
+ attributes[i].populate(operation, model);
+ }
+ }
+
+
+ @Override
+ protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
+ final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
+
+ ServiceTarget target = context.getServiceTarget();
+
+ final JBossLifeCycleListener shutdownListener = new JBossLifeCycleListener();
+
+ final String asyncThreadPoolName = Element.ASYNC_THREAD_POOL_ELEMENT.asString(operation);
+
+ // translator repository
+ final TranslatorRepository translatorRepo = new TranslatorRepository();
+ ValueService<TranslatorRepository> translatorService = new ValueService<TranslatorRepository>(new org.jboss.msc.value.Value<TranslatorRepository>() {
+ @Override
+ public TranslatorRepository getValue() throws IllegalStateException, IllegalArgumentException {
+ return translatorRepo;
+ }
+ });
+ ServiceController<TranslatorRepository> service = target.addService(TeiidServiceNames.TRANSLATOR_REPO, translatorService).install();
+ newControllers.add(service);
+
+ // system function tree
+ SystemFunctionManager systemFunctionManager = new SystemFunctionManager();
+ if (Element.ALLOW_ENV_FUNCTION_ELEMENT.isDefined(operation)) {
+ systemFunctionManager.setAllowEnvFunction(Element.ALLOW_ENV_FUNCTION_ELEMENT.asBoolean(operation));
+ }
+ else {
+ systemFunctionManager.setAllowEnvFunction(false);
+ }
+ systemFunctionManager.setClassloader(Module.getCallerModule().getClassLoader());
+
+ // VDB repository
+ final VDBRepository vdbRepository = new VDBRepository();
+ vdbRepository.setSystemFunctionManager(systemFunctionManager);
+ VDBRepositoryService vdbRepositoryService = new VDBRepositoryService(vdbRepository);
+ newControllers.add(target.addService(TeiidServiceNames.VDB_REPO, vdbRepositoryService).install());
+
+ // System VDB Service
+ SystemVDBDeployer systemVDB = new SystemVDBDeployer();
+ systemVDB.setVDBRepository(vdbRepository);
+ SystemVDBService systemVDBService = new SystemVDBService(systemVDB);
+ newControllers.add(target.addService(TeiidServiceNames.SYSTEM_VDB, systemVDBService).install());
+
+ newControllers.add(RelativePathService.addService(TeiidServiceNames.DATA_DIR, "teiid-data", "jboss.server.data.dir", target)); //$NON-NLS-1$ //$NON-NLS-2$
+ final ObjectsSerializerService serializer = new ObjectsSerializerService();
+ ServiceBuilder<ObjectSerializer> objectSerializerService = target.addService(TeiidServiceNames.OBJECT_SERIALIZER, serializer);
+ objectSerializerService.addDependency(TeiidServiceNames.DATA_DIR, String.class, serializer.getPathInjector());
+ newControllers.add(objectSerializerService.install());
+
+ // TODO: remove verbose service by moving the buffer service from runtime project
+ newControllers.add(RelativePathService.addService(TeiidServiceNames.BUFFER_DIR, "teiid-buffer", "jboss.server.temp.dir", target)); //$NON-NLS-1$ //$NON-NLS-2$
+ final BufferServiceImpl bufferManager = buildBufferManager(operation);
+ BufferManagerService bufferService = new BufferManagerService(bufferManager);
+ ServiceBuilder<BufferServiceImpl> bufferServiceBuilder = target.addService(TeiidServiceNames.BUFFER_MGR, bufferService);
+ bufferServiceBuilder.addDependency(TeiidServiceNames.BUFFER_DIR, String.class, bufferService.pathInjector);
+ newControllers.add(bufferServiceBuilder.install());
+
+ PolicyDecider policyDecider;
+ if (Element.POLICY_DECIDER_MODULE_ATTRIBUTE.isDefined(operation)) {
+ policyDecider = buildService(PolicyDecider.class, Element.POLICY_DECIDER_MODULE_ATTRIBUTE.asString(operation));
+ }
+ else {
+ DataRolePolicyDecider drpd = new DataRolePolicyDecider();
+ drpd.setAllowCreateTemporaryTablesByDefault(true);
+ drpd.setAllowFunctionCallsByDefault(true);
+ policyDecider = drpd;
+ }
+
+ final AuthorizationValidator authValidator;
+ if (Element.AUTHORIZATION_VALIDATOR_MODULE_ATTRIBUTE.isDefined(operation)) {
+ authValidator = buildService(AuthorizationValidator.class, Element.AUTHORIZATION_VALIDATOR_MODULE_ATTRIBUTE.asString(operation));
+ authValidator.setEnabled(true);
+ }
+ else {
+ DefaultAuthorizationValidator dap = new DefaultAuthorizationValidator();
+ dap.setPolicyDecider(policyDecider);
+ dap.setEnabled(true);
+ authValidator = dap;
+ }
+
+ ValueService<AuthorizationValidator> authValidatorService = new ValueService<AuthorizationValidator>(new org.jboss.msc.value.Value<AuthorizationValidator>() {
+ @Override
+ public AuthorizationValidator getValue() throws IllegalStateException, IllegalArgumentException {
+ return authValidator;
+ }
+ });
+ newControllers.add(target.addService(TeiidServiceNames.AUTHORIZATION_VALIDATOR, authValidatorService).install());
+
+ // resultset cache
+ final SessionAwareCache<CachedResults> resultsetCache = buildResultsetCache(operation, bufferManager.getBufferManager());
+ ValueService<SessionAwareCache<CachedResults>> resultSetService = new ValueService<SessionAwareCache<CachedResults>>(new org.jboss.msc.value.Value<SessionAwareCache<CachedResults>>() {
+ @Override
+ public SessionAwareCache<CachedResults> getValue() throws IllegalStateException, IllegalArgumentException {
+ return resultsetCache;
+ }
+ });
+ newControllers.add(target.addService(TeiidServiceNames.CACHE_RESULTSET, resultSetService).install());
+
+ // prepared-plan cache
+ final SessionAwareCache<PreparedPlan> preparedPlanCache = buildPreparedPlanCache(operation, bufferManager.getBufferManager());
+ ValueService<SessionAwareCache<PreparedPlan>> preparedPlanService = new ValueService<SessionAwareCache<PreparedPlan>>(new org.jboss.msc.value.Value<SessionAwareCache<PreparedPlan>>() {
+ @Override
+ public SessionAwareCache<PreparedPlan> getValue() throws IllegalStateException, IllegalArgumentException {
+ return preparedPlanCache;
+ }
+ });
+ newControllers.add(target.addService(TeiidServiceNames.CACHE_PREPAREDPLAN, preparedPlanService).install());
+
+ // Object Replicator
+ if (Element.OR_STACK_ATTRIBUTE.isDefined(operation)) {
+ String stack = Element.OR_STACK_ATTRIBUTE.asString(operation);
+
+ String clusterName = "teiid-rep"; //$NON-NLS-1$
+ if (Element.OR_CLUSTER_NAME_ATTRIBUTE.isDefined(operation)) {
+ clusterName = Element.OR_CLUSTER_NAME_ATTRIBUTE.asString(operation);
+ }
+
+ JGroupsObjectReplicatorService replicatorService = new JGroupsObjectReplicatorService(clusterName);
+ replicatorService.setBufferManager(bufferManager.getBufferManager());
+ ServiceBuilder<JGroupsObjectReplicator> serviceBuilder = target.addService(TeiidServiceNames.OBJECT_REPLICATOR, replicatorService);
+ serviceBuilder.addDependency(ServiceName.JBOSS.append("jgroups", stack), ChannelFactory.class, replicatorService.channelFactoryInjector); //$NON-NLS-1$
+ newControllers.add(serviceBuilder.install());
+ }
+
+ // Query Engine
+ final RuntimeEngineDeployer engine = buildQueryEngine(operation);
+
+ ServiceBuilder<DQPCore> engineBuilder = target.addService(TeiidServiceNames.ENGINE, engine);
+ engineBuilder.addDependency(ServiceName.JBOSS.append("connector", "workmanager"), WorkManager.class, engine.getWorkManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("txn", "XATerminator"), XATerminator.class, engine.getXaTerminatorInjector()); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("txn", "TransactionManager"), TransactionManager.class, engine.getTxnManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(TeiidServiceNames.BUFFER_MGR, BufferServiceImpl.class, engine.getBufferServiceInjector());
+ engineBuilder.addDependency(TeiidServiceNames.SYSTEM_VDB, SystemVDBDeployer.class, new InjectedValue<SystemVDBDeployer>());
+ engineBuilder.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, engine.getTranslatorRepositoryInjector());
+ engineBuilder.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class, engine.getVdbRepositoryInjector());
+ engineBuilder.addDependency(TeiidServiceNames.AUTHORIZATION_VALIDATOR, AuthorizationValidator.class, engine.getAuthorizationValidatorInjector());
+ engineBuilder.addDependency(TeiidServiceNames.CACHE_RESULTSET, SessionAwareCache.class, engine.getResultSetCacheInjector());
+ engineBuilder.addDependency(TeiidServiceNames.CACHE_PREPAREDPLAN, SessionAwareCache.class, engine.getPreparedPlanCacheInjector());
+ engineBuilder.addDependency(DependencyType.OPTIONAL, TeiidServiceNames.OBJECT_REPLICATOR, ObjectReplicator.class, engine.getObjectReplicatorInjector());
+
+ engineBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
+ ServiceController<DQPCore> controller = engineBuilder.install();
+ newControllers.add(controller);
+ ServiceContainer container = controller.getServiceContainer();
+ container.addTerminateListener(shutdownListener);
+
+ // Register VDB deployer
+ context.addStep(new AbstractDeploymentChainStep() {
+ @Override
+ public void execute(DeploymentProcessorTarget processorTarget) {
+ processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT,new DynamicVDBRootMountDeployer());
+ processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT|0x0001,new VDBStructureDeployer());
+ processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_WEB_DEPLOYMENT|0x0001, new VDBParserDeployer());
+ processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, Phase.DEPENDENCIES_WAR_MODULE|0x0001, new VDBDependencyDeployer());
+ processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT|0x0001, new VDBDeployer(translatorRepo, asyncThreadPoolName));
+ }
+
+ }, OperationContext.Stage.RUNTIME);
+ }
+
+ private <T> T buildService(Class<T> type, String moduleName) throws OperationFailedException {
+ final ModuleIdentifier moduleId;
+ final Module module;
+ try {
+ moduleId = ModuleIdentifier.create(moduleName);
+ module = Module.getCallerModuleLoader().loadModule(moduleId);
+ } catch (ModuleLoadException e) {
+ throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName))); //$NON-NLS-1$
+ }
+ ServiceLoader<T> services = module.loadService(type);
+ return services.iterator().next();
+ }
+
+
+ private BufferServiceImpl buildBufferManager(ModelNode node) {
+ BufferServiceImpl bufferManger = new BufferServiceImpl();
+
+ if (node == null) {
+ return bufferManger;
+ }
+
+ if (Element.USE_DISK_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setUseDisk(Element.USE_DISK_ATTRIBUTE.asBoolean(node));
+ }
+ if (Element.PROCESSOR_BATCH_SIZE_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setProcessorBatchSize(Element.PROCESSOR_BATCH_SIZE_ATTRIBUTE.asInt(node));
+ }
+ if (Element.CONNECTOR_BATCH_SIZE_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setConnectorBatchSize(Element.CONNECTOR_BATCH_SIZE_ATTRIBUTE.asInt(node));
+ }
+ if (Element.MAX_PROCESSING_KB_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setMaxProcessingKb(Element.MAX_PROCESSING_KB_ATTRIBUTE.asInt(node));
+ }
+ if (Element.MAX_RESERVED_KB_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setMaxReserveKb(Element.MAX_RESERVED_KB_ATTRIBUTE.asInt(node));
+ }
+ if (Element.MAX_FILE_SIZE_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setMaxFileSize(Element.MAX_FILE_SIZE_ATTRIBUTE.asLong(node));
+ }
+ if (Element.MAX_BUFFER_SPACE_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setMaxBufferSpace(Element.MAX_BUFFER_SPACE_ATTRIBUTE.asLong(node));
+ }
+ if (Element.MAX_OPEN_FILES_ATTRIBUTE.isDefined(node)) {
+ bufferManger.setMaxOpenFiles(Element.MAX_OPEN_FILES_ATTRIBUTE.asInt(node));
+ }
+ return bufferManger;
+ }
+
+ private SessionAwareCache<CachedResults> buildResultsetCache(ModelNode node, BufferManager bufferManager) {
+
+ CacheConfiguration cacheConfig = new CacheConfiguration();
+ // these settings are not really used; they are defined by infinispan
+ cacheConfig.setMaxEntries(1024);
+ cacheConfig.setMaxAgeInSeconds(7200);
+ cacheConfig.setType(Policy.EXPIRATION.name());
+ cacheConfig.setLocation("resultset"); //$NON-NLS-1$
+ cacheConfig.setMaxStaleness(60);
+
+ if (Element.RSC_ENABLE_ATTRIBUTE.isDefined(node)) {
+ if (!Element.RSC_ENABLE_ATTRIBUTE.asBoolean(node)) {
+ return null;
+ }
+ }
+
+ ClusterableCacheFactory cacheFactory = null;
+
+ if (Element.RSC_CONTAINER_NAME_ELEMENT.isDefined(node)) {
+ cacheFactory = new ClusterableCacheFactory();
+ cacheFactory.setCacheManager(Element.RSC_CONTAINER_NAME_ELEMENT.asString(node));
+ }
+ else {
+ SessionAwareCache<CachedResults> resultsetCache = new SessionAwareCache<CachedResults>(new DefaultCacheFactory(), SessionAwareCache.Type.RESULTSET, cacheConfig);
+ resultsetCache.setBufferManager(bufferManager);
+ return resultsetCache;
+ }
+
+ if (Element.RSC_NAME_ELEMENT.isDefined(node)) {
+ cacheFactory.setResultsetCacheName(Element.RSC_NAME_ELEMENT.asString(node));
+ }
+ else {
+ cacheFactory.setResultsetCacheName("resultset"); //$NON-NLS-1$
+ }
+
+ if (Element.RSC_MAX_STALENESS_ELEMENT.isDefined(node)) {
+ cacheConfig.setMaxStaleness(Element.RSC_MAX_STALENESS_ELEMENT.asInt(node));
+ }
+
+ SessionAwareCache<CachedResults> resultsetCache = new SessionAwareCache<CachedResults>(cacheFactory, SessionAwareCache.Type.RESULTSET, cacheConfig);
+ resultsetCache.setBufferManager(bufferManager);
+ return resultsetCache;
+ }
+
+
+ private SessionAwareCache<PreparedPlan> buildPreparedPlanCache(ModelNode node, BufferManager bufferManager) {
+ CacheConfiguration cacheConfig = new CacheConfiguration();
+ if (Element.PPC_MAX_ENTRIES_ATTRIBUTE.isDefined(node)) {
+ cacheConfig.setMaxEntries(Element.PPC_MAX_ENTRIES_ATTRIBUTE.asInt(node));
+ }
+ else {
+ cacheConfig.setMaxEntries(512);
+ }
+
+ if (Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE.isDefined(node)) {
+ cacheConfig.setMaxAgeInSeconds(Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE.asInt(node));
+ }
+ else {
+ cacheConfig.setMaxAgeInSeconds(28800);
+ }
+
+ cacheConfig.setType(Policy.LRU.name());
+
+ cacheConfig.setLocation("prepared"); //$NON-NLS-1$
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>(new DefaultCacheFactory(), SessionAwareCache.Type.PREPAREDPLAN, cacheConfig);
+ cache.setBufferManager(bufferManager);
+
+ return cache;
+ }
+
+
+ private RuntimeEngineDeployer buildQueryEngine(ModelNode node) {
+ RuntimeEngineDeployer engine = new RuntimeEngineDeployer();
+
+ if (Element.MAX_THREADS_ELEMENT.isDefined(node)) {
+ engine.setMaxThreads(Element.MAX_THREADS_ELEMENT.asInt(node));
+ }
+ if (Element.MAX_ACTIVE_PLANS_ELEMENT.isDefined(node)) {
+ engine.setMaxActivePlans(Element.MAX_ACTIVE_PLANS_ELEMENT.asInt(node));
+ }
+ if (Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT.isDefined(node)) {
+ engine.setUserRequestSourceConcurrency(Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT.asInt(node));
+ }
+ if (Element.TIME_SLICE_IN_MILLI_ELEMENT.isDefined(node)) {
+ engine.setTimeSliceInMilli(Element.TIME_SLICE_IN_MILLI_ELEMENT.asInt(node));
+ }
+ if (Element.MAX_ROWS_FETCH_SIZE_ELEMENT.isDefined(node)) {
+ engine.setMaxRowsFetchSize(Element.MAX_ROWS_FETCH_SIZE_ELEMENT.asInt(node));
+ }
+ if (Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT.isDefined(node)) {
+ engine.setLobChunkSizeInKB(Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT.asInt(node));
+ }
+ if (Element.QUERY_THRESHOLD_IN_SECS_ELEMENT.isDefined(node)) {
+ engine.setQueryThresholdInSecs(Element.QUERY_THRESHOLD_IN_SECS_ELEMENT.asInt(node));
+ }
+ if (Element.MAX_SOURCE_ROWS_ELEMENT.isDefined(node)) {
+ engine.setMaxSourceRows(Element.MAX_SOURCE_ROWS_ELEMENT.asInt(node));
+ }
+ if (Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT.isDefined(node)) {
+ engine.setExceptionOnMaxSourceRows(Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT.asBoolean(node));
+ }
+ if (Element.DETECTING_CHANGE_EVENTS_ELEMENT.isDefined(node)) {
+ engine.setDetectingChangeEvents(Element.DETECTING_CHANGE_EVENTS_ELEMENT.asBoolean(node));
+ }
+ return engine;
+ }
+}
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -1,477 +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 static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.ServiceLoader;
-
-import javax.resource.spi.XATerminator;
-import javax.resource.spi.work.WorkManager;
-import javax.transaction.TransactionManager;
-
-import org.jboss.as.clustering.jgroups.ChannelFactory;
-import org.jboss.as.controller.AbstractAddStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
-import org.jboss.as.controller.descriptions.DescriptionProvider;
-import org.jboss.as.server.AbstractDeploymentChainStep;
-import org.jboss.as.server.DeploymentProcessorTarget;
-import org.jboss.as.server.deployment.Phase;
-import org.jboss.as.server.services.path.RelativePathService;
-import org.jboss.dmr.ModelNode;
-import org.jboss.modules.Module;
-import org.jboss.modules.ModuleIdentifier;
-import org.jboss.modules.ModuleLoadException;
-import org.jboss.msc.service.ServiceBuilder;
-import org.jboss.msc.service.ServiceBuilder.DependencyType;
-import org.jboss.msc.service.ServiceContainer;
-import org.jboss.msc.service.ServiceController;
-import org.jboss.msc.service.ServiceName;
-import org.jboss.msc.service.ServiceTarget;
-import org.jboss.msc.service.ValueService;
-import org.jboss.msc.value.InjectedValue;
-import org.teiid.PolicyDecider;
-import org.teiid.cache.CacheConfiguration;
-import org.teiid.cache.CacheConfiguration.Policy;
-import org.teiid.cache.DefaultCacheFactory;
-import org.teiid.cache.jboss.ClusterableCacheFactory;
-import org.teiid.common.buffer.BufferManager;
-import org.teiid.deployers.SystemVDBDeployer;
-import org.teiid.deployers.VDBRepository;
-import org.teiid.dqp.internal.datamgr.TranslatorRepository;
-import org.teiid.dqp.internal.process.AuthorizationValidator;
-import org.teiid.dqp.internal.process.CachedResults;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DataRolePolicyDecider;
-import org.teiid.dqp.internal.process.DefaultAuthorizationValidator;
-import org.teiid.dqp.internal.process.PreparedPlan;
-import org.teiid.dqp.internal.process.SessionAwareCache;
-import org.teiid.jboss.deployers.RuntimeEngineDeployer;
-import org.teiid.query.ObjectReplicator;
-import org.teiid.query.function.SystemFunctionManager;
-import org.teiid.replication.jboss.JGroupsObjectReplicator;
-import org.teiid.services.BufferServiceImpl;
-
-class TeiidBootServicesAdd extends AbstractAddStepHandler implements DescriptionProvider {
-
- private static Element[] attributes = {
- Element.ALLOW_ENV_FUNCTION_ELEMENT,
- Element.ASYNC_THREAD_POOL_ELEMENT,
- Element.MAX_THREADS_ELEMENT,
- Element.MAX_ACTIVE_PLANS_ELEMENT,
- Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT,
- Element.TIME_SLICE_IN_MILLI_ELEMENT,
- Element.MAX_ROWS_FETCH_SIZE_ELEMENT,
- Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT,
- Element.QUERY_THRESHOLD_IN_SECS_ELEMENT,
- Element.MAX_SOURCE_ROWS_ELEMENT,
- Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT,
- Element.DETECTING_CHANGE_EVENTS_ELEMENT,
- Element.AUTHORIZATION_VALIDATOR_MODULE_ATTRIBUTE,
- Element.POLICY_DECIDER_MODULE_ATTRIBUTE,
-
- // object replicator
- Element.OR_STACK_ATTRIBUTE,
- Element.OR_CLUSTER_NAME_ATTRIBUTE,
-
- // Buffer Service
- Element.USE_DISK_ATTRIBUTE,
- Element.PROCESSOR_BATCH_SIZE_ATTRIBUTE,
- Element.CONNECTOR_BATCH_SIZE_ATTRIBUTE,
- Element.MAX_PROCESSING_KB_ATTRIBUTE,
- Element.MAX_RESERVED_KB_ATTRIBUTE,
- Element.MAX_FILE_SIZE_ATTRIBUTE,
- Element.MAX_BUFFER_SPACE_ATTRIBUTE,
- Element.MAX_OPEN_FILES_ATTRIBUTE,
-
- // prepared plan cache
- Element.PPC_MAX_ENTRIES_ATTRIBUTE,
- Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE,
- Element.PPC_MAX_STALENESS_ATTRIBUTE,
-
- // resultset cache
- Element.RSC_NAME_ELEMENT,
- Element.RSC_CONTAINER_NAME_ELEMENT,
- Element.RSC_MAX_STALENESS_ELEMENT,
- Element.RSC_ENABLE_ATTRIBUTE
- };
-
- @Override
- public ModelNode getModelDescription(Locale locale) {
- final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
- final ModelNode node = new ModelNode();
- node.get(OPERATION_NAME).set(ADD);
- node.get(DESCRIPTION).set(bundle.getString("teiid.add")); //$NON-NLS-1$
-
- describeTeiid(node, REQUEST_PROPERTIES, bundle);
-
- return node;
- }
-
- static void describeTeiid(final ModelNode node, String type, final ResourceBundle bundle) {
- for (int i = 0; i < attributes.length; i++) {
- attributes[i].describe(node, type, bundle);
- }
- }
-
- @Override
- protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
- populate(operation, model);
- }
-
- static void populate(ModelNode operation, ModelNode model) {
- for (int i = 0; i < attributes.length; i++) {
- attributes[i].populate(operation, model);
- }
- }
-
-
- @Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- ServiceTarget target = context.getServiceTarget();
-
- final JBossLifeCycleListener shutdownListener = new JBossLifeCycleListener();
-
- final String asyncThreadPoolName = Element.ASYNC_THREAD_POOL_ELEMENT.asString(operation);
-
- // translator repository
- final TranslatorRepository translatorRepo = new TranslatorRepository();
- ValueService<TranslatorRepository> translatorService = new ValueService<TranslatorRepository>(new org.jboss.msc.value.Value<TranslatorRepository>() {
- @Override
- public TranslatorRepository getValue() throws IllegalStateException, IllegalArgumentException {
- return translatorRepo;
- }
- });
- ServiceController<TranslatorRepository> service = target.addService(TeiidServiceNames.TRANSLATOR_REPO, translatorService).install();
- newControllers.add(service);
-
- // system function tree
- SystemFunctionManager systemFunctionManager = new SystemFunctionManager();
- if (Element.ALLOW_ENV_FUNCTION_ELEMENT.isDefined(operation)) {
- systemFunctionManager.setAllowEnvFunction(Element.ALLOW_ENV_FUNCTION_ELEMENT.asBoolean(operation));
- }
- else {
- systemFunctionManager.setAllowEnvFunction(false);
- }
- systemFunctionManager.setClassloader(Module.getCallerModule().getClassLoader());
-
- // VDB repository
- final VDBRepository vdbRepository = new VDBRepository();
- vdbRepository.setSystemFunctionManager(systemFunctionManager);
- VDBRepositoryService vdbRepositoryService = new VDBRepositoryService(vdbRepository);
- newControllers.add(target.addService(TeiidServiceNames.VDB_REPO, vdbRepositoryService).install());
-
- // System VDB Service
- SystemVDBDeployer systemVDB = new SystemVDBDeployer();
- systemVDB.setVDBRepository(vdbRepository);
- SystemVDBService systemVDBService = new SystemVDBService(systemVDB);
- newControllers.add(target.addService(TeiidServiceNames.SYSTEM_VDB, systemVDBService).install());
-
- newControllers.add(RelativePathService.addService(TeiidServiceNames.DATA_DIR, "teiid-data", "jboss.server.data.dir", target)); //$NON-NLS-1$ //$NON-NLS-2$
- final ObjectsSerializerService serializer = new ObjectsSerializerService();
- ServiceBuilder<ObjectSerializer> objectSerializerService = target.addService(TeiidServiceNames.OBJECT_SERIALIZER, serializer);
- objectSerializerService.addDependency(TeiidServiceNames.DATA_DIR, String.class, serializer.getPathInjector());
- newControllers.add(objectSerializerService.install());
-
- // TODO: remove verbose service by moving the buffer service from runtime project
- newControllers.add(RelativePathService.addService(TeiidServiceNames.BUFFER_DIR, "teiid-buffer", "jboss.server.temp.dir", target)); //$NON-NLS-1$ //$NON-NLS-2$
- final BufferServiceImpl bufferManager = buildBufferManager(operation);
- BufferManagerService bufferService = new BufferManagerService(bufferManager);
- ServiceBuilder<BufferServiceImpl> bufferServiceBuilder = target.addService(TeiidServiceNames.BUFFER_MGR, bufferService);
- bufferServiceBuilder.addDependency(TeiidServiceNames.BUFFER_DIR, String.class, bufferService.pathInjector);
- newControllers.add(bufferServiceBuilder.install());
-
- PolicyDecider policyDecider;
- if (Element.POLICY_DECIDER_MODULE_ATTRIBUTE.isDefined(operation)) {
- policyDecider = buildService(PolicyDecider.class, Element.POLICY_DECIDER_MODULE_ATTRIBUTE.asString(operation));
- }
- else {
- DataRolePolicyDecider drpd = new DataRolePolicyDecider();
- drpd.setAllowCreateTemporaryTablesByDefault(true);
- drpd.setAllowFunctionCallsByDefault(true);
- policyDecider = drpd;
- }
-
- final AuthorizationValidator authValidator;
- if (Element.AUTHORIZATION_VALIDATOR_MODULE_ATTRIBUTE.isDefined(operation)) {
- authValidator = buildService(AuthorizationValidator.class, Element.AUTHORIZATION_VALIDATOR_MODULE_ATTRIBUTE.asString(operation));
- authValidator.setEnabled(true);
- }
- else {
- DefaultAuthorizationValidator dap = new DefaultAuthorizationValidator();
- dap.setPolicyDecider(policyDecider);
- dap.setEnabled(true);
- authValidator = dap;
- }
-
- ValueService<AuthorizationValidator> authValidatorService = new ValueService<AuthorizationValidator>(new org.jboss.msc.value.Value<AuthorizationValidator>() {
- @Override
- public AuthorizationValidator getValue() throws IllegalStateException, IllegalArgumentException {
- return authValidator;
- }
- });
- newControllers.add(target.addService(TeiidServiceNames.AUTHORIZATION_VALIDATOR, authValidatorService).install());
-
- // resultset cache
- final SessionAwareCache<CachedResults> resultsetCache = buildResultsetCache(operation, bufferManager.getBufferManager());
- ValueService<SessionAwareCache<CachedResults>> resultSetService = new ValueService<SessionAwareCache<CachedResults>>(new org.jboss.msc.value.Value<SessionAwareCache<CachedResults>>() {
- @Override
- public SessionAwareCache<CachedResults> getValue() throws IllegalStateException, IllegalArgumentException {
- return resultsetCache;
- }
- });
- newControllers.add(target.addService(TeiidServiceNames.CACHE_RESULTSET, resultSetService).install());
-
- // prepared-plan cache
- final SessionAwareCache<PreparedPlan> preparedPlanCache = buildPreparedPlanCache(operation, bufferManager.getBufferManager());
- ValueService<SessionAwareCache<PreparedPlan>> preparedPlanService = new ValueService<SessionAwareCache<PreparedPlan>>(new org.jboss.msc.value.Value<SessionAwareCache<PreparedPlan>>() {
- @Override
- public SessionAwareCache<PreparedPlan> getValue() throws IllegalStateException, IllegalArgumentException {
- return preparedPlanCache;
- }
- });
- newControllers.add(target.addService(TeiidServiceNames.CACHE_PREPAREDPLAN, preparedPlanService).install());
-
- // Object Replicator
- if (Element.OR_STACK_ATTRIBUTE.isDefined(operation)) {
- String stack = Element.OR_STACK_ATTRIBUTE.asString(operation);
-
- String clusterName = "teiid-rep"; //$NON-NLS-1$
- if (Element.OR_CLUSTER_NAME_ATTRIBUTE.isDefined(operation)) {
- clusterName = Element.OR_CLUSTER_NAME_ATTRIBUTE.asString(operation);
- }
-
- JGroupsObjectReplicatorService replicatorService = new JGroupsObjectReplicatorService(clusterName);
- replicatorService.setBufferManager(bufferManager.getBufferManager());
- ServiceBuilder<JGroupsObjectReplicator> serviceBuilder = target.addService(TeiidServiceNames.OBJECT_REPLICATOR, replicatorService);
- serviceBuilder.addDependency(ServiceName.JBOSS.append("jgroups", stack), ChannelFactory.class, replicatorService.channelFactoryInjector); //$NON-NLS-1$
- newControllers.add(serviceBuilder.install());
- }
-
- // Query Engine
- final RuntimeEngineDeployer engine = buildQueryEngine(operation);
-
- ServiceBuilder<DQPCore> engineBuilder = target.addService(TeiidServiceNames.ENGINE, engine);
- engineBuilder.addDependency(ServiceName.JBOSS.append("connector", "workmanager"), WorkManager.class, engine.getWorkManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
- engineBuilder.addDependency(ServiceName.JBOSS.append("txn", "XATerminator"), XATerminator.class, engine.getXaTerminatorInjector()); //$NON-NLS-1$ //$NON-NLS-2$
- engineBuilder.addDependency(ServiceName.JBOSS.append("txn", "TransactionManager"), TransactionManager.class, engine.getTxnManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
- engineBuilder.addDependency(TeiidServiceNames.BUFFER_MGR, BufferServiceImpl.class, engine.getBufferServiceInjector());
- engineBuilder.addDependency(TeiidServiceNames.SYSTEM_VDB, SystemVDBDeployer.class, new InjectedValue<SystemVDBDeployer>());
- engineBuilder.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, engine.getTranslatorRepositoryInjector());
- engineBuilder.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class, engine.getVdbRepositoryInjector());
- engineBuilder.addDependency(TeiidServiceNames.AUTHORIZATION_VALIDATOR, AuthorizationValidator.class, engine.getAuthorizationValidatorInjector());
- engineBuilder.addDependency(TeiidServiceNames.CACHE_RESULTSET, SessionAwareCache.class, engine.getResultSetCacheInjector());
- engineBuilder.addDependency(TeiidServiceNames.CACHE_PREPAREDPLAN, SessionAwareCache.class, engine.getPreparedPlanCacheInjector());
- engineBuilder.addDependency(DependencyType.OPTIONAL, TeiidServiceNames.OBJECT_REPLICATOR, ObjectReplicator.class, engine.getObjectReplicatorInjector());
-
- engineBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
- ServiceController<DQPCore> controller = engineBuilder.install();
- newControllers.add(controller);
- ServiceContainer container = controller.getServiceContainer();
- container.addTerminateListener(shutdownListener);
-
- // Register VDB deployer
- context.addStep(new AbstractDeploymentChainStep() {
- @Override
- public void execute(DeploymentProcessorTarget processorTarget) {
- processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT,new DynamicVDBRootMountDeployer());
- processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT|0x0001,new VDBStructureDeployer());
- processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_WEB_DEPLOYMENT|0x0001, new VDBParserDeployer());
- processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, Phase.DEPENDENCIES_WAR_MODULE|0x0001, new VDBDependencyDeployer());
- processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT|0x0001, new VDBDeployer(translatorRepo, asyncThreadPoolName));
- }
-
- }, OperationContext.Stage.RUNTIME);
- }
-
- private <T> T buildService(Class<T> type, String moduleName) throws OperationFailedException {
- final ModuleIdentifier moduleId;
- final Module module;
- try {
- moduleId = ModuleIdentifier.create(moduleName);
- module = Module.getCallerModuleLoader().loadModule(moduleId);
- } catch (ModuleLoadException e) {
- throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName))); //$NON-NLS-1$
- }
- ServiceLoader<T> services = module.loadService(type);
- return services.iterator().next();
- }
-
-
- private BufferServiceImpl buildBufferManager(ModelNode node) {
- BufferServiceImpl bufferManger = new BufferServiceImpl();
-
- if (node == null) {
- return bufferManger;
- }
-
- if (Element.USE_DISK_ATTRIBUTE.isDefined(node)) {
- bufferManger.setUseDisk(Element.USE_DISK_ATTRIBUTE.asBoolean(node));
- }
- if (Element.PROCESSOR_BATCH_SIZE_ATTRIBUTE.isDefined(node)) {
- bufferManger.setProcessorBatchSize(Element.PROCESSOR_BATCH_SIZE_ATTRIBUTE.asInt(node));
- }
- if (Element.CONNECTOR_BATCH_SIZE_ATTRIBUTE.isDefined(node)) {
- bufferManger.setConnectorBatchSize(Element.CONNECTOR_BATCH_SIZE_ATTRIBUTE.asInt(node));
- }
- if (Element.MAX_PROCESSING_KB_ATTRIBUTE.isDefined(node)) {
- bufferManger.setMaxProcessingKb(Element.MAX_PROCESSING_KB_ATTRIBUTE.asInt(node));
- }
- if (Element.MAX_RESERVED_KB_ATTRIBUTE.isDefined(node)) {
- bufferManger.setMaxReserveKb(Element.MAX_RESERVED_KB_ATTRIBUTE.asInt(node));
- }
- if (Element.MAX_FILE_SIZE_ATTRIBUTE.isDefined(node)) {
- bufferManger.setMaxFileSize(Element.MAX_FILE_SIZE_ATTRIBUTE.asLong(node));
- }
- if (Element.MAX_BUFFER_SPACE_ATTRIBUTE.isDefined(node)) {
- bufferManger.setMaxBufferSpace(Element.MAX_BUFFER_SPACE_ATTRIBUTE.asLong(node));
- }
- if (Element.MAX_OPEN_FILES_ATTRIBUTE.isDefined(node)) {
- bufferManger.setMaxOpenFiles(Element.MAX_OPEN_FILES_ATTRIBUTE.asInt(node));
- }
- return bufferManger;
- }
-
- private SessionAwareCache<CachedResults> buildResultsetCache(ModelNode node, BufferManager bufferManager) {
-
- CacheConfiguration cacheConfig = new CacheConfiguration();
- // these settings are not really used; they are defined by infinispan
- cacheConfig.setMaxEntries(1024);
- cacheConfig.setMaxAgeInSeconds(7200);
- cacheConfig.setType(Policy.EXPIRATION.name());
- cacheConfig.setLocation("resultset"); //$NON-NLS-1$
- cacheConfig.setMaxStaleness(60);
-
- if (Element.RSC_ENABLE_ATTRIBUTE.isDefined(node)) {
- if (!Element.RSC_ENABLE_ATTRIBUTE.asBoolean(node)) {
- return null;
- }
- }
-
- ClusterableCacheFactory cacheFactory = null;
-
- if (Element.RSC_CONTAINER_NAME_ELEMENT.isDefined(node)) {
- cacheFactory = new ClusterableCacheFactory();
- cacheFactory.setCacheManager(Element.RSC_CONTAINER_NAME_ELEMENT.asString(node));
- }
- else {
- SessionAwareCache<CachedResults> resultsetCache = new SessionAwareCache<CachedResults>(new DefaultCacheFactory(), SessionAwareCache.Type.RESULTSET, cacheConfig);
- resultsetCache.setBufferManager(bufferManager);
- return resultsetCache;
- }
-
- if (Element.RSC_NAME_ELEMENT.isDefined(node)) {
- cacheFactory.setResultsetCacheName(Element.RSC_NAME_ELEMENT.asString(node));
- }
- else {
- cacheFactory.setResultsetCacheName("resultset"); //$NON-NLS-1$
- }
-
- if (Element.RSC_MAX_STALENESS_ELEMENT.isDefined(node)) {
- cacheConfig.setMaxStaleness(Element.RSC_MAX_STALENESS_ELEMENT.asInt(node));
- }
-
- SessionAwareCache<CachedResults> resultsetCache = new SessionAwareCache<CachedResults>(cacheFactory, SessionAwareCache.Type.RESULTSET, cacheConfig);
- resultsetCache.setBufferManager(bufferManager);
- return resultsetCache;
- }
-
-
- private SessionAwareCache<PreparedPlan> buildPreparedPlanCache(ModelNode node, BufferManager bufferManager) {
- CacheConfiguration cacheConfig = new CacheConfiguration();
- if (Element.PPC_MAX_ENTRIES_ATTRIBUTE.isDefined(node)) {
- cacheConfig.setMaxEntries(Element.PPC_MAX_ENTRIES_ATTRIBUTE.asInt(node));
- }
- else {
- cacheConfig.setMaxEntries(512);
- }
-
- if (Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE.isDefined(node)) {
- cacheConfig.setMaxAgeInSeconds(Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE.asInt(node));
- }
- else {
- cacheConfig.setMaxAgeInSeconds(28800);
- }
-
- if (Element.PPC_MAX_STALENESS_ATTRIBUTE.isDefined(node)) {
- cacheConfig.setMaxStaleness(Element.PPC_MAX_STALENESS_ATTRIBUTE.asInt(node));
- }
- else {
- cacheConfig.setMaxStaleness(0);
- }
- cacheConfig.setType(Policy.LRU.name());
-
- cacheConfig.setLocation("prepared"); //$NON-NLS-1$
- SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>(new DefaultCacheFactory(), SessionAwareCache.Type.PREPAREDPLAN, cacheConfig);
- cache.setBufferManager(bufferManager);
-
- return cache;
- }
-
-
- private RuntimeEngineDeployer buildQueryEngine(ModelNode node) {
- RuntimeEngineDeployer engine = new RuntimeEngineDeployer();
-
- if (Element.MAX_THREADS_ELEMENT.isDefined(node)) {
- engine.setMaxThreads(Element.MAX_THREADS_ELEMENT.asInt(node));
- }
- if (Element.MAX_ACTIVE_PLANS_ELEMENT.isDefined(node)) {
- engine.setMaxActivePlans(Element.MAX_ACTIVE_PLANS_ELEMENT.asInt(node));
- }
- if (Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT.isDefined(node)) {
- engine.setUserRequestSourceConcurrency(Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT.asInt(node));
- }
- if (Element.TIME_SLICE_IN_MILLI_ELEMENT.isDefined(node)) {
- engine.setTimeSliceInMilli(Element.TIME_SLICE_IN_MILLI_ELEMENT.asInt(node));
- }
- if (Element.MAX_ROWS_FETCH_SIZE_ELEMENT.isDefined(node)) {
- engine.setMaxRowsFetchSize(Element.MAX_ROWS_FETCH_SIZE_ELEMENT.asInt(node));
- }
- if (Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT.isDefined(node)) {
- engine.setLobChunkSizeInKB(Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT.asInt(node));
- }
- if (Element.QUERY_THRESHOLD_IN_SECS_ELEMENT.isDefined(node)) {
- engine.setQueryThresholdInSecs(Element.QUERY_THRESHOLD_IN_SECS_ELEMENT.asInt(node));
- }
- if (Element.MAX_SOURCE_ROWS_ELEMENT.isDefined(node)) {
- engine.setMaxSourceRows(Element.MAX_SOURCE_ROWS_ELEMENT.asInt(node));
- }
- if (Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT.isDefined(node)) {
- engine.setExceptionOnMaxSourceRows(Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT.asBoolean(node));
- }
- if (Element.DETECTING_CHANGE_EVENTS_ELEMENT.isDefined(node)) {
- engine.setDetectingChangeEvents(Element.DETECTING_CHANGE_EVENTS_ELEMENT.asBoolean(node));
- }
- return engine;
- }
-}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -55,7 +55,7 @@
private static TransportRemove TRANSPORT_REMOVE = new TransportRemove();
private static TranslatorAdd TRANSLATOR_ADD = new TranslatorAdd();
private static TranslatorRemove TRANSLATOR_REMOVE = new TranslatorRemove();
- private static TeiidBootServicesAdd TEIID_BOOT_ADD = new TeiidBootServicesAdd();
+ private static TeiidAdd TEIID_BOOT_ADD = new TeiidAdd();
private static TeiidSubsystemDescribe TEIID_DESCRIBE = new TeiidSubsystemDescribe();
@Override
@@ -128,8 +128,6 @@
new AssignDataSource().register(teiidSubsystem);
new ChangeVDBConnectionType().register(teiidSubsystem);
new RemoveAnyAuthenticatedDataRole().register(teiidSubsystem);
-
- // engine level admin api handlers
new ListRequests().register(teiidSubsystem);
new ListSessions().register(teiidSubsystem);
new RequestsPerSession().register(teiidSubsystem);
Copied: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java (from rev 3548, branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java)
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -0,0 +1,1185 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., 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.jboss;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REPLY_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.impl.*;
+import org.teiid.adminapi.impl.VDBMetadataMapper.TransactionMetadataMapper;
+import org.teiid.adminapi.impl.VDBMetadataMapper.VDBTranslatorMetaDataMapper;
+import org.teiid.client.RequestMessage;
+import org.teiid.client.ResultsMessage;
+import org.teiid.client.security.SessionToken;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+
+abstract class TeiidOperationHandler extends BaseOperationHandler<DQPCore> {
+ List<Transport> transports = new ArrayList<Transport>();
+ protected VDBRepository vdbRepo;
+ protected DQPCore engine;
+
+ protected TeiidOperationHandler(String operationName){
+ super(operationName);
+ }
+
+ @Override
+ protected DQPCore getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ List<ServiceName> services = context.getServiceRegistry(false).getServiceNames();
+ for (ServiceName name:services) {
+ if (name.isParentOf(TeiidServiceNames.TRANSPORT_BASE)) {
+ ServiceController<?> transport = context.getServiceRegistry(false).getService(name);
+ if (transport != null) {
+ this.transports.add(Transport.class.cast(transport.getValue()));
+ }
+ }
+ }
+ ServiceController<?> repo = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ if (repo != null) {
+ this.vdbRepo = VDBRepository.class.cast(repo.getValue());
+ }
+
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.ENGINE);
+ if (sc != null) {
+ this.engine = DQPCore.class.cast(sc.getValue());
+ }
+ return this.engine;
+ }
+}
+
+abstract class TranslatorOperationHandler extends BaseOperationHandler<TranslatorRepository> {
+
+ protected TranslatorOperationHandler(String operationName){
+ super(operationName);
+ }
+
+ @Override
+ public TranslatorRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.TRANSLATOR_REPO);
+ return TranslatorRepository.class.cast(sc.getValue());
+ }
+}
+
+class GetRuntimeVersion extends TeiidOperationHandler{
+ protected GetRuntimeVersion(String operationName) {
+ super(operationName);
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ context.getResult().set(engine.getRuntimeVersion());
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.STRING);
+ }
+}
+
+class GetActiveSessionsCount extends TeiidOperationHandler{
+ protected GetActiveSessionsCount(String operationName) {
+ super(operationName);
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ try {
+ int count = 0;
+ for (Transport t: this.transports) {
+ count += t.getActiveSessionsCount();
+ }
+ context.getResult().set(String.valueOf(count));
+ } catch (AdminException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.INT);
+ }
+}
+
+class ListSessions extends TeiidOperationHandler{
+ protected ListSessions() {
+ super("list-sessions"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ ModelNode result = context.getResult();
+ for (Transport t: this.transports) {
+ Collection<SessionMetadata> sessions = t.getActiveSessions();
+ for (SessionMetadata session:sessions) {
+ VDBMetadataMapper.SessionMetadataMapper.INSTANCE.wrap(session, result.add());
+ }
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.SessionMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class RequestsPerSession extends TeiidOperationHandler{
+ protected RequestsPerSession() {
+ super("requests-per-session"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
+ ModelNode result = context.getResult();
+ List<RequestMetadata> requests = engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
+ for (RequestMetadata request:requests) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
+
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class ListRequests extends TeiidOperationHandler{
+ protected ListRequests() {
+ super("list-requests"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ ModelNode result = context.getResult();
+ List<RequestMetadata> requests = engine.getRequests();
+ for (RequestMetadata request:requests) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class RequestsPerVDB extends TeiidOperationHandler{
+ protected RequestsPerVDB() {
+ super("requests-per-vdb"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
+ ModelNode result = context.getResult();
+ String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
+ int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
+ for (Transport t: this.transports) {
+ List<RequestMetadata> requests = t.getRequestsUsingVDB(vdbName,vdbVersion);
+ for (RequestMetadata request:requests) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.INT);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class GetLongRunningQueries extends TeiidOperationHandler{
+ protected GetLongRunningQueries() {
+ super("long-running-queries"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ ModelNode result = context.getResult();
+ List<RequestMetadata> requests = engine.getLongRunningRequests();
+ for (RequestMetadata request:requests) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class TerminateSession extends TeiidOperationHandler{
+ protected TerminateSession() {
+ super("terminate-session"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
+ for (Transport t: this.transports) {
+ t.terminateSession(operation.get(OperationsConstants.SESSION).asString());
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
+ }
+}
+
+class CancelRequest extends TeiidOperationHandler{
+ protected CancelRequest() {
+ super("cancel-request"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException{
+ try {
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.EXECUTION_ID)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.EXECUTION_ID+MISSING)));
+ }
+ boolean pass = engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(), operation.get(OperationsConstants.EXECUTION_ID).asLong());
+ ModelNode result = context.getResult();
+ result.set(pass);
+ } catch (TeiidComponentException e) {
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, TYPE).set(ModelType.LONG);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.EXECUTION_ID));
+
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.BOOLEAN);
+ }
+}
+
+abstract class BaseCachehandler extends BaseOperationHandler<SessionAwareCache>{
+ BaseCachehandler(String operationName){
+ super(operationName);
+ }
+
+ @Override
+ protected SessionAwareCache getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ String cacheType = Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.name();
+
+ if (operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
+ //throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
+
+ ServiceController<?> sc;
+ if (SessionAwareCache.isResultsetCache(cacheType)) {
+ sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.CACHE_RESULTSET);
+ }
+ else {
+ sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.CACHE_PREPAREDPLAN);
+ }
+
+ return SessionAwareCache.class.cast(sc.getValue());
+ }
+}
+
+
+class CacheTypes extends BaseCachehandler {
+ protected CacheTypes() {
+ super("cache-types"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, SessionAwareCache cache, ModelNode operation) throws OperationFailedException {
+ ModelNode result = context.getResult();
+ Collection<String> types = SessionAwareCache.getCacheTypes();
+ for (String type:types) {
+ result.add(type);
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ ModelNode node = new ModelNode();
+ node.get(OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
+ node.get(OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
+ node.get(OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+ operationNode.get(REPLY_PROPERTIES).add(node);
+ }
+}
+
+class ClearCache extends BaseCachehandler {
+
+ protected ClearCache() {
+ super("clear-cache"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, SessionAwareCache cache, ModelNode operation) throws OperationFailedException {
+ if (operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
+
+ String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
+ if (operation.hasDefined(OperationsConstants.VDB_NAME) && operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
+ int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
+ LogManager.logInfo(LogConstants.CTX_DQP, IntegrationPlugin.Util.getString("clearing_cache_vdb", cacheType, vdbName, vdbVersion)); //$NON-NLS-1$
+ cache.clearForVDB(vdbName, vdbVersion);
+ }
+ else {
+ LogManager.logInfo(LogConstants.CTX_DQP, IntegrationPlugin.Util.getString("clearing_cache", cacheType)); //$NON-NLS-1$
+ cache.clearAll();
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(false);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.INT);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(false);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ }
+}
+
+class CacheStatistics extends BaseCachehandler {
+
+ protected CacheStatistics() {
+ super("cache-statistics"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, SessionAwareCache cache, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
+ ModelNode result = context.getResult();
+ String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
+ CacheStatisticsMetadata stats = buildCacheStats(cacheType, cache);
+ VDBMetadataMapper.CacheStatisticsMetadataMapper.INSTANCE.wrap(stats, result);
+ }
+
+ private CacheStatisticsMetadata buildCacheStats(String name, SessionAwareCache cache) {
+ CacheStatisticsMetadata stats = new CacheStatisticsMetadata();
+ stats.setName(name);
+ stats.setHitRatio(cache.getRequestCount() == 0?0:((double)cache.getCacheHitCount()/cache.getRequestCount())*100);
+ stats.setTotalEntries(cache.getTotalCacheEntries());
+ stats.setRequestCount(cache.getRequestCount());
+ return stats;
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+
+ ModelNode node = new ModelNode();
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.CacheStatisticsMetadataMapper.INSTANCE.describe(node));
+ }
+}
+
+class WorkerPoolStatistics extends TeiidOperationHandler{
+
+ protected WorkerPoolStatistics() {
+ super("workerpool-statistics"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
+ ModelNode result = context.getResult();
+ WorkerPoolStatisticsMetadata stats = engine.getWorkerPoolStatistics();
+ VDBMetadataMapper.WorkerPoolStatisticsMetadataMapper.INSTANCE.wrap(stats, result);
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.WorkerPoolStatisticsMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class ListTransactions extends TeiidOperationHandler{
+
+ protected ListTransactions() {
+ super("list-transactions"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
+ ModelNode result = context.getResult();
+ Collection<TransactionMetadata> txns = engine.getTransactions();
+ for (TransactionMetadata txn:txns) {
+ VDBMetadataMapper.TransactionMetadataMapper.INSTANCE.wrap(txn, result.add());
+ }
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ ModelNode node = new ModelNode();
+ operationNode.get(REPLY_PROPERTIES).add(TransactionMetadataMapper.INSTANCE.describe(node));
+ }
+}
+
+class TerminateTransaction extends TeiidOperationHandler{
+
+ protected TerminateTransaction() {
+ super("terminate-transaction"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.XID)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.XID+MISSING)));
+ }
+
+ String xid = operation.get(OperationsConstants.XID).asString();
+ try {
+ engine.terminateTransaction(xid);
+ } catch (AdminException e) {
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ }
+}
+
+class MergeVDBs extends BaseOperationHandler<VDBRepository>{
+
+ protected MergeVDBs() {
+ super("merge-vdbs"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.SOURCE_VDBNAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBNAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.SOURCE_VDBVERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBVERSION+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.TARGET_VDBNAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBNAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.TARGET_VDBVERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBVERSION+MISSING)));
+ }
+
+ String sourceVDBName = operation.get(OperationsConstants.SOURCE_VDBNAME).asString();
+ int sourceVDBversion = operation.get(OperationsConstants.SOURCE_VDBVERSION).asInt();
+ String targetVDBName = operation.get(OperationsConstants.TARGET_VDBNAME).asString();
+ int targetVDBversion = operation.get(OperationsConstants.TARGET_VDBVERSION).asInt();
+ try {
+ repo.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
+ } catch (AdminException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBNAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBVERSION));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBNAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBVERSION));
+ }
+}
+
+class ExecuteQuery extends TeiidOperationHandler{
+
+ protected ExecuteQuery() {
+ super("execute-query"); //$NON-NLS-1$
+ }
+ @Override
+ protected void executeOperation(OperationContext context, DQPCore engine, ModelNode operation) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.SQL_QUERY)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SQL_QUERY+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.TIMEOUT_IN_MILLI)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TIMEOUT_IN_MILLI+MISSING)));
+ }
+
+ ModelNode result = context.getResult();
+ String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
+ int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
+ String sql = operation.get(OperationsConstants.SQL_QUERY).asString();
+ int timeout = operation.get(OperationsConstants.TIMEOUT_IN_MILLI).asInt();
+
+ result.set(executeQuery(vdbName, vdbVersion, sql, timeout, new ModelNode()));
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SQL_QUERY));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TIMEOUT_IN_MILLI));
+
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.LIST);
+ }
+
+ public ModelNode executeQuery(final String vdbName, final int version, final String command, final long timoutInMilli, final ModelNode resultsNode) throws OperationFailedException {
+ String user = "CLI ADMIN"; //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("admin_executing", user, command)); //$NON-NLS-1$
+
+ SessionMetadata session = createTemporarySession(vdbName, version, user);
+
+ final long requestID = 0L;
+
+ DQPWorkContext context = new DQPWorkContext();
+ context.setSession(session);
+
+ try {
+ return context.runInContext(new Callable<ModelNode>() {
+ @Override
+ public ModelNode call() throws Exception {
+
+ long start = System.currentTimeMillis();
+ RequestMessage request = new RequestMessage(command);
+ request.setExecutionId(0L);
+ request.setRowLimit(engine.getMaxRowsFetchSize()); // this would limit the number of rows that are returned.
+ Future<ResultsMessage> message = engine.executeRequest(requestID, request);
+ ResultsMessage rm = null;
+ if (timoutInMilli < 0) {
+ rm = message.get();
+ } else {
+ rm = message.get(timoutInMilli, TimeUnit.MILLISECONDS);
+ }
+ if (rm.getException() != null) {
+ throw new AdminProcessingException(rm.getException());
+ }
+
+ if (rm.isUpdateResult()) {
+ writeResults(resultsNode, Arrays.asList("update-count"), rm.getResultsList()); //$NON-NLS-1$
+ }
+ else {
+ writeResults(resultsNode, Arrays.asList(rm.getColumnNames()), rm.getResultsList());
+
+ while (rm.getFinalRow() == -1 || rm.getLastRow() < rm.getFinalRow()) {
+ long elapsed = System.currentTimeMillis() - start;
+ message = engine.processCursorRequest(requestID, rm.getLastRow()+1, 1024);
+ rm = message.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
+ writeResults(resultsNode, Arrays.asList(rm.getColumnNames()), rm.getResultsList());
+ }
+ }
+
+ long elapsed = System.currentTimeMillis() - start;
+ ResultsFuture<?> response = engine.closeRequest(requestID);
+ response.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
+ return resultsNode;
+ }
+ });
+ } catch (Throwable t) {
+ throw new OperationFailedException(new ModelNode().set(t.getMessage()));
+ }
+ }
+
+ private void writeResults(ModelNode resultsNode, List<String> columns, List<? extends List<?>> results) throws SQLException {
+ for (List<?> row:results) {
+ ModelNode rowNode = new ModelNode();
+
+ for (int colNum = 0; colNum < columns.size(); colNum++) {
+
+ Object aValue = row.get(colNum);
+ if (aValue != null) {
+ if (aValue instanceof Integer) {
+ rowNode.get(columns.get(colNum)).set((Integer)aValue);
+ }
+ else if (aValue instanceof Long) {
+ rowNode.get(columns.get(colNum)).set((Long)aValue);
+ }
+ else if (aValue instanceof Double) {
+ rowNode.get(columns.get(colNum)).set((Double)aValue);
+ }
+ else if (aValue instanceof Boolean) {
+ rowNode.get(columns.get(colNum)).set((Boolean)aValue);
+ }
+ else if (aValue instanceof BigInteger) {
+ rowNode.get(columns.get(colNum)).set((BigInteger)aValue);
+ }
+ else if (aValue instanceof BigDecimal) {
+ rowNode.get(columns.get(colNum)).set((BigDecimal)aValue);
+ }
+ else if (aValue instanceof String) {
+ rowNode.get(columns.get(colNum), TYPE).set(ModelType.STRING);
+ rowNode.get(columns.get(colNum)).set((String)aValue);
+ }
+ else if (aValue instanceof Blob) {
+ rowNode.get(columns.get(colNum), TYPE).set(ModelType.OBJECT);
+ rowNode.get(columns.get(colNum)).set("blob"); //$NON-NLS-1$
+ }
+ else if (aValue instanceof Clob) {
+ rowNode.get(columns.get(colNum), TYPE).set(ModelType.OBJECT);
+ rowNode.get(columns.get(colNum)).set("clob"); //$NON-NLS-1$
+ }
+ else if (aValue instanceof SQLXML) {
+ SQLXML xml = (SQLXML)aValue;
+ rowNode.get(columns.get(colNum), TYPE).set(ModelType.STRING);
+ rowNode.get(columns.get(colNum)).set(xml.getString());
+ }
+ else {
+ rowNode.get(columns.get(colNum), TYPE).set(ModelType.STRING);
+ rowNode.get(columns.get(colNum)).set(aValue.toString());
+ }
+ }
+ }
+ resultsNode.add(rowNode);
+ }
+ }
+
+ private SessionMetadata createTemporarySession(final String vdbName, final int version, final String userName) {
+
+ long creationTime = System.currentTimeMillis();
+
+ // Return a new session info object
+ SessionMetadata newSession = new SessionMetadata();
+ newSession.setSessionToken(new SessionToken(userName));
+ newSession.setSessionId(newSession.getSessionToken().getSessionID());
+ newSession.setUserName(userName);
+ newSession.setCreatedTime(creationTime);
+ newSession.setApplicationName("admin-console"); //$NON-NLS-1$
+ newSession.setVDBName(vdbName);
+ newSession.setVDBVersion(version);
+
+ newSession.setVdb(this.vdbRepo.getVDB(vdbName, version));
+ return newSession;
+ }
+}
+
+class GetVDB extends BaseOperationHandler<VDBRepository>{
+
+ protected GetVDB() {
+ super("get-vdb"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
+ ModelNode result = context.getResult();
+ String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
+ int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
+
+ VDBMetaData vdb = repo.getVDB(vdbName, vdbVersion);
+ VDBMetadataMapper.INSTANCE.wrap(vdb, result);
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ operationNode.get(REPLY_PROPERTIES).set(VDBMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class ListVDBs extends BaseOperationHandler<VDBRepository>{
+
+ protected ListVDBs() {
+ super("list-vdbs"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
+ ModelNode result = context.getResult();
+ List<VDBMetaData> vdbs = repo.getVDBs();
+ for (VDBMetaData vdb:vdbs) {
+ VDBMetadataMapper.INSTANCE.wrap(vdb, result.add());
+ }
+ }
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class ListTranslators extends TranslatorOperationHandler{
+
+ protected ListTranslators() {
+ super("list-translators"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, TranslatorRepository repo, ModelNode operation) throws OperationFailedException {
+ ModelNode result = context.getResult();
+ List<VDBTranslatorMetaData> translators = repo.getTranslators();
+ for (VDBTranslatorMetaData t:translators) {
+ VDBMetadataMapper.VDBTranslatorMetaDataMapper.INSTANCE.wrap(t, result.add());
+ }
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(VDBMetadataMapper.VDBTranslatorMetaDataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+class GetTranslator extends TranslatorOperationHandler{
+
+ protected GetTranslator() {
+ super("get-translator"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, TranslatorRepository repo, ModelNode operation) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
+ }
+
+ ModelNode result = context.getResult();
+ String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
+ VDBTranslatorMetaData translator = repo.getTranslatorMetaData(translatorName);
+ VDBMetadataMapper.VDBTranslatorMetaDataMapper.INSTANCE.wrap(translator, result);
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
+
+ operationNode.get(REPLY_PROPERTIES).set(VDBTranslatorMetaDataMapper.INSTANCE.describe(new ModelNode()));
+ }
+}
+
+abstract class VDBOperations extends BaseOperationHandler<VDBMetaData>{
+ private ObjectSerializer serializer;
+
+ public VDBOperations(String operationName) {
+ super(operationName);
+ }
+
+ @Override
+ public VDBMetaData getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
+ String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
+ int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
+
+ ServiceController<?> osSvc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.OBJECT_SERIALIZER);
+ this.serializer = ObjectSerializer.class.cast(osSvc.getValue());
+
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.vdbServiceName(vdbName, vdbVersion));
+ return VDBMetaData.class.cast(sc.getValue());
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+ }
+
+ protected void save(VDBMetaData vdb) throws AdminProcessingException{
+ try {
+ VDBMetadataParser.marshell(vdb, this.serializer.getVdbXmlOutputStream(vdb));
+ } catch (IOException e) {
+ throw new AdminProcessingException(e);
+ } catch (XMLStreamException e) {
+ throw new AdminProcessingException(e);
+ }
+ }
+}
+
+class AddDataRole extends VDBOperations {
+
+ public AddDataRole() {
+ super("add-data-role"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.MAPPED_ROLE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MAPPED_ROLE+MISSING)));
+ }
+
+ String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
+ String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE).asString();
+
+ try {
+ DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
+
+ if (policy == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+
+ policy.addMappedRoleName(mappedRole);
+ save(vdb);
+ } catch (AdminProcessingException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ @Override
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ super.describeParameters(operationNode, bundle);
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MAPPED_ROLE));
+ }
+}
+
+class RemoveDataRole extends VDBOperations {
+
+ public RemoveDataRole() {
+ super("remove-data-role"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.MAPPED_ROLE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MAPPED_ROLE+MISSING)));
+ }
+
+ String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
+ String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE).asString();
+
+ try {
+ DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
+
+ if (policy == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+
+ policy.removeMappedRoleName(mappedRole);
+ save(vdb);
+ } catch (AdminProcessingException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ @Override
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ super.describeParameters(operationNode, bundle);
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MAPPED_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MAPPED_ROLE));
+ }
+}
+
+class AddAnyAuthenticatedDataRole extends VDBOperations {
+
+ public AddAnyAuthenticatedDataRole() {
+ super("add-anyauthenticated-role"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
+ }
+
+ String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
+
+ try {
+ DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
+
+ if (policy == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+
+ policy.setAnyAuthenticated(true);
+ save(vdb);
+ } catch (AdminProcessingException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ @Override
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ super.describeParameters(operationNode, bundle);
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
+ }
+
+}
+
+class RemoveAnyAuthenticatedDataRole extends VDBOperations {
+
+ public RemoveAnyAuthenticatedDataRole() {
+ super("remove-anyauthenticated-role"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
+ }
+
+ String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
+
+ try {
+ DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
+
+ if (policy == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+
+ policy.setAnyAuthenticated(false);
+ save(vdb);
+ } catch (AdminProcessingException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ @Override
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ super.describeParameters(operationNode, bundle);
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DATA_ROLE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DATA_ROLE));
+ }
+}
+
+class ChangeVDBConnectionType extends VDBOperations {
+
+ public ChangeVDBConnectionType() {
+ super("change-vdb-connection-type"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.CONNECTION_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CONNECTION_TYPE+MISSING)));
+ }
+
+ String connectionType = operation.get(OperationsConstants.CONNECTION_TYPE).asString();
+ try {
+ vdb.setConnectionType(connectionType);
+ save(vdb);
+ } catch (AdminProcessingException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ @Override
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ super.describeParameters(operationNode, bundle);
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CONNECTION_TYPE, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CONNECTION_TYPE, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CONNECTION_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CONNECTION_TYPE));
+ }
+}
+
+class AssignDataSource extends VDBOperations {
+
+ public AssignDataSource() {
+ super("assign-datasource"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode operation) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.MODEL_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MODEL_NAME+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.SOURCE_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_NAME+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.DS_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DS_NAME+MISSING)));
+ }
+
+
+ String modelName = operation.get(OperationsConstants.MODEL_NAME).asString();
+ String sourceName = operation.get(OperationsConstants.SOURCE_NAME).asString();
+ String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
+ String dsName = operation.get(OperationsConstants.DS_NAME).asString();
+
+ try {
+ ModelMetaData model = vdb.getModel(modelName);
+
+ if (model == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("model_not_found", modelName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+
+ SourceMappingMetadata source = model.getSourceMapping(sourceName);
+ if(source == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("source_not_found", sourceName, modelName, vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+ source.setTranslatorName(translatorName);
+ source.setConnectionJndiName(dsName);
+ save(vdb);
+ } catch (AdminProcessingException e) {
+ throw new OperationFailedException(new ModelNode().set(e.getMessage()));
+ }
+ }
+
+ @Override
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ super.describeParameters(operationNode, bundle);
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MODEL_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MODEL_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.MODEL_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MODEL_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.MODEL_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DS_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DS_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.DS_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.DS_NAME));
+
+ }
+}
\ No newline at end of file
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescribe.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescribe.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescribe.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -49,7 +49,7 @@
node.get(ModelDescriptionConstants.TAIL_COMMENT_ALLOWED).set(true);
node.get(ModelDescriptionConstants.NAMESPACE).set(Namespace.CURRENT.getUri());
- TeiidBootServicesAdd.describeTeiid(node, ATTRIBUTES, bundle);
+ TeiidAdd.describeTeiid(node, ATTRIBUTES, bundle);
node.get(CHILDREN, Element.TRANSPORT_ELEMENT.getLocalName(), DESCRIPTION).set(Element.TRANSPORT_ELEMENT.getDescription(bundle));
node.get(CHILDREN, Element.TRANSPORT_ELEMENT.getLocalName(), REQUIRED).set(true);
@@ -69,7 +69,7 @@
subsystemAdd.get(OP).set(ADD);
subsystemAdd.get(OP_ADDR).set(rootAddress.toModelNode());
- TeiidBootServicesAdd.populate(subModel, subsystemAdd);
+ TeiidAdd.populate(subModel, subsystemAdd);
result.add(subsystemAdd);
if (subModel.hasDefined(Element.TRANSPORT_ELEMENT.getLocalName())) {
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -213,7 +213,6 @@
private void writePreparedPlanCacheConfiguration(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
writeAttribute(writer, Element.PPC_MAX_ENTRIES_ATTRIBUTE, node);
writeAttribute(writer, Element.PPC_MAX_AGE_IN_SECS_ATTRIBUTE, node);
- writeAttribute(writer, Element.PPC_MAX_STALENESS_ATTRIBUTE, node);
}
private boolean has(ModelNode node, String name) {
@@ -680,9 +679,6 @@
node.get(element.getModelName()).set(Integer.parseInt(attrValue));
break;
- case PPC_MAX_STALENESS_ATTRIBUTE:
- node.get(element.getModelName()).set(Integer.parseInt(attrValue));
- break;
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -83,19 +83,26 @@
final String translatorName = pathAddress.getLastElement().getValue();
- final String moduleName = Element.TRANSLATOR_MODULE_ATTRIBUTE.asString(operation);
+ String moduleName = null;
+ if (Element.TRANSLATOR_MODULE_ATTRIBUTE.isDefined(operation)) {
+ moduleName = Element.TRANSLATOR_MODULE_ATTRIBUTE.asString(operation);
+ }
final ServiceTarget target = context.getServiceTarget();
final Module module;
- try {
- module = Module.getCallerModuleLoader().loadModule(ModuleIdentifier.create(moduleName));
- } catch (ModuleLoadException e) {
- throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName, translatorName))); //$NON-NLS-1$
+ ClassLoader translatorLoader = this.getClass().getClassLoader();
+ if (moduleName != null) {
+ try {
+ module = Module.getCallerModuleLoader().loadModule(ModuleIdentifier.create(moduleName));
+ translatorLoader = module.getClassLoader();
+ } catch (ModuleLoadException e) {
+ throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName, translatorName))); //$NON-NLS-1$
+ }
}
boolean added = false;
- final ServiceLoader<ExecutionFactory> serviceLoader = module.loadService(ExecutionFactory.class);
+ final ServiceLoader<ExecutionFactory> serviceLoader = ServiceLoader.load(ExecutionFactory.class, translatorLoader);
if (serviceLoader != null) {
for (ExecutionFactory ef:serviceLoader) {
VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(ef, moduleName);
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -27,10 +27,8 @@
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -49,13 +47,9 @@
import org.teiid.client.security.ILogon;
import org.teiid.client.util.ExceptionUtil;
import org.teiid.core.ComponentNotFoundException;
-import org.teiid.core.util.LRUCache;
-import org.teiid.deployers.CompositeVDB;
-import org.teiid.deployers.VDBLifeCycleListener;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.dqp.service.SessionServiceException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -70,7 +64,6 @@
import org.teiid.transport.ODBCSocketListener;
import org.teiid.transport.SocketConfiguration;
import org.teiid.transport.SocketListener;
-import org.teiid.vdb.runtime.VDBKey;
public class Transport implements Service<ClientServiceRegistry>, ClientServiceRegistry {
private enum Protocol {teiid, pg};
@@ -89,8 +82,6 @@
private final InjectedValue<SocketBinding> socketBindingInjector = new InjectedValue<SocketBinding>();
private final InjectedValue<VDBRepository> vdbRepositoryInjector = new InjectedValue<VDBRepository>();
- private final InjectedValue<SessionAwareCache> preparedPlanCacheInjector = new InjectedValue<SessionAwareCache>();
- private final InjectedValue<SessionAwareCache> resultSetCacheInjector = new InjectedValue<SessionAwareCache>();
private final InjectedValue<DQPCore> dqpInjector = new InjectedValue<DQPCore>();
private final InjectedValue<BufferServiceImpl> bufferServiceInjector = new InjectedValue<BufferServiceImpl>();
@@ -155,39 +146,6 @@
DQP dqpProxy = proxyService(DQP.class, getDQP(), LogConstants.CTX_DQP);
this.csr.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
this.csr.registerClientService(DQP.class, dqpProxy, LogConstants.CTX_DQP);
-
- // add vdb life cycle listeners
- getVdbRepository().addListener(new VDBLifeCycleListener() {
-
- private Set<VDBKey> recentlyRemoved = Collections.newSetFromMap(new LRUCache<VDBKey, Boolean>(10000));
-
- @Override
- public void removed(String name, int version, CompositeVDB vdb) {
- recentlyRemoved.add(new VDBKey(name, version));
- }
-
- @Override
- public void added(String name, int version, CompositeVDB vdb) {
- if (!recentlyRemoved.remove(new VDBKey(name, version))) {
- return;
- }
- // terminate all the previous sessions
- try {
- Collection<SessionMetadata> sessions = sessionService.getActiveSessions();
- for (SessionMetadata session:sessions) {
- if (name.equalsIgnoreCase(session.getVDBName()) && version == session.getVDBVersion()){
- sessionService.terminateSession(session.getSessionId(), null);
- }
- }
- } catch (SessionServiceException e) {
- //ignore
- }
-
- // dump the caches.
- getResultSetCacheInjector().getValue().clearForVDB(name, version);
- getPreparedPlanCacheInjector().getValue().clearForVDB(name, version);
- }
- });
}
@Override
@@ -222,17 +180,13 @@
}));
}
- public List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) throws AdminException {
+ public List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) {
List<RequestMetadata> requests = new ArrayList<RequestMetadata>();
- try {
- Collection<SessionMetadata> sessions = this.sessionService.getActiveSessions();
- for (SessionMetadata session:sessions) {
- if (session.getVDBName().equals(vdbName) && session.getVDBVersion() == vdbVersion) {
- requests.addAll(getDQP().getRequestsForSession(session.getSessionId()));
- }
+ Collection<SessionMetadata> sessions = this.sessionService.getActiveSessions();
+ for (SessionMetadata session:sessions) {
+ if (session.getVDBName().equals(vdbName) && session.getVDBVersion() == vdbVersion) {
+ requests.addAll(getDQP().getRequestsForSession(session.getSessionId()));
}
- } catch (SessionServiceException e) {
- throw new AdminComponentException(e);
}
return requests;
}
@@ -241,12 +195,8 @@
this.sessionService.terminateSession(terminateeId, DQPWorkContext.getWorkContext().getSessionId());
}
- public Collection<SessionMetadata> getActiveSessions() throws AdminException {
- try {
- return this.sessionService.getActiveSessions();
- } catch (SessionServiceException e) {
- throw new AdminComponentException(e);
- }
+ public Collection<SessionMetadata> getActiveSessions(){
+ return this.sessionService.getActiveSessions();
}
public int getActiveSessionsCount() throws AdminException{
@@ -300,14 +250,6 @@
private VDBRepository getVdbRepository() {
return vdbRepositoryInjector.getValue();
}
-
- public InjectedValue<SessionAwareCache> getResultSetCacheInjector() {
- return resultSetCacheInjector;
- }
-
- public InjectedValue<SessionAwareCache> getPreparedPlanCacheInjector() {
- return preparedPlanCacheInjector;
- }
private DQPCore getDQP() {
return getDqpInjector().getValue();
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -56,7 +56,6 @@
import org.jboss.msc.service.ServiceTarget;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.services.BufferServiceImpl;
@@ -177,8 +176,6 @@
}
transportBuilder.addDependency(TeiidServiceNames.BUFFER_MGR, BufferServiceImpl.class, transport.getBufferServiceInjector());
transportBuilder.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class, transport.getVdbRepositoryInjector());
- transportBuilder.addDependency(TeiidServiceNames.CACHE_RESULTSET, SessionAwareCache.class, transport.getResultSetCacheInjector());
- transportBuilder.addDependency(TeiidServiceNames.CACHE_PREPAREDPLAN, SessionAwareCache.class, transport.getPreparedPlanCacheInjector());
transportBuilder.addDependency(TeiidServiceNames.ENGINE, DQPCore.class, transport.getDqpInjector());
@@ -193,7 +190,7 @@
// register a JNDI name, this looks hard.
if (transport.isEmbedded() && !isEmbeddedRegistered()) {
- final ClientServiceRegistryReferenceFactoryService referenceFactoryService = new ClientServiceRegistryReferenceFactoryService();
+ final CSRReferenceFactoryService referenceFactoryService = new CSRReferenceFactoryService();
final ServiceName referenceFactoryServiceName =TeiidServiceNames.transportServiceName(transportName).append("reference-factory"); //$NON-NLS-1$
final ServiceBuilder<?> referenceBuilder = target.addService(referenceFactoryServiceName,referenceFactoryService);
referenceBuilder.addDependency(TeiidServiceNames.transportServiceName(transportName), ClientServiceRegistry.class, referenceFactoryService.getCSRInjector());
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -25,8 +25,11 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.Set;
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkManager;
@@ -34,12 +37,18 @@
import org.jboss.modules.Module;
import org.jboss.msc.service.Service;
+import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.LRUCache;
+import org.teiid.deployers.CompositeVDB;
+import org.teiid.deployers.VDBLifeCycleListener;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.dqp.internal.process.AuthorizationValidator;
@@ -53,6 +62,8 @@
import org.teiid.events.EventDistributor;
import org.teiid.events.EventDistributorFactory;
import org.teiid.jboss.IntegrationPlugin;
+import org.teiid.jboss.TeiidServiceNames;
+import org.teiid.jboss.Transport;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -71,6 +82,7 @@
import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.services.BufferServiceImpl;
import org.teiid.transport.LocalServerConnection;
+import org.teiid.vdb.runtime.VDBKey;
public class RuntimeEngineDeployer extends DQPConfiguration implements Serializable, EventDistributor, EventDistributorFactory, Service<DQPCore> {
@@ -93,7 +105,7 @@
private final InjectedValue<ObjectReplicator> objectReplicatorInjector = new InjectedValue<ObjectReplicator>();
@Override
- public void start(StartContext context) {
+ public void start(final StartContext context) {
this.transactionServerImpl.setWorkManager(getWorkManagerInjector().getValue());
this.transactionServerImpl.setXaTerminator(getXaTerminatorInjector().getValue());
this.transactionServerImpl.setTransactionManager(getTxnManagerInjector().getValue());
@@ -132,6 +144,44 @@
return null;
}
});
+
+ // add vdb life cycle listeners
+ getVdbRepository().addListener(new VDBLifeCycleListener() {
+
+ private Set<VDBKey> recentlyRemoved = Collections.newSetFromMap(new LRUCache<VDBKey, Boolean>(10000));
+
+ @Override
+ public void removed(String name, int version, CompositeVDB vdb) {
+ recentlyRemoved.add(new VDBKey(name, version));
+ }
+
+ @Override
+ public void added(String name, int version, CompositeVDB vdb) {
+ if (!recentlyRemoved.remove(new VDBKey(name, version))) {
+ return;
+ }
+ // terminate all the previous sessions
+ List<ServiceName> services = context.getController().getServiceContainer().getServiceNames();
+ for (ServiceName service:services) {
+ if (service.isParentOf(TeiidServiceNames.TRANSPORT_BASE)) {
+ ServiceController<?> transport = context.getController().getServiceContainer().getService(service);
+ if (transport != null) {
+ Transport t = Transport.class.cast(transport.getValue());
+ Collection<SessionMetadata> sessions = t.getActiveSessions();
+ for (SessionMetadata session:sessions) {
+ if (name.equalsIgnoreCase(session.getVDBName()) && version == session.getVDBVersion()){
+ t.terminateSession(session.getSessionId());
+ }
+ }
+ }
+ }
+ }
+
+ // dump the caches.
+ getResultSetCacheInjector().getValue().clearForVDB(name, version);
+ getPreparedPlanCacheInjector().getValue().clearForVDB(name, version);
+ }
+ });
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_started", this.dqpCore.getRuntimeVersion(), new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
}
Modified: branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-10-18 15:56:08 UTC (rev 3559)
@@ -100,11 +100,10 @@
#prepared-plan
preparedplan-cache-max-entries.describe=Max Entries allowed
preparedplan-cache-max-age-in-seconds.describe=Max age in seconds
-preparedplan-cache-max-staleness.describe=Max staleness in seconds. Modifications are based upon data updates -1 indicates no max. (default 60 - 1 minute)
#resultset cache
-resultset-cache-enable.describe= Resultset cache enabled
-resultset-cache-container-name.describe=Infinispan cache container name
+resultset-cache-enable.describe= Resultset cache enabled
+resultset-cache-container-name.describe=Infinispan cache container name
resultset-cache-name.describe = Infinispan cache name for resultset
resultset-cache-max-age-in-seconds.describe=Max age in seconds
resultset-cache-max-staleness.describe=Max staleness in seconds. Modifications are based upon data updates -1 indicates no max. (default 60 - 1 minute)
Deleted: branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidAdminOperations.java
===================================================================
--- branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidAdminOperations.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidAdminOperations.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -1,326 +0,0 @@
-package org.teiid.jboss;
-
-import static junit.framework.Assert.assertEquals;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-import junit.framework.Assert;
-
-import org.jboss.as.controller.OperationContext.Type;
-import org.jboss.as.controller.PathAddress;
-import org.jboss.as.controller.PathElement;
-import org.jboss.as.subsystem.test.AbstractSubsystemTest;
-import org.jboss.as.subsystem.test.AdditionalInitialization;
-import org.jboss.as.subsystem.test.KernelServices;
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-import org.teiid.core.util.ObjectConverterUtil;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
- at SuppressWarnings("nls")
-public class TestTeiidAdminOperations extends AbstractSubsystemTest {
-
- public TestTeiidAdminOperations() {
- super(TeiidExtension.TEIID_SUBSYSTEM, new TeiidExtension());
- }
-
- @Test
- public void testDescribeHandler() throws Exception {
- String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
- KernelServices servicesA = super.installInController(
- new AdditionalInitialization() {
- @Override
- protected Type getType() {
- return Type.MANAGEMENT;
- }
- },
- subsystemXml);
-
-
- //Get the model and the describe operations from the first controller
- ModelNode modelA = servicesA.readWholeModel();
- String marshalled = servicesA.getPersistedSubsystemXml();
-
- ModelNode describeOp = new ModelNode();
- describeOp.get(OP).set(DESCRIBE);
- describeOp.get(OP_ADDR).set(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM)).toModelNode());
- List<ModelNode> operations = super.checkResultAndGetContents(servicesA.executeOperation(describeOp)).asList();
-
-
- //Install the describe options from the first controller into a second controller
- KernelServices servicesB = super.installInController(operations);
- ModelNode modelB = servicesB.readWholeModel();
-
- //Make sure the models from the two controllers are identical
- super.compare(modelA, modelB);
- }
-
- @Test
- public void testMinimumConfiguration() throws Exception {
- String subsystemXml = "<subsystem xmlns=\"urn:jboss:domain:teiid:1.0\">\n" +
- " <async-thread-pool>teiid-async</async-thread-pool>"+
- "</subsystem>";
- KernelServices services = super.installInController(subsystemXml);
- ModelNode model = services.readWholeModel();
- }
-
- @Test
- public void testOutputPerisitence() throws Exception {
- String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
-
- String json = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-model-json.txt"));
- ModelNode testModel = ModelNode.fromJSONString(json);
- String triggered = outputModel(testModel);
-
- KernelServices services = super.installInController(
- new AdditionalInitialization() {
- @Override
- protected Type getType() {
- return Type.MANAGEMENT;
- }
- },
- subsystemXml);
- //Get the model and the persisted xml from the controller
- ModelNode model = services.readWholeModel();
- String marshalled = services.getPersistedSubsystemXml();
-
- //System.out.println(marshalled);
-
- Assert.assertEquals(marshalled, triggered);
- Assert.assertEquals(normalizeXML(marshalled), normalizeXML(triggered));
- }
-
- @Test
- public void testOutputModel() throws Exception {
- String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
-
- String json = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-model-json.txt"));
- ModelNode testModel = ModelNode.fromJSONString(json);
- String triggered = outputModel(testModel);
-
- KernelServices services = super.installInController(
- new AdditionalInitialization() {
- @Override
- protected Type getType() {
- return Type.MANAGEMENT;
- }
- },
- subsystemXml);
- //Get the model and the persisted xml from the controller
- ModelNode model = services.readWholeModel();
- String marshalled = services.getPersistedSubsystemXml();
-
- Assert.assertEquals(marshalled, triggered);
- Assert.assertEquals(normalizeXML(marshalled), normalizeXML(triggered));
- }
-
- @Test
- public void testSchema() throws Exception {
- String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
- validate(subsystemXml);
-
- KernelServices services = super.installInController(
- new AdditionalInitialization() {
- @Override
- protected Type getType() {
- return Type.MANAGEMENT;
- }
- },
- subsystemXml);
- //Get the model and the persisted xml from the controller
- ModelNode model = services.readWholeModel();
- String marshalled = services.getPersistedSubsystemXml();
-
- validate(marshalled);
- }
-
- private void validate(String marshalled) throws SAXException, IOException {
- URL xsdURL = Thread.currentThread().getContextClassLoader().getResource("schema/jboss-teiid.xsd");
- System.out.println(marshalled);
-
- SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
- Schema schema = factory.newSchema(xsdURL);
-
- Validator validator = schema.newValidator();
- Source source = new StreamSource(new ByteArrayInputStream(marshalled.getBytes()));
- validator.setErrorHandler(new ErrorHandler() {
-
- @Override
- public void warning(SAXParseException exception) throws SAXException {
- fail(exception.getMessage());
- }
-
- @Override
- public void fatalError(SAXParseException exception) throws SAXException {
- fail(exception.getMessage());
- }
-
- @Override
- public void error(SAXParseException exception) throws SAXException {
- if (!exception.getMessage().contains("cvc-enumeration-valid") && !exception.getMessage().contains("cvc-type"))
- fail(exception.getMessage());
- }
- });
-
- validator.validate(source);
- }
-
- @Test
- public void testSubSystemDescription() throws IOException {
- ModelNode node = new ModelNode();
- TeiidBootServicesAdd.describeTeiid(node, ATTRIBUTES, IntegrationPlugin.getResourceBundle(null));
- assertEquals(ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-model-config.txt")), node.toString());
- }
-
- @Test
- public void testParseSubsystem() throws Exception {
- //Parse the subsystem xml into operations
- String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
- List<ModelNode> operations = super.parse(subsystemXml);
-
- ///Check that we have the expected number of operations
- Assert.assertEquals(5, operations.size());
-
- //Check that each operation has the correct content
- ModelNode addSubsystem = operations.get(0);
- Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
- PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
- Assert.assertEquals(1, addr.size());
- PathElement element = addr.getElement(0);
- Assert.assertEquals(SUBSYSTEM, element.getKey());
- Assert.assertEquals(TeiidExtension.TEIID_SUBSYSTEM, element.getValue());
- }
-
- @Test
- public void testQueryOperatrions() throws Exception {
- KernelServices services = buildSubsystem();
-
- PathAddress addr = PathAddress.pathAddress(
- PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM));
- ModelNode addOp = new ModelNode();
- addOp.get(OP).set("read-operation-names");
- addOp.get(OP_ADDR).set(addr.toModelNode());
-
- ModelNode result = services.executeOperation(addOp);
- Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
-
- List<String> opNames = getList(result);
- assertEquals(36, opNames.size());
- String[] ops = { "add", "add-anyauthenticated-role", "add-data-role",
- "assign-datasource", "cache-statistics", "cache-types",
- "cancel-request", "change-vdb-connection-type", "clear-cache",
- "describe", "execute-query", "get-translator", "get-vdb",
- "list-requests", "list-sessions", "list-transactions",
- "list-translators", "list-vdbs", "long-running-queries",
- "merge-vdbs", "read-attribute", "read-children-names",
- "read-children-resources", "read-children-types",
- "read-operation-description", "read-operation-names",
- "read-resource", "read-resource-description",
- "remove-anyauthenticated-role", "remove-data-role",
- "requests-per-session", "requests-per-vdb",
- "terminate-session", "terminate-transaction",
- "workerpool-statistics", "write-attribute" };
- assertEquals(Arrays.asList(ops), opNames);
- }
-
- @Test
- public void testAddRemoveTransport() throws Exception {
- KernelServices services = buildSubsystem();
-
- PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM));
-
- // look at current query engines make sure there are only two from configuration.
- ModelNode read = new ModelNode();
- read.get(OP).set("read-children-names");
- read.get(OP_ADDR).set(addr.toModelNode());
- read.get(CHILD_TYPE).set("transport");
-
- ModelNode result = services.executeOperation(read);
- Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
-
- List<String> opNames = getList(result);
- assertEquals(2, opNames.size());
- String [] ops = {"jdbc", "odbc"};
- assertEquals(Arrays.asList(ops), opNames);
-
- // add transport
- ModelNode addOp = new ModelNode();
- addOp.get(OP).set("add");
- addOp.get(OP_ADDR).set(addr.toModelNode().add("transport", "newbie")); //$NON-NLS-1$);
- addOp.get("protocol").set("pg");
- addOp.get("socket-binding").set("socket");
- addOp.get("authentication-security-domain").set("teiid-security");
-
- result = services.executeOperation(addOp);
- Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
-
- result = services.executeOperation(read);
- Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
- opNames = getList(result);
- assertEquals(3, opNames.size());
- String [] ops2 = {"jdbc", "newbie", "odbc"};
- assertEquals(Arrays.asList(ops2), opNames);
-
- // add transport
- ModelNode remove = new ModelNode();
- addOp.get(OP).set("remove");
- addOp.get(OP_ADDR).set(addr.toModelNode().add("transport", "jdbc")); //$NON-NLS-1$);
- result = services.executeOperation(addOp);
- Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
-
- result = services.executeOperation(read);
- Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
- opNames = getList(result);
- assertEquals(2, opNames.size());
- String [] ops3 = {"newbie", "odbc"};
- assertEquals(Arrays.asList(ops3), opNames);
- }
-
- private KernelServices buildSubsystem() throws IOException,
- FileNotFoundException, Exception {
- String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
-
- KernelServices services = super.installInController(
- new AdditionalInitialization() {
- @Override
- protected Type getType() {
- return Type.MANAGEMENT;
- }
- },
- subsystemXml);
- return services;
- }
-
- private static List<String> getList(ModelNode operationResult) {
- if(!operationResult.hasDefined("result"))
- return Collections.emptyList();
-
- List<ModelNode> nodeList = operationResult.get("result").asList();
- if(nodeList.isEmpty())
- return Collections.emptyList();
-
- List<String> list = new ArrayList<String>(nodeList.size());
- for(ModelNode node : nodeList) {
- list.add(node.asString());
- }
- return list;
- }
-}
Copied: branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidOperations.java (from rev 3548, branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidAdminOperations.java)
===================================================================
--- branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidOperations.java (rev 0)
+++ branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidOperations.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -0,0 +1,419 @@
+package org.teiid.jboss;
+
+import static junit.framework.Assert.assertEquals;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import junit.framework.Assert;
+
+import org.jboss.as.cli.Util;
+import org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress;
+import org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder;
+import org.jboss.as.controller.OperationContext.Type;
+import org.jboss.as.controller.client.OperationBuilder;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.subsystem.test.AbstractSubsystemTest;
+import org.jboss.as.subsystem.test.AdditionalInitialization;
+import org.jboss.as.subsystem.test.KernelServices;
+import org.jboss.dmr.ModelNode;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.UnitTestUtil;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+ at SuppressWarnings("nls")
+public class TestTeiidOperations extends AbstractSubsystemTest {
+
+ public TestTeiidOperations() {
+ super(TeiidExtension.TEIID_SUBSYSTEM, new TeiidExtension());
+ }
+
+ @Test
+ public void testDescribeHandler() throws Exception {
+ String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
+ KernelServices servicesA = super.installInController(
+ new AdditionalInitialization() {
+ @Override
+ protected Type getType() {
+ return Type.MANAGEMENT;
+ }
+ },
+ subsystemXml);
+
+
+ //Get the model and the describe operations from the first controller
+ ModelNode modelA = servicesA.readWholeModel();
+ String marshalled = servicesA.getPersistedSubsystemXml();
+
+ ModelNode describeOp = new ModelNode();
+ describeOp.get(OP).set(DESCRIBE);
+ describeOp.get(OP_ADDR).set(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM)).toModelNode());
+ List<ModelNode> operations = super.checkResultAndGetContents(servicesA.executeOperation(describeOp)).asList();
+
+
+ //Install the describe options from the first controller into a second controller
+ KernelServices servicesB = super.installInController(operations);
+ ModelNode modelB = servicesB.readWholeModel();
+
+ //Make sure the models from the two controllers are identical
+ super.compare(modelA, modelB);
+ }
+
+ @Test
+ public void testMinimumConfiguration() throws Exception {
+ String subsystemXml = "<subsystem xmlns=\"urn:jboss:domain:teiid:1.0\">\n" +
+ " <async-thread-pool>teiid-async</async-thread-pool>"+
+ "</subsystem>";
+ KernelServices services = super.installInController(subsystemXml);
+ services.readWholeModel();
+ }
+
+ @Test
+ public void testOutputPerisitence() throws Exception {
+ String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
+
+ String json = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-model-json.txt"));
+ ModelNode testModel = ModelNode.fromJSONString(json);
+ String triggered = outputModel(testModel);
+
+ KernelServices services = super.installInController(
+ new AdditionalInitialization() {
+ @Override
+ protected Type getType() {
+ return Type.MANAGEMENT;
+ }
+ },
+ subsystemXml);
+ //Get the model and the persisted xml from the controller
+ ModelNode model = services.readWholeModel();
+ String marshalled = services.getPersistedSubsystemXml();
+
+ //System.out.println(marshalled);
+
+ Assert.assertEquals(marshalled, triggered);
+ Assert.assertEquals(normalizeXML(marshalled), normalizeXML(triggered));
+ }
+
+ @Test
+ public void testOutputModel() throws Exception {
+ String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
+
+ String json = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-model-json.txt"));
+ ModelNode testModel = ModelNode.fromJSONString(json);
+ String triggered = outputModel(testModel);
+
+ KernelServices services = super.installInController(
+ new AdditionalInitialization() {
+ @Override
+ protected Type getType() {
+ return Type.MANAGEMENT;
+ }
+ },
+ subsystemXml);
+ //Get the model and the persisted xml from the controller
+ ModelNode model = services.readWholeModel();
+ String marshalled = services.getPersistedSubsystemXml();
+
+ Assert.assertEquals(marshalled, triggered);
+ Assert.assertEquals(normalizeXML(marshalled), normalizeXML(triggered));
+ }
+
+ @Test
+ public void testSchema() throws Exception {
+ String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
+ validate(subsystemXml);
+
+ KernelServices services = super.installInController(
+ new AdditionalInitialization() {
+ @Override
+ protected Type getType() {
+ return Type.MANAGEMENT;
+ }
+ },
+ subsystemXml);
+ //Get the model and the persisted xml from the controller
+ ModelNode model = services.readWholeModel();
+ String marshalled = services.getPersistedSubsystemXml();
+
+ validate(marshalled);
+ }
+
+ private void validate(String marshalled) throws SAXException, IOException {
+ URL xsdURL = Thread.currentThread().getContextClassLoader().getResource("schema/jboss-teiid.xsd");
+ System.out.println(marshalled);
+
+ SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
+ Schema schema = factory.newSchema(xsdURL);
+
+ Validator validator = schema.newValidator();
+ Source source = new StreamSource(new ByteArrayInputStream(marshalled.getBytes()));
+ validator.setErrorHandler(new ErrorHandler() {
+
+ @Override
+ public void warning(SAXParseException exception) throws SAXException {
+ fail(exception.getMessage());
+ }
+
+ @Override
+ public void fatalError(SAXParseException exception) throws SAXException {
+ fail(exception.getMessage());
+ }
+
+ @Override
+ public void error(SAXParseException exception) throws SAXException {
+ if (!exception.getMessage().contains("cvc-enumeration-valid") && !exception.getMessage().contains("cvc-type"))
+ fail(exception.getMessage());
+ }
+ });
+
+ validator.validate(source);
+ }
+
+ @Test
+ public void testSubSystemDescription() throws IOException {
+ ModelNode node = new ModelNode();
+ TeiidAdd.describeTeiid(node, ATTRIBUTES, IntegrationPlugin.getResourceBundle(null));
+ assertEquals(ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-model-config.txt")), node.toString());
+ }
+
+ @Test
+ public void testParseSubsystem() throws Exception {
+ //Parse the subsystem xml into operations
+ String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
+ List<ModelNode> operations = super.parse(subsystemXml);
+
+ ///Check that we have the expected number of operations
+ Assert.assertEquals(5, operations.size());
+
+ //Check that each operation has the correct content
+ ModelNode addSubsystem = operations.get(0);
+ Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
+ PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
+ Assert.assertEquals(1, addr.size());
+ PathElement element = addr.getElement(0);
+ Assert.assertEquals(SUBSYSTEM, element.getKey());
+ Assert.assertEquals(TeiidExtension.TEIID_SUBSYSTEM, element.getValue());
+ }
+
+ @Test
+ public void testQueryOperations() throws Exception {
+ KernelServices services = buildSubsystem();
+
+ PathAddress addr = PathAddress.pathAddress(
+ PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM));
+ ModelNode addOp = new ModelNode();
+ addOp.get(OP).set("read-operation-names");
+ addOp.get(OP_ADDR).set(addr.toModelNode());
+
+ ModelNode result = services.executeOperation(addOp);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ List<String> opNames = getList(result);
+ assertEquals(36, opNames.size());
+ String[] ops = { "add", "add-anyauthenticated-role", "add-data-role",
+ "assign-datasource", "cache-statistics", "cache-types",
+ "cancel-request", "change-vdb-connection-type", "clear-cache",
+ "describe", "execute-query", "get-translator", "get-vdb",
+ "list-requests", "list-sessions", "list-transactions",
+ "list-translators", "list-vdbs", "long-running-queries",
+ "merge-vdbs", "read-attribute", "read-children-names",
+ "read-children-resources", "read-children-types",
+ "read-operation-description", "read-operation-names",
+ "read-resource", "read-resource-description",
+ "remove-anyauthenticated-role", "remove-data-role",
+ "requests-per-session", "requests-per-vdb",
+ "terminate-session", "terminate-transaction",
+ "workerpool-statistics", "write-attribute" };
+ assertEquals(Arrays.asList(ops), opNames);
+ }
+
+ @Test
+ public void testAddRemoveTransport() throws Exception {
+ KernelServices services = buildSubsystem();
+
+ PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM));
+
+ // look at current query engines make sure there are only two from configuration.
+ ModelNode read = new ModelNode();
+ read.get(OP).set("read-children-names");
+ read.get(OP_ADDR).set(addr.toModelNode());
+ read.get(CHILD_TYPE).set("transport");
+
+ ModelNode result = services.executeOperation(read);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ List<String> opNames = getList(result);
+ assertEquals(2, opNames.size());
+ String [] ops = {"jdbc", "odbc"};
+ assertEquals(Arrays.asList(ops), opNames);
+
+ // add transport
+ ModelNode addOp = new ModelNode();
+ addOp.get(OP).set("add");
+ addOp.get(OP_ADDR).set(addr.toModelNode().add("transport", "newbie")); //$NON-NLS-1$);
+ addOp.get("protocol").set("pg");
+ addOp.get("socket-binding").set("socket");
+ addOp.get("authentication-security-domain").set("teiid-security");
+
+ result = services.executeOperation(addOp);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ result = services.executeOperation(read);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+ opNames = getList(result);
+ assertEquals(3, opNames.size());
+ String [] ops2 = {"jdbc", "newbie", "odbc"};
+ assertEquals(Arrays.asList(ops2), opNames);
+
+ // add transport
+ ModelNode remove = new ModelNode();
+ remove.get(OP).set("remove");
+ remove.get(OP_ADDR).set(addr.toModelNode().add("transport", "jdbc")); //$NON-NLS-1$);
+ result = services.executeOperation(remove);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ result = services.executeOperation(read);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+ opNames = getList(result);
+ assertEquals(2, opNames.size());
+ String [] ops3 = {"newbie", "odbc"};
+ assertEquals(Arrays.asList(ops3), opNames);
+ }
+
+ private KernelServices buildSubsystem() throws IOException,
+ FileNotFoundException, Exception {
+ String subsystemXml = ObjectConverterUtil.convertToString(new FileReader("src/test/resources/teiid-sample-config.xml"));
+
+ KernelServices services = super.installInController(subsystemXml);
+ return services;
+ }
+
+ private static List<String> getList(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ List<ModelNode> nodeList = operationResult.get("result").asList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(ModelNode node : nodeList) {
+ list.add(node.asString());
+ }
+ return list;
+ }
+
+ private ModelNode buildProperty(String name, String value) {
+ ModelNode node = new ModelNode();
+ node.get("property-name").set(name);
+ node.get("property-value").set(value);
+ return node;
+ }
+
+ @Test
+ public void testTranslator() throws Exception {
+ KernelServices services = buildSubsystem();
+
+ PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM));
+
+ ModelNode addOp = new ModelNode();
+ addOp.get(OP).set("add");
+ addOp.get(OP_ADDR).set(addr.toModelNode().add("translator", "oracle"));
+ services.executeOperation(addOp);
+
+ ModelNode listOp = new ModelNode();
+ listOp.get(OP).set("list-translators");
+ listOp.get(OP_ADDR).set(addr.toModelNode());
+
+ ModelNode result = services.executeOperation(listOp);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ List<ModelNode> translators = result.get("result").asList();
+
+ ModelNode oracle = new ModelNode();
+ oracle.get("translator-name").set("oracle");
+ oracle.get("description").set("A translator for Oracle 9i Database or later");
+ oracle.get("children", "properties").add(buildProperty("execution-factory-class","org.teiid.translator.jdbc.oracle.OracleExecutionFactory"));
+ oracle.get("children", "properties").add(buildProperty("TrimStrings","false"));
+ oracle.get("children", "properties").add(buildProperty("SupportedJoinCriteria","ANY"));
+ oracle.get("children", "properties").add(buildProperty("requiresCriteria","false"));
+ oracle.get("children", "properties").add(buildProperty("supportsOuterJoins","true"));
+ oracle.get("children", "properties").add(buildProperty("useCommentsInSourceQuery","false"));
+ oracle.get("children", "properties").add(buildProperty("useBindVariables","true"));
+ oracle.get("children", "properties").add(buildProperty("MaxPreparedInsertBatchSize","2048"));
+ oracle.get("children", "properties").add(buildProperty("supportsInnerJoins","true"));
+ oracle.get("children", "properties").add(buildProperty("MaxInCriteriaSize","1000"));
+ oracle.get("children", "properties").add(buildProperty("supportsSelectDistinct","true"));
+ oracle.get("children", "properties").add(buildProperty("supportsOrderBy","true"));
+ oracle.get("children", "properties").add(buildProperty("supportsFullOuterJoins","true"));
+ oracle.get("children", "properties").add(buildProperty("Immutable","false"));
+ oracle.get("children", "properties").add(buildProperty("MaxDependentInPredicates","50"));
+
+ super.compare(translators.get(0), oracle);
+ }
+
+ @Ignore
+ public void testVDBOperations() throws Exception {
+ KernelServices services = buildSubsystem();
+ String fileName = "bqt.vdb";
+
+ byte[] bytes = ObjectConverterUtil.convertToByteArray(new FileInputStream(UnitTestUtil.getTestDataFile(fileName)));
+ PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TeiidExtension.TEIID_SUBSYSTEM));
+
+ // add
+ ModelNode composite = new ModelNode();
+ composite.get("operation").set("composite");
+ composite.get("address").setEmptyList();
+ ModelNode steps = composite.get("steps");
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ builder.setOperationName("add");
+ builder.addNode("deployment", fileName);
+
+ builder.getModelNode().get("content").get(0).get("bytes").set(bytes);
+ steps.add(builder.buildRequest());
+
+ // deploy
+ builder = new DefaultOperationRequestBuilder();
+ builder.setOperationName("deploy");
+ builder.addNode("deployment", fileName);
+ steps.add(builder.buildRequest());
+
+ ModelNode result = services.executeOperation(composite);
+
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ ModelNode addOp = new ModelNode();
+ addOp.get(OP).set("list-vdbs");
+ addOp.get(OP_ADDR).set(addr.toModelNode());
+
+ result = services.executeOperation(addOp);
+ Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+ List<String> opNames = getList(result);
+ assertEquals(2, opNames.size());
+ String [] ops3 = {"newbie", "odbc"};
+ assertEquals(Arrays.asList(ops3), opNames);
+ }
+}
Property changes on: branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidOperations.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/jboss-integration/src/test/resources/bqt.vdb
===================================================================
(Binary files differ)
Property changes on: branches/as7/jboss-integration/src/test/resources/bqt.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-10-18 15:56:08 UTC (rev 3559)
@@ -176,13 +176,6 @@
"max-occurs" => 1,
"default" => 28800
},
- "preparedplan-cache-max-staleness" => {
- "type" => INT,
- "description" => "Max staleness in seconds. Modifications are based upon data updates -1 indicates no max. (default 60 - 1 minute)",
- "required" => false,
- "max-occurs" => 1,
- "default" => 0
- },
"resultset-cache-name" => {
"type" => STRING,
"description" => "Infinispan cache name for resultset",
@@ -192,7 +185,7 @@
},
"resultset-cache-container-name" => {
"type" => STRING,
- "description" => "Infinispan cache container name ",
+ "description" => "Infinispan cache container name",
"required" => false,
"max-occurs" => 1
},
@@ -205,7 +198,7 @@
},
"resultset-cache-enable" => {
"type" => BOOLEAN,
- "description" => "Resultset cache enabled ",
+ "description" => "Resultset cache enabled",
"required" => false,
"max-occurs" => 1
}
Modified: branches/as7/jboss-integration/src/test/resources/teiid-model-json.txt
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-model-json.txt 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/test/resources/teiid-model-json.txt 2011-10-18 15:56:08 UTC (rev 3559)
@@ -20,7 +20,6 @@
"object-replicator-stack" : "stack",
"preparedplan-cache-max-age-in-seconds" : 28800,
"preparedplan-cache-max-entries" : 512,
- "preparedplan-cache-max-staleness" : 90,
"query-threshold-in-seconds" : 600,
"resultset-cache-container-name" : "container",
"resultset-cache-enable" : false,
Modified: branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-10-18 15:56:08 UTC (rev 3559)
@@ -23,7 +23,7 @@
<resultset-cache name="cache" container-name="container" enable="false" max-staleness="90"/>
- <preparedplan-cache max-entries="512" max-age-in-seconds="28800" max-staleness="90"/>
+ <preparedplan-cache max-entries="512" max-age-in-seconds="28800"/>
<object-replicator stack="stack" cluster-name="cluster"/>
Modified: branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-10-18 15:56:08 UTC (rev 3559)
@@ -272,7 +272,7 @@
}
@Override
- public Collection<SessionMetadata> getActiveSessions() throws SessionServiceException {
+ public Collection<SessionMetadata> getActiveSessions() {
return new ArrayList<SessionMetadata>(this.sessionCache.values());
}
Modified: branches/as7/test-integration/common/pom.xml
===================================================================
--- branches/as7/test-integration/common/pom.xml 2011-10-18 15:46:00 UTC (rev 3558)
+++ branches/as7/test-integration/common/pom.xml 2011-10-18 15:56:08 UTC (rev 3559)
@@ -20,11 +20,7 @@
<artifactId>h2</artifactId>
<version>1.2.147</version>
</dependency>
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-clustering-jgroups</artifactId>
- <scope>provided</scope>
- </dependency>
+
<dependency>
<artifactId>teiid-cache-jbosscache</artifactId>
<groupId>org.jboss.teiid</groupId>
More information about the teiid-commits
mailing list