Author: rareddy
Date: 2011-10-20 13:09:57 -0400 (Thu, 20 Oct 2011)
New Revision: 3574
Modified:
branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/as7/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/pom.xml
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
Log:
TEIID-1720: corrected VDB dependencies on the data sources and admin api corrections
Modified: branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java 2011-10-20 15:37:18 UTC
(rev 3573)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java 2011-10-20 17:09:57 UTC
(rev 3574)
@@ -287,11 +287,4 @@
* @throws AdminException
*/
Set<String> getDataSourceTemplateNames() throws AdminException;
-
- /**
- * Tell the engine that the given source is available. Pending dynamic vdb metadata
loads will be resumed.
- * @param jndiName
- * @throws AdminException
- */
- void markDataSourceAvailable(String jndiName) throws AdminException;
}
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-20
15:37:18 UTC (rev 3573)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -27,6 +27,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.net.UnknownHostException;
import java.util.*;
@@ -41,6 +43,8 @@
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.protocol.old.StreamUtils;
import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.teiid.adminapi.PropertyDefinition.RestartType;
import org.teiid.adminapi.VDB.ConnectionType;
import org.teiid.adminapi.impl.*;
import org.teiid.adminapi.impl.VDBMetadataMapper.RequestMetadataMapper;
@@ -187,23 +191,10 @@
}
}
- private void createConnectionFactoryRequest(String deploymentName, String templateName,
Properties properties) throws AdminException {
- DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
- try {
- builder.operationName("add");
- builder.addNode("subsystem", "resource-adapters"); //$NON-NLS-1$
//$NON-NLS-2$
- builder.addNode("resource-adapter", templateName); //$NON-NLS-1$
-
- builder.addProperty("archive", templateName);
- builder.addProperty("transaction-support",
properties.getProperty("transaction-support", "NoTransaction"));
- properties.remove("transaction-support");
-
-
- } catch (OperationFormatException e) {
- throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
- }
-
-
+ private void createConnectionFactoryRequest(String deploymentName, String templateName,
Properties properties, DefaultOperationRequestBuilder builder) throws AdminException {
+ builder.addProperty("archive", templateName);
+ builder.addProperty("transaction-support",
properties.getProperty("transaction-support", "NoTransaction"));
+ properties.remove("transaction-support");
}
@Override
@@ -223,9 +214,10 @@
else if (templateName.equals("resource-adapters")) {
builder.addNode("subsystem", "resource-adapters");
//$NON-NLS-1$ //$NON-NLS-2$
builder.addNode("resource-adapter", deploymentName);
//$NON-NLS-1$
+ createConnectionFactoryRequest(deploymentName, templateName, properties,
builder);
}
- builder.operationName("add");
+ builder.setOperationName("add");
request = builder.buildRequest();
builder.addProperty("jndi-name",
"java:/"+deploymentName);
@@ -433,7 +425,7 @@
try {
builder.addNode("subsystem", "resource-adapters");
//$NON-NLS-1$ //$NON-NLS-2$
builder.addNode("resource-adapter", resource); //$NON-NLS-1$
//$NON-NLS-2$
- builder.operationName("read-resource");
+ builder.setOperationName("read-resource");
ModelNode request = builder.buildRequest();
ModelNode outcome = this.connection.execute(request);
@@ -490,7 +482,7 @@
@Override
public WorkerPoolStatistics getWorkerPoolStats() throws AdminException {
- final ModelNode request =
buildEngineRequest("workerpool-statistics");//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"workerpool-statistics");//$NON-NLS-1$
if (request != null) {
try {
ModelNode outcome = this.connection.execute(request);
@@ -510,7 +502,7 @@
@Override
public void cancelRequest(String sessionId, long executionId) throws AdminException {
- final ModelNode request = buildEngineRequest("terminate-session",
"session", sessionId, "execution-id",
String.valueOf(executionId));//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"terminate-session", "session", sessionId, "execution-id",
String.valueOf(executionId));//$NON-NLS-1$
if (request == null) {
return;
}
@@ -526,7 +518,7 @@
@Override
public Collection<? extends Request> getRequests() throws AdminException {
- final ModelNode request = buildEngineRequest("list-requests");//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"list-requests");//$NON-NLS-1$
if (request != null) {
try {
ModelNode outcome = this.connection.execute(request);
@@ -542,7 +534,7 @@
@Override
public Collection<? extends Request> getRequestsForSession(String sessionId)
throws AdminException {
- final ModelNode request = buildEngineRequest("requests-per-session",
"session", sessionId);//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"requests-per-session", "session", sessionId);//$NON-NLS-1$
if (request != null) {
try {
ModelNode outcome = this.connection.execute(request);
@@ -558,7 +550,7 @@
@Override
public Collection<? extends Session> getSessions() throws AdminException {
- final ModelNode request = buildEngineRequest("list-sessions");//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"list-sessions");//$NON-NLS-1$
if (request != null) {
try {
ModelNode outcome = this.connection.execute(request);
@@ -572,15 +564,133 @@
return Collections.emptyList();
}
- @Override
+ /**
+ * pattern on CLI
+ * /subsystem=datasources/data-source=foo:read-resource-description
+ */
+ @Override
public Collection<PropertyDefinition> getTemplatePropertyDefinitions(String
templateName) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ ModelNode request = null;
+ try {
+ // data-source,xa-data-source,resource-adapters
+ if (templateName.equals("data-source")) {
+ builder.addNode("subsystem", "datasources");
//$NON-NLS-1$ //$NON-NLS-2$
+ builder.addNode("data-source", "any"); //$NON-NLS-1$
+ }
+ else if (templateName.equals("xa-data-source")) {
+ builder.addNode("subsystem", "datasources");
//$NON-NLS-1$ //$NON-NLS-2$
+ builder.addNode("xa-data-source", "any");
//$NON-NLS-1$
+ }
+ else {
+ builder.addNode("subsystem", "resource-adapters");
//$NON-NLS-1$ //$NON-NLS-2$
+ builder.addNode("resource-adapter", templateName); //$NON-NLS-1$
+ }
+
+ builder.setOperationName("read-resource-description");
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
+ }
+
+ ModelNode result = null;
+ try {
+ ModelNode outcome = this.connection.execute(request);
+ if (!Util.isSuccess(outcome)) {
+ throw new
AdminProcessingException(Util.getFailureDescription(outcome));
+ }
+ result = outcome.get("result");
+ } catch (IOException e) {
+ throw new AdminProcessingException(e);
+ }
+
+ ArrayList<PropertyDefinition> propDefinitions = new
ArrayList<PropertyDefinition>();
+ List<ModelNode> propsNodes = null;
+ if (templateName.equals("data-source") ||
templateName.equals("xa-data-source")) {
+ propsNodes = result.get("attributes").asList();
+ }
+ else {
+ propsNodes = result.get("connection-definitions",
"attributes").asList();
+ }
+
+ for (ModelNode node:propsNodes) {
+ PropertyDefinitionMetadata def = new PropertyDefinitionMetadata();
+ Set<String> keys = node.keys();
+
+ String name = keys.iterator().next();
+ def.setName(name);
+ node = node.get(name);
+
+ if (node.hasDefined("description")) {
+ def.setDescription(node.get("description").asString());
+ }
+
+ if (node.hasDefined("required")) {
+ def.setRequired(node.get("required").asBoolean());
+ }
+
+ if (node.hasDefined("access-type")) {
+ String access = node.get("access-type").asString();
+ if ("read-only".equals(access)) {
+ def.setModifiable(false);
+ }
+ else if ("read-write".equals(access)) {
+ def.setModifiable(true);
+ }
+ }
+
+ if (node.hasDefined("restart-required")) {
+ def.setRequiresRestart(RestartType.CLUSTER);
+ }
+
+ String type = node.get("type").asString();
+ if (ModelType.STRING.name().equals(type)) {
+ def.setPropertyTypeClassName(String.class.getName());
+ }
+ else if (ModelType.INT.name().equals(type)) {
+ def.setPropertyTypeClassName(Integer.class.getName());
+ }
+ else if (ModelType.LONG.name().equals(type)) {
+ def.setPropertyTypeClassName(Long.class.getName());
+ }
+ else if (ModelType.BOOLEAN.name().equals(type)) {
+ def.setPropertyTypeClassName(Boolean.class.getName());
+ }
+ else if (ModelType.BIG_INTEGER.name().equals(type)) {
+ def.setPropertyTypeClassName(BigInteger.class.getName());
+ }
+ else if (ModelType.BIG_DECIMAL.name().equals(type)) {
+ def.setPropertyTypeClassName(BigDecimal.class.getName());
+ }
+
+ if (node.hasDefined("default")) {
+ if (ModelType.STRING.name().equals(type)) {
+ def.setDefaultValue(node.get("default").asString());
+ }
+ else if (ModelType.INT.name().equals(type)) {
+ def.setDefaultValue(node.get("default").asInt());
+ }
+ else if (ModelType.LONG.name().equals(type)) {
+ def.setDefaultValue(node.get("default").asLong());
+ }
+ else if (ModelType.BOOLEAN.name().equals(type)) {
+ def.setDefaultValue(node.get("default").asBoolean());
+ }
+ else if (ModelType.BIG_INTEGER.name().equals(type)) {
+ def.setDefaultValue(node.get("default").asBigInteger());
+ }
+ else if (ModelType.BIG_DECIMAL.name().equals(type)) {
+ def.setDefaultValue(node.get("default").asBigDecimal());
+ }
+ }
+ propDefinitions.add(def);
+ }
+ return propDefinitions;
}
@Override
public Collection<? extends Transaction> getTransactions() throws AdminException
{
- final ModelNode request =
buildEngineRequest("list-transactions");//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"list-transactions");//$NON-NLS-1$
if (request != null) {
try {
ModelNode outcome = this.connection.execute(request);
@@ -596,7 +706,7 @@
@Override
public void terminateSession(String sessionId) throws AdminException {
- final ModelNode request = buildEngineRequest("terminate-session",
"session", sessionId);//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"terminate-session", "session", sessionId);//$NON-NLS-1$
if (request == null) {
return;
}
@@ -612,7 +722,7 @@
@Override
public void terminateTransaction(String transactionId) throws AdminException {
- final ModelNode request = buildEngineRequest("terminate-transaction",
"xid", transactionId);//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"terminate-transaction", "xid", transactionId);//$NON-NLS-1$
if (request == null) {
return;
}
@@ -662,20 +772,20 @@
return Collections.emptyList();
}
- private List<String> getEngines(ModelControllerClient client) {
+ public List<String> getTransports() {
DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
final ModelNode request;
try {
builder.addNode("subsystem", "teiid"); //$NON-NLS-1$
//$NON-NLS-2$
- builder.operationName("read-children-names");
- builder.addProperty("child-type", "query-engine");
+ builder.setOperationName("read-children-names");
+ builder.addProperty("child-type", "transport");
request = builder.buildRequest();
} catch (OperationFormatException e) {
throw new IllegalStateException("Failed to build operation", e);
}
try {
- ModelNode outcome = client.execute(request);
+ ModelNode outcome = this.connection.execute(request);
if (Util.isSuccess(outcome)) {
return Util.getList(outcome);
}
@@ -685,41 +795,12 @@
return Collections.emptyList();
}
- private ModelNode buildEngineRequest(String operationName, String... params) {
- ModelNode composite = new ModelNode();
- composite.get("operation").set("composite");
- composite.get("address").setEmptyList();
- ModelNode steps = composite.get("steps");
-
- List<String> engines = getEngines(this.connection);
-
- for (String engine:engines) {
- DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
- final ModelNode request;
- try {
- builder.addNode("subsystem", "teiid"); //$NON-NLS-1$
//$NON-NLS-2$
- builder.addNode("query-engine", engine); //$NON-NLS-1$
//$NON-NLS-2$
- builder.operationName(operationName);
- request = builder.buildRequest();
- if (params != null && params.length % 2 == 0) {
- for (int i = 0; i < params.length; i+=2) {
- builder.addProperty(params[i], params[i+1]);
- }
- }
- steps.add(request);
- } catch (OperationFormatException e) {
- throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
- }
- }
- return composite;
- }
-
private ModelNode buildRequest(String subsystem, String operationName, String...
params) {
DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
final ModelNode request;
try {
builder.addNode("subsystem", subsystem); //$NON-NLS-1$
//$NON-NLS-2$
- builder.operationName(operationName);
+ builder.setOperationName(operationName);
request = builder.buildRequest();
if (params != null && params.length % 2 == 0) {
for (int i = 0; i < params.length; i+=2) {
@@ -804,12 +885,6 @@
}
@Override
- public void markDataSourceAvailable(String jndiName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
String targetVDBName, int targetVDBVersion)
throws AdminException {
Modified: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-10-20
15:37:18 UTC (rev 3573)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -220,6 +220,10 @@
this.translators.getMap().put(t.getName(), t);
}
+ public boolean isOverideTranslator(String name) {
+ return this.translators.getMap().containsKey(name);
+ }
+
@Override
public String getDescription() {
return this.description;
Modified: branches/as7/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- branches/as7/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2011-10-20
15:37:18 UTC (rev 3573)
+++ branches/as7/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -413,11 +413,4 @@
@Doc(text = "method name") String method) {
help.help(method);
}
-
- @Doc(text = "Tell the engine that the given source is available. Pending dynamic
vdb metadata loads will be resumed.")
- public static void markDataSourceAvailable(
- @Doc(text = "jndi name") String name) throws AdminException {
- getAdmin().markDataSourceAvailable(name);
- }
-
}
Modified: branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-10-20
15:37:18 UTC (rev 3573)
+++ branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -208,7 +208,15 @@
public void setSourceRequired(boolean value) {
this.sourceRequired = value;
- }
+ }
+
+ /**
+ * Flag to determine between if a underlying connection is a data source or
connection-factory
+ * @return false
+ */
+ public boolean isJDBCSource() {
+ return false;
+ }
/**
* Obtain a reference to the default LanguageFactory that can be used to construct
Modified:
branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
---
branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-10-20
15:37:18 UTC (rev 3573)
+++
branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -224,6 +224,11 @@
return true;
}
+ @Override
+ public boolean isJDBCSource() {
+ return true;
+ }
+
@Override
public ResultSetExecution createResultSetExecution(QueryExpression command,
ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn)
throws TranslatorException {
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-10-20
15:37:18 UTC (rev 3573)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -31,6 +31,7 @@
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ServiceLoader;
+import java.util.concurrent.Executor;
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkManager;
@@ -66,6 +67,7 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.deployers.SystemVDBDeployer;
import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.dqp.internal.process.AuthorizationValidator;
import org.teiid.dqp.internal.process.CachedResults;
@@ -190,6 +192,18 @@
VDBRepositoryService vdbRepositoryService = new
VDBRepositoryService(vdbRepository);
newControllers.add(target.addService(TeiidServiceNames.VDB_REPO,
vdbRepositoryService).install());
+ // VDB Status manager
+ final VDBStatusChecker statusChecker = new VDBStatusChecker(vdbRepository);
+ ValueService<VDBStatusChecker> statusService = new
ValueService<VDBStatusChecker>(new
org.jboss.msc.value.Value<VDBStatusChecker>() {
+ @Override
+ public VDBStatusChecker getValue() throws IllegalStateException,
IllegalArgumentException {
+ return statusChecker;
+ }
+ });
+ ServiceBuilder<VDBStatusChecker> statusBuilder =
target.addService(TeiidServiceNames.VDB_STATUS_CHECKER, statusService);
+
statusBuilder.addDependency(TeiidServiceNames.executorServiceName(asyncThreadPoolName),
Executor.class, statusChecker.getExecutorInjector());
+ newControllers.add(statusBuilder.install());
+
// System VDB Service
SystemVDBDeployer systemVDB = new SystemVDBDeployer();
systemVDB.setVDBRepository(vdbRepository);
@@ -307,7 +321,7 @@
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));
+ processorTarget.addDeploymentProcessor(Phase.INSTALL,
Phase.INSTALL_WAR_DEPLOYMENT|0x0001, new VDBDeployer(translatorRepo, asyncThreadPoolName,
statusChecker));
}
}, OperationContext.Stage.RUNTIME);
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-10-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -39,8 +39,9 @@
public static ServiceName CACHE_RESULTSET = ServiceName.JBOSS.append("teiid",
"cache", "resultset"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public static ServiceName CACHE_PREPAREDPLAN =
ServiceName.JBOSS.append("teiid", "cache", "prepared-plan");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public static ServiceName OBJECT_REPLICATOR =
ServiceName.JBOSS.append("teiid", "object-replicator"); //$NON-NLS-1$
//$NON-NLS-2$
+ public static ServiceName VDB_STATUS_CHECKER =
ServiceName.JBOSS.append("teiid", "vdb-status-checker"); //$NON-NLS-1$
//$NON-NLS-2$
+ public static ServiceName DS_LISTENER_BASE = ServiceName.JBOSS.append("teiid",
"ds-listener"); //$NON-NLS-1$ //$NON-NLS-2$
-
public static ServiceName translatorServiceName(String name) {
return ServiceName.of(TRANSLATOR_BASE, name);
}
@@ -56,4 +57,8 @@
public static ServiceName transportServiceName(String name) {
return ServiceName.of(TRANSPORT_BASE, name);
}
+
+ public static ServiceName dsListenerServiceName(String name) {
+ return ServiceName.of(DS_LISTENER_BASE, name);
+ }
}
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-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -47,6 +47,7 @@
import org.jboss.msc.service.ServiceTarget;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.deployers.TranslatorUtil;
+import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -116,6 +117,7 @@
TranslatorService translatorService = new TranslatorService(metadata);
ServiceBuilder<VDBTranslatorMetaData> builder =
target.addService(TeiidServiceNames.translatorServiceName(metadata.getName()),
translatorService);
builder.addDependency(TeiidServiceNames.TRANSLATOR_REPO,
TranslatorRepository.class, translatorService.repositoryInjector);
+ builder.addDependency(TeiidServiceNames.VDB_STATUS_CHECKER,
VDBStatusChecker.class, translatorService.statusCheckerInjector);
newControllers.add(builder.setInitialMode(ServiceController.Mode.ACTIVE).install());
added = true;
}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorService.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorService.java 2011-10-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorService.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -28,13 +28,15 @@
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
+import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
class TranslatorService implements Service<VDBTranslatorMetaData> {
private VDBTranslatorMetaData translator;
final InjectedValue<TranslatorRepository> repositoryInjector = new
InjectedValue<TranslatorRepository>();
-
+ final InjectedValue<VDBStatusChecker> statusCheckerInjector = new
InjectedValue<VDBStatusChecker>();
+
public TranslatorService(VDBTranslatorMetaData translator) {
this.translator = translator;
}
@@ -42,11 +44,13 @@
@Override
public void start(StartContext context) throws StartException {
this.repositoryInjector.getValue().addTranslatorMetadata(this.translator.getName(),
this.translator);
+ this.statusCheckerInjector.getValue().translatorAdded(this.translator.getName());
}
@Override
public void stop(StopContext context) {
this.repositoryInjector.getValue().removeTranslatorMetadata(this.translator.getName());
+ this.statusCheckerInjector.getValue().translatorRemoved(this.translator.getName());
}
@Override
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-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -43,7 +43,7 @@
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.naming.ManagedReferenceFactory;
-import org.jboss.as.naming.NamingStore;
+import org.jboss.as.naming.ServiceBasedNamingStore;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.as.naming.service.BinderService;
import org.jboss.as.network.SocketBinding;
@@ -200,7 +200,7 @@
final BinderService embedded = new BinderService(bindInfo.getBindName());
final ServiceBuilder<?> embeddedBinderBuilder =
target.addService(bindInfo.getBinderServiceName(), embedded);
embeddedBinderBuilder.addDependency(referenceFactoryServiceName,
ManagedReferenceFactory.class, embedded.getManagedObjectInjector());
- embeddedBinderBuilder.addDependency(bindInfo.getParentContextServiceName(),
NamingStore.class, embedded.getNamingStoreInjector());
+ embeddedBinderBuilder.addDependency(bindInfo.getParentContextServiceName(),
ServiceBasedNamingStore.class, embedded.getNamingStoreInjector());
embeddedBinderBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
newControllers.add(referenceBuilder.install());
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-10-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -22,6 +22,8 @@
package org.teiid.jboss;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.List;
import java.util.concurrent.Executor;
@@ -33,10 +35,11 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.modules.Module;
-import org.jboss.msc.service.ServiceBuilder;
+import org.jboss.msc.service.*;
import org.jboss.msc.service.ServiceBuilder.DependencyType;
-import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceController.Mode;
+import org.jboss.msc.service.ServiceController.State;
+import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
@@ -44,23 +47,28 @@
import org.teiid.deployers.TeiidAttachments;
import org.teiid.deployers.UDFMetaData;
import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
+import org.teiid.jboss.VDBService.TranslatorNotFoundException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.query.ObjectReplicator;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.services.BufferServiceImpl;
+import org.teiid.translator.ExecutionFactory;
class VDBDeployer implements DeploymentUnitProcessor {
private static final String JAVA_CONTEXT = "java:/"; //$NON-NLS-1$
private TranslatorRepository translatorRepository;
private String asyncThreadPoolName;
+ private VDBStatusChecker vdbStatusChecker;
- public VDBDeployer (TranslatorRepository translatorRepo, String poolName) {
+ public VDBDeployer (TranslatorRepository translatorRepo, String poolName,
VDBStatusChecker vdbStatusChecker) {
this.translatorRepository = translatorRepo;
this.asyncThreadPoolName = poolName;
+ this.vdbStatusChecker = vdbStatusChecker;
}
public void deploy(final DeploymentPhaseContext context) throws
DeploymentUnitProcessingException {
@@ -69,7 +77,7 @@
return;
}
final String deploymentName = deploymentUnit.getName();
- VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
+ final VDBMetaData deployment =
deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
// check to see if there is old vdb already deployed.
final ServiceController<?> controller =
context.getServiceRegistry().getService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()));
@@ -119,18 +127,38 @@
// build a VDB service
ArrayList<String> unAvailableDS = new ArrayList<String>();
VDBService vdb = new VDBService(deployment);
- ServiceBuilder<VDBMetaData> vdbService =
context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()), vdb);
+ final ServiceBuilder<VDBMetaData> vdbService =
context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()), vdb);
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
for (String sourceName:model.getSourceNames()) {
- //TODO: need to make the service as dependency; otherwise dynamic vdbs will not work
correctly.
- //vdbService.addDependency(ServiceName.JBOSS.append("data-source",
model.getSourceConnectionJndiName(sourceName))); //$NON-NLS-1$
if (!isSourceAvailable(model.getSourceConnectionJndiName(sourceName))) {
unAvailableDS.add(model.getSourceConnectionJndiName(sourceName));
}
}
}
+ // add dependencies to data-sources
+ dataSourceDependencies(deployment, new DependentServices() {
+ @Override
+ public void serviceFound(String dsName, ServiceName svcName) {
+ DataSourceListener dsl = new DataSourceListener(dsName, svcName,
vdbStatusChecker);
+ ServiceBuilder<DataSourceListener> sb =
context.getServiceTarget().addService(TeiidServiceNames.dsListenerServiceName(dsName),
dsl);
+ sb.addDependency(svcName);
+ sb.setInitialMode(Mode.PASSIVE).install();
+ }
+ });
+
// adding the translator services is redundant, however if one is removed then it is an
issue.
+ for (Model model:deployment.getModels()) {
+ List<String> sourceNames = model.getSourceNames();
+ for (String sourceName:sourceNames) {
+ String translatorName = model.getSourceTranslatorName(sourceName);
+ if (!deployment.isOverideTranslator(translatorName)) {
+ vdbService.addDependency(TeiidServiceNames.translatorServiceName(translatorName));
+ }
+ }
+ }
+
+ //override translators (if any)
for (Translator t: deployment.getOverrideTranslators()) {
VDBTranslatorMetaData data = (VDBTranslatorMetaData)t;
String type = data.getType();
@@ -149,13 +177,79 @@
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("vdb-inactive", deployment.getName(),
deployment.getVersion(), unAvailableDS)); //$NON-NLS-1$
}
}
+
+ private void dataSourceDependencies(VDBMetaData deployment, DependentServices
svcListener) throws DeploymentUnitProcessingException {
+
+ for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
+ for (String sourceName:model.getSourceNames()) {
+ String translatorName = model.getSourceTranslatorName(sourceName);
+ if (deployment.isOverideTranslator(translatorName)) {
+ VDBTranslatorMetaData translator = deployment.getTranslator(translatorName);
+ translatorName = translator.getType();
+ }
+
+ boolean jdbcSource = true;
+ try {
+ ExecutionFactory ef = VDBService.getExecutionFactory(translatorName, new
TranslatorRepository(), this.translatorRepository, deployment, new
IdentityHashMap<Translator, ExecutionFactory<Object, Object>>(), new
HashSet<String>());
+ jdbcSource = ef.isJDBCSource();
+ } catch (TranslatorNotFoundException e) {
+ if (e.getCause() != null) {
+ throw new DeploymentUnitProcessingException(e.getCause());
+ }
+ throw new DeploymentUnitProcessingException(e.getMessage());
+ }
+ // Need to make the data source service as dependency; otherwise dynamic vdbs will
not work correctly.
+ String dsName = model.getSourceConnectionJndiName(sourceName);
+ ServiceName svcName = ServiceName.JBOSS.append("data-source",
getJndiName(dsName)); //$NON-NLS-1$
+ if (!jdbcSource) {
+ // TODO: add service dependency on connection-factory (this is pending in AS7)
+ svcName = ServiceName.JBOSS.append("resource-adaptor",
getJndiName(dsName)); //$NON-NLS-1$
+ }
+
+ svcListener.serviceFound(dsName, svcName);
+ }
+ }
+ }
+
+ interface DependentServices {
+ void serviceFound(String dsName, ServiceName svc);
+ }
+
+ static class DataSourceListener implements Service<DataSourceListener>{
+ private VDBStatusChecker vdbStatusChecker;
+ private String dsName;
+ private ServiceName svcName;
+
+ public DataSourceListener(String dsName, ServiceName svcName, VDBStatusChecker checker)
{
+ this.dsName = dsName;
+ this.svcName = svcName;
+ this.vdbStatusChecker = checker;
+ }
+
+ public DataSourceListener getValue() throws
IllegalStateException,IllegalArgumentException {
+ return this;
+ }
+ @Override
+ public void start(StartContext context) throws StartException {
+ ServiceController s =
context.getController().getServiceContainer().getService(this.svcName);
+ if (s != null) {
+ this.vdbStatusChecker.dataSourceAdded(this.dsName);
+ }
+ }
+
+ @Override
+ public void stop(StopContext context) {
+ ServiceController s =
context.getController().getServiceContainer().getService(this.svcName);
+ if (s.getMode().equals(Mode.REMOVE) || s.getState().equals(State.STOPPING)) {
+ this.vdbStatusChecker.dataSourceRemoved(this.dsName);
+ }
+ }
+ }
+
private boolean isSourceAvailable(String name) {
- String jndiName = name;
- if (!name.startsWith(JAVA_CONTEXT)) {
- jndiName = JAVA_CONTEXT + jndiName;
- }
+ String jndiName = getJndiName(name);
try {
InitialContext ic = new InitialContext();
try {
@@ -169,6 +263,14 @@
return false;
}
return true;
+ }
+
+ private String getJndiName(String name) {
+ String jndiName = name;
+ if (!name.startsWith(JAVA_CONTEXT)) {
+ jndiName = JAVA_CONTEXT + jndiName;
+ }
+ return jndiName;
}
@Override
@@ -177,12 +279,25 @@
return;
}
- VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
+ final VDBMetaData deployment =
deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
final ServiceController<?> controller =
deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()));
if (controller != null) {
VDBService vdbService = (VDBService)controller.getService();
vdbService.undeployInProgress();
+ try {
+ dataSourceDependencies(deployment, new DependentServices() {
+ @Override
+ public void serviceFound(String dsName, ServiceName svcName) {
+ ServiceController<?> controller =
deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.dsListenerServiceName(dsName));
+ if (controller != null) {
+ controller.setMode(ServiceController.Mode.REMOVE);
+ }
+ }
+ });
+ } catch (DeploymentUnitProcessingException e) {
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, e,
IntegrationPlugin.Util.getString("vdb-undeploy-failed", deployment.getName(),
deployment.getVersion())); //$NON-NLS-1$
+ }
controller.setMode(ServiceController.Mode.REMOVE);
}
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-10-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -234,24 +234,31 @@
String name = model.getSourceTranslatorName(source);
ConnectorManager cm = new ConnectorManager(name,
model.getSourceConnectionJndiName(source));
- ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo,
deployment, map, new HashSet<String>());
- cm.setExecutionFactory(ef);
- cm.setModelName(model.getName());
- cmr.addConnectorManager(source, cm);
+ try {
+ ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo,
getTranslatorRepository(), deployment, map, new HashSet<String>());
+ cm.setExecutionFactory(ef);
+ cm.setModelName(model.getName());
+ cmr.addConnectorManager(source, cm);
+ } catch (TranslatorNotFoundException e) {
+ if (e.getCause() != null) {
+ throw new StartException(e.getCause());
+ }
+ throw new StartException(e.getMessage());
+ }
}
}
}
- private ExecutionFactory<Object, Object> getExecutionFactory(String name,
TranslatorRepository repo, VDBMetaData deployment, IdentityHashMap<Translator,
ExecutionFactory<Object, Object>> map, HashSet<String> building) throws
StartException {
+ static ExecutionFactory<Object, Object> getExecutionFactory(String name,
TranslatorRepository vdbRepo, TranslatorRepository repo, VDBMetaData deployment,
IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map,
HashSet<String> building) throws TranslatorNotFoundException {
if (!building.add(name)) {
- throw new
StartException(RuntimePlugin.Util.getString("recursive_delegation",
deployment.getName(), deployment.getVersion(), building)); //$NON-NLS-1$
+ throw new
TranslatorNotFoundException(RuntimePlugin.Util.getString("recursive_delegation",
deployment.getName(), deployment.getVersion(), building)); //$NON-NLS-1$
}
- VDBTranslatorMetaData translator = repo.getTranslatorMetaData(name);
+ VDBTranslatorMetaData translator = vdbRepo.getTranslatorMetaData(name);
if (translator == null) {
- translator = getTranslatorRepository().getTranslatorMetaData(name);
+ translator = repo.getTranslatorMetaData(name);
}
if (translator == null) {
- throw new
StartException(RuntimePlugin.Util.getString("translator_not_found",
deployment.getName(), deployment.getVersion(), name)); //$NON-NLS-1$
+ throw new
TranslatorNotFoundException(RuntimePlugin.Util.getString("translator_not_found",
deployment.getName(), deployment.getVersion(), name)); //$NON-NLS-1$
}
try {
ExecutionFactory<Object, Object> ef = map.get(translator);
@@ -261,7 +268,7 @@
DelegatingExecutionFactory delegator = (DelegatingExecutionFactory)ef;
String delegateName = delegator.getDelegateName();
if (delegateName != null) {
- ExecutionFactory<Object, Object> delegate = getExecutionFactory(delegateName,
repo, deployment, map, building);
+ ExecutionFactory<Object, Object> delegate = getExecutionFactory(delegateName,
vdbRepo, repo, deployment, map, building);
((DelegatingExecutionFactory) ef).setDelegate(delegate);
}
}
@@ -269,7 +276,7 @@
}
return ef;
} catch(TeiidException e) {
- throw new StartException(e);
+ throw new TranslatorNotFoundException(e);
}
}
@@ -527,4 +534,14 @@
throw new AdminProcessingException(e);
}
}
+
+ @SuppressWarnings("serial")
+ static class TranslatorNotFoundException extends TeiidException {
+ public TranslatorNotFoundException(String msg) {
+ super(msg);
+ }
+ public TranslatorNotFoundException(Throwable t) {
+ super(t);
+ }
+ }
}
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-20
15:37:18 UTC (rev 3573)
+++
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-10-20
17:09:57 UTC (rev 3574)
@@ -62,6 +62,7 @@
wrong_protocol=Wrong type of protocol supplied
socket_binding_not_defined=Socket binding not specified for transport {0}; only embedded
access is granted.
embedded_enabled=Teiid Embedded transport enabled.
+vdb-undeploy-failed=error during the undeploy of vdb {0}.{1}
# subsystem description
teiid.add = Add the Teiid Subsystem
Modified: branches/as7/pom.xml
===================================================================
--- branches/as7/pom.xml 2011-10-20 15:37:18 UTC (rev 3573)
+++ branches/as7/pom.xml 2011-10-20 17:09:57 UTC (rev 3574)
@@ -10,7 +10,7 @@
<properties>
<ant.version>1.7.0</ant.version>
<
site.url>http://www.jboss.org/teiid</site.url>
- <jbossas-version>7.0.1.Final</jbossas-version>
+ <jbossas-version>7.1.0.Alpha1-SNAPSHOT</jbossas-version>
</properties>
<scm>
<
connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</con...
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-10-20
15:37:18 UTC (rev 3573)
+++
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-10-20
17:09:57 UTC (rev 3574)
@@ -22,8 +22,9 @@
package org.teiid.deployers;
import java.util.LinkedList;
+import java.util.concurrent.Executor;
-import org.jboss.util.threadpool.ThreadPool;
+import org.jboss.msc.value.InjectedValue;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -36,14 +37,14 @@
public class VDBStatusChecker {
- private static final String JAVA_CONTEXT = "java:"; //$NON-NLS-1$
+ private static final String JAVA_CONTEXT = "java:/"; //$NON-NLS-1$
private VDBRepository vdbRepository;
- private ThreadPool threadPool;
+ private final InjectedValue<Executor> executorInjector = new
InjectedValue<Executor>();
- public VDBStatusChecker(VDBRepository vdbRepository, ThreadPool threadPool) {
+ public VDBStatusChecker(VDBRepository vdbRepository) {
this.vdbRepository = vdbRepository;
- this.threadPool = threadPool;
}
+
public void translatorAdded(String translatorName) {
resourceAdded(translatorName, true);
}
@@ -113,7 +114,7 @@
if (!runnables.isEmpty()) {
//the task themselves will set the status on completion/failure
for (Runnable runnable : runnables) {
- this.threadPool.run(runnable);
+ getExecutor().execute(runnable);
}
} else if (valid) {
vdb.setStatus(VDB.Status.ACTIVE);
@@ -140,7 +141,7 @@
msg = RuntimePlugin.Util.getString("translator_not_found",
vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName));
//$NON-NLS-1$
}
else {
- msg = RuntimePlugin.Util.getString("datasource_not_found",
vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName));
//$NON-NLS-1$
+ msg = RuntimePlugin.Util.getString("datasource_not_found",
vdb.getName(), vdb.getVersion(), resourceName); //$NON-NLS-1$
}
model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
@@ -169,4 +170,12 @@
}
return null;
}
+
+ public InjectedValue<Executor> getExecutorInjector(){
+ return this.executorInjector;
+ }
+
+ private Executor getExecutor() {
+ return this.executorInjector.getValue();
+ }
}