Author: shawkins
Date: 2012-06-08 09:49:43 -0400 (Fri, 08 Jun 2012)
New Revision: 4169
Added:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TeiidExecutor.java
trunk/runtime/src/main/java/org/teiid/runtime/DoNothingSecurityHelper.java
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
trunk/runtime/src/main/java/org/teiid/runtime/ReplicatedCacheImpl.java
trunk/runtime/src/main/java/org/teiid/runtime/WorkManagerTeiidExecutor.java
trunk/runtime/src/main/java/org/teiid/services/AbstractEventDistributorFactoryService.java
trunk/runtime/src/main/java/org/teiid/services/InternalEventDistributorFactory.java
Removed:
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/
trunk/runtime/src/main/java/org/teiid/logging/
trunk/runtime/src/main/java/org/teiid/templates/
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
trunk/client/src/main/java/org/teiid/jdbc/TeiidDriver.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/EventDistributorFactoryService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java
trunk/runtime/pom.xml
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCProceduresSchema.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestStats.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java
trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
TEIID-2062 initial refactoring of FakeServer for general use
Modified: trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2012-06-05 23:07:38 UTC
(rev 4168)
+++ trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2012-06-08 13:49:43 UTC
(rev 4169)
@@ -67,7 +67,7 @@
@SuppressWarnings("nls")
public class AdminFactory {
private static final Logger LOGGER = Logger.getLogger(AdminFactory.class.getName());
- private static Set<String> optionalProps = new
HashSet<String>(Arrays.asList("connection-url", "password",
"check-valid-connection-sql", "pool-prefill",
"max-pool-size", "min-pool-size"));
+ private static Set<String> optionalProps = new
HashSet<String>(Arrays.asList("password",
"check-valid-connection-sql", "pool-prefill",
"max-pool-size", "min-pool-size"));
private static AdminFactory INSTANCE = new AdminFactory();
public static AdminFactory getInstance() {
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-05 23:07:38
UTC (rev 4168)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-08 13:49:43
UTC (rev 4169)
@@ -22,6 +22,7 @@
package org.teiid.adminapi.impl;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -141,15 +142,12 @@
}
/**
- * This method required to make the JNDI assignment on the model work; if not persistent
Management framework
- * treating "models" as ReadOnly property. The actual assignment is done in
the VDBMetaDataClassInstancefactory
* @param models
*/
- public void setModels(List<Model> models) {
+ public void setModels(Collection<ModelMetaData> models) {
this.models.getMap().clear();
- for (Model obj : models) {
- ModelMetaData model = (ModelMetaData) obj;
- addModel(model);
+ for (ModelMetaData obj : models) {
+ addModel(obj);
}
}
@@ -206,7 +204,6 @@
if (!getValidityErrors().isEmpty()) {
return false;
}
-
if (getModels().isEmpty()) {
return false;
}
@@ -216,11 +213,6 @@
if (resourceNames.isEmpty()) {
return false;
}
- for (String sourceName:resourceNames) {
- if (m.getSourceConnectionJndiName(sourceName) == null) {
- return false;
- }
- }
}
}
return true;
Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-06-05 23:07:38 UTC
(rev 4168)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-06-08 13:49:43 UTC
(rev 4169)
@@ -427,6 +427,19 @@
return false;
}
+ /**
+ *
+ * @param varargs
+ * @return true if the value was successfully set.
+ */
+ public boolean setVarArgs(boolean varargs) {
+ if (this.inParameters != null && this.inParameters.size() > 0) {
+ inParameters.get(inParameters.size() - 1).setVarArg(varargs);
+ return true;
+ }
+ return false;
+ }
+
public void setParent(Schema parent) {
this.parent = parent;
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidDriver.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidDriver.java 2012-06-05 23:07:38 UTC
(rev 4168)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidDriver.java 2012-06-08 13:49:43 UTC
(rev 4169)
@@ -22,7 +22,6 @@
package org.teiid.jdbc;
-import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
@@ -78,14 +77,7 @@
return INSTANCE;
}
- /**
- * Should be a singleton and only constructed in {@link #getInstance}.
- */
- public TeiidDriver() {
- // this is not singleton, if you want singleton make this private.
- }
-
- public Connection connect(String url, Properties info) throws SQLException {
+ public ConnectionImpl connect(String url, Properties info) throws SQLException {
ConnectionType conn = JDBCURL.acceptsUrl(url);
if (conn == null) {
return null;
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -23,13 +23,36 @@
package org.teiid.dqp.internal.datamgr;
import java.io.Serializable;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.TeiidException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.translator.ExecutionFactory;
+
public class ConnectorManagerRepository implements Serializable{
+
+ @SuppressWarnings("serial")
+ public static class ConnectorManagerException extends TeiidException {
+ public ConnectorManagerException(String msg) {
+ super(msg);
+ }
+ public ConnectorManagerException(Throwable t) {
+ super(t);
+ }
+ }
+
+ public interface ExecutionFactoryProvider {
+ ExecutionFactory<Object, Object> getExecutionFactory(String name) throws
ConnectorManagerException;
+ }
+
private static final long serialVersionUID = -1611063218178314458L;
-
+
private Map<String, ConnectorManager> repo = new ConcurrentHashMap<String,
ConnectorManager>();
public void addConnectorManager(String connectorName, ConnectorManager mgr) {
@@ -47,4 +70,37 @@
public ConnectorManager removeConnectorManager(String connectorName) {
return this.repo.remove(connectorName);
}
+
+ public void createConnectorManagers(VDBMetaData deployment, ExecutionFactoryProvider
provider) throws ConnectorManagerException {
+ for (ModelMetaData model : deployment.getModelMetaDatas().values()) {
+ List<String> sourceNames = model.getSourceNames();
+ if (sourceNames.size() != new HashSet<String>(sourceNames).size()) {
+ throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31101,
model.getName(), deployment.getName(), deployment.getVersion()));
+ }
+ if (sourceNames.size() > 1 && !model.isSupportsMultiSourceBindings()) {
+ throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31102,
model.getName(), deployment.getName(), deployment.getVersion()));
+ }
+ for (String source:sourceNames) {
+ ConnectorManager cm = getConnectorManager(source);
+ String name = model.getSourceTranslatorName(source);
+ String connection = model.getSourceConnectionJndiName(source);
+ if (cm != null) {
+ if (!cm.getTranslatorName().equals(name)
+ || !cm.getConnectionName().equals(connection)) {
+ throw new
ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31103, source,
deployment.getName(), deployment.getVersion()));
+ }
+ continue;
+ }
+ cm = createConnectorManager(name, connection);
+ ExecutionFactory<Object, Object> ef = provider.getExecutionFactory(name);
+ cm.setExecutionFactory(ef);
+ addConnectorManager(source, cm);
+ }
+ }
+ }
+
+ protected ConnectorManager createConnectorManager(String name,
+ String connection) {
+ return new ConnectorManager(name, connection);
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -179,4 +179,8 @@
return queryTimeout;
}
+ public TeiidExecutor getTeiidExecutor() {
+ return new ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME,
getMaxThreads());
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -179,7 +179,7 @@
}
}
- private ThreadReuseExecutor processWorkerPool;
+ private TeiidExecutor processWorkerPool;
// Resources
private BufferManager bufferManager;
@@ -650,12 +650,12 @@
return chunkSize;
}
- public void start(DQPConfiguration config) {
- this.config = config;
+ public void start(DQPConfiguration theConfig) {
+ this.config = theConfig;
this.authorizationValidator = config.getAuthorizationValidator();
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
- this.processWorkerPool = new
ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
+ this.processWorkerPool = config.getTeiidExecutor();
//we don't want cancellations waiting on normal processing, so they get a
small dedicated pool
//TODO: overflow to the worker pool
Executor timeoutExecutor = ExecutorUtils.newFixedThreadPool(3, "Server Side
Timeout"); //$NON-NLS-1$
Added: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TeiidExecutor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/TeiidExecutor.java
(rev 0)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TeiidExecutor.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+public interface TeiidExecutor extends Executor {
+
+ void execute(final Runnable command);
+
+ WorkerPoolStatisticsMetadata getStats();
+
+ List<Runnable> shutdownNow();
+
+ boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException;
+
+ ScheduledFuture<?> schedule(final Runnable command, long delay,
+ TimeUnit unit);
+
+}
\ No newline at end of file
Property changes on:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TeiidExecutor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -31,7 +31,6 @@
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.Delayed;
-import java.util.concurrent.Executor;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledFuture;
@@ -41,6 +40,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.resource.spi.work.Work;
+
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.core.util.NamedThreadFactory;
import org.teiid.logging.LogConstants;
@@ -70,7 +71,7 @@
* TODO: bounded queuing - we never bothered bounding in the past with our worker pools,
but reasonable
* defaults would be a good idea.
*/
-public class ThreadReuseExecutor implements Executor {
+public class ThreadReuseExecutor implements TeiidExecutor {
public interface PrioritizedRunnable extends Runnable {
@@ -84,7 +85,7 @@
}
- static class RunnableWrapper implements PrioritizedRunnable {
+ public static class RunnableWrapper implements PrioritizedRunnable, Work {
Runnable r;
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
long creationTime;
@@ -125,6 +126,11 @@
public DQPWorkContext getDqpWorkContext() {
return workContext;
}
+
+ @Override
+ public void release() {
+
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -29,7 +29,6 @@
import javax.transaction.xa.Xid;
import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.Transaction;
import org.teiid.adminapi.impl.TransactionMetadata;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-06-05 23:07:38 UTC
(rev 4168)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-06-08 13:49:43 UTC
(rev 4169)
@@ -542,5 +542,8 @@
TEIID31098, //alter imported
TEIID31099, //vdb loading
TEIID31100, //parse exception
+ TEIID31101,
+ TEIID31102,
+ TEIID31103,
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -57,7 +57,6 @@
import org.teiid.events.EventDistributor;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.MetadataRepository;
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -435,6 +435,7 @@
SessionMetadata session = createTemporarySession(context.getUserName(),
"asynch-mat-view-load", context.getDQPWorkContext().getVDB()); //$NON-NLS-1$
session.setSubject(context.getSubject());
session.setSecurityDomain(context.getSession().getSecurityDomain());
+ session.setSecurityContext(context.getSession().getSecurityContext());
DQPWorkContext workContext = new DQPWorkContext();
workContext.setAdmin(true);
DQPWorkContext current = context.getDQPWorkContext();
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -42,8 +42,8 @@
import org.teiid.CommandListener;
import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Session;
import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
@@ -136,7 +136,7 @@
private Subject subject;
private HashSet<Object> dataObjects;
- private Session session;
+ private SessionMetadata session;
private RequestID requestId;
@@ -579,11 +579,11 @@
}
@Override
- public Session getSession() {
+ public SessionMetadata getSession() {
return this.globalState.session;
}
- public void setSession(Session session) {
+ public void setSession(SessionMetadata session) {
this.globalState.session = session;
}
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-06-05 23:07:38
UTC (rev 4168)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-06-08 13:49:43
UTC (rev 4169)
@@ -1018,4 +1018,8 @@
TEIID31096=Canceling query {0} since it has exceeded the timeout of {1} milliseconds.
-TEIID31099=VDB {0} is still loading. Resubmit your query after loading has completed.
\ No newline at end of file
+TEIID31099=VDB {0} is still loading. Resubmit your query after loading has completed.
+
+TEIID31101=Source names are not unique for model {0} in {1}.{2}
+TEIID31102=Multiple sources on non multi-source model {0} in {1}.{2}
+TEIID31103=There are different sources with the name {0} in {1}.{2}
Modified: trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -37,6 +37,7 @@
import org.junit.Test;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.dqp.internal.process.TeiidExecutor;
import org.teiid.dqp.internal.process.ThreadReuseExecutor;
import org.teiid.dqp.internal.process.DQPCore.FutureWork;
@@ -125,7 +126,7 @@
}
@Test(expected=ExecutionException.class) public void testScheduleException() throws
Exception {
- ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5);
//$NON-NLS-1$
+ TeiidExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
ScheduledFuture<?> future = pool.schedule(new Runnable() {
@Override
public void run() {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -52,10 +52,10 @@
import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.dqp.internal.process.TransactionServerImpl;
import org.teiid.dqp.service.TransactionService;
-import org.teiid.events.EventDistributorFactory;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.services.InternalEventDistributorFactory;
import org.teiid.vdb.runtime.VDBKey;
@@ -74,7 +74,7 @@
private final InjectedValue<AuthorizationValidator> authorizationValidatorInjector
= new InjectedValue<AuthorizationValidator>();
private final InjectedValue<SessionAwareCache> preparedPlanCacheInjector = new
InjectedValue<SessionAwareCache>();
private final InjectedValue<SessionAwareCache> resultSetCacheInjector = new
InjectedValue<SessionAwareCache>();
- private final InjectedValue<EventDistributorFactory>
eventDistributorFactoryInjector = new InjectedValue<EventDistributorFactory>();
+ private final InjectedValue<InternalEventDistributorFactory>
eventDistributorFactoryInjector = new
InjectedValue<InternalEventDistributorFactory>();
@Override
public void start(final StartContext context) {
@@ -86,7 +86,7 @@
this.dqpCore.setBufferManager(bufferManagerInjector.getValue());
this.dqpCore.setTransactionService((TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG,
transactionServerImpl, new Class[] {TransactionService.class}, MessageLevel.DETAIL,
Thread.currentThread().getContextClassLoader()));
- this.dqpCore.setEventDistributor(getEventDistributorFactoryInjector().getValue().getEventDistributor());
+ this.dqpCore.setEventDistributor(getEventDistributorFactoryInjector().getValue().getReplicatedEventDistributor());
this.dqpCore.setResultsetCache(getResultSetCacheInjector().getValue());
this.dqpCore.setPreparedPlanCache(getPreparedPlanCacheInjector().getValue());
this.dqpCore.start(this);
@@ -197,7 +197,7 @@
return workManagerInjector;
}
- public InjectedValue<EventDistributorFactory> getEventDistributorFactoryInjector()
{
+ public InjectedValue<InternalEventDistributorFactory>
getEventDistributorFactoryInjector() {
return eventDistributorFactoryInjector;
}
}
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/EventDistributorFactoryService.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/EventDistributorFactoryService.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/EventDistributorFactoryService.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -21,81 +21,39 @@
*/
package org.teiid.jboss;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
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.InjectedValue;
-import org.teiid.deployers.EventDistributorImpl;
import org.teiid.deployers.VDBRepository;
-import org.teiid.events.EventDistributor;
-import org.teiid.events.EventDistributorFactory;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
import org.teiid.query.ObjectReplicator;
+import org.teiid.services.AbstractEventDistributorFactoryService;
+import org.teiid.services.InternalEventDistributorFactory;
-public class EventDistributorFactoryService implements
Service<EventDistributorFactory> {
+public class EventDistributorFactoryService extends
AbstractEventDistributorFactoryService implements
Service<InternalEventDistributorFactory> {
InjectedValue<ObjectReplicator> objectReplicatorInjector = new
InjectedValue<ObjectReplicator>();
InjectedValue<VDBRepository> vdbRepositoryInjector = new
InjectedValue<VDBRepository>();
- private EventDistributor replicatableEventDistributor;
- private EventDistributor eventDistributorProxy;
-
+
@Override
- public EventDistributorFactory getValue() throws IllegalStateException,
IllegalArgumentException {
- return new EventDistributorFactory() {
- @Override
- public EventDistributor getEventDistributor() {
- return eventDistributorProxy;
- }
- };
- }
-
- @Override
public void start(StartContext context) throws StartException {
- final EventDistributor ed = new EventDistributorImpl() {
- @Override
- public VDBRepository getVdbRepository() {
- return vdbRepositoryInjector.getValue();
- }
- };
-
- // this instance is by use of teiid internally; only invokes the remote instances
- if (objectReplicatorInjector.getValue() != null) {
- try {
- this.replicatableEventDistributor =
objectReplicatorInjector.getValue().replicate("$TEIID_ED$",
EventDistributor.class, ed, 0); //$NON-NLS-1$
- } catch (Exception e) {
- LogManager.logError(LogConstants.CTX_RUNTIME, e,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50004, this));
- }
- LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50003));
- }
- else {
- LogManager.logDetail(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("distributed_cache_not_enabled"));
//$NON-NLS-1$
- }
-
- // for external client to call. invokes local instance and remote ones too.
- this.eventDistributorProxy =
(EventDistributor)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[] {EventDistributor.class}, new InvocationHandler() {
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- method.invoke(ed, args);
- if (replicatableEventDistributor != null) {
- method.invoke(replicatableEventDistributor, args);
- }
- return null;
- }
- });
+ start();
}
@Override
public void stop(StopContext context) {
- if (objectReplicatorInjector.getValue() != null &&
this.replicatableEventDistributor != null) {
- objectReplicatorInjector.getValue().stop(this.replicatableEventDistributor);
- this.replicatableEventDistributor = null;
- }
+ stop();
}
+
+ @Override
+ protected ObjectReplicator getObjectReplicator() {
+ return objectReplicatorInjector.getValue();
+ }
+
+ @Override
+ protected VDBRepository getVdbRepository() {
+ return vdbRepositoryInjector.getValue();
+ }
+
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -43,7 +43,6 @@
TEIID50001,
TEIID50002,
TEIID50003,
- TEIID50004,
TEIID50005,
TEIID50006,
TEIID50007, // failed to load module
@@ -66,10 +65,7 @@
TEIID50026, // VDB undeployed
TEIID50029, // dynamic metadata loaded
TEIID50030,
- TEIID50031, // multiple sources, non-multisource
TEIID50032, // duplicate VDB
- TEIID50033, // duplicate source name in vdb
- TEIID50034, // Source name mismatch
TEIID50035, // translator not found
TEIID50036,
TEIID50037, // odbc enabled
@@ -100,7 +96,6 @@
TEIID50070,
TEIID50071,
TEIID50072,
- TEIID50073,
TEIID50074,
TEIID50075,
TEIID50076,
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -22,10 +22,8 @@
package org.teiid.jboss;
import java.security.Principal;
-import java.security.acl.Group;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
@@ -48,61 +46,32 @@
}
@Override
- protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains, boolean onlyallowPassthrough)
+ protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains)
throws LoginException {
- return authenticateUser(userName, credentials, applicationName, domains,
securityDomainMap, onlyallowPassthrough);
- }
-
- private TeiidLoginContext authenticateUser(String username, final Credentials
credential, String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, boolean onlyallowPassthrough)
- throws LoginException {
-
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[]
{"authenticateUser", username, applicationName}); //$NON-NLS-1$
-
- final String baseUsername = getBaseUsername(username);
+ final String baseUsername = getBaseUsername(userName);
- if (onlyallowPassthrough) {
- for (String domain:getDomainsForUser(domains, username)) {
- Subject existing = this.securityHelper.getSubjectInContext(domain);
- if (existing != null) {
- return new TeiidLoginContext(getUserName(existing)+AT+domain, existing, domain,
this.securityHelper.getSecurityContext(domain));
- }
- }
- throw new
LoginException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50073));
- }
-
-
// If username specifies a domain (user@domain) only that domain is authenticated
against.
// If username specifies no domain, then all domains are tried in order.
- for (String domain:getDomainsForUser(domains, username)) {
+ for (String domain:getDomainsForUser(domains, userName)) {
// this is the configured login for teiid
SecurityDomainContext securityDomainContext = securityDomainMap.get(domain);
if (securityDomainContext != null) {
AuthenticationManager authManager =
securityDomainContext.getAuthenticationManager();
if (authManager != null) {
- Principal userPrincipal = new SimplePrincipal(username);
+ Principal userPrincipal = new SimplePrincipal(userName);
Subject subject = new Subject();
- boolean isValid = authManager.isValid(userPrincipal,
credential==null?null:new String(credential.getCredentialsAsCharArray()), subject);
+ String credString = credentials==null?null:new
String(credentials.getCredentialsAsCharArray());
+ boolean isValid = authManager.isValid(userPrincipal, credString,
subject);
if (isValid) {
- String userName = baseUsername+AT+domain;
- Object securityContext = this.securityHelper.createSecurityContext(domain,
userPrincipal, credential==null?null:new String(credential.getCredentialsAsCharArray()),
subject);
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", username, "\""}); //$NON-NLS-1$
//$NON-NLS-2$
- return new TeiidLoginContext(userName, subject, domain, securityContext);
+ String qualifiedUserName = baseUsername+AT+domain;
+ Object securityContext = this.securityHelper.createSecurityContext(domain,
userPrincipal, credString, subject);
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", userName, "\""}); //$NON-NLS-1$
//$NON-NLS-2$
+ return new TeiidLoginContext(qualifiedUserName, subject, domain,
securityContext);
}
}
}
}
- throw new
LoginException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50072, username ));
+ throw new
LoginException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50072, userName ));
}
-
- private String getUserName(Subject subject) {
- Set<Principal> principals = subject.getPrincipals();
- for (Principal p:principals) {
- if (p instanceof Group) {
- continue;
- }
- return p.getName();
- }
- return null;
- }
-
+
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -22,10 +22,7 @@
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 static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
import java.util.List;
import java.util.Locale;
@@ -44,8 +41,8 @@
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.AttributeAccess.Storage;
-import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.services.path.RelativePathService;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.ServiceBasedNamingStore;
@@ -59,17 +56,17 @@
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.service.ServiceBuilder.DependencyType;
import org.jboss.msc.value.InjectedValue;
import org.teiid.PolicyDecider;
import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.CacheFactory;
import org.teiid.cache.CacheConfiguration.Policy;
-import org.teiid.cache.CacheFactory;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBufferCache;
import org.teiid.deployers.SystemVDBDeployer;
@@ -89,6 +86,7 @@
import org.teiid.query.ObjectReplicator;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.replication.jboss.JGroupsObjectReplicator;
+import org.teiid.services.InternalEventDistributorFactory;
class TeiidAdd extends AbstractAddStepHandler implements DescriptionProvider {
@@ -257,6 +255,9 @@
ServiceBuilder<JGroupsObjectReplicator> serviceBuilder =
target.addService(TeiidServiceNames.OBJECT_REPLICATOR, replicatorService);
serviceBuilder.addDependency(ServiceName.JBOSS.append("jgroups",
"stack", stack), ChannelFactory.class,
replicatorService.channelFactoryInjector); //$NON-NLS-1$ //$NON-NLS-2$
newControllers.add(serviceBuilder.install());
+ LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50003));
+ } else {
+ LogManager.logDetail(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("distributed_cache_not_enabled"));
//$NON-NLS-1$
}
// TODO: remove verbose service by moving the buffer service from runtime project
@@ -274,7 +275,7 @@
EventDistributorFactoryService edfs = new EventDistributorFactoryService();
- ServiceBuilder<EventDistributorFactory> edfsServiceBuilder =
target.addService(TeiidServiceNames.EVENT_DISTRIBUTOR_FACTORY, edfs);
+ ServiceBuilder<InternalEventDistributorFactory> edfsServiceBuilder =
target.addService(TeiidServiceNames.EVENT_DISTRIBUTOR_FACTORY, edfs);
edfsServiceBuilder.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class,
edfs.vdbRepositoryInjector);
edfsServiceBuilder.addDependency(replicatorAvailable?DependencyType.REQUIRED:DependencyType.OPTIONAL,
TeiidServiceNames.OBJECT_REPLICATOR, ObjectReplicator.class,
edfs.objectReplicatorInjector);
newControllers.add(edfsServiceBuilder.install());
@@ -369,7 +370,7 @@
engineBuilder.addDependency(TeiidServiceNames.AUTHORIZATION_VALIDATOR,
AuthorizationValidator.class, engine.getAuthorizationValidatorInjector());
engineBuilder.addDependency(rsCache?DependencyType.REQUIRED:DependencyType.OPTIONAL,
TeiidServiceNames.CACHE_RESULTSET, SessionAwareCache.class,
engine.getResultSetCacheInjector());
engineBuilder.addDependency(TeiidServiceNames.CACHE_PREPAREDPLAN,
SessionAwareCache.class, engine.getPreparedPlanCacheInjector());
- engineBuilder.addDependency(TeiidServiceNames.EVENT_DISTRIBUTOR_FACTORY,
EventDistributorFactory.class, engine.getEventDistributorFactoryInjector());
+ engineBuilder.addDependency(TeiidServiceNames.EVENT_DISTRIBUTOR_FACTORY,
InternalEventDistributorFactory.class, engine.getEventDistributorFactoryInjector());
engineBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
ServiceController<DQPCore> controller = engineBuilder.install();
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -67,6 +67,7 @@
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
+import
org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Datatype;
@@ -240,54 +241,35 @@
return this.vdb;
}
- private void createConnectorManagers(ConnectorManagerRepository cmr,
TranslatorRepository repo, final VDBMetaData deployment) throws StartException {
- IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map = new
IdentityHashMap<Translator, ExecutionFactory<Object, Object>>();
+ private void createConnectorManagers(ConnectorManagerRepository cmr, final
TranslatorRepository repo, final VDBMetaData deployment) throws StartException {
+ final IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map =
new IdentityHashMap<Translator, ExecutionFactory<Object, Object>>();
- for (Model model:deployment.getModels()) {
- List<String> sourceNames = model.getSourceNames();
- if (sourceNames.size() != new HashSet<String>(sourceNames).size()) {
- throw new
StartException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50033,
model.getName(), deployment.getName(), deployment.getVersion()));
- }
- if (sourceNames.size() > 1 && !model.isSupportsMultiSourceBindings()) {
- throw new
StartException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50031,
model.getName(), deployment.getName(), deployment.getVersion()));
- }
- for (String source:sourceNames) {
- ConnectorManager cm = cmr.getConnectorManager(source);
- String name = model.getSourceTranslatorName(source);
- String connection = model.getSourceConnectionJndiName(source);
- if (cm != null) {
- if (!cm.getTranslatorName().equals(name)
- || !cm.getConnectionName().equals(connection)) {
- throw new
StartException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50034, source,
deployment.getName(), deployment.getVersion()));
- }
- continue;
+ try {
+ cmr.createConnectorManagers(deployment, new
ConnectorManagerRepository.ExecutionFactoryProvider() {
+
+ @Override
+ public ExecutionFactory<Object, Object> getExecutionFactory(String name) throws
ConnectorManagerException {
+ return VDBService.getExecutionFactory(name, repo, getTranslatorRepository(),
deployment, map, new HashSet<String>());
}
-
- cm = new ConnectorManager(name, connection);
- try {
- ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo,
getTranslatorRepository(), deployment, map, new HashSet<String>());
- cm.setExecutionFactory(ef);
- cmr.addConnectorManager(source, cm);
- } catch (TranslatorNotFoundException e) {
- if (e.getCause() != null) {
- throw new StartException(IntegrationPlugin.Event.TEIID50035.name(), e.getCause());
- }
- throw new StartException(IntegrationPlugin.Event.TEIID50035.name()+"
"+e.getMessage()); //$NON-NLS-1$
- }
+ });
+ } catch (ConnectorManagerException e) {
+ if (e.getCause() != null) {
+ throw new StartException(IntegrationPlugin.Event.TEIID50035.name()+"
"+e.getMessage(), e.getCause()); //$NON-NLS-1$
}
+ throw new StartException(e.getMessage());
}
}
- static ExecutionFactory<Object, Object> getExecutionFactory(String name,
TranslatorRepository vdbRepo, TranslatorRepository repo, VDBMetaData deployment,
IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map,
HashSet<String> building) throws TranslatorNotFoundException {
+ static ExecutionFactory<Object, Object> getExecutionFactory(String name,
TranslatorRepository vdbRepo, TranslatorRepository repo, VDBMetaData deployment,
IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map,
HashSet<String> building) throws ConnectorManagerException {
if (!building.add(name)) {
- throw new
TranslatorNotFoundException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50076,
deployment.getName(), deployment.getVersion(), building));
+ throw new
ConnectorManagerException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50076,
deployment.getName(), deployment.getVersion(), building));
}
VDBTranslatorMetaData translator = vdbRepo.getTranslatorMetaData(name);
if (translator == null) {
translator = repo.getTranslatorMetaData(name);
}
if (translator == null) {
- throw new
TranslatorNotFoundException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50078,
deployment.getName(), deployment.getVersion(), name));
+ throw new
ConnectorManagerException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50078,
deployment.getName(), deployment.getVersion(), name));
}
try {
ExecutionFactory<Object, Object> ef = map.get(translator);
@@ -311,7 +293,7 @@
}
return ef;
} catch(TeiidException e) {
- throw new TranslatorNotFoundException(e);
+ throw new ConnectorManagerException(e);
}
}
@@ -531,13 +513,4 @@
return policy;
}
- @SuppressWarnings("serial")
- static class TranslatorNotFoundException extends TeiidException {
- public TranslatorNotFoundException(String msg) {
- super(msg);
- }
- public TranslatorNotFoundException(Throwable t) {
- super(t);
- }
- }
}
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-08
13:49:43 UTC (rev 4169)
@@ -33,7 +33,6 @@
TEIID50063=Source with name {0} not found in the Model {1} in VDB {2}.{3}
TEIID50062=Model with name {0} not found in the VDB {1}.{2}
event_distributor_bound=org.teiid.events.EventDistributorFactory is bound to {0} for
manual control of Teiid events.
-TEIID50004=Could not replicate object {0}
TEIID50019=Re-deploying VDB {0}
TEIID50066=Cache system has been shutdown
TEIID50051=Policy {0} not found in VDB {1}.{2}
@@ -65,15 +64,11 @@
TEIID50030=VDB {0}.{1} model "{2}" metadata loaded. End Time: {3}
TEIID50036=VDB {0}.{1} model "{2}" metadata failed to load. Reason:{3}
TEIID50042=error setting state {0}
-TEIID50033=Source names are not unique for model {0} in {1}.{2}
-TEIID50031=Multiple sources on non multi-source model {0} in {1}.{2}
-TEIID50034=There are different sources with the name {0} in {1}.{2}
TEIID50043=Invalid metadata file found at {0}; delete this file and restart server.
TEIID50069=Failed to load module {0}
TEIID50007=Failed to load module {1} for translator {2}
TEIID50088=Failed to load module {0} for UDF in VDB {1}.{2}:{3}
TEIID50072=The username "{0}" and/or password and/or payload token could not be
authenticated by any membership domain.
-TEIID50073 = Passthrough authentication failed. No authentication information found.
TEIID50074=VDB has validity errors; failed to deploy - {0}
TEIID50075=No "path" information found to load the FUNCTION model {0}; FUNCTION
model must have path information.
TEIID50076=For {0}.{1} VDB, recursive delegation {2} found.
Modified:
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java
===================================================================
---
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -100,7 +100,7 @@
jss.setSecurityHelper(ms);
jss.setSecurityDomains(domains);
- TeiidLoginContext c = jss.authenticate("user1", credentials, null,
domains, false); //$NON-NLS-1$ //$NON-NLS-2$
+ TeiidLoginContext c = jss.authenticate("user1", credentials, null,
domains); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("user1@testFile", c.getUserName()); //$NON-NLS-1$
}
@@ -116,7 +116,7 @@
jss.setSecurityHelper(ms);
jss.setSecurityDomains(domains);
- TeiidLoginContext c = jss.authenticate("user1", new
Credentials("pass1".toCharArray()), null, domains, true); //$NON-NLS-1$
//$NON-NLS-2$
+ TeiidLoginContext c = jss.passThroughLogin("user1", domains);
//$NON-NLS-1$ //$NON-NLS-2$
assertEquals("alreadylogged@passthrough", c.getUserName());
//$NON-NLS-1$
}
Modified: trunk/runtime/pom.xml
===================================================================
--- trunk/runtime/pom.xml 2012-06-05 23:07:38 UTC (rev 4168)
+++ trunk/runtime/pom.xml 2012-06-08 13:49:43 UTC (rev 4169)
@@ -68,5 +68,15 @@
<artifactId>connector-api</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-06-05 23:07:38
UTC (rev 4168)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-06-08 13:49:43
UTC (rev 4169)
@@ -110,7 +110,7 @@
VDBMetaData newMergedVDB = new VDBMetaData();
newMergedVDB.setName(this.vdb.getName());
newMergedVDB.setVersion(this.vdb.getVersion());
- newMergedVDB.setModels(this.vdb.getModels());
+ newMergedVDB.setModels(this.vdb.getModelMetaDatas().values());
newMergedVDB.setDataPolicies(this.vdb.getDataPolicies());
newMergedVDB.setDescription(this.vdb.getDescription());
newMergedVDB.setStatus(this.vdb.getStatus());
Added: trunk/runtime/src/main/java/org/teiid/runtime/DoNothingSecurityHelper.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/DoNothingSecurityHelper.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/DoNothingSecurityHelper.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,67 @@
+/*
+ * 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.runtime;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.teiid.security.SecurityHelper;
+
+/**
+ * A {@link SecurityHelper} that does nothing and always assumes that thread
+ * has the proper security context.
+ */
+public final class DoNothingSecurityHelper implements SecurityHelper {
+ @Override
+ public boolean sameSubject(String securityDomain, Object context,
+ Subject subject) {
+ return true;
+ }
+
+ @Override
+ public Subject getSubjectInContext(String securityDomain) {
+ return new Subject();
+ }
+
+ @Override
+ public Object getSecurityContext(String securityDomain) {
+ return new Object();
+ }
+
+ @Override
+ public Object createSecurityContext(String securityDomain, Principal p,
+ Object credentials, Subject subject) {
+ return new Object();
+ }
+
+ @Override
+ public void clearSecurityContext() {
+
+ }
+
+ @Override
+ public Object associateSecurityContext(Object context) {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/runtime/src/main/java/org/teiid/runtime/DoNothingSecurityHelper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,103 @@
+/*
+ * 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.runtime;
+
+import java.util.List;
+
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.TransactionManager;
+
+import org.teiid.dqp.internal.process.DQPConfiguration;
+import org.teiid.dqp.internal.process.TeiidExecutor;
+import org.teiid.dqp.internal.process.ThreadReuseExecutor;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.query.ObjectReplicator;
+import org.teiid.security.SecurityHelper;
+
+public class EmbeddedConfiguration extends DQPConfiguration {
+
+ private SecurityHelper securityHelper;
+ private List<String> securityDomains;
+ private TransactionManager transactionManager;
+ private MetadataStore systemStore;
+ private ObjectReplicator objectReplicator;
+ private WorkManager workManager;
+
+ public SecurityHelper getSecurityHelper() {
+ return securityHelper;
+ }
+ /**
+ * Set the {@link SecurityHelper} that can associate the appropriate SecurityContext
+ * with threads executing Teiid tasks. Will also set the appropriate user/subject
information
+ * on the Teiid contexts. Not required if a {@link WorkManager} is set.
+ *
+ * @param securityHelper
+ */
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
+ }
+ public List<String> getSecurityDomains() {
+ return securityDomains;
+ }
+ public void setSecurityDomains(List<String> securityDomains) {
+ this.securityDomains = securityDomains;
+ }
+ public TransactionManager getTransactionManager() {
+ return transactionManager;
+ }
+ public void setTransactionManager(TransactionManager transactionManager) {
+ this.transactionManager = transactionManager;
+ }
+ public MetadataStore getSystemStore() {
+ return systemStore;
+ }
+ public void setSystemStore(MetadataStore systemStore) {
+ this.systemStore = systemStore;
+ }
+ public ObjectReplicator getObjectReplicator() {
+ return objectReplicator;
+ }
+ public void setObjectReplicator(ObjectReplicator objectReplicator) {
+ this.objectReplicator = objectReplicator;
+ }
+ /**
+ * Sets the {@link WorkManager} to be used instead of a {@link ThreadReuseExecutor}.
+ * This means that Teiid will not own the processing threads and will not necessarily
be
+ * responsible for security context propagation.
+ * @param workManager
+ */
+ public void setWorkManager(WorkManager workManager) {
+ this.workManager = workManager;
+ }
+ public WorkManager getWorkManager() {
+ return workManager;
+ }
+
+ @Override
+ public TeiidExecutor getTeiidExecutor() {
+ if (workManager == null) {
+ return super.getTeiidExecutor();
+ }
+ return new WorkManagerTeiidExecutor(workManager);
+ }
+}
Property changes on:
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-06-08 13:49:43
UTC (rev 4169)
@@ -0,0 +1,419 @@
+/*
+ * 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.runtime;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.transaction.TransactionManager;
+
+import org.teiid.Replicated;
+import org.teiid.Replicated.ReplicationMode;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.cache.Cache;
+import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.DefaultCacheFactory;
+import org.teiid.cache.CacheConfiguration.Policy;
+import org.teiid.client.DQP;
+import org.teiid.client.security.ILogon;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBufferCache;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.deployers.CompositeVDB;
+import org.teiid.deployers.UDFMetaData;
+import org.teiid.deployers.VDBLifeCycleListener;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VirtualDatabaseException;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import
org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.PreparedPlan;
+import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.internal.process.TransactionServerImpl;
+import org.teiid.dqp.service.BufferService;
+import org.teiid.events.EventDistributor;
+import org.teiid.events.EventDistributorFactory;
+import org.teiid.jdbc.ConnectionImpl;
+import org.teiid.jdbc.ConnectionProfile;
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.jdbc.TeiidSQLException;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.net.CommunicationException;
+import org.teiid.net.ConnectionException;
+import org.teiid.query.ObjectReplicator;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
+import org.teiid.query.tempdata.GlobalTableStore;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
+import org.teiid.services.AbstractEventDistributorFactoryService;
+import org.teiid.services.BufferServiceImpl;
+import org.teiid.services.SessionServiceImpl;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.transport.ClientServiceRegistry;
+import org.teiid.transport.ClientServiceRegistryImpl;
+import org.teiid.transport.LocalServerConnection;
+import org.teiid.transport.LogonImpl;
+
+/**
+ * A simplified server environment for embedded use.
+ *
+ * Needs to be started prior to use with a call to {@link #start(EmbeddedConfiguration)}
+ */
+@SuppressWarnings("serial")
+public class EmbeddedServer implements EventDistributorFactory {
+
+ protected class ProviderAwareConnectorManagerRepository extends
+ ConnectorManagerRepository {
+ protected ConnectorManager createConnectorManager(
+ String translatorName, String connectionName) {
+ return new ConnectorManager(translatorName, connectionName) {
+ @Override
+ public Object getConnectionFactory() throws TranslatorException {
+ ConnectionFactoryProvider<?> connectionFactoryProvider =
connectionFactoryProviders.get(getConnectionName());
+ if (connectionFactoryProvider != null) {
+ return connectionFactoryProvider.getConnectionFactory();
+ }
+ return super.getConnectionFactory();
+ }
+ };
+ }
+ }
+
+ public interface ConnectionFactoryProvider<T> {
+ T getConnectionFactory() throws TranslatorException;
+ }
+
+ /**
+ * Annotated cache for use with the {@link EmbeddedServer} with an {@link
ObjectReplicator} instead of Infinispan.
+ * @param <K> key
+ * @param <V> value
+ */
+ public interface ReplicatedCache<K, V> extends Cache<K, V> {
+
+ @Replicated(replicateState = ReplicationMode.PULL)
+ public V get(K key);
+
+ @Replicated(replicateState = ReplicationMode.PUSH)
+ V put(K key, V value, Long ttl);
+
+ @Replicated()
+ V remove(K key);
+
+ }
+
+ protected DQPCore dqp = new DQPCore();
+ protected VDBRepository repo = new VDBRepository();
+ private ConcurrentHashMap<String, ExecutionFactory<?, ?>> translators = new
ConcurrentHashMap<String, ExecutionFactory<?, ?>>();
+ private ConcurrentHashMap<String, ConnectionFactoryProvider<?>>
connectionFactoryProviders = new ConcurrentHashMap<String,
ConnectionFactoryProvider<?>>();
+ protected SessionServiceImpl sessionService = new SessionServiceImpl();
+ protected ObjectReplicator replicator;
+ protected BufferServiceImpl bufferService = new BufferServiceImpl();
+ protected TransactionServerImpl transactionService = new TransactionServerImpl();
+ protected ClientServiceRegistryImpl services = new ClientServiceRegistryImpl();
+ protected LogonImpl logon;
+ private TeiidDriver driver = new TeiidDriver();
+ protected ConnectorManagerRepository cmr = new
ProviderAwareConnectorManagerRepository();
+ protected DefaultCacheFactory dcf = new DefaultCacheFactory() {
+
+ List<ReplicatedCache<?, ?>> caches = new ArrayList<ReplicatedCache<?,
?>>();
+
+ public boolean isReplicated() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <K, V> Cache<K, V> get(String location,
+ CacheConfiguration config) {
+ Cache<K, V> result = super.get(location, config);
+ if (replicator != null) {
+ try {
+ ReplicatedCache cache = replicator.replicate("$RS$",
ReplicatedCache.class, new ReplicatedCacheImpl(result), 0); //$NON-NLS-1$
+ caches.add(cache);
+ return cache;
+ } catch (Exception e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void destroy() {
+ if (replicator != null) {
+ for (ReplicatedCache<?, ?> cache : caches) {
+ replicator.stop(cache);
+ }
+ caches.clear();
+ }
+ super.destroy();
+ }
+ };
+ protected AbstractEventDistributorFactoryService eventDistributorFactoryService = new
AbstractEventDistributorFactoryService() {
+
+ @Override
+ protected VDBRepository getVdbRepository() {
+ return repo;
+ }
+
+ @Override
+ protected ObjectReplicator getObjectReplicator() {
+ return replicator;
+ }
+ };
+ protected boolean useCallingThread = true;
+ private Boolean running;
+
+ public EmbeddedServer() {
+
+ }
+
+ public void addConnectionFactoryProvider(String name,
+ ConnectionFactoryProvider<?> connectionFactoryProvider) {
+ this.connectionFactoryProviders.put(name, connectionFactoryProvider);
+ }
+
+ public synchronized void start(EmbeddedConfiguration dqpConfiguration) {
+ if (running != null) {
+ throw new IllegalStateException();
+ }
+ this.eventDistributorFactoryService.start();
+ this.dqp.setEventDistributor(this.eventDistributorFactoryService.getReplicatedEventDistributor());
+ this.replicator = dqpConfiguration.getObjectReplicator();
+ this.repo.setSystemStore(dqpConfiguration.getSystemStore());
+ if (dqpConfiguration.getTransactionManager() == null) {
+ LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
+ this.transactionService.setTransactionManager((TransactionManager)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new
Class<?>[] {TransactionManager.class}, new InvocationHandler() {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ throw new
UnsupportedOperationException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
+ }
+ }));
+ } else {
+ this.transactionService.setTransactionManager(dqpConfiguration.getTransactionManager());
+ }
+ if (dqpConfiguration.getSecurityHelper() != null) {
+ this.sessionService.setSecurityHelper(dqpConfiguration.getSecurityHelper());
+ } else {
+ this.sessionService.setSecurityHelper(new DoNothingSecurityHelper());
+ }
+ if (dqpConfiguration.getSecurityDomains() != null) {
+ this.sessionService.setSecurityDomains(dqpConfiguration.getSecurityDomains());
+ } else {
+ this.sessionService.setSecurityDomains(Arrays.asList("teiid-security"));
//$NON-NLS-1$
+ }
+
+ this.sessionService.setVDBRepository(repo);
+
+ BufferService bs = getBufferService();
+ this.dqp.setBufferManager(bs.getBufferManager());
+
+ startVDBRepository();
+
+ SessionAwareCache<CachedResults> rs = new
SessionAwareCache<CachedResults>(dcf, SessionAwareCache.Type.RESULTSET, new
CacheConfiguration(Policy.LRU, 60, 250, "resultsetcache")); //$NON-NLS-1$
+ SessionAwareCache<PreparedPlan> ppc = new
SessionAwareCache<PreparedPlan>(dcf, SessionAwareCache.Type.PREPAREDPLAN, new
CacheConfiguration());
+ rs.setTupleBufferCache(bs.getTupleBufferCache());
+ this.dqp.setResultsetCache(rs);
+
+ ppc.setTupleBufferCache(bs.getTupleBufferCache());
+ this.dqp.setPreparedPlanCache(ppc);
+
+ this.dqp.setTransactionService(this.transactionService);
+
+ this.dqp.start(dqpConfiguration);
+ this.sessionService.setDqp(this.dqp);
+ this.services.setSecurityHelper(this.sessionService.getSecurityHelper());
+ this.logon = new LogonImpl(sessionService, null);
+ services.registerClientService(ILogon.class, logon, null);
+ services.registerClientService(DQP.class, dqp, null);
+ initDriver();
+ running = true;
+ }
+
+ private void initDriver() {
+ driver.setEmbeddedProfile(new ConnectionProfile() {
+
+ @Override
+ public ConnectionImpl connect(String url, Properties info)
+ throws TeiidSQLException {
+ LocalServerConnection conn;
+ try {
+ conn = new LocalServerConnection(info, useCallingThread) {
+ @Override
+ protected ClientServiceRegistry getClientServiceRegistry() {
+ return services;
+ }
+ };
+ } catch (CommunicationException e) {
+ throw TeiidSQLException.create(e);
+ } catch (ConnectionException e) {
+ throw TeiidSQLException.create(e);
+ }
+ return new ConnectionImpl(conn, info, url);
+ }
+ });
+ }
+
+ private void startVDBRepository() {
+ this.repo.addListener(new VDBLifeCycleListener() {
+
+ @Override
+ public void added(String name, int version, CompositeVDB vdb) {
+
+ }
+
+ @Override
+ public void removed(String name, int version, CompositeVDB vdb) {
+ if (replicator != null) {
+ replicator.stop(vdb.getVDB().getAttachment(GlobalTableStore.class));
+ }
+ }
+
+ @Override
+ public void finishedDeployment(String name, int version,
+ CompositeVDB vdb) {
+ GlobalTableStore gts = new GlobalTableStoreImpl(dqp.getBufferManager(),
vdb.getVDB().getAttachment(TransformationMetadata.class));
+ if (replicator != null) {
+ try {
+ gts = replicator.replicate(name + version, GlobalTableStore.class, gts, 300000);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
+ }
+ });
+ this.repo.setSystemFunctionManager(new SystemFunctionManager());
+ this.repo.start();
+ }
+
+ protected BufferService getBufferService() {
+ bufferService.start();
+ if (replicator != null) {
+ try {
+ final TupleBufferCache tbc = replicator.replicate("$BM$",
TupleBufferCache.class, bufferService.getBufferManager(), 0); //$NON-NLS-1$
+ return new BufferService() {
+
+ @Override
+ public BufferManager getBufferManager() {
+ return bufferService.getBufferManager();
+ }
+
+ @Override
+ public TupleBufferCache getTupleBufferCache() {
+ return tbc;
+ }
+
+ };
+ } catch (Exception e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+ return bufferService;
+ }
+
+ public void addTranslator(ExecutionFactory<?, ?> ef) {
+ Translator t = ef.getClass().getAnnotation(Translator.class);
+ String name = ef.getClass().getName();
+ if (t != null) {
+ name = t.name();
+ }
+ translators.put(name, ef);
+ }
+
+ public void deployVDB(String name, List<ModelMetaData> models)
+ throws ConnectorManagerException, VirtualDatabaseException {
+ checkStarted();
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName(name);
+ vdb.setModels(models);
+ cmr.createConnectorManagers(vdb,
+ new ConnectorManagerRepository.ExecutionFactoryProvider() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public ExecutionFactory<Object, Object> getExecutionFactory(
+ String translator) throws ConnectorManagerException {
+ ExecutionFactory<?, ?> ef = translators.get(translator);
+ if (ef == null) {
+ throw new ConnectorManagerException(translator);
+ }
+ return (ExecutionFactory<Object, Object>) ef;
+ }
+ });
+ MetadataStore metadataStore = new MetadataStore();
+ repo.addVDB(vdb, metadataStore, new LinkedHashMap<String, Resource>(),
+ new UDFMetaData(), cmr);
+ // metadata load
+
+ }
+
+ public void undeployVDB(String vdbName) {
+ this.repo.removeVDB(vdbName, 1);
+ }
+
+ /**
+ * Stops the server. Once stopped it cannot be restarted.
+ */
+ public synchronized void stop() {
+ dqp.stop();
+ eventDistributorFactoryService.stop();
+ bufferService = null;
+ dqp = null;
+ running = false;
+ }
+
+ private synchronized void checkStarted() {
+ if (running == null || !running) {
+ throw new IllegalStateException();
+ }
+ }
+
+ public TeiidDriver getDriver() {
+ checkStarted();
+ return driver;
+ }
+
+ @Override
+ public EventDistributor getEventDistributor() {
+ return this.eventDistributorFactoryService.getEventDistributor();
+ }
+
+}
Property changes on: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/runtime/src/main/java/org/teiid/runtime/ReplicatedCacheImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/ReplicatedCacheImpl.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/ReplicatedCacheImpl.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,124 @@
+/*
+ * 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.runtime;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Set;
+
+import org.teiid.cache.Cache;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.ReplicatedObject;
+import org.teiid.runtime.EmbeddedServer.ReplicatedCache;
+
+class ReplicatedCacheImpl<K extends Serializable, V>
+ implements ReplicatedCache<K, V>, ReplicatedObject<K> {
+ private Cache<K, V> cache;
+
+ public ReplicatedCacheImpl(Cache<K, V> cache) {
+ this.cache = cache;
+ }
+
+ public void clear() {
+ cache.clear();
+ }
+
+ public V get(K key) {
+ return cache.get(key);
+ }
+
+ public String getName() {
+ return cache.getName();
+ }
+
+ public Set<K> keys() {
+ return cache.keys();
+ }
+
+ public V put(K key, V value, Long ttl) {
+ return cache.put(key, value, ttl);
+ }
+
+ public V remove(K key) {
+ return cache.remove(key);
+ }
+
+ public int size() {
+ return cache.size();
+ }
+
+ @Override
+ public void getState(K stateId, OutputStream ostream) {
+ V value = get(stateId);
+ if (value != null) {
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(ostream);
+ oos.writeObject(value);
+ oos.close();
+ } catch (IOException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setState(K stateId, InputStream istream) {
+ try {
+ ObjectInputStream ois = new ObjectInputStream(istream);
+ V value = (V) ois.readObject();
+ this.put(stateId, value, null);
+ } catch (IOException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (ClassNotFoundException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ @Override
+ public boolean hasState(K stateId) {
+ return cache.get(stateId) != null;
+ }
+
+ @Override
+ public void droppedMembers(Collection<Serializable> addresses) {
+ }
+
+ @Override
+ public void getState(OutputStream ostream) {
+ }
+
+ @Override
+ public void setAddress(Serializable address) {
+ }
+
+ @Override
+ public void setState(InputStream istream) {
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/runtime/src/main/java/org/teiid/runtime/ReplicatedCacheImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-05 23:07:38
UTC (rev 4168)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-08 13:49:43
UTC (rev 4169)
@@ -102,5 +102,8 @@
TEIID40084, //imported role conflict
TEIID40085, //imported model conflict
TEIID40086, //imported connector manager conflict
+ TEIID40087, //pass-through failed
+ TEIID40088, //event distributor replication failed
+ TEIID40089, //txn disabled
}
}
Added: trunk/runtime/src/main/java/org/teiid/runtime/WorkManagerTeiidExecutor.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/WorkManagerTeiidExecutor.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/WorkManagerTeiidExecutor.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,96 @@
+/*
+ * 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.runtime;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.core.util.NamedThreadFactory;
+import org.teiid.dqp.internal.process.TeiidExecutor;
+import org.teiid.dqp.internal.process.ThreadReuseExecutor;
+import org.teiid.security.SecurityHelper;
+
+/**
+ * A {@link TeiidExecutor} that allows for a dummy {@link SecurityHelper} to be used
+ * and prevents Teiid from owning processing threads.
+ */
+final class WorkManagerTeiidExecutor implements TeiidExecutor {
+ WorkManager workManager;
+ private ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new
NamedThreadFactory("Scheduler")); //$NON-NLS-1$
+
+ WorkManagerTeiidExecutor(WorkManager workManager) {
+ this.workManager = workManager;
+ }
+
+ @Override
+ public List<Runnable> shutdownNow() {
+ workManager = null;
+ return Collections.emptyList();
+ }
+
+ @Override
+ public ScheduledFuture<?> schedule(Runnable command, long delay,
+ TimeUnit unit) {
+ final ThreadReuseExecutor.RunnableWrapper wrapper = new
ThreadReuseExecutor.RunnableWrapper(command);
+ return stpe.schedule(new Runnable() {
+ @Override
+ public void run() {
+ execute(wrapper);
+ }
+ }, delay, unit);
+ }
+
+ @Override
+ public WorkerPoolStatisticsMetadata getStats() {
+ return null;
+ }
+
+ @Override
+ public void execute(Runnable command) {
+ final ThreadReuseExecutor.RunnableWrapper wrapper = new
ThreadReuseExecutor.RunnableWrapper(command);
+ executeDirect(wrapper);
+ }
+
+ private void executeDirect(
+ final ThreadReuseExecutor.RunnableWrapper wrapper) {
+ try {
+ workManager.scheduleWork(wrapper);
+ } catch (WorkException e) {
+ throw new RejectedExecutionException(e);
+ }
+ }
+
+ @Override
+ public boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ return false;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/runtime/src/main/java/org/teiid/runtime/WorkManagerTeiidExecutor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/runtime/src/main/java/org/teiid/services/AbstractEventDistributorFactoryService.java
===================================================================
---
trunk/runtime/src/main/java/org/teiid/services/AbstractEventDistributorFactoryService.java
(rev 0)
+++
trunk/runtime/src/main/java/org/teiid/services/AbstractEventDistributorFactoryService.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,97 @@
+/*
+ * 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.services;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.teiid.deployers.EventDistributorImpl;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.events.EventDistributor;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.query.ObjectReplicator;
+import org.teiid.runtime.RuntimePlugin;
+
+public abstract class AbstractEventDistributorFactoryService implements
InternalEventDistributorFactory {
+
+ private EventDistributor replicatableEventDistributor;
+ private EventDistributor eventDistributorProxy;
+
+ public InternalEventDistributorFactory getValue() throws IllegalStateException,
IllegalArgumentException {
+ return this;
+ }
+
+ protected abstract VDBRepository getVdbRepository();
+ protected abstract ObjectReplicator getObjectReplicator();
+
+ public void start() {
+ final EventDistributor ed = new EventDistributorImpl() {
+ @Override
+ public VDBRepository getVdbRepository() {
+ return AbstractEventDistributorFactoryService.this.getVdbRepository();
+ }
+ };
+
+ ObjectReplicator objectReplicator = getObjectReplicator();
+ // this instance is by use of teiid internally; only invokes the remote instances
+ if (objectReplicator != null) {
+ try {
+ this.replicatableEventDistributor =
objectReplicator.replicate("$TEIID_ED$", EventDistributor.class, ed, 0);
//$NON-NLS-1$
+ } catch (Exception e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40088, this));
+ }
+ }
+
+ // for external client to call. invokes local instance and remote ones too.
+ this.eventDistributorProxy =
(EventDistributor)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[] {EventDistributor.class}, new InvocationHandler() {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ method.invoke(ed, args);
+ if (replicatableEventDistributor != null) {
+ method.invoke(replicatableEventDistributor, args);
+ }
+ return null;
+ }
+ });
+ }
+
+ public void stop() {
+ ObjectReplicator objectReplicator = getObjectReplicator();
+ if (objectReplicator != null && this.replicatableEventDistributor != null)
{
+ objectReplicator.stop(this.replicatableEventDistributor);
+ this.replicatableEventDistributor = null;
+ }
+ }
+
+ @Override
+ public EventDistributor getReplicatedEventDistributor() {
+ return replicatableEventDistributor;
+ }
+
+ @Override
+ public EventDistributor getEventDistributor() {
+ return eventDistributorProxy;
+ }
+}
Property changes on:
trunk/runtime/src/main/java/org/teiid/services/AbstractEventDistributorFactoryService.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -80,10 +80,6 @@
public void start(){
try {
- LogManager.logDetail(LogConstants.CTX_DQP, "Starting BufferManager
using", bufferDir); //$NON-NLS-1$
- if (!bufferDir.exists()) {
- this.bufferDir.mkdirs();
- }
// Construct and initialize the buffer manager
this.bufferMgr = new BufferManagerImpl();
this.bufferMgr.setConnectorBatchSize(Integer.valueOf(connectorBatchSize));
@@ -95,6 +91,10 @@
// If necessary, add disk storage manager
if(useDisk) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Starting BufferManager
using", bufferDir); //$NON-NLS-1$
+ if (!bufferDir.exists()) {
+ this.bufferDir.mkdirs();
+ }
// start the file storage manager in clean state
// wise FileStorageManager is smart enough to clean up after itself
cleanDirectory(bufferDir);
Added:
trunk/runtime/src/main/java/org/teiid/services/InternalEventDistributorFactory.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/InternalEventDistributorFactory.java
(rev 0)
+++
trunk/runtime/src/main/java/org/teiid/services/InternalEventDistributorFactory.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.services;
+
+import org.teiid.events.EventDistributor;
+import org.teiid.events.EventDistributorFactory;
+
+public interface InternalEventDistributorFactory extends EventDistributorFactory {
+
+ EventDistributor getReplicatedEventDistributor();
+
+}
Property changes on:
trunk/runtime/src/main/java/org/teiid/services/InternalEventDistributorFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -24,15 +24,9 @@
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import javax.security.auth.Subject;
@@ -67,7 +61,7 @@
/**
* This class serves as the primary implementation of the Session Service.
*/
-public abstract class SessionServiceImpl implements SessionService {
+public class SessionServiceImpl implements SessionService {
public static final String AT = "@"; //$NON-NLS-1$
/*
* Configuration state
@@ -153,8 +147,15 @@
if (domains!= null && !domains.isEmpty() && authenticate) {
// Authenticate user...
// if not authenticated, this method throws exception
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[]
{"authenticateUser", userName, applicationName}); //$NON-NLS-1$
+
boolean onlyAllowPassthrough =
Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
"false")); //$NON-NLS-1$
- TeiidLoginContext membership = authenticate(userName, credentials,
applicationName, domains, onlyAllowPassthrough);
+ TeiidLoginContext membership = null;
+ if (onlyAllowPassthrough) {
+ membership = passThroughLogin(userName, domains);
+ } else {
+ membership = authenticate(userName, credentials, applicationName, domains);
+ }
userName = membership.getUserName();
securityDomain = membership.getSecurityDomain();
securityContext = membership.getSecurityContext();
@@ -189,9 +190,44 @@
this.sessionCache.put(newSession.getSessionId(), newSession);
return newSession;
}
+
+ public TeiidLoginContext passThroughLogin(String userName,
+ List<String> domains)
+ throws LoginException {
+
+ for (String domain:getDomainsForUser(domains, userName)) {
+ Subject existing = this.securityHelper.getSubjectInContext(domain);
+ if (existing != null) {
+ return new TeiidLoginContext(getUserName(existing, userName)+AT+domain, existing,
domain, this.securityHelper.getSecurityContext(domain));
+ }
+ }
+ throw new LoginException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40087));
+ }
- abstract protected TeiidLoginContext authenticate(String userName, Credentials
credentials, String applicationName, List<String> domains, boolean
onlyallowPassthrough)
- throws LoginException;
+ private String getUserName(Subject subject, String userName) {
+ Set<Principal> principals = subject.getPrincipals();
+ for (Principal p:principals) {
+ if (p instanceof Group) {
+ continue;
+ }
+ return p.getName();
+ }
+ return getBaseUsername(userName);
+ }
+
+ /**
+ *
+ * @param userName
+ * @param credentials
+ * @param applicationName
+ * @param domains
+ * @return
+ * @throws LoginException
+ */
+ protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains)
+ throws LoginException {
+ return passThroughLogin(userName, domains);
+ }
VDBMetaData getActiveVDB(String vdbName, String vdbVersion) throws
SessionServiceException {
VDBMetaData vdb = null;
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-05 23:07:38
UTC (rev 4168)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-08 13:49:43
UTC (rev 4169)
@@ -87,4 +87,8 @@
TEIID40083={0}.{1} imports a non-existent VDB {2}.{3}
TEIID40084={0}.{1} imports a conflicting role {4} from {2}.{3}
TEIID40085={0}.{1} imports a conflicting model {4} from {2}.{3}
-TEIID40086={0}.{1} imports a duplicate source {4} from {2}.{3}
\ No newline at end of file
+TEIID40086={0}.{1} imports a duplicate source {4} from {2}.{3}
+
+TEIID40087=Passthrough authentication failed. No authentication information found.
+TEIID40088=Could not replicate object {0}
+TEIID40089=No transaction manager set, transaction support is not enabled.
\ No newline at end of file
Modified: trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -1,7 +1,6 @@
package org.teiid.services;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
import java.util.List;
@@ -26,7 +25,7 @@
@Override
protected TeiidLoginContext authenticate(String userName,
Credentials credentials, String applicationName,
- List<String> domains, boolean onlyallowPassthrough)
+ List<String> domains)
throws LoginException {
return null;
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -47,6 +47,7 @@
import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.runtime.EmbeddedConfiguration;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
@@ -102,9 +103,9 @@
}
@BeforeClass public static void oneTimeSetUp() throws Exception {
- DQPConfiguration config = new DQPConfiguration();
+ EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setUserRequestSourceConcurrency(1);
- server = new FakeServer(config);
+ server = new FakeServer(false);
server.setConnectorManagerRepository(new ConnectorManagerRepository() {
private ConnectorManager cm = new ConnectorManager("x", "y") {
private ExecutionFactory<Object, Object> ef = new ExecutionFactory<Object,
Object>() {
@@ -134,6 +135,7 @@
return cm;
}
});
+ server.start(config, false);
server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
}
@@ -149,20 +151,20 @@
ts.submitExecute("select part_id from parts", new StatementCallback() {
int rowCount;
@Override
- public void onRow(Statement s, ResultSet rs) throws SQLException {
+ public void onRow(Statement stmt, ResultSet rs) throws SQLException {
rowCount++;
if (rowCount == EXEC_COUNT) {
- s.close();
+ stmt.close();
}
}
@Override
- public void onException(Statement s, Exception e) {
+ public void onException(Statement stmt, Exception e) {
result.getResultsReceiver().receiveResults(rowCount);
}
@Override
- public void onComplete(Statement s) {
+ public void onComplete(Statement stmt) {
result.getResultsReceiver().receiveResults(rowCount);
}
}, new RequestOptions().continuous(true));
Modified:
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -62,7 +62,7 @@
@BeforeClass public static void oneTimeSetUp() throws Exception {
//DQPConfiguration config = new DQPConfiguration();
//config.setUserRequestSourceConcurrency(1);
- server = new FakeServer();
+ server = new FakeServer(true);
JdbcDataSource h2ds = new JdbcDataSource();
h2ds.setURL("jdbc:h2:zip:src/test/resources/relate/test.zip!/test");
final DataSource ds = JdbcConnectionPool.create(h2ds);
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-05
23:07:38 UTC (rev 4168)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -22,51 +22,25 @@
package org.teiid.jdbc;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginException;
+import javax.resource.spi.XATerminator;
+import javax.transaction.TransactionManager;
-import org.mockito.Mockito;
-import org.teiid.Replicated;
-import org.teiid.Replicated.ReplicationMode;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBImportMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.cache.Cache;
-import org.teiid.cache.CacheConfiguration;
-import org.teiid.cache.DefaultCacheFactory;
-import org.teiid.cache.CacheConfiguration.Policy;
-import org.teiid.client.DQP;
-import org.teiid.client.security.ILogon;
-import org.teiid.common.buffer.TupleBufferCache;
-import org.teiid.core.TeiidRuntimeException;
+import org.teiid.common.queue.FakeWorkManager;
+import org.teiid.core.util.SimpleMock;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.deployers.CompositeVDB;
import org.teiid.deployers.UDFMetaData;
-import org.teiid.deployers.VDBLifeCycleListener;
-import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VirtualDatabaseException;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.FakeTransactionService;
-import org.teiid.dqp.internal.process.CachedResults;
-import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.PreparedPlan;
-import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.dqp.service.BufferService;
import org.teiid.dqp.service.FakeBufferService;
import org.teiid.metadata.FunctionMethod;
@@ -75,265 +49,34 @@
import org.teiid.metadata.Schema;
import org.teiid.metadata.index.IndexMetadataStore;
import org.teiid.metadata.index.VDBMetadataFactory;
-import org.teiid.net.CommunicationException;
-import org.teiid.net.ConnectionException;
-import org.teiid.query.ObjectReplicator;
-import org.teiid.query.ReplicatedObject;
-import org.teiid.query.function.SystemFunctionManager;
-import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
-import org.teiid.query.tempdata.GlobalTableStore;
-import org.teiid.query.tempdata.GlobalTableStoreImpl;
-import org.teiid.security.Credentials;
-import org.teiid.security.SecurityHelper;
-import org.teiid.services.BufferServiceImpl;
-import org.teiid.services.SessionServiceImpl;
-import org.teiid.services.TeiidLoginContext;
-import org.teiid.transport.ClientServiceRegistry;
+import org.teiid.runtime.EmbeddedConfiguration;
+import org.teiid.runtime.EmbeddedServer;
import org.teiid.transport.ClientServiceRegistryImpl;
-import org.teiid.transport.LocalServerConnection;
-import org.teiid.transport.LogonImpl;
@SuppressWarnings({"nls"})
-public class FakeServer extends ClientServiceRegistryImpl implements ConnectionProfile {
+public class FakeServer extends EmbeddedServer {
public static class DeployVDBParameter {
public Map<String, Collection<FunctionMethod>> udfs;
- public MetadataRepository metadataRepo;
+ public MetadataRepository<?, ?> metadataRepo;
public List<VDBImportMetadata> vdbImports;
public DeployVDBParameter(Map<String, Collection<FunctionMethod>> udfs,
- MetadataRepository metadataRepo) {
+ MetadataRepository<?, ?> metadataRepo) {
this.udfs = udfs;
this.metadataRepo = metadataRepo;
}
}
- public interface ReplicatedCache<K, V> extends Cache<K, V> {
-
- @Replicated(replicateState=ReplicationMode.PULL)
- public V get(K key);
-
- @Replicated(replicateState=ReplicationMode.PUSH)
- V put(K key, V value, Long ttl);
-
- @Replicated()
- V remove(K key);
-
- }
+ private boolean realBufferManager;
- public static class ReplicatedCacheImpl<K extends Serializable, V> implements
ReplicatedCache<K, V>, ReplicatedObject<K> {
- private Cache<K, V> cache;
-
- public ReplicatedCacheImpl(Cache<K, V> cache) {
- this.cache = cache;
- }
-
- public void clear() {
- cache.clear();
- }
-
- public V get(K key) {
- return cache.get(key);
- }
-
- public String getName() {
- return cache.getName();
- }
-
- public Set<K> keys() {
- return cache.keys();
- }
-
- public V put(K key, V value, Long ttl) {
- return cache.put(key, value, ttl);
- }
-
- public V remove(K key) {
- return cache.remove(key);
- }
-
- public int size() {
- return cache.size();
- }
-
- @Override
- public void getState(K stateId, OutputStream ostream) {
- V value = get(stateId);
- if (value != null) {
- try {
- ObjectOutputStream oos = new ObjectOutputStream(ostream);
- oos.writeObject(value);
- oos.close();
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- }
- }
- }
-
- @Override
- public void setState(K stateId, InputStream istream) {
- try {
- ObjectInputStream ois = new ObjectInputStream(istream);
- V value = (V) ois.readObject();
- this.put(stateId, value, null);
- } catch (IOException e) {
- throw new TeiidRuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new TeiidRuntimeException(e);
- }
- }
-
- @Override
- public boolean hasState(K stateId) {
- return cache.get(stateId) != null;
- }
-
- @Override
- public void droppedMembers(Collection<Serializable> addresses) {
- }
-
- @Override
- public void getState(OutputStream ostream) {
- }
-
- @Override
- public void setAddress(Serializable address) {
- }
-
- @Override
- public void setState(InputStream istream) {
- }
-
-
- }
-
- SessionServiceImpl sessionService = new SessionServiceImpl() {
- @Override
- protected TeiidLoginContext authenticate(String userName,
- Credentials credentials, String applicationName,
- List<String> domains, boolean onlyallowPassthrough)
- throws LoginException {
- return new TeiidLoginContext(userName+"(a)"+domains.get(0), new Subject(),
domains.get(0), new Object());
- }
-
- };
- LogonImpl logon;
- DQPCore dqp = new DQPCore();
- VDBRepository repo = new VDBRepository();
- private ConnectorManagerRepository cmr;
- private boolean useCallingThread = true;
- private ObjectReplicator replicator;
-
- public FakeServer() {
- this(new DQPConfiguration());
- }
-
- public void setReplicator(ObjectReplicator replicator) {
- this.replicator = replicator;
- }
-
- public FakeServer(DQPConfiguration config) {
- start(config, false);
- }
-
- public FakeServer(boolean start) {
- if (start) {
- start(new DQPConfiguration(), false);
- }
- }
-
@SuppressWarnings("serial")
- public void start(DQPConfiguration config, boolean realBufferMangaer) {
- sessionService.setSecurityHelper(Mockito.mock(SecurityHelper.class));
- sessionService.setSecurityDomains(Arrays.asList("somedomain"));
-
- this.logon = new LogonImpl(sessionService, null);
- this.repo.addListener(new VDBLifeCycleListener() {
-
+ public FakeServer(boolean start) {
+ cmr = new ProviderAwareConnectorManagerRepository() {
@Override
- public void added(String name, int version,
- CompositeVDB vdb) {
-
- }
-
- @Override
- public void removed(String name, int version, CompositeVDB vdb) {
-
- }
-
- @Override
- public void finishedDeployment(String name, int version, CompositeVDB vdb) {
- GlobalTableStore gts = new GlobalTableStoreImpl(dqp.getBufferManager(),
vdb.getVDB().getAttachment(TransformationMetadata.class));
- if (replicator != null) {
- try {
- gts = replicator.replicate(name + version, GlobalTableStore.class, gts, 300000);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
- }
- });
- this.repo.setSystemStore(VDBMetadataFactory.getSystem());
- this.repo.setSystemFunctionManager(new SystemFunctionManager());
- this.repo.odbcEnabled();
- this.repo.start();
-
- this.sessionService.setVDBRepository(repo);
- BufferService bs = null;
- if (!realBufferMangaer) {
- bs = new FakeBufferService(false);
- } else {
- BufferServiceImpl bsi = new BufferServiceImpl();
- bsi.setDiskDirectory(UnitTestUtil.getTestScratchPath());
- bsi.start();
- bs = bsi;
- }
- if (replicator != null) {
- try {
- final TupleBufferCache tbc = replicator.replicate("$BM$",
TupleBufferCache.class, bs.getBufferManager(), 0);
- bs = new FakeBufferService(bs.getBufferManager(), tbc);
- } catch (Exception e) {
- throw new TeiidRuntimeException(e);
- }
- }
- this.dqp.setBufferManager(bs.getBufferManager());
-
- //TODO: wire in an infinispan cluster rather than this dummy replicated cache
- DefaultCacheFactory dcf = new DefaultCacheFactory() {
- public boolean isReplicated() {
- return true;
- }
-
- @Override
- public <K, V> Cache<K, V> get(String location,
- CacheConfiguration config) {
- Cache<K, V> result = super.get(location, config);
- if (replicator != null) {
- try {
- return replicator.replicate("$RS$", ReplicatedCache.class, new
ReplicatedCacheImpl(result), 0);
- } catch (Exception e) {
- throw new TeiidRuntimeException(e);
- }
- }
- return result;
- }
- };
- SessionAwareCache rs = new SessionAwareCache<CachedResults>(dcf,
SessionAwareCache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, 250,
"resultsetcache"));
- SessionAwareCache ppc = new SessionAwareCache<PreparedPlan>(dcf,
SessionAwareCache.Type.PREPAREDPLAN, new CacheConfiguration());
- rs.setTupleBufferCache(bs.getTupleBufferCache());
- this.dqp.setResultsetCache(rs);
-
- ppc.setTupleBufferCache(bs.getTupleBufferCache());
- this.dqp.setPreparedPlanCache(ppc);
-
- this.dqp.setTransactionService(new FakeTransactionService());
-
- cmr = new ConnectorManagerRepository() {
- @Override
- public ConnectorManager getConnectorManager(String connectorName) {
+ public ConnectorManager getConnectorManager(String connectorName) {
ConnectorManager cm = super.getConnectorManager(connectorName);
if (cm != null) {
return cm;
@@ -347,16 +90,36 @@
};
}
return null;
- }
- };
-
- this.dqp.start(config);
- this.sessionService.setDqp(this.dqp);
-
- registerClientService(ILogon.class, logon, null);
- registerClientService(DQP.class, dqp, null);
+ }
+ };
+ if (start) {
+ start(new EmbeddedConfiguration(), false);
+ }
}
+
+ public void start(EmbeddedConfiguration config, boolean realBufferMangaer) {
+ if (config.getSystemStore() == null) {
+ config.setSystemStore(VDBMetadataFactory.getSystem());
+ }
+ if (config.getTransactionManager() == null) {
+ config.setTransactionManager(SimpleMock.createSimpleMock(TransactionManager.class));
+ this.transactionService.setXaTerminator(SimpleMock.createSimpleMock(XATerminator.class));
+ this.transactionService.setWorkManager(new FakeWorkManager());
+ }
+ this.repo.odbcEnabled();
+ this.realBufferManager = realBufferMangaer;
+ start(config);
+ }
+ @Override
+ protected BufferService getBufferService() {
+ if (!realBufferManager) {
+ return new FakeBufferService(false);
+ }
+ bufferService.setDiskDirectory(UnitTestUtil.getTestScratchPath());
+ return super.getBufferService();
+ }
+
public DQPCore getDqp() {
return dqp;
}
@@ -369,10 +132,6 @@
this.cmr = cmr;
}
- public void stop() {
- this.dqp.stop();
- }
-
public void setUseCallingThread(boolean useCallingThread) {
this.useCallingThread = useCallingThread;
}
@@ -446,29 +205,11 @@
}
public ConnectionImpl createConnection(String embeddedURL) throws Exception {
- final Properties p = new Properties();
- TeiidDriver.parseURL(embeddedURL, p);
-
- return connect(embeddedURL, p);
+ return getDriver().connect(embeddedURL, null);
}
- @Override
- public ConnectionImpl connect(String url, Properties info)
- throws TeiidSQLException {
- LocalServerConnection conn;
- try {
- conn = new LocalServerConnection(info, useCallingThread) {
- @Override
- protected ClientServiceRegistry getClientServiceRegistry() {
- return FakeServer.this;
- }
- };
- } catch (CommunicationException e) {
- throw TeiidSQLException.create(e);
- } catch (ConnectionException e) {
- throw TeiidSQLException.create(e);
- }
- return new ConnectionImpl(conn, info, url);
+ public ClientServiceRegistryImpl getClientServiceRegistry() {
+ return services;
}
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -41,7 +41,7 @@
////////////////////Query Related Methods///////////////////////////
@Before public void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB("test", UnitTestUtil.getTestDataPath() +
"/TestCase3473/test.vdb");
Connection conn = server.createConnection("jdbc:teiid:test");
//$NON-NLS-1$
dbmd = conn.getMetaData();
Modified:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -55,7 +55,7 @@
private FakeServer server;
@Before public void setup() {
- this.server = new FakeServer();
+ this.server = new FakeServer(true);
}
@After public void tearDown() {
Modified:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -94,7 +94,7 @@
return 1;
}
- static FakeServer server = new FakeServer();
+ static FakeServer server = new FakeServer(true);
@SuppressWarnings("serial")
@BeforeClass public static void oneTimeSetup() throws Exception {
@@ -223,7 +223,7 @@
final Statement s = c.createStatement();
s.execute("select 1");
- assertFalse(server.dqp.getRequests().isEmpty());
+ assertFalse(server.getDqp().getRequests().isEmpty());
Thread t = new Thread() {
public void run() {
@@ -242,7 +242,7 @@
fail();
}
- assertTrue(server.dqp.getRequests().isEmpty());
+ assertTrue(server.getDqp().getRequests().isEmpty());
if (handler.t != null) {
throw handler.t;
Modified:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -146,7 +146,7 @@
@BeforeClass
public static void oneTimeSetUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB("QT_Ora9DS",
UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb");
conn = server.createConnection("jdbc:teiid:QT_Ora9DS"); //$NON-NLS-1$
//$NON-NLS-2$
}
@@ -915,7 +915,7 @@
expected.put("getSystemFunctions",
DatabaseMetaDataImpl.SYSTEM_FUNCTIONS); //$NON-NLS-1$
expected.put("getTimeDateFunctions",
DatabaseMetaDataImpl.DATE_FUNCTIONS); //$NON-NLS-1$
//expected.put("getUrl", primaryUrl + serverUrl); //$NON-NLS-1$
- expected.put("getUserName",
CoreConstants.DEFAULT_ANON_USERNAME+"@somedomain"); //$NON-NLS-1$
+ expected.put("getUserName",
CoreConstants.DEFAULT_ANON_USERNAME+"@teiid-security"); //$NON-NLS-1$
// return type - Object
expected.put("getConnection", conn); //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -38,7 +38,7 @@
private static Connection conn;
@BeforeClass public static void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB("test", UnitTestUtil.getTestDataPath() +
"/TestCase3473/test.vdb");
conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
//$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -39,7 +39,7 @@
private Connection conn;
@Before public void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB("test", UnitTestUtil.getTestDataPath() +
"/TestCase3473/test.vdb");
conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
//$NON-NLS-2$
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -14,7 +14,7 @@
private static final String VDB1 = "PartsSupplier"; //$NON-NLS-1$
private static final String VDB2 = "QT_Ora9DS"; //$NON-NLS-1$
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
@Test
public void testMerge() throws Throwable {
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -48,7 +48,7 @@
private FakeServer server;
@Before public void setUp() throws Exception {
- server = new FakeServer();
+ server = new FakeServer(true);
VDBRepository vdbRepository = new VDBRepository();
vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -67,7 +67,7 @@
}
@Before public void setUp() throws Exception {
- server = new FakeServer();
+ server = new FakeServer(true);
HashMap<String, Collection<FunctionMethod>> udfs = new
HashMap<String, Collection<FunctionMethod>>();
udfs.put("funcs", Arrays.asList(new FunctionMethod("pause",
null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause",
null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER),
true, Determinism.NONDETERMINISTIC)));
server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() +
"/matviews.vdb", new DeployVDBParameter(udfs, null));
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -50,7 +50,7 @@
static final String VDB = "metadata";
@BeforeClass public static void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/metadata.vdb",
new DeployVDBParameter(null, getMetadataRepo()));
connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$
//$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCProceduresSchema.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCProceduresSchema.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCProceduresSchema.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -43,7 +43,7 @@
}
@BeforeClass public static void oneTimeSetup() throws Exception {
- server = new FakeServer();
+ server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/bqt.vdb");
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -20,7 +20,7 @@
}
@Before public void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
this.internalConnection = server.createConnection("jdbc:teiid:" + VDB);
//$NON-NLS-1$ //$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -46,7 +46,7 @@
static final String VDB = "PartsSupplier";
@BeforeClass public static void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$
//$NON-NLS-2$
dbMetadata = connection.getMetaData();
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -39,7 +39,6 @@
import org.junit.Test;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.jdbc.FakeServer;
import org.teiid.jdbc.FakeServer.DeployVDBParameter;
import org.teiid.metadata.FunctionMethod;
@@ -47,6 +46,7 @@
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.replication.jboss.JGroupsObjectReplicator;
+import org.teiid.runtime.EmbeddedConfiguration;
@SuppressWarnings("nls")
public class TestReplication {
@@ -142,8 +142,9 @@
}
});
- server.setReplicator(jor);
- server.start(new DQPConfiguration(), true);
+ EmbeddedConfiguration config = new EmbeddedConfiguration();
+ config.setObjectReplicator(jor);
+ server.start(config, true);
HashMap<String, Collection<FunctionMethod>> udfs = new
HashMap<String, Collection<FunctionMethod>>();
udfs.put("funcs", Arrays.asList(new FunctionMethod("pause",
null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause",
null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER),
true, Determinism.NONDETERMINISTIC)));
server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() +
"/matviews.vdb", new DeployVDBParameter(udfs, null));
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -44,7 +44,7 @@
}
@Before public void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
this.internalConnection = server.createConnection("jdbc:teiid:" + VDB);
//$NON-NLS-1$ //$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestStats.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestStats.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestStats.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -42,7 +42,7 @@
static final String VDB = "PartsSupplier";
@BeforeClass public static void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$
//$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -58,7 +58,7 @@
}
@Before public void setUp() throws Exception {
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
this.internalConnection = server.createConnection("jdbc:teiid:" + VDB);
//$NON-NLS-1$ //$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -50,7 +50,7 @@
}
@BeforeClass public static void oneTimeSetup() throws Exception {
- server = new FakeServer();
+ server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/xml-vp/xmlvp_1.vdb");
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -39,7 +39,6 @@
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.service.AutoGenDataService;
import org.teiid.jdbc.ConnectionImpl;
import org.teiid.jdbc.ConnectionProfile;
@@ -50,6 +49,7 @@
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.socket.SocketServerConnectionFactory;
+import org.teiid.runtime.EmbeddedConfiguration;
import org.teiid.translator.TranslatorException;
@SuppressWarnings("nls")
@@ -66,13 +66,14 @@
config.setBindAddress(addr.getHostName());
config.setPortNumber(0);
- DQPConfiguration dqpConfig = new DQPConfiguration();
+ EmbeddedConfiguration dqpConfig = new EmbeddedConfiguration();
dqpConfig.setMaxActivePlans(2);
- server = new FakeServer(dqpConfig);
+ server = new FakeServer(false);
+ server.start(dqpConfig, false);
server.setUseCallingThread(false);
server.deployVDB("parts", UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
- jdbcTransport = new SocketListener(addr, config, server,
BufferManagerFactory.getStandaloneBufferManager());
+ jdbcTransport = new SocketListener(addr, config, server.getClientServiceRegistry(),
BufferManagerFactory.getStandaloneBufferManager());
}
@AfterClass public static void oneTimeTearDown() throws Exception {
Modified:
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2012-06-05
23:07:38 UTC (rev 4168)
+++
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2012-06-08
13:49:43 UTC (rev 4169)
@@ -22,10 +22,7 @@
package org.teiid.transport;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.net.InetAddress;
@@ -34,21 +31,28 @@
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.mockito.Mockito;
import org.postgresql.Driver;
import org.teiid.client.security.ILogon;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.FakeServer;
-import org.teiid.jdbc.TeiidDriver;
import org.teiid.jdbc.TestMMDatabaseMetaData;
import org.teiid.net.socket.SocketUtil;
@@ -126,13 +130,11 @@
config.setPortNumber(addr.getPort());
odbcTransport = new ODBCSocketListener(addr, config,
Mockito.mock(ClientServiceRegistryImpl.class),
BufferManagerFactory.getStandaloneBufferManager(), 100000, Mockito.mock(ILogon.class));
odbcTransport.setMaxBufferSize(1000); //set to a small size to ensure buffering over
the limit works
- FakeServer server = new FakeServer();
+ FakeServer server = new FakeServer(true);
server.setUseCallingThread(false);
server.deployVDB("parts", UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
- TeiidDriver driver = new TeiidDriver();
- driver.setEmbeddedProfile(server);
- odbcTransport.setDriver(driver);
+ odbcTransport.setDriver(server.getDriver());
}
public void stop() {