teiid SVN: r3451 - in branches/as7: adminshell/src/main/java/org/teiid/adminshell and 85 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-05 10:27:44 -0400 (Mon, 05 Sep 2011)
New Revision: 3451
Added:
branches/as7/api/src/main/java/org/teiid/Replicated.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java
branches/as7/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java
branches/as7/engine/src/main/java/org/teiid/query/ObjectReplicator.java
branches/as7/engine/src/main/java/org/teiid/query/ReplicatedObject.java
branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java
branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
branches/as7/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewReplication.java
Removed:
branches/as7/cache-jbosscache/src/main/java/org/teiid/events/jboss/
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java
Modified:
branches/as7/
branches/as7/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
branches/as7/api/src/main/java/org/teiid/events/EventDistributor.java
branches/as7/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
branches/as7/build/kits/jboss-container/conf/jboss-teiid-log4j.xml
branches/as7/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
branches/as7/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
branches/as7/build/kits/jboss-container/teiid-releasenotes.html
branches/as7/build/pom.xml
branches/as7/cache-jbosscache/pom.xml
branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
branches/as7/client/src/main/java/org/teiid/client/security/LogonResult.java
branches/as7/client/src/main/java/org/teiid/jdbc/BatchResults.java
branches/as7/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
branches/as7/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
branches/as7/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
branches/as7/client/src/main/java/org/teiid/jdbc/JDBCURL.java
branches/as7/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
branches/as7/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
branches/as7/client/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java
branches/as7/client/src/main/java/org/teiid/jdbc/SQLStates.java
branches/as7/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/as7/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java
branches/as7/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
branches/as7/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java
branches/as7/client/src/test/java/org/teiid/jdbc/TestBatchResults.java
branches/as7/client/src/test/java/org/teiid/jdbc/TestConnection.java
branches/as7/client/src/test/java/org/teiid/jdbc/TestSQLException.java
branches/as7/client/src/test/java/org/teiid/jdbc/TestStatement.java
branches/as7/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
branches/as7/common-core/src/main/java/org/teiid/core/TeiidException.java
branches/as7/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java
branches/as7/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java
branches/as7/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java
branches/as7/connectors/connector-file/src/main/rar/META-INF/ra.xml
branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
branches/as7/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java
branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
branches/as7/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
branches/as7/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml
branches/as7/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
branches/as7/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml
branches/as7/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
branches/as7/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
branches/as7/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/BlockedException.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/SPage.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/STree.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
branches/as7/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java
branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
branches/as7/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
branches/as7/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
branches/as7/engine/src/main/java/org/teiid/query/processor/proc/Program.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java
branches/as7/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
branches/as7/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
branches/as7/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/as7/engine/src/main/java/org/teiid/query/sql/LanguageObject.java
branches/as7/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
branches/as7/engine/src/main/java/org/teiid/query/tempdata/AlterTempTable.java
branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
branches/as7/engine/src/main/java/org/teiid/query/util/CommandContext.java
branches/as7/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java
branches/as7/engine/src/main/java/org/teiid/security/SecurityHelper.java
branches/as7/engine/src/main/resources/org/teiid/query/i18n.properties
branches/as7/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
branches/as7/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
branches/as7/engine/src/test/java/org/teiid/query/function/TestFunction.java
branches/as7/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
branches/as7/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
branches/as7/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java
branches/as7/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
branches/as7/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
branches/as7/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java
branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
branches/as7/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
branches/as7/engine/src/test/java/org/teiid/query/validator/TestValidator.java
branches/as7/engine/src/test/resources/text/cdm_dos_win.txt
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/pom.xml
branches/as7/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/as7/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
branches/as7/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java
branches/as7/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
branches/as7/runtime/src/main/resources/org/teiid/runtime/i18n.properties
branches/as7/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
branches/as7/test-integration/common/pom.xml
branches/as7/test-integration/common/src/test/java/org/teiid/cdk/api/TestTranslationUtility.java
branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
branches/as7/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_TYPE.expected
branches/as7/test-integration/common/src/test/resources/TestODBCSocketTransport/testPk.expected
branches/as7/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected
branches/as7/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedureParams.expected
branches/as7/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedures.expected
Log:
TEIID-1720: -r3382:3450 forward merge trunk
Property changes on: branches/as7
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:3188-3382
+ /trunk:3188-3450
Property changes on: branches/as7/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java:2901-2940
/trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java:3188-3382
+ /branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java:2901-2940
/trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java:3188-3450
Copied: branches/as7/api/src/main/java/org/teiid/Replicated.java (from rev 3450, trunk/api/src/main/java/org/teiid/Replicated.java)
===================================================================
--- branches/as7/api/src/main/java/org/teiid/Replicated.java (rev 0)
+++ branches/as7/api/src/main/java/org/teiid/Replicated.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Used to replicate Teiid components - this should be used in extension logic.
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface Replicated {
+ /**
+ * @return true if members should be called asynchronously. asynch methods should be void.
+ */
+ boolean asynch() default true;
+ /**
+ * @return the timeout in milliseconds, or 0 if no timeout. affects only synch calls.
+ */
+ long timeout() default 0;
+ /**
+ * @return true if only remote members should be called. should not be used with replicateState. method should be void.
+ */
+ boolean remoteOnly() default false;
+ /**
+ * @return true if the remote members should have a partial state replication called using the first argument as the state after
+ * the local method has been invoked. should not be used with remoteOnly.
+ */
+ boolean replicateState() default false;
+
+}
\ No newline at end of file
Modified: branches/as7/api/src/main/java/org/teiid/events/EventDistributor.java
===================================================================
--- branches/as7/api/src/main/java/org/teiid/events/EventDistributor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/api/src/main/java/org/teiid/events/EventDistributor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -24,6 +24,7 @@
import java.util.List;
+import org.teiid.Replicated;
import org.teiid.metadata.ColumnStats;
import org.teiid.metadata.Table;
import org.teiid.metadata.TableStats;
@@ -45,6 +46,7 @@
* @param tuple
* @param delete
*/
+ @Replicated(remoteOnly=true)
void updateMatViewRow(String vdbName, int vdbVersion, String schema, String viewName, List<?> tuple, boolean delete);
/**
@@ -54,6 +56,7 @@
* @param schema
* @param tableNames
*/
+ @Replicated(remoteOnly=true)
void dataModification(String vdbName, int vdbVersion, String schema, String... tableNames);
/**
@@ -65,6 +68,7 @@
* @param columnName
* @param stats
*/
+ @Replicated(remoteOnly=true)
void setColumnStats(String vdbName, int vdbVersion, String schemaName,
String tableName, String columnName, ColumnStats stats);
@@ -76,6 +80,7 @@
* @param tableName
* @param stats
*/
+ @Replicated(remoteOnly=true)
void setTableStats(String vdbName, int vdbVersion, String schemaName,
String tableName, TableStats stats);
@@ -87,6 +92,7 @@
* @param name
* @param value
*/
+ @Replicated(remoteOnly=true)
void setProperty(String vdbName, int vdbVersion, String uuid, String name, String value);
/**
@@ -99,6 +105,7 @@
* @param triggerDefinition
* @param enabled
*/
+ @Replicated(remoteOnly=true)
void setInsteadOfTriggerDefinition(String vdbName, int vdbVersion, String schema, String viewName, Table.TriggerEvent triggerEvent, String triggerDefinition, Boolean enabled);
/**
@@ -109,6 +116,7 @@
* @param procName
* @param definition
*/
+ @Replicated(remoteOnly=true)
void setProcedureDefinition(String vdbName, int vdbVersion, String schema, String procName, String definition);
/**
@@ -119,13 +127,7 @@
* @param viewName
* @param definition
*/
+ @Replicated(remoteOnly=true)
void setViewDefinition(String vdbName, int vdbVersion, String schema, String viewName, String definition);
- /**
- *
- * @param vdbName
- * @param vdbVersion
- * @param viewName
- */
- void refreshMatView(String vdbName, int vdbVersion, String tableName);
}
Property changes on: branches/as7/api/src/main/java/org/teiid/events/EventDistributor.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/api/src/main/java/org/teiid/events/EventDistributor.java:3340-3349
/trunk/api/src/main/java/org/teiid/events/EventDistributor.java:3188-3382
+ /branches/7.4.x/api/src/main/java/org/teiid/events/EventDistributor.java:3340-3349
/trunk/api/src/main/java/org/teiid/events/EventDistributor.java:3188-3450
Modified: branches/as7/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- branches/as7/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -927,6 +927,7 @@
buffer.append(WITH);
buffer.append(Tokens.SPACE);
append(obj.getItems());
+ buffer.append(Tokens.SPACE);
}
@Override
@@ -940,6 +941,7 @@
buffer.append(Tokens.SPACE);
}
buffer.append(AS);
+ buffer.append(Tokens.SPACE);
buffer.append(Tokens.LPAREN);
append(obj.getSubquery());
buffer.append(Tokens.RPAREN);
Modified: branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -887,6 +887,14 @@
}
/**
+ * @return true if distinct aggregates can be windowed function.
+ * @since 7.6
+ */
+ public boolean supportsWindowDistinctAggregates() {
+ return supportsElementaryOlapOperations();
+ }
+
+ /**
* @return true if array_agg is supported
* @since 7.5
*/
Modified: branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -276,7 +276,7 @@
<async-thread-group>teiid-async</async-thread-group>
<query-engine name = "default">
- <event-distributor-name>teiid/event-distributor</event-distributor-name>
+ <object-replicator-name>teiid/replicator</object-replicator-name>
<security-domain>teiid-security</security-domain>
<jdbc>
<socket-binding>teiid-jdbc</socket-binding>
Modified: branches/as7/build/kits/jboss-container/conf/jboss-teiid-log4j.xml
===================================================================
--- branches/as7/build/kits/jboss-container/conf/jboss-teiid-log4j.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/build/kits/jboss-container/conf/jboss-teiid-log4j.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,3 +1,18 @@
+
+ <!-- un-comment to enable Teiid COMMAND log,
+ NOTE: if there are categories above this appender, this will need to be moved above the categories
+ in order for this appender to work.
+ <appender name="COMMAND" class="org.jboss.logging.appender.RollingFileAppender">
+ <param name="File" value="${jboss.server.log.dir}/teiid-command.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="MaxBackupIndex" value="25"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+
<!--
This file contains log4j.xml snippets that can be used in your main jboss-log4j.xml to control
Teiid logging in more depth. By default all messages will go to the org.teiid category and
@@ -5,14 +20,14 @@
-->
<!-- Teiid root category snippet. Use this to control all of Teiid logging from a single category -->
- <logger name="org.teiid">
- <level value="INFO" />
- </logger>
+ <category name="org.teiid">
+ <priority value="INFO" />
+ </category>
<!-- this is to avoid the "Unable to remove nodes to reduce region size below 1024. Set expiration for nodes in this region" error -->
- <logger name="org.jboss.cache">
- <level value="ERROR" />
- </logger>
+ <category name="org.jboss.cache">
+ <priority value="ERROR" />
+ </category>
<!-- Other categories:
org.teiid.PROCESSOR - Query processing logs. See also org.teiid.PLANNER for query planning logs.
@@ -49,27 +64,17 @@
-->
<!-- un-comment to enable COMMAND log - also needs the COMMAND appender to be uncommented
- <logger name="org.teiid.COMMAND_LOG" additivity="false">
- <level value="DEBUG"/>
+ <category name="org.teiid.COMMAND_LOG" additivity="false">
+ <priority value="DEBUG"/>
<appender-ref ref="COMMAND"/>
- </logger>
+ </category>
-->
<!-- Un-comment to enable AUDIT log - also needs the AUDIT appender to be uncommented.
JBoss already has an AUDIT appender, or you may create your own - see the COMMAND appender below
- <logger name="org.teiid.AUDIT_LOG" additivity="false">
- <level value="DEBUG"/>
+ <category name="org.teiid.AUDIT_LOG" additivity="false">
+ <priority value="DEBUG"/>
<appender-ref ref="AUDIT"/>
- </logger>
+ </category>
-->
-
- <!-- un-comment to enable Teiid COMMAND log
- <appender name="COMMAND" class="org.jboss.logging.appender.RollingFileAppender">
- <param name="File" value="${jboss.server.log.dir}/teiid-command.log"/>
- <param name="MaxFileSize" value="1000KB"/>
- <param name="MaxBackupIndex" value="25"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
- </layout>
- </appender>
- -->
+
Modified: branches/as7/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
===================================================================
--- branches/as7/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -138,14 +138,13 @@
</property>
</bean>
- <bean name="EventDistributorFactory" class="org.teiid.events.jboss.JGroupsEventDistributor">
- <property name="jndiName">teiid/event-distributor</property>
+ <bean name="ObjectReplicator" class="org.teiid.replication.jboss.JGroupsObjectReplicator">
+ <property name="jndiName">teiid/replicator</property>
<property name="channelFactory">
<inject bean="JChannelFactory" />
</property>
- <property name="clusterName">${jboss.partition.name:DefaultPartition}-teiid-events</property>
+ <property name="clusterName">${jboss.partition.name:DefaultPartition}-teiid-rep</property>
<property name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>
- <property name="localEventDistributorName">teiid/engine-deployer</property>
</bean>
</deployment>
\ No newline at end of file
Modified: branches/as7/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- branches/as7/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -131,7 +131,7 @@
<!-- Maximum size of lob allowed through ODBC connection in bytes (default 5MB) -->
<property name="maxODBCLobSizeAllowed">5242880</property>
<!-- The JNDI name of the Teiid Event Distributor -->
- <property name="eventDistributorName">teiid/event-distributor</property>
+ <property name="objectReplicatorName">teiid/replicator</property>
<!-- Set to true for the engine to detect local change events. Should be disabled if using external change data capture tools. (default true) -->
<property name="detectingChangeEvents">true</property>
</bean>
Modified: branches/as7/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/as7/build/kits/jboss-container/teiid-releasenotes.html 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/build/kits/jboss-container/teiid-releasenotes.html 2011-09-05 14:27:44 UTC (rev 3451)
@@ -29,6 +29,7 @@
<LI><B>Procedure language features</B> - Added support for compound/block statements, BEGIN [[NOT] ATOMIC], loop/block labels, and the leave statement. See the reference for more.
<LI><B>File Enhancements</B> - the file translator can now optionally (via the ExceptionIfFileNotFound property) throw an exception if the path refers to a file that doesn't exist. The file resource adapter can be configured to map file names and can prevent parent path .. references. See the Admin Guide or the file-ds.xml template for more.
<LI><B>TEXTTABLE Enhancements</B> - TEXTTABLE can now parse fixed width files that do not use a row delimiter and can optionally produce fixed values that haven't been trimmed.
+ <LI><B>Temp table transactions</B> - Internal materialized views and temp table usage from a session and within procedures can take advantage of greater transaction support.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: branches/as7/build/pom.xml
===================================================================
--- branches/as7/build/pom.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/build/pom.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -119,9 +119,9 @@
<mainClass>net.sf.retrotranslator.transformer.Retrotranslator</mainClass>
<arguments>
<argument>-srcjar</argument>
- <argument>${pom.basedir}/target/teiid-${project.version}-client.jar</argument>
+ <argument>${project.basedir}/target/teiid-${project.version}-client.jar</argument>
<argument>-destjar</argument>
- <argument>${pom.basedir}/target/teiid-${project.version}-client-jdk15.jar</argument>
+ <argument>${project.basedir}/target/teiid-${project.version}-client-jdk15.jar</argument>
<argument>-embed</argument>
<argument>org.teiid.retroruntime</argument>
</arguments>
Modified: branches/as7/cache-jbosscache/pom.xml
===================================================================
--- branches/as7/cache-jbosscache/pom.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/pom.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -25,17 +25,15 @@
<artifactId>teiid-engine</artifactId>
<scope>provided</scope>
</dependency>
- <!--
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- <scope>provided</scope>
- </dependency>
- -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
--- branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -35,6 +35,12 @@
public ExpirationAwareCache(Cache cacheStore, Fqn fqn) {
super(cacheStore, fqn);
}
+
+ @Override
+ protected boolean validateNode(Node node) {
+ Long future = (Long) node.get(ExpirationAlgorithmConfig.EXPIRATION_KEY);
+ return future == null || future > System.currentTimeMillis();
+ }
@Override
public V put(K key, V value) {
Modified: branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
--- branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -52,10 +52,17 @@
Node<K, V> node = getRootNode();
Node child = node.getChild(getFqn(key));
if (child != null) {
- return (V)child.get(key);
+ if (validateNode(child)) {
+ return (V)child.get(key);
+ }
+ remove(key);
}
return null;
}
+
+ protected boolean validateNode(Node node) {
+ return true;
+ }
protected Fqn<String> getFqn(K key) {
if (key.getClass().isPrimitive() || key instanceof String) {
Modified: branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -29,6 +29,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.Region;
import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
@@ -71,6 +72,8 @@
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
cacheRegion.activate();
+ cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
+ cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
JBossCache jc = null;
if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
Deleted: branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.replication.jboss;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class JGroupsInputStream extends InputStream {
-
- static long TIME_OUT = 15000; //TODO make configurable
-
- private volatile byte[] buf;
- private volatile int index=0;
- private ReentrantLock lock = new ReentrantLock();
- private Condition write = lock.newCondition();
- private Condition doneReading = lock.newCondition();
-
- @Override
- public int read() throws IOException {
- if (index < 0) {
- return -1;
- }
- if (buf == null) {
- lock.lock();
- try {
- write.await(TIME_OUT, TimeUnit.MILLISECONDS);
- if (index < 0) {
- return -1;
- }
- if (buf == null) {
- throw new IOException(new TimeoutException());
- }
- } catch(InterruptedException e) {
- throw new IOException(e);
- } finally {
- lock.unlock();
- }
- }
- if (index == buf.length) {
- lock.lock();
- try {
- buf = null;
- index = 0;
- doneReading.signal();
- } finally {
- lock.unlock();
- }
- return read();
- }
- return buf[index++] & 0xff;
- }
-
- @Override
- public void close() {
- lock.lock();
- try {
- buf = null;
- index = -1;
- doneReading.signal();
- } finally {
- lock.unlock();
- }
- }
-
- public void receive(byte[] bytes) throws InterruptedException {
- lock.lock();
- try {
- if (index == -1) {
- return;
- }
- if (buf != null) {
- doneReading.await();
- }
- if (index == -1) {
- return;
- }
- buf = bytes;
- if (bytes == null) {
- index = -1;
- }
- write.signal();
- } finally {
- lock.unlock();
- }
- }
-
-}
\ No newline at end of file
Copied: branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java (from rev 3450, trunk/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java)
===================================================================
--- branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java (rev 0)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,111 @@
+/*
+ * 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.replication.jboss;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class JGroupsInputStream extends InputStream {
+
+ static long TIME_OUT = 15000; //TODO make configurable
+
+ private volatile byte[] buf;
+ private volatile int index=0;
+ private ReentrantLock lock = new ReentrantLock();
+ private Condition write = lock.newCondition();
+ private Condition doneReading = lock.newCondition();
+
+ @Override
+ public int read() throws IOException {
+ if (index < 0) {
+ return -1;
+ }
+ if (buf == null) {
+ lock.lock();
+ try {
+ write.await(TIME_OUT, TimeUnit.MILLISECONDS);
+ if (index < 0) {
+ return -1;
+ }
+ if (buf == null) {
+ throw new IOException(new TimeoutException());
+ }
+ } catch(InterruptedException e) {
+ throw new IOException(e);
+ } finally {
+ lock.unlock();
+ }
+ }
+ if (index == buf.length) {
+ lock.lock();
+ try {
+ buf = null;
+ index = 0;
+ doneReading.signal();
+ } finally {
+ lock.unlock();
+ }
+ return read();
+ }
+ return buf[index++] & 0xff;
+ }
+
+ @Override
+ public void close() {
+ lock.lock();
+ try {
+ buf = null;
+ index = -1;
+ doneReading.signal();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ public void receive(byte[] bytes) throws InterruptedException {
+ lock.lock();
+ try {
+ if (index == -1) {
+ return;
+ }
+ if (buf != null) {
+ doneReading.await();
+ }
+ if (index == -1) {
+ return;
+ }
+ buf = bytes;
+ if (bytes == null) {
+ index = -1;
+ }
+ write.signal();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+}
\ No newline at end of file
Deleted: branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,446 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.replication.jboss;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.ChannelFactory;
-import org.jgroups.ExtendedReceiverAdapter;
-import org.jgroups.Message;
-import org.jgroups.View;
-import org.jgroups.blocks.GroupRequest;
-import org.jgroups.blocks.MethodCall;
-import org.jgroups.blocks.MethodLookup;
-import org.jgroups.blocks.RpcDispatcher;
-import org.jgroups.util.Promise;
-import org.jgroups.util.RspList;
-import org.jgroups.util.Util;
-import org.teiid.Replicated;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.query.ObjectReplicator;
-import org.teiid.query.ReplicatedObject;
-
-public class JGroupsObjectReplicator implements ObjectReplicator, Serializable {
-
- private static final long serialVersionUID = -6851804958313095166L;
- private static final String CREATE_STATE = "createState"; //$NON-NLS-1$
- private static final String BUILD_STATE = "buildState"; //$NON-NLS-1$
- private static final String FINISH_STATE = "finishState"; //$NON-NLS-1$
-
- private final class StreamingRunner implements Runnable {
- private final Object object;
- private final String stateId;
- private final JGroupsInputStream is;
-
- private StreamingRunner(Object object, String stateId, JGroupsInputStream is) {
- this.object = object;
- this.stateId = stateId;
- this.is = is;
- }
-
- @Override
- public void run() {
- try {
- ((ReplicatedObject)object).setState(stateId, is);
- LogManager.logDetail(LogConstants.CTX_RUNTIME, "state set " + stateId); //$NON-NLS-1$
- } catch (Exception e) {
- LogManager.logError(LogConstants.CTX_RUNTIME, e, "error setting state " + stateId); //$NON-NLS-1$
- } finally {
- is.close();
- }
- }
- }
-
- private final static class ReplicatedInvocationHandler<S> extends ExtendedReceiverAdapter implements
- InvocationHandler, Serializable {
-
- private static final long serialVersionUID = -2943462899945966103L;
- private final S object;
- private RpcDispatcher disp;
- private final HashMap<Method, Short> methodMap;
- protected Vector<Address> remoteMembers = new Vector<Address>();
- protected final transient Promise<Boolean> state_promise=new Promise<Boolean>();
-
- private ReplicatedInvocationHandler(S object,
- HashMap<Method, Short> methodMap) {
- this.object = object;
- this.methodMap = methodMap;
- }
-
- public void setDisp(RpcDispatcher disp) {
- this.disp = disp;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- Short methodNum = methodMap.get(method);
- if (methodNum == null || remoteMembers.isEmpty()) {
- if (methodNum != null) {
- Replicated annotation = method.getAnnotation(Replicated.class);
- if (annotation != null && annotation.remoteOnly()) {
- return null;
- }
- }
- try {
- return method.invoke(object, args);
- } catch (InvocationTargetException e) {
- throw e.getCause();
- }
- }
- try {
- Replicated annotation = method.getAnnotation(Replicated.class);
- if (annotation.replicateState()) {
- Object result = null;
- try {
- result = method.invoke(object, args);
- } catch (InvocationTargetException e) {
- throw e.getCause();
- }
- Vector<Address> dests = null;
- synchronized (remoteMembers) {
- dests = new Vector<Address>(remoteMembers);
- }
- ReplicatedObject ro = (ReplicatedObject)object;
- String stateId = (String)args[0];
- LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "replicating state", stateId); //$NON-NLS-1$
- JGroupsOutputStream oStream = new JGroupsOutputStream(disp, dests, stateId, (short)(methodMap.size() - 3));
- try {
- ro.getState(stateId, oStream);
- } finally {
- oStream.close();
- }
- LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "sent state", stateId); //$NON-NLS-1$
- return result;
- }
- MethodCall call=new MethodCall(methodNum, args);
- Vector<Address> dests = null;
- if (annotation.remoteOnly()) {
- synchronized (remoteMembers) {
- dests = new Vector<Address>(remoteMembers);
- }
- }
- RspList responses = disp.callRemoteMethods(dests, call, annotation.asynch()?GroupRequest.GET_NONE:GroupRequest.GET_ALL, annotation.timeout());
- if (annotation.asynch()) {
- return null;
- }
- Vector<Object> results = responses.getResults();
- if (method.getReturnType() == boolean.class) {
- for (Object o : results) {
- if (!Boolean.TRUE.equals(o)) {
- return false;
- }
- }
- return true;
- } else if (method.getReturnType() == Collection.class) {
- ArrayList<Object> result = new ArrayList<Object>();
- for (Object o : results) {
- result.addAll((Collection)o);
- }
- return results;
- }
- return null;
- } catch(Exception e) {
- throw new RuntimeException(method + " " + args + " failed"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- @Override
- public void viewAccepted(View newView) {
- if (newView.getMembers() != null) {
- synchronized (remoteMembers) {
- remoteMembers.removeAll(newView.getMembers());
- if (object instanceof ReplicatedObject && !remoteMembers.isEmpty()) {
- ((ReplicatedObject)object).droppedMembers(new HashSet<Serializable>(remoteMembers));
- }
- remoteMembers.clear();
- remoteMembers.addAll(newView.getMembers());
- remoteMembers.remove(this.disp.getChannel().getLocalAddress());
- }
- }
- }
-
- @Override
- public void setState(InputStream istream) {
- LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "loading initial state"); //$NON-NLS-1$
- try {
- ((ReplicatedObject)object).setState(istream);
- state_promise.setResult(Boolean.TRUE);
- } catch (Exception e) {
- state_promise.setResult(Boolean.FALSE);
- LogManager.logError(LogConstants.CTX_RUNTIME, e, "error loading initial state"); //$NON-NLS-1$
- } finally {
- Util.close(istream);
- }
- }
-
- @Override
- public void getState(OutputStream ostream) {
- LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "getting initial state"); //$NON-NLS-1$
- try {
- ((ReplicatedObject)object).getState(ostream);
- } catch (Exception e) {
- LogManager.logError(LogConstants.CTX_RUNTIME, e, "error gettting initial state"); //$NON-NLS-1$
- } finally {
- Util.close(ostream);
- }
- }
- }
-
- private interface Streaming {
- void createState(String id);
- void buildState(String id, byte[] bytes);
- void finishState(String id);
- }
-
- private transient ChannelFactory channelFactory;
- private String multiplexerStack;
- private String clusterName;
- private String jndiName;
- //TODO: this should be configurable, or use a common executor
- private transient Executor executor = Executors.newCachedThreadPool();
-
- public ChannelFactory getChannelFactory() {
- return channelFactory;
- }
-
- public void setJndiName(String jndiName) {
- this.jndiName = jndiName;
- }
-
- public String getJndiName() {
- return jndiName;
- }
-
- public String getMultiplexerStack() {
- return multiplexerStack;
- }
-
- public String getClusterName() {
- return clusterName;
- }
-
- public void setChannelFactory(ChannelFactory channelFactory) {
- this.channelFactory = channelFactory;
- }
-
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
-
- public void setMultiplexerStack(String multiplexerStack) {
- this.multiplexerStack = multiplexerStack;
- }
-
- public void start() throws Exception {
- if (this.channelFactory == null) {
- return; //no need to distribute events
- }
- if (jndiName != null) {
- final InitialContext ic = new InitialContext();
- org.jboss.util.naming.Util.bind(ic, jndiName, this);
- }
- }
-
- public void stop() {
- if (jndiName != null) {
- final InitialContext ic ;
- try {
- ic = new InitialContext() ;
- org.jboss.util.naming.Util.unbind(ic, jndiName) ;
- } catch (final NamingException ne) {
- }
- }
- }
-
- public void stop(Object object) {
- ReplicatedInvocationHandler<?> handler = (ReplicatedInvocationHandler<?>) Proxy.getInvocationHandler(object);
- Channel c = handler.disp.getChannel();
- handler.disp.stop();
- c.close();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T, S> T replicate(String mux_id,
- Class<T> iface, final S object, long startTimeout) throws Exception {
- Channel channel = this.channelFactory.createMultiplexerChannel(this.multiplexerStack, mux_id);
- Method[] methods = iface.getMethods();
-
- final HashMap<Method, Short> methodMap = new HashMap<Method, Short>();
- final ArrayList<Method> methodList = new ArrayList<Method>();
-
- for (Method method : methods) {
- if (method.getAnnotation(Replicated.class) == null) {
- continue;
- }
- methodList.add(method);
- methodMap.put(method, (short)(methodList.size() - 1));
- }
-
- //add in streaming methods
- Method createState = JGroupsObjectReplicator.Streaming.class.getMethod(CREATE_STATE, new Class<?>[] {String.class});
- methodList.add(createState);
- methodMap.put(createState, (short)(methodList.size() - 1));
- Method buildState = JGroupsObjectReplicator.Streaming.class.getMethod(BUILD_STATE, new Class<?>[] {String.class, byte[].class});
- methodList.add(buildState);
- methodMap.put(buildState, (short)(methodList.size() - 1));
- Method finishState = JGroupsObjectReplicator.Streaming.class.getMethod(FINISH_STATE, new Class<?>[] {String.class});
- methodList.add(finishState);
- methodMap.put(finishState, (short)(methodList.size() - 1));
-
- ReplicatedInvocationHandler<S> proxy = new ReplicatedInvocationHandler<S>(object, methodMap);
- /*
- * TODO: could have an object implement streaming
- * Override the normal handle method to support streaming
- */
- RpcDispatcher disp = new RpcDispatcher(channel, proxy, proxy, object) {
- Map<List<?>, JGroupsInputStream> inputStreams = new ConcurrentHashMap<List<?>, JGroupsInputStream>();
- @Override
- public Object handle(Message req) {
- Object body=null;
-
- if(req == null || req.getLength() == 0) {
- if(log.isErrorEnabled()) log.error("message or message buffer is null"); //$NON-NLS-1$
- return null;
- }
-
- try {
- body=req_marshaller != null?
- req_marshaller.objectFromByteBuffer(req.getBuffer(), req.getOffset(), req.getLength())
- : req.getObject();
- }
- catch(Throwable e) {
- if(log.isErrorEnabled()) log.error("exception marshalling object", e); //$NON-NLS-1$
- return e;
- }
-
- if(!(body instanceof MethodCall)) {
- if(log.isErrorEnabled()) log.error("message does not contain a MethodCall object"); //$NON-NLS-1$
-
- // create an exception to represent this and return it
- return new IllegalArgumentException("message does not contain a MethodCall object") ; //$NON-NLS-1$
- }
-
- final MethodCall method_call=(MethodCall)body;
-
- try {
- if(log.isTraceEnabled())
- log.trace("[sender=" + req.getSrc() + "], method_call: " + method_call); //$NON-NLS-1$ //$NON-NLS-2$
-
- if(method_lookup == null)
- throw new Exception("MethodCall uses ID=" + method_call.getId() + ", but method_lookup has not been set"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (method_call.getId() >= methodList.size() - 3) {
- Serializable address = req.getSrc();
- String stateId = (String)method_call.getArgs()[0];
- List<?> key = Arrays.asList(stateId, address);
- JGroupsInputStream is = inputStreams.get(key);
- if (method_call.getId() == methodList.size() - 3) {
- LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "create state", stateId); //$NON-NLS-1$
- if (is != null) {
- is.receive(null);
- }
- is = new JGroupsInputStream();
- this.inputStreams.put(key, is);
- executor.execute(new StreamingRunner(object, stateId, is));
- } else if (method_call.getId() == methodList.size() - 2) {
- LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "building state", stateId); //$NON-NLS-1$
- if (is != null) {
- is.receive((byte[])method_call.getArgs()[1]);
- }
- } else if (method_call.getId() == methodList.size() - 1) {
- LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "finished state", stateId); //$NON-NLS-1$
- if (is != null) {
- is.receive(null);
- }
- this.inputStreams.remove(key);
- }
- return null;
- }
-
- Method m=method_lookup.findMethod(method_call.getId());
- if(m == null)
- throw new Exception("no method found for " + method_call.getId()); //$NON-NLS-1$
- method_call.setMethod(m);
-
- return method_call.invoke(server_obj);
- }
- catch(Throwable x) {
- return x;
- }
- }
- };
-
- proxy.setDisp(disp);
- disp.setMethodLookup(new MethodLookup() {
- public Method findMethod(short id) {
- return methodList.get(id);
- }
- });
-
- T replicatedProxy = (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, proxy);
-
- channel.connect(clusterName);
- if (object instanceof ReplicatedObject) {
- ((ReplicatedObject)object).setLocalAddress(channel.getLocalAddress());
- boolean getState = channel.getState(null, startTimeout);
- if (getState) {
- boolean loaded = proxy.state_promise.getResult(startTimeout);
- if (loaded) {
- LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "loaded"); //$NON-NLS-1$
- } else {
- LogManager.logWarning(LogConstants.CTX_RUNTIME, object + " load timeout"); //$NON-NLS-1$
- }
- } else {
- LogManager.logInfo(LogConstants.CTX_RUNTIME, object + " first member or timeout exceeded"); //$NON-NLS-1$
- }
- }
-
- return replicatedProxy;
- }
-
-}
Copied: branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java (from rev 3450, trunk/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java)
===================================================================
--- branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java (rev 0)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsObjectReplicator.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -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.replication.jboss;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import org.jgroups.*;
+import org.jgroups.blocks.GroupRequest;
+import org.jgroups.blocks.MethodCall;
+import org.jgroups.blocks.MethodLookup;
+import org.jgroups.blocks.RpcDispatcher;
+import org.jgroups.util.Promise;
+import org.jgroups.util.RspList;
+import org.jgroups.util.Util;
+import org.teiid.Replicated;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.query.ObjectReplicator;
+import org.teiid.query.ReplicatedObject;
+
+public class JGroupsObjectReplicator implements ObjectReplicator, Serializable {
+
+ private static final long serialVersionUID = -6851804958313095166L;
+ private static final String CREATE_STATE = "createState"; //$NON-NLS-1$
+ private static final String BUILD_STATE = "buildState"; //$NON-NLS-1$
+ private static final String FINISH_STATE = "finishState"; //$NON-NLS-1$
+
+ private final class StreamingRunner implements Runnable {
+ private final Object object;
+ private final String stateId;
+ private final JGroupsInputStream is;
+
+ private StreamingRunner(Object object, String stateId, JGroupsInputStream is) {
+ this.object = object;
+ this.stateId = stateId;
+ this.is = is;
+ }
+
+ @Override
+ public void run() {
+ try {
+ ((ReplicatedObject)object).setState(stateId, is);
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, "state set " + stateId); //$NON-NLS-1$
+ } catch (Exception e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, "error setting state " + stateId); //$NON-NLS-1$
+ } finally {
+ is.close();
+ }
+ }
+ }
+
+ private final static class ReplicatedInvocationHandler<S> extends ExtendedReceiverAdapter implements
+ InvocationHandler, Serializable {
+
+ private static final long serialVersionUID = -2943462899945966103L;
+ private final S object;
+ private RpcDispatcher disp;
+ private final HashMap<Method, Short> methodMap;
+ protected Vector<Address> remoteMembers = new Vector<Address>();
+ protected final transient Promise<Boolean> state_promise=new Promise<Boolean>();
+
+ private ReplicatedInvocationHandler(S object,
+ HashMap<Method, Short> methodMap) {
+ this.object = object;
+ this.methodMap = methodMap;
+ }
+
+ public void setDisp(RpcDispatcher disp) {
+ this.disp = disp;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ Short methodNum = methodMap.get(method);
+ if (methodNum == null || remoteMembers.isEmpty()) {
+ if (methodNum != null) {
+ Replicated annotation = method.getAnnotation(Replicated.class);
+ if (annotation != null && annotation.remoteOnly()) {
+ return null;
+ }
+ }
+ try {
+ return method.invoke(object, args);
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ }
+ }
+ try {
+ Replicated annotation = method.getAnnotation(Replicated.class);
+ if (annotation.replicateState()) {
+ Object result = null;
+ try {
+ result = method.invoke(object, args);
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ }
+ Vector<Address> dests = null;
+ synchronized (remoteMembers) {
+ dests = new Vector<Address>(remoteMembers);
+ }
+ ReplicatedObject ro = (ReplicatedObject)object;
+ String stateId = (String)args[0];
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "replicating state", stateId); //$NON-NLS-1$
+ JGroupsOutputStream oStream = new JGroupsOutputStream(disp, dests, stateId, (short)(methodMap.size() - 3));
+ try {
+ ro.getState(stateId, oStream);
+ } finally {
+ oStream.close();
+ }
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "sent state", stateId); //$NON-NLS-1$
+ return result;
+ }
+ MethodCall call=new MethodCall(methodNum, args);
+ Vector<Address> dests = null;
+ if (annotation.remoteOnly()) {
+ synchronized (remoteMembers) {
+ dests = new Vector<Address>(remoteMembers);
+ }
+ }
+ RspList responses = disp.callRemoteMethods(dests, call, annotation.asynch()?GroupRequest.GET_NONE:GroupRequest.GET_ALL, annotation.timeout());
+ if (annotation.asynch()) {
+ return null;
+ }
+ Vector<Object> results = responses.getResults();
+ if (method.getReturnType() == boolean.class) {
+ for (Object o : results) {
+ if (!Boolean.TRUE.equals(o)) {
+ return false;
+ }
+ }
+ return true;
+ } else if (method.getReturnType() == Collection.class) {
+ ArrayList<Object> result = new ArrayList<Object>();
+ for (Object o : results) {
+ result.addAll((Collection)o);
+ }
+ return results;
+ }
+ return null;
+ } catch(Exception e) {
+ throw new RuntimeException(method + " " + args + " failed"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ @Override
+ public void viewAccepted(View newView) {
+ if (newView.getMembers() != null) {
+ synchronized (remoteMembers) {
+ remoteMembers.removeAll(newView.getMembers());
+ if (object instanceof ReplicatedObject && !remoteMembers.isEmpty()) {
+ ((ReplicatedObject)object).droppedMembers(new HashSet<Serializable>(remoteMembers));
+ }
+ remoteMembers.clear();
+ remoteMembers.addAll(newView.getMembers());
+ remoteMembers.remove(this.disp.getChannel().getLocalAddress());
+ }
+ }
+ }
+
+ @Override
+ public void setState(InputStream istream) {
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "loading initial state"); //$NON-NLS-1$
+ try {
+ ((ReplicatedObject)object).setState(istream);
+ state_promise.setResult(Boolean.TRUE);
+ } catch (Exception e) {
+ state_promise.setResult(Boolean.FALSE);
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, "error loading initial state"); //$NON-NLS-1$
+ } finally {
+ Util.close(istream);
+ }
+ }
+
+ @Override
+ public void getState(OutputStream ostream) {
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "getting initial state"); //$NON-NLS-1$
+ try {
+ ((ReplicatedObject)object).getState(ostream);
+ } catch (Exception e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, "error gettting initial state"); //$NON-NLS-1$
+ } finally {
+ Util.close(ostream);
+ }
+ }
+ }
+
+ private interface Streaming {
+ void createState(String id);
+ void buildState(String id, byte[] bytes);
+ void finishState(String id);
+ }
+
+ private transient ChannelFactory channelFactory;
+ private String multiplexerStack;
+ private String clusterName;
+ private String jndiName;
+ //TODO: this should be configurable, or use a common executor
+ private transient Executor executor = Executors.newCachedThreadPool();
+
+ public ChannelFactory getChannelFactory() {
+ return channelFactory;
+ }
+
+ public void setJndiName(String jndiName) {
+ this.jndiName = jndiName;
+ }
+
+ public String getJndiName() {
+ return jndiName;
+ }
+
+ public String getMultiplexerStack() {
+ return multiplexerStack;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public void setChannelFactory(ChannelFactory channelFactory) {
+ this.channelFactory = channelFactory;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ public void setMultiplexerStack(String multiplexerStack) {
+ this.multiplexerStack = multiplexerStack;
+ }
+
+ public void start() throws Exception {
+ if (this.channelFactory == null) {
+ return; //no need to distribute events
+ }
+ }
+
+ public void stop() {
+ }
+
+ public void stop(Object object) {
+ ReplicatedInvocationHandler<?> handler = (ReplicatedInvocationHandler<?>) Proxy.getInvocationHandler(object);
+ Channel c = handler.disp.getChannel();
+ handler.disp.stop();
+ c.close();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T, S> T replicate(String mux_id,
+ Class<T> iface, final S object, long startTimeout) throws Exception {
+ Channel channel = this.channelFactory.createMultiplexerChannel(this.multiplexerStack, mux_id);
+ Method[] methods = iface.getMethods();
+
+ final HashMap<Method, Short> methodMap = new HashMap<Method, Short>();
+ final ArrayList<Method> methodList = new ArrayList<Method>();
+
+ for (Method method : methods) {
+ if (method.getAnnotation(Replicated.class) == null) {
+ continue;
+ }
+ methodList.add(method);
+ methodMap.put(method, (short)(methodList.size() - 1));
+ }
+
+ //add in streaming methods
+ Method createState = JGroupsObjectReplicator.Streaming.class.getMethod(CREATE_STATE, new Class<?>[] {String.class});
+ methodList.add(createState);
+ methodMap.put(createState, (short)(methodList.size() - 1));
+ Method buildState = JGroupsObjectReplicator.Streaming.class.getMethod(BUILD_STATE, new Class<?>[] {String.class, byte[].class});
+ methodList.add(buildState);
+ methodMap.put(buildState, (short)(methodList.size() - 1));
+ Method finishState = JGroupsObjectReplicator.Streaming.class.getMethod(FINISH_STATE, new Class<?>[] {String.class});
+ methodList.add(finishState);
+ methodMap.put(finishState, (short)(methodList.size() - 1));
+
+ ReplicatedInvocationHandler<S> proxy = new ReplicatedInvocationHandler<S>(object, methodMap);
+ /*
+ * TODO: could have an object implement streaming
+ * Override the normal handle method to support streaming
+ */
+ RpcDispatcher disp = new RpcDispatcher(channel, proxy, proxy, object) {
+ Map<List<?>, JGroupsInputStream> inputStreams = new ConcurrentHashMap<List<?>, JGroupsInputStream>();
+ @Override
+ public Object handle(Message req) {
+ Object body=null;
+
+ if(req == null || req.getLength() == 0) {
+ if(log.isErrorEnabled()) log.error("message or message buffer is null"); //$NON-NLS-1$
+ return null;
+ }
+
+ try {
+ body=req_marshaller != null?
+ req_marshaller.objectFromByteBuffer(req.getBuffer(), req.getOffset(), req.getLength())
+ : req.getObject();
+ }
+ catch(Throwable e) {
+ if(log.isErrorEnabled()) log.error("exception marshalling object", e); //$NON-NLS-1$
+ return e;
+ }
+
+ if(!(body instanceof MethodCall)) {
+ if(log.isErrorEnabled()) log.error("message does not contain a MethodCall object"); //$NON-NLS-1$
+
+ // create an exception to represent this and return it
+ return new IllegalArgumentException("message does not contain a MethodCall object") ; //$NON-NLS-1$
+ }
+
+ final MethodCall method_call=(MethodCall)body;
+
+ try {
+ if(log.isTraceEnabled())
+ log.trace("[sender=" + req.getSrc() + "], method_call: " + method_call); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if(method_lookup == null)
+ throw new Exception("MethodCall uses ID=" + method_call.getId() + ", but method_lookup has not been set"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (method_call.getId() >= methodList.size() - 3) {
+ Serializable address = req.getSrc();
+ String stateId = (String)method_call.getArgs()[0];
+ List<?> key = Arrays.asList(stateId, address);
+ JGroupsInputStream is = inputStreams.get(key);
+ if (method_call.getId() == methodList.size() - 3) {
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "create state", stateId); //$NON-NLS-1$
+ if (is != null) {
+ is.receive(null);
+ }
+ is = new JGroupsInputStream();
+ this.inputStreams.put(key, is);
+ executor.execute(new StreamingRunner(object, stateId, is));
+ } else if (method_call.getId() == methodList.size() - 2) {
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "building state", stateId); //$NON-NLS-1$
+ if (is != null) {
+ is.receive((byte[])method_call.getArgs()[1]);
+ }
+ } else if (method_call.getId() == methodList.size() - 1) {
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, object, "finished state", stateId); //$NON-NLS-1$
+ if (is != null) {
+ is.receive(null);
+ }
+ this.inputStreams.remove(key);
+ }
+ return null;
+ }
+
+ Method m=method_lookup.findMethod(method_call.getId());
+ if(m == null)
+ throw new Exception("no method found for " + method_call.getId()); //$NON-NLS-1$
+ method_call.setMethod(m);
+
+ return method_call.invoke(server_obj);
+ }
+ catch(Throwable x) {
+ return x;
+ }
+ }
+ };
+
+ proxy.setDisp(disp);
+ disp.setMethodLookup(new MethodLookup() {
+ public Method findMethod(short id) {
+ return methodList.get(id);
+ }
+ });
+
+ T replicatedProxy = (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, proxy);
+
+ channel.connect(clusterName);
+ if (object instanceof ReplicatedObject) {
+ ((ReplicatedObject)object).setLocalAddress(channel.getLocalAddress());
+ boolean getState = channel.getState(null, startTimeout);
+ if (getState) {
+ boolean loaded = proxy.state_promise.getResult(startTimeout);
+ if (loaded) {
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, object, "loaded"); //$NON-NLS-1$
+ } else {
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, object + " load timeout"); //$NON-NLS-1$
+ }
+ } else {
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, object + " first member or timeout exceeded"); //$NON-NLS-1$
+ }
+ }
+
+ return replicatedProxy;
+ }
+
+}
Deleted: branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.replication.jboss;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.Vector;
-
-import org.jgroups.Address;
-import org.jgroups.blocks.GroupRequest;
-import org.jgroups.blocks.MethodCall;
-import org.jgroups.blocks.RpcDispatcher;
-import org.teiid.core.types.Streamable;
-
-public class JGroupsOutputStream extends OutputStream {
-
- static final int CHUNK_SIZE=Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
-
- protected final RpcDispatcher disp;
- protected final Vector<Address> dests;
- protected final String stateId;
- protected final short methodOffset;
-
- private volatile boolean closed=false;
- private final byte[] buffer=new byte[CHUNK_SIZE];
- private int index=0;
-
- public JGroupsOutputStream(RpcDispatcher disp, Vector<Address> dests, String stateId, short methodOffset) {
- this.disp=disp;
- this.dests=dests;
- this.stateId=stateId;
- this.methodOffset = methodOffset;
- disp.callRemoteMethods(this.dests, new MethodCall(methodOffset, new Object[] {stateId}), GroupRequest.GET_NONE, 0);
- }
-
- public void close() throws IOException {
- if(closed) {
- return;
- }
- flush();
- try {
- disp.callRemoteMethods(dests, new MethodCall((short)(methodOffset + 2), new Object[] {stateId}), GroupRequest.GET_NONE, 0);
- } catch(Exception e) {
- }
- closed=true;
- }
-
- public void flush() throws IOException {
- checkClosed();
- try {
- if(index == 0) {
- return;
- }
- disp.callRemoteMethods(dests, new MethodCall((short)(methodOffset + 1), new Object[] {stateId, Arrays.copyOf(buffer, index)}), GroupRequest.GET_NONE, 0);
- index=0;
- } catch(Exception e) {
- throw new IOException(e);
- }
- }
-
- private void checkClosed() throws IOException {
- if(closed) {
- throw new IOException("output stream is closed"); //$NON-NLS-1$
- }
- }
-
- public void write(int b) throws IOException {
- checkClosed();
- if(index >= buffer.length) {
- flush();
- }
- buffer[index++]=(byte)b;
- }
-
-}
\ No newline at end of file
Copied: branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java (from rev 3450, trunk/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java)
===================================================================
--- branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java (rev 0)
+++ branches/as7/cache-jbosscache/src/main/java/org/teiid/replication/jboss/JGroupsOutputStream.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -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.replication.jboss;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Vector;
+
+import org.jgroups.Address;
+import org.jgroups.blocks.GroupRequest;
+import org.jgroups.blocks.MethodCall;
+import org.jgroups.blocks.RpcDispatcher;
+import org.teiid.core.types.Streamable;
+
+public class JGroupsOutputStream extends OutputStream {
+
+ static final int CHUNK_SIZE=Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
+
+ protected final RpcDispatcher disp;
+ protected final Vector<Address> dests;
+ protected final String stateId;
+ protected final short methodOffset;
+
+ private volatile boolean closed=false;
+ private final byte[] buffer=new byte[CHUNK_SIZE];
+ private int index=0;
+
+ public JGroupsOutputStream(RpcDispatcher disp, Vector<Address> dests, String stateId, short methodOffset) {
+ this.disp=disp;
+ this.dests=dests;
+ this.stateId=stateId;
+ this.methodOffset = methodOffset;
+ disp.callRemoteMethods(this.dests, new MethodCall(methodOffset, new Object[] {stateId}), GroupRequest.GET_NONE, 0);
+ }
+
+ public void close() throws IOException {
+ if(closed) {
+ return;
+ }
+ flush();
+ try {
+ disp.callRemoteMethods(dests, new MethodCall((short)(methodOffset + 2), new Object[] {stateId}), GroupRequest.GET_NONE, 0);
+ } catch(Exception e) {
+ }
+ closed=true;
+ }
+
+ public void flush() throws IOException {
+ checkClosed();
+ try {
+ if(index == 0) {
+ return;
+ }
+ disp.callRemoteMethods(dests, new MethodCall((short)(methodOffset + 1), new Object[] {stateId, Arrays.copyOf(buffer, index)}), GroupRequest.GET_NONE, 0);
+ index=0;
+ } catch(Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ private void checkClosed() throws IOException {
+ if(closed) {
+ throw new IOException("output stream is closed"); //$NON-NLS-1$
+ }
+ }
+
+ public void write(int b) throws IOException {
+ checkClosed();
+ if(index >= buffer.length) {
+ flush();
+ }
+ buffer[index++]=(byte)b;
+ }
+
+}
\ No newline at end of file
Modified: branches/as7/client/src/main/java/org/teiid/client/security/LogonResult.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/client/security/LogonResult.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/main/java/org/teiid/client/security/LogonResult.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -26,6 +26,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.OptionalDataException;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
@@ -116,7 +117,11 @@
timeZone = (TimeZone)in.readObject();
clusterName = (String)in.readObject();
vdbVersion = in.readInt();
- addtionalProperties = ExternalizeUtil.readMap(in);
+ try {
+ addtionalProperties = ExternalizeUtil.readMap(in);
+ } catch (OptionalDataException e) {
+
+ }
}
@Override
Modified: branches/as7/client/src/main/java/org/teiid/jdbc/BatchResults.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/jdbc/BatchResults.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/main/java/org/teiid/jdbc/BatchResults.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -187,11 +187,11 @@
}
if (row > 0) {
- //row is greater than highest, but the last row is not known
- while (row + offset > highestRowNumber && lastRowNumber == -1) {
- requestNextBatch();
+
+ if (row + offset > highestRowNumber && lastRowNumber == -1) {
+ requestBatchAndWait(row + offset);
}
-
+
if (row + offset <= highestRowNumber) {
setCurrentRowNumber(row);
return true;
@@ -203,9 +203,9 @@
row -= offset;
- while (lastRowNumber == -1) {
- requestNextBatch();
- }
+ if (lastRowNumber == -1) {
+ requestBatchAndWait(Integer.MAX_VALUE);
+ }
int positiveRow = lastRowNumber + row + 1;
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java:3149-3217
/trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java:3149-3217
/trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java:3188-3450
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java:3281-3325
/trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java:3281-3325
/trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java:3188-3450
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java:3149-3217
/trunk/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java:3149-3217
/trunk/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java:3188-3450
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/JDBCURL.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java:3149-3217,3281-3325
/trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java:3149-3217,3281-3325
/trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java:3188-3450
Modified: branches/as7/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -191,8 +191,8 @@
throw new TeiidSQLException(msg);
}
- public ResultsFuture<Boolean> submitExecute() throws SQLException {
- return executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER, false);
+ public ResultsFuture<Boolean> submitExecute(ResultsMode mode) throws SQLException {
+ return executeSql(new String[] {this.prepareSql}, false, mode, false);
}
@Override
@@ -236,14 +236,6 @@
return message;
}
- /**
- * <p>Retreives a ResultSetMetaData object with information about the numbers,
- * types, and properties of columns in the ResultSet object that will be returned
- * when this preparedstatement object is executed.
- * @return ResultSetMetaData object
- * @throws SQLException, currently there is no means of getting results
- * metadata before getting results.
- */
public ResultSetMetaData getMetaData() throws SQLException {
// check if the statement is open
Modified: branches/as7/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -245,6 +245,7 @@
public void onCompletion(ResultsFuture<ResultsMessage> future) {
try {
batchResults.setBatch(processBatch(future.get()));
+ result.getResultsReceiver().receiveResults(next());
} catch (Throwable t) {
result.getResultsReceiver().exceptionOccurred(t);
}
@@ -253,13 +254,6 @@
return result;
}
- /**
- * Move row pointer forward one row. This may cause the cursor
- * to fetch more rows.
- * @return True if the current index is on a valid row, false if
- * the pointer is past the end of the rows
- * @throws SQLException if this result set has an exception
- */
public boolean next() throws SQLException {
checkClosed();
if (hasNext()) {
@@ -269,24 +263,12 @@
return false;
}
- /**
- * Move row pointer backward one row. This may cause the cursor
- * to fetch more rows.
- * @return True if the current index is on a valid row, false if
- * the pointer is before the beginning of the rows
- * @throws SQLException if this result set has an exception
- */
public boolean previous() throws SQLException {
checkClosed();
checkNotForwardOnly();
return batchResults.previous();
}
- /**
- * Get current row pointer.
- * @return Index of current row
- * @throws SQLException if this result set has an exception
- */
public int getRow() throws SQLException {
checkClosed();
if (isAfterLast()) {
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java:3281-3325
/trunk/client/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java:3281-3325
/trunk/client/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java:3188-3450
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/SQLStates.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/SQLStates.java:3220-3275
/trunk/client/src/main/java/org/teiid/jdbc/SQLStates.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/SQLStates.java:3220-3275
/trunk/client/src/main/java/org/teiid/jdbc/SQLStates.java:3188-3450
Modified: branches/as7/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -423,7 +423,7 @@
JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getExecutionProperties());
}
this.updateCounts = new int[] {0};
- return booleanFuture(true);
+ return booleanFuture(false);
}
match = TRANSACTION_STATEMENT.matcher(commands[0]);
if (match.matches()) {
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/StatementImpl.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java:3149-3217,3220-3275,3281-3325,3355-3365
/trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java:3149-3217,3220-3275,3281-3325,3355-3365
/trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java:3188-3450
Property changes on: branches/as7/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java:3220-3275
/trunk/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java:3220-3275
/trunk/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java:3188-3450
Property changes on: branches/as7/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java:3149-3217
/trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java:3188-3382
+ /branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java:3149-3217
/trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java:3188-3450
Modified: branches/as7/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -34,14 +34,13 @@
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
@@ -709,30 +708,27 @@
cs.next();
}
- static ResultSetImpl helpTestBatching(StatementImpl statement, int fetchSize, int batchLength,
- int totalLength) throws InterruptedException, ExecutionException,
- TeiidProcessingException, SQLException, TimeoutException {
+ static ResultSetImpl helpTestBatching(StatementImpl statement, final int fetchSize, final int batchLength,
+ final int totalLength) throws TeiidProcessingException, SQLException {
DQP dqp = statement.getDQP();
if (dqp == null) {
dqp = mock(DQP.class);
stub(statement.getDQP()).toReturn(dqp);
}
stub(statement.getFetchSize()).toReturn(fetchSize);
- for (int i = batchLength; i < totalLength; i += batchLength) {
- //forward requests
- ResultsFuture<ResultsMessage> nextBatch = mock(ResultsFuture.class);
- stub(nextBatch.get(Matchers.anyLong(), (TimeUnit)Matchers.anyObject())).toReturn(exampleResultsMsg4(i + 1, Math.min(batchLength, totalLength - i), fetchSize, i + batchLength >= totalLength));
- stub(dqp.processCursorRequest(REQUEST_ID, i + 1, fetchSize)).toReturn(nextBatch);
-
- if (i + batchLength < totalLength) {
- //backward requests
- ResultsFuture<ResultsMessage> previousBatch = mock(ResultsFuture.class);
- stub(previousBatch.get(Matchers.anyLong(), (TimeUnit)Matchers.anyObject())).toReturn(exampleResultsMsg4(i - batchLength + 1, i, fetchSize, false));
- stub(dqp.processCursorRequest(REQUEST_ID, i, fetchSize)).toReturn(previousBatch);
+ stub(dqp.processCursorRequest(Matchers.eq(REQUEST_ID), Matchers.anyInt(), Matchers.eq(fetchSize))).toAnswer(new Answer<ResultsFuture<ResultsMessage>>() {
+ @Override
+ public ResultsFuture<ResultsMessage> answer(
+ InvocationOnMock invocation) throws Throwable {
+ ResultsFuture<ResultsMessage> nextBatch = new ResultsFuture<ResultsMessage>();
+ int begin = Math.min(totalLength, (Integer)invocation.getArguments()[1]);
+ int length = Math.min(totalLength - begin + 1, batchLength);
+ nextBatch.getResultsReceiver().receiveResults(exampleResultsMsg4(begin, length, begin + length - 1>= totalLength));
+ return nextBatch;
}
- }
+ });
- ResultsMessage msg = exampleResultsMsg4(1, batchLength, fetchSize, batchLength == totalLength);
+ ResultsMessage msg = exampleResultsMsg4(1, batchLength, batchLength == totalLength);
return new ResultSetImpl(msg, statement, new ResultSetMetaDataImpl(new MetadataProvider(DeferredMetadataProvider.loadPartialMetadata(msg.getColumnNames(), msg.getDataTypes())), null), 0);
}
@@ -835,7 +831,7 @@
return exampleMessage(new List[0], new String[] { "IntNum", "StringNum" }, new String[] { JDBCSQLTypeInfo.INTEGER, JDBCSQLTypeInfo.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
}
- private static ResultsMessage exampleResultsMsg4(int begin, int length, int fetchSize, boolean lastBatch) {
+ private static ResultsMessage exampleResultsMsg4(int begin, int length, boolean lastBatch) {
RequestMessage request = new RequestMessage();
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
Modified: branches/as7/client/src/test/java/org/teiid/jdbc/TestBatchResults.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/jdbc/TestBatchResults.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/client/src/test/java/org/teiid/jdbc/TestBatchResults.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -41,13 +41,13 @@
static class MockBatchFetcher implements BatchFetcher {
- private int totalRows = 50;
+ private int totalRows;
private boolean throwException;
private boolean useLastRow;
List<Integer> batchCalls = new ArrayList<Integer>();
public MockBatchFetcher() {
-
+ this(50);
}
public MockBatchFetcher(int totalRows) {
@@ -68,7 +68,11 @@
if (beginRow%10==0) {
endRow = beginRow - 9;
}
- if(beginRow > endRow) {
+ if (beginRow > totalRows) {
+ beginRow = totalRows + 1;
+ endRow = totalRows;
+ isLast = true;
+ } else if(beginRow > endRow) {
if(endRow < 1) {
endRow = 1;
}
@@ -76,7 +80,7 @@
beginRow = endRow;
endRow = i;
} else if(endRow > totalRows) {
- endRow = totalRows;
+ endRow = totalRows;
isLast = true;
}
Batch batch = new Batch(createBatch(beginRow, endRow), beginRow, endRow, isLast);
Property changes on: branches/as7/client/src/test/java/org/teiid/jdbc/TestConnection.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestConnection.java:3281-3325
/trunk/client/src/test/java/org/teiid/jdbc/TestConnection.java:3188-3382
+ /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestConnection.java:3281-3325
/trunk/client/src/test/java/org/teiid/jdbc/TestConnection.java:3188-3450
Property changes on: branches/as7/client/src/test/java/org/teiid/jdbc/TestSQLException.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestSQLException.java:3220-3275
/trunk/client/src/test/java/org/teiid/jdbc/TestSQLException.java:3188-3382
+ /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestSQLException.java:3220-3275
/trunk/client/src/test/java/org/teiid/jdbc/TestSQLException.java:3188-3450
Property changes on: branches/as7/client/src/test/java/org/teiid/jdbc/TestStatement.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestStatement.java:3149-3217,3220-3275
/trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java:3188-3382
+ /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestStatement.java:3149-3217,3220-3275
/trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java:3188-3450
Property changes on: branches/as7/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java:3149-3217,3281-3325
/trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java:3188-3382
+ /branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java:3149-3217,3281-3325
/trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java:3188-3450
Property changes on: branches/as7/common-core/src/main/java/org/teiid/core/TeiidException.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/common-core/src/main/java/org/teiid/core/TeiidException.java:3220-3275
/trunk/common-core/src/main/java/org/teiid/core/TeiidException.java:3188-3382
+ /branches/7.4.x/common-core/src/main/java/org/teiid/core/TeiidException.java:3220-3275
/trunk/common-core/src/main/java/org/teiid/core/TeiidException.java:3188-3450
Property changes on: branches/as7/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java:3220-3275
/trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java:3188-3382
+ /branches/7.4.x/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java:3220-3275
/trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java:3188-3450
Modified: branches/as7/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java
===================================================================
--- branches/as7/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -118,6 +118,7 @@
while ((l_nbytes = is.read(l_buffer, 0, readLength)) != -1) {
if (length != -1 && writen > length - l_nbytes) {
out.write(l_buffer, 0, writen + l_nbytes - length);
+ writen = length;
break;
}
out.write(l_buffer,0,l_nbytes);
@@ -143,7 +144,7 @@
return write(out, is, new byte[DEFAULT_READING_SIZE], length, close); // buffer holding bytes to be transferred
}
- public static void write(final Writer out, final Reader is, int length) throws IOException {
+ public static int write(final Writer out, final Reader is, int length, boolean close) throws IOException {
int writen = 0;
try {
char[] l_buffer = new char[DEFAULT_READING_SIZE]; // buffer holding bytes to be transferred
@@ -151,16 +152,20 @@
while ((l_nbytes = is.read(l_buffer)) != -1) {
if (length != -1 && writen > length - l_nbytes) {
out.write(l_buffer, 0, writen + l_nbytes - length);
+ writen = length;
break;
}
out.write(l_buffer,0,l_nbytes);
writen += l_nbytes;
}
+ return writen;
} finally {
- try {
- is.close();
- } finally {
- out.close();
+ if (close) {
+ try {
+ is.close();
+ } finally {
+ out.close();
+ }
}
}
}
@@ -192,7 +197,7 @@
public static void write(final Reader reader, final File f) throws IOException {
f.getParentFile().mkdirs();
FileWriter fw = new FileWriter(f);
- write(fw, reader, -1);
+ write(fw, reader, -1, true);
}
public static void write(final InputStream is, final File f) throws IOException {
@@ -290,7 +295,7 @@
public static char[] convertToCharArray(Reader reader, int length) throws IOException {
StringWriter sb = new StringWriter();
- write(sb, reader, length);
+ write(sb, reader, length, true);
return sb.toString().toCharArray();
}
Property changes on: branches/as7/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java:3220-3275
/trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java:3188-3382
+ /branches/7.4.x/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java:3220-3275
/trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java:3188-3450
Modified: branches/as7/connectors/connector-file/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/as7/connectors/connector-file/src/main/rar/META-INF/ra.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/connectors/connector-file/src/main/rar/META-INF/ra.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<connector xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
- http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
- version="1.5">
+<connector version="1.5">
<vendor-name>Red Hat Middleware LLC</vendor-name>
<eis-type>Teiid Text Connector</eis-type>
@@ -55,7 +51,7 @@
<config-property>
<description>{$display:"Allow Parent Paths"}</description>
<config-property-name>AllowParentPaths</config-property-name>
- <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-type>boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
Modified: branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
--- branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -506,6 +506,11 @@
}
@Override
+ public boolean supportsWindowDistinctAggregates() {
+ return false;
+ }
+
+ @Override
public boolean supportsSimilarTo() {
return true;
}
Modified: branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
===================================================================
--- branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -233,6 +233,11 @@
}
@Override
+ public boolean supportsWindowDistinctAggregates() {
+ return false;
+ }
+
+ @Override
public boolean supportsWindowOrderByWithAggregates() {
return false;
}
Modified: branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -200,5 +200,14 @@
Command obj = commandBuilder.getCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, trans, obj);
}
+
+ @Test public void testWith() throws Exception {
+ String input = "with x as (select intkey from bqt1.smalla) select intkey from x limit 100"; //$NON-NLS-1$
+ String output = "WITH x AS (SELECT SmallA.IntKey FROM SmallA) SELECT TOP 100 g_0.intkey AS c_0 FROM x g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, trans, obj);
+ }
}
Modified: branches/as7/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java
===================================================================
--- branches/as7/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -71,14 +71,18 @@
@Override
public void execute() throws TranslatorException {
- if(getCommand().getProcedureName().endsWith("getUpdated")) {
+ String name = getCommand().getMetadataObject().getNameInSource();
+ if (name == null) {
+ name = getCommand().getProcedureName();
+ }
+ if("GetUpdated".equalsIgnoreCase(name)) { //$NON-NLS-1$
execution = new GetUpdatedExecutionImpl(this);
- execution.execute(this);
- }
- else if(getCommand().getProcedureName().endsWith("getDeleted")) {
+ } else if("GetDeleted".equalsIgnoreCase(name)) { //$NON-NLS-1$
execution = new GetDeletedExecutionImpl(this);
- execution.execute(this);
+ } else {
+ throw new AssertionError("Unknown procedure " + getCommand().getProcedureName() + " with name in source " + getCommand().getMetadataObject().getNameInSource()); //$NON-NLS-1$ //$NON-NLS-2$
}
+ execution.execute(this);
}
public void setCommand(Call command) {
Copied: branches/as7/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java (from rev 3450, trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java)
===================================================================
--- branches/as7/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java (rev 0)
+++ branches/as7/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestProcedureExecution.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,59 @@
+/*
+ * 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.translator.salesforce.execution;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.cdk.api.TranslationUtility;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.execution.visitors.TestVisitors;
+
+@SuppressWarnings("nls")
+public class TestProcedureExecution {
+
+ private static TranslationUtility translationUtility = new TranslationUtility(TestVisitors.exampleSalesforce());
+
+ @Test public void testProcedureName() throws Exception {
+ Call command = (Call)translationUtility.parseCommand("exec getupdated('foo', {d '1970-01-01'}, {d '1990-01-01'})"); //$NON-NLS-1$
+ SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
+ UpdatedResult ur = new UpdatedResult();
+ ur.setIDs(Arrays.asList("1", "2"));
+ Mockito.stub(sfc.getUpdated(Mockito.eq("foo"), (XMLGregorianCalendar)Mockito.anyObject(), (XMLGregorianCalendar)Mockito.anyObject())).toReturn(ur);
+ ProcedureExecutionParentImpl pepi = new ProcedureExecutionParentImpl(command, sfc, Mockito.mock(RuntimeMetadata.class), Mockito.mock(ExecutionContext.class));
+ pepi.execute();
+ assertNotNull(pepi.next());
+ assertNotNull(pepi.next());
+ assertNull(pepi.next());
+ pepi.close();
+ }
+
+}
Modified: branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
===================================================================
--- branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -30,5 +30,10 @@
If a traditional join is not possible (such as with NOT IN) a merge join version of the semijoin or antijoin will be considered by upon the costing information available.
</para>
</listitem>
+ <listitem>
+ <para><emphasis>org.teiid.ODBCPacketSize</emphasis> - defaults to 307200.
+ Target size in bytes of the ODBC results buffer. This is not a hard maximum, lobs and wide rows may use larger buffers.
+ </para>
+ </listitem>
</itemizedlist>
</appendix>
\ No newline at end of file
Modified: branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
<chapter id="custom_security">
<title>Teiid Security</title>
<para>The Teiid system provides a range of built-in and extensible security features to enable the
@@ -106,23 +109,21 @@
<section>
<title>Kerberos support through GSSAPI</title>
<para>Teiid supports kerberos authentication using GSSAPI, to be used with single sign-on applications.
- This service ticket negotiation based authentication is supported through remote JDBC and ODBC drivers and as
- well as in LocalConnections. However, configuration is varies for local connections vs remote connections</para>
+ This service ticket negotiation based authentication is supported through remote JDBC and ODBC drivers and LocalConnections.
+ Client configuration is different for all connection types.</para>
<section>
<title>LocalConnection</title>
- <para>For supporting kerberos through local connections, provide JDBC URL property <emphasis>PassthroughAuthentication</emphasis>
- as true and use the <ulink url="http://community.jboss.org/docs/DOC-10680">JBoss Negotiation</ulink> as
- authentication configure your web-application for kerberos. When the web application authenticates with the provided
+ <para>Set the JDBC URL property <emphasis>PassthroughAuthentication</emphasis>
+ as true and use <ulink url="http://community.jboss.org/docs/DOC-10680">JBoss Negotiation</ulink> for
+ authentication of your web-application with kerberos. When the web application authenticates with the provided
kerberos token, the same subject authenticated will be used in Teiid. For details about configuration, check the
JBoss Negotiation documentation.</para>
</section>
<section>
- <title>Remote JDBC Connection</title>
- <para>Server: For supporting the kerberos through jdbc from a remote client application, follow the below configuration.
- On the server, edit "{jboss-as}/server/{profile}/deploy/teiid/teiid-jboss-beans.xml" file, and make sure under
- "SessionService" bean definition the following properties are set.
+ <title>Remote Connections</title>
+ <para>On the server, edit the &jboss-beans; under the "SessionService" bean definition, as follows:
<programlisting><![CDATA[
<!-- Sets the authentication Type -->
<property name="authenticationType">KRB5</property>
@@ -130,12 +131,11 @@
<property name="krb5SecurityDomain">teiid-krb5</property>
]]></programlisting>
- Now we need to define security domain context for kerberos with name mentioned in above, and since the kerberos
- authorization can not define authorization roles, we need devise a way to define them using another login context.
- Given below is sample configuration to define roles using UserRolesLoginModule.
- Note that the below configuration replaces the default Teiid login configuration. Note to change the principal
- and key tab locations accordingly.
-
+ Now we need to define a security domain context for kerberos with the name mentioned in above.
+ Since kerberos authorization cannot define authorization roles, we'll define them using another login context.
+ Given below is a sample configuration to define roles using a UserRolesLoginModule.
+ <note><para>This configuration replaces the default Teiid login configuration, and you should change the principal
+ and key tab locations accordingly.</para></note>
<programlisting><![CDATA[
<!--login module that negotiates the login conext for kerberos -->
<application-policy xmlns="urn:jboss:security-beans:1.0" name="teiid-krb5">
@@ -166,51 +166,59 @@
</authentication>
</application-policy>
]]></programlisting>
- Edit "run.conf" or "run.conf.bat"file depending upon the environment in "${jboss-as}/bin" directory
- and add the following JVM options to startup script (note to change the realm and KDC settings according to your environment)
+ Edit the "run.conf" or "run.conf.bat" file depending upon the environment in the "${jboss-as}/bin" directory
+ and add the following JVM options (changing the realm and KDC settings according to your environment)
<programlisting><![CDATA[
JAVA_OPTS = "$JAVA_OPTS -Djava.security.krb5.realm=EXAMPLE.COM -Djava.security.krb5.kdc=kerberos.example.com -Djavax.security.auth.useSubjectCredsOnly=false"
]]></programlisting>
This finishes the configuration on the server side, restart the server and make sure that there were no errors during startup.
</para>
- <para>Client: The following configuration needs to be done on the Teiid client application VM. For client VM, JAAS
- configuration for kerberos authentication needs to be written. A sample configuration file (client.conf) is show below
-
- <programlisting><![CDATA[
- Client {
- com.sun.security.auth.module.Krb5LoginModule required
- useTicketCache=true
- storeKey=true
- useKeyTab=true
- keyTab="/path/to/krb5.keytab"
- doNotPrompt=false
- debug=false
- principal="demo(a)EXAMPLE.COM";
- };
- ]]></programlisting>
-
- Add the following JVM options to your client's startup script, note the change Realm and KDC settings according to
- your environment
- <programlisting><![CDATA[
- -Djava.security.krb5.realm=EXAMPLE.COM
- -Djava.security.krb5.kdc=kerberos.example.com
- -Djavax.security.auth.useSubjectCredsOnly=false
- -Dsun.security.krb5.debug=false
- -Djava.security.auth.login.config=/path/to/client.conf
- ]]></programlisting>
-
- Add the following URL connection properties to Teiid JDBC connection string
- <programlisting><![CDATA[
- authenticationType=KRB5;jaasName=Client;kerberosServicePrincipleName=demo(a)EXAMPLE.COM
- ]]></programlisting>
- There is no need to provide the user name and password, when the application is trying to make JDBC connection it
- will authenticate locally and use the same user credetinals to neogitiate service token with server and grant the
- connection. See Client Developer's guide for information on connection properties and how to configure data sources.
- </para>
- </section>
-
- </section>
+ <section>
+ <title>JDBC Client Configuration</title>
+ <para>In you client VM the JAAS
+ configuration for kerberos authentication needs to be written. A sample configuration file (client.conf) is show below
+
+ <programlisting><![CDATA[
+ Client {
+ com.sun.security.auth.module.Krb5LoginModule required
+ useTicketCache=true
+ storeKey=true
+ useKeyTab=true
+ keyTab="/path/to/krb5.keytab"
+ doNotPrompt=false
+ debug=false
+ principal="demo(a)EXAMPLE.COM";
+ };
+ ]]></programlisting>
+
+ Add the following JVM options to your client's startup script - change Realm and KDC settings according to
+ your environment
+ <programlisting><![CDATA[
+ -Djava.security.krb5.realm=EXAMPLE.COM
+ -Djava.security.krb5.kdc=kerberos.example.com
+ -Djavax.security.auth.useSubjectCredsOnly=false
+ -Dsun.security.krb5.debug=false
+ -Djava.security.auth.login.config=/path/to/client.conf
+ ]]></programlisting>
+
+ Add the following URL connection properties to Teiid JDBC connection string
+ <programlisting><![CDATA[
+ authenticationType=KRB5;jaasName=Client;kerberosServicePrincipleName=demo(a)EXAMPLE.COM
+ ]]></programlisting>
+ There is no need to provide the user name and password, when the application is trying to make JDBC connection it
+ will authenticate locally and use the same user credetinals to neogitiate service token with server and grant the
+ connection. See Client Developer's guide for information on connection properties and how to configure data sources.
+ </para>
+ </section>
+
+ </section>
+ </section>
+
+ <section>
+ <title>ODBC Client Configuration</title>
+ <para>Consult the PostgreSQL ODBC client documentation.</para>
+ </section>
<section>
<title>Security at Data Source level</title>
Modified: branches/as7/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- branches/as7/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -104,6 +104,7 @@
Internal materialization also provides more built-in facilities for refreshing and monitoring.</para>
<para>The cache hint, when used in the context of an internal materialized view transformation query, provides the ability to fine tune the materialized table.
The pref_mem option also applies to internal materialized views. Internal table index pages already have a memory preference, so the perf_mem option indicates that the data pages should prefer memory as well.</para>
+ <para>All internal materialized view refresh and updates happen atomically. Internal materialized views support READ_COMMITTED (used also for READ_UNCOMMITED) and SERIALIZABLE (used also for REPEATABLE_READ) transaction isolation levels.</para>
<section>
<title>Loading And Refreshing</title>
<para>An internal materialized view table is initially in an invalid state (there is no data). The first user query will trigger an implicit loading of the data.
@@ -120,22 +121,6 @@
subsequent refreshes performed with <code>refreshMatView</code> will use dependent materialized view tables if they exist. Only one load may occur at a time. If a load is already in progress when
the <code>SYSADMIN.refreshMatView</code> procedure is called, it will return -1 immediately rather than preempting the current load.
</para>
- <para>
- When Teiid is running clustered mode, after of loading of internal materialized view contents, an event will be sent to all
- the other participating nodes in the cluster to refresh the contents from the original node in asynchronus fashion.
- During this remote node loading process, if the node that is reading the contents gets a request from user to serve the
- results of that view, then the current results in cache will be served. If no results were available at that node, then
- request will be blocked until load process is finished.
- </para>
- <para>
- When a Teiid node joins the cluster, at the end of start-up cycle, an asynchronus job
- will be started to fetch all the previously cached internal materialized views at other nodes
- for the deployed VDBs. The query request behaviour during this load process is same as above.
- </para>
- <note><para>In the clustered mode, the "invalidate=true" flag in the "SYSADMIN.refreshMatView" procedure
- will only apply to the node that is refreshing the contents from source. All other nodes, will still serve the
- old contents during the refresh process.</para>
- </note>
<section>
<title>TTL Snapshot Refresh</title>
<para>The <link linkend="cache-hint">cache hint</link> may be used to automatically trigger a full snapshot refresh after a specified time to live (ttl).
@@ -198,12 +183,9 @@
<section>
<title>Clustering Considerations</title>
<para>Each member in a cluster maintains its own copy of each materialized table and associated indexes.
- With cache clustering enabled, an additional snapshot copy of the table is maintained for loading by other members.
An attempt is made to ensure each member receives the same full refresh events as the others.
Full consistency for updatable materialized views however is not guaranteed.
Periodic full refreshes of updatable materialized view tables helps ensure consistency among members.
- <note><para>Loads of materialized tables are not coordinated across the cluster. It is possible for the same ttl expiration to trigger a load at each member.</para></note>
- In many clustered scenarios using external materialization is advantageous to fully control the loading of the tables and to have materialized data that is durable.
</para>
</section>
</section>
Modified: branches/as7/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml
===================================================================
--- branches/as7/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -203,21 +203,21 @@
Description = PostgreSQL Data Source
Servername = <Teiid Host name or ip>
Port = 35432
- Protocol = 7.4
+ Protocol = 7.4-1
UserName = <user-name>
Password = <password>
Database = <vdb-name>
ReadOnly = no
ServerType = Postgres
ConnSettings =
- UseServerSidePrepare=0
+ UseServerSidePrepare=1
ByteaAsLongVarBinary=1
Optimizer=0
Ksqo=0
- Trace = No
- TraceFile = /var/log/trace.log
- Debug = No
- DebugFile = /var/log/debug.log
+ Debug=0
+ Fetch = 10000
+ # enable below when dealing large resultsets
+ #UseDeclareFetch=1
]]></programlisting>
<para>Note that you need "sudo" permissions to edit the "/etc/odbc.ini" file.
Modified: branches/as7/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
===================================================================
--- branches/as7/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1331,7 +1331,7 @@
<para>WindowOrderByWithAggregates</para>
</entry>
<entry>
- <para/>
+ <para>ElementaryOlapOperations</para>
</entry>
<entry>
<para>Translator supports windowed aggregates with a window order by clause.</para>
@@ -1339,10 +1339,21 @@
</row>
<row>
<entry>
+ <para>WindowDistinctAggregates</para>
+ </entry>
+ <entry>
+ <para>ElementaryOlapOperations, AggregatesDistinct</para>
+ </entry>
+ <entry>
+ <para>Translator supports windowed distinct aggregates.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>AdvancedOlapOperations</para>
</entry>
<entry>
- <para/>
+ <para>ElementaryOlapOperations</para>
</entry>
<entry>
<para>Translator supports aggregate conditions.</para>
Modified: branches/as7/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml
===================================================================
--- branches/as7/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -77,7 +77,7 @@
</para>
</listitem>
<listitem>
- <para>Only local temporary tables are supported. This implies that the scope of temp table will be either to the sesssion or the block of a virtual procedure that creates it.
+ <para>Only local temporary tables are supported. This implies that the scope of temp table will be either to the session or the block of a virtual procedure that creates it.
</para>
</listitem>
<listitem>
@@ -85,7 +85,9 @@
</para>
</listitem>
<listitem>
- <para>Temp tables are non-transactional.
+ <para>Temp tables support a READ_UNCOMMITED transaction isolation level. There are no locking mechanisms available to support higher isolation levels and the result of a rollback may be inconsistent across multiple transactions.
+ If concurrent transactions are not associated with the same local temporary table or session, then the transaction isolation level is effectively SERIALIZABLE.
+ If you want full constency with local temporary tables, then only use a connection with 1 transaction at a time. This mode of operation is ensured by connection pooling that tracking connections by transaction.
</para>
</listitem>
<listitem>
Modified: branches/as7/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- branches/as7/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -326,7 +326,7 @@
</para>
</listitem>
<listitem>
- <para>Windowed aggregates may not use DISTINCT.
+ <para>Windowed aggregates may not use DISTINCT if the window specification is ordered.
</para>
</listitem>
</itemizedlist>
Modified: branches/as7/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
===================================================================
--- branches/as7/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -341,11 +341,6 @@
connector, however this isolation level is fixed and cannot be
changed at runtime for specific connections/commands.</para>
</listitem>
- <listitem>
- <para>Temporary tables are not transactional. For example,
- a global temporary table will retain all inserts performed during a
- local transaction that was rolled back.</para>
- </listitem>
<!-- <listitem>
<para>Connectors may be set to immutable to prevent their
participation in transactions. This is useful in situations where
Modified: branches/as7/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -26,6 +26,12 @@
public interface BatchManager {
+ public interface CleanupHook {
+
+ void cleanup();
+
+ }
+
public interface ManagedBatch {
TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException;
@@ -34,6 +40,13 @@
void setPrefersMemory(boolean prefers);
+ /**
+ * Get an object that can cleaup the {@link ManagedBatch}, but does not hold a hard reference to
+ * the {@link ManagedBatch} or the {@link BatchManager}
+ * @return
+ */
+ CleanupHook getCleanupHook();
+
}
ManagedBatch createManagedBatch(TupleBatch batch, boolean softCache) throws TeiidComponentException;
Property changes on: branches/as7/engine/src/main/java/org/teiid/common/buffer/BlockedException.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/BlockedException.java:3149-3217
/trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/BlockedException.java:3149-3217
/trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java:3188-3450
Property changes on: branches/as7/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/BufferManager.java:3220-3275
/trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/BufferManager.java:3220-3275
/trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/common/buffer/SPage.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/common/buffer/SPage.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/common/buffer/SPage.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,24 +22,34 @@
package org.teiid.common.buffer;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Set;
+import org.teiid.common.buffer.BatchManager.CleanupHook;
import org.teiid.common.buffer.BatchManager.ManagedBatch;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
/**
* A linked list Page entry in the tree
*
* TODO: return the tuplebatch from getvalues, since that is what we're tracking
*
+ * State cloning allows a single storage reference to be shared in many trees.
+ * A phantom reference is used for proper cleanup once cloned.
+ *
+ * TODO: a better purging strategy for managedbatchs.
+ *
*/
@SuppressWarnings("unchecked")
-class SPage {
+class SPage implements Cloneable {
static final int MIN_PERSISTENT_SIZE = 16;
@@ -54,24 +64,75 @@
}
}
- private static AtomicInteger counter = new AtomicInteger();
-
+ private static final Set<PhantomReference<Object>> REFERENCES = Collections.newSetFromMap(new IdentityHashMap<PhantomReference<Object>, Boolean>());
+ private static ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
+ static class CleanupReference extends PhantomReference<Object> {
+
+ private CleanupHook batch;
+
+ public CleanupReference(Object referent, CleanupHook batch) {
+ super(referent, QUEUE);
+ this.batch = batch;
+ }
+
+ public void cleanup() {
+ try {
+ this.batch.cleanup();
+ } finally {
+ this.clear();
+ }
+ }
+ }
+
STree stree;
+ private int id;
protected SPage next;
protected SPage prev;
protected ManagedBatch managedBatch;
+ private Object trackingObject;
protected TupleBatch values;
protected ArrayList<SPage> children;
+ //TODO: could track cloning more completely, which would allow for earlier batch removal
+ private boolean cloned;
SPage(STree stree, boolean leaf) {
this.stree = stree;
- this.values = new TupleBatch(counter.getAndIncrement(), new ArrayList(stree.pageSize/4));
+ this.id = stree.counter.getAndIncrement();
+ stree.pages.put(this.id, this);
+ //TODO: this counter is a hack. need a better idea of a storage id
+ this.values = new TupleBatch(id, new ArrayList(stree.pageSize/4));
if (!leaf) {
children = new ArrayList<SPage>(stree.pageSize/4);
}
}
+ public SPage clone(STree tree) {
+ try {
+ if (this.managedBatch != null && trackingObject == null) {
+ cloned = true;
+ this.trackingObject = new Object();
+ CleanupReference managedBatchReference = new CleanupReference(trackingObject, managedBatch.getCleanupHook());
+ REFERENCES.add(managedBatchReference);
+ }
+ SPage clone = (SPage) super.clone();
+ clone.stree = tree;
+ if (children != null) {
+ clone.children = new ArrayList<SPage>(children);
+ }
+ if (values != null) {
+ clone.values = new TupleBatch(stree.counter.getAndIncrement(), new ArrayList<List<?>>(values.getTuples()));
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ public int getId() {
+ return id;
+ }
+
static SearchResult search(SPage page, List k, LinkedList<SearchResult> parent) throws TeiidComponentException {
TupleBatch previousValues = null;
for (;;) {
@@ -121,7 +182,7 @@
}
protected void setValues(TupleBatch values) throws TeiidComponentException {
- if (managedBatch != null) {
+ if (managedBatch != null && !cloned) {
managedBatch.remove();
}
if (values.getTuples().size() < MIN_PERSISTENT_SIZE) {
@@ -134,17 +195,25 @@
} else {
values.setDataTypes(stree.types);
}
+ if (cloned) {
+ values.setRowOffset(stree.counter.getAndIncrement());
+ cloned = false;
+ trackingObject = null;
+ }
if (children != null) {
managedBatch = stree.keyManager.createManagedBatch(values, true);
} else {
managedBatch = stree.leafManager.createManagedBatch(values, stree.preferMemory);
}
}
-
- protected void remove() {
+
+ protected void remove(boolean force) {
if (managedBatch != null) {
- managedBatch.remove();
+ if (force || !cloned) {
+ managedBatch.remove();
+ }
managedBatch = null;
+ trackingObject = null;
}
values = null;
children = null;
@@ -157,6 +226,14 @@
if (managedBatch == null) {
throw new AssertionError("Batch removed"); //$NON-NLS-1$
}
+ for (int i = 0; i < 10; i++) {
+ CleanupReference ref = (CleanupReference)QUEUE.poll();
+ if (ref == null) {
+ break;
+ }
+ REFERENCES.remove(ref);
+ ref.cleanup();
+ }
if (children != null) {
return managedBatch.getBatch(true, stree.keytypes);
}
@@ -173,7 +250,7 @@
if (current.children != null) {
current.children.addAll(current.next.children);
}
- current.next.remove();
+ current.next.remove(false);
current.next = current.next.next;
if (current.next != null) {
current.next.prev = current;
Modified: branches/as7/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/common/buffer/STree.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/common/buffer/STree.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -23,16 +23,22 @@
package org.teiid.common.buffer;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
+import org.teiid.client.BatchSerializer;
import org.teiid.common.buffer.SPage.SearchResult;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.query.processor.relational.ListNestedSortComparator;
/**
@@ -41,7 +47,7 @@
* but with fewer updates.
*/
@SuppressWarnings("unchecked")
-public class STree {
+public class STree implements Cloneable {
public enum InsertMode {ORDERED, NEW, UPDATE}
@@ -50,7 +56,9 @@
protected int randomSeed;
private int mask = 1;
private int shift = 1;
-
+
+ protected AtomicInteger counter = new AtomicInteger();
+ protected ConcurrentHashMap<Integer, SPage> pages = new ConcurrentHashMap<Integer, SPage>();
protected volatile SPage[] header = new SPage[] {new SPage(this, true)};
protected BatchManager keyManager;
protected BatchManager leafManager;
@@ -88,6 +96,70 @@
this.keytypes = Arrays.copyOf(types, keyLength);
}
+ public STree clone() {
+ updateLock.lock();
+ try {
+ STree clone = (STree) super.clone();
+ clone.updateLock = new ReentrantLock();
+ clone.rowCount = new AtomicInteger(rowCount.get());
+ //clone the pages
+ clone.pages = new ConcurrentHashMap<Integer, SPage>(pages);
+ for (Map.Entry<Integer, SPage> entry : clone.pages.entrySet()) {
+ entry.setValue(entry.getValue().clone(clone));
+ }
+ //reset the pointers
+ for (Map.Entry<Integer, SPage> entry : clone.pages.entrySet()) {
+ SPage clonePage = entry.getValue();
+ clonePage.next = clone.getPage(clonePage.next);
+ clonePage.prev = clone.getPage(clonePage.prev);
+ if (clonePage.children != null) {
+ for (int i = 0; i < clonePage.children.size(); i++) {
+ clonePage.children.set(i, clone.getPage(clonePage.children.get(i)));
+ }
+ }
+ }
+ clone.header = Arrays.copyOf(header, header.length);
+ for (int i = 0; i < header.length; i++) {
+ clone.header[i] = clone.pages.get(header[i].getId());
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ } finally {
+ updateLock.unlock();
+ }
+ }
+
+ private SPage getPage(SPage page) {
+ if (page == null) {
+ return page;
+ }
+ return pages.get(page.getId());
+ }
+
+ public void writeValuesTo(ObjectOutputStream oos) throws TeiidComponentException, IOException {
+ SPage page = header[0];
+ oos.writeInt(this.rowCount.get());
+ while (true) {
+ TupleBatch batch = page.getValues();
+ BatchSerializer.writeBatch(oos, types, batch.getAllTuples());
+ if (page.next == null) {
+ break;
+ }
+ }
+ }
+
+ public void readValuesFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException, TeiidComponentException {
+ int size = ois.readInt();
+ int sizeHint = this.getExpectedHeight(size);
+ while (this.getRowCount() < size) {
+ List[] batch = BatchSerializer.readBatch(ois, types);
+ for (List list : batch) {
+ this.insert(list, InsertMode.ORDERED, sizeHint);
+ }
+ }
+ }
+
protected SPage findChildTail(SPage page) {
if (page == null) {
page = header[header.length - 1];
@@ -331,7 +403,7 @@
int size = searchResult.values.getTuples().size();
if (size == 0) {
if (header[i] != searchResult.page) {
- searchResult.page.remove();
+ searchResult.page.remove(false);
if (searchResult.page.next != null) {
searchResult.page.next.prev = searchResult.page.prev;
}
@@ -340,7 +412,7 @@
searchResult.page.prev = null;
continue;
}
- header[i].remove();
+ header[i].remove(false);
if (header[i].next != null) {
header[i] = header[i].next;
header[i].prev = null;
@@ -375,7 +447,7 @@
}
public void remove() {
- truncate();
+ truncate(false);
this.keyManager.remove();
this.leafManager.remove();
}
@@ -384,12 +456,12 @@
return this.rowCount.get();
}
- public int truncate() {
+ public int truncate(boolean force) {
int oldSize = rowCount.getAndSet(0);
for (int i = 0; i < header.length; i++) {
SPage page = header[i];
while (page != null) {
- page.remove();
+ page.remove(force);
page = page.next;
}
}
Property changes on: branches/as7/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java:3220-3275
/trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java:3220-3275
/trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java:3188-3450
Property changes on: branches/as7/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java:3149-3217,3220-3275,3340-3349
/trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java:3149-3217,3220-3275,3340-3349
/trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -92,6 +92,28 @@
private static final int IO_BUFFER_SIZE = 1 << 14;
private static final int COMPACTION_THRESHOLD = 1 << 25; //start checking at 32 megs
+ private final class CleanupHook implements org.teiid.common.buffer.BatchManager.CleanupHook {
+
+ private long id;
+ private int beginRow;
+ private WeakReference<BatchManagerImpl> ref;
+
+ CleanupHook(long id, int beginRow, BatchManagerImpl batchManager) {
+ this.id = id;
+ this.beginRow = beginRow;
+ this.ref = new WeakReference<BatchManagerImpl>(batchManager);
+ }
+
+ public void cleanup() {
+ BatchManagerImpl batchManager = ref.get();
+ if (batchManager == null) {
+ return;
+ }
+ cleanupManagedBatch(batchManager, beginRow, id);
+ }
+
+ }
+
private final class BatchManagerImpl implements BatchManager {
private final String id;
private volatile FileStore store;
@@ -163,7 +185,9 @@
store = newStore;
long oldOffset = offset;
offset = store.getLength();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
return offset;
} finally {
this.compactionLock.writeLock().unlock();
@@ -213,7 +237,9 @@
this.lobManager = new LobManager();
}
sizeEstimate = (int) Math.max(1, manager.sizeUtility.getBatchSize(batch) / 1024);
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
@Override
@@ -249,7 +275,9 @@
@Override
public TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException {
long reads = readAttempts.incrementAndGet();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
synchronized (activeBatches) {
TupleBufferInfo tbi = activeBatches.remove(batchManager.id);
if (tbi != null) {
@@ -286,7 +314,9 @@
}
}
long count = readCount.incrementAndGet();
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+ }
try {
this.batchManager.compactionLock.readLock().lock();
long[] info = batchManager.physicalMapping.get(this.id);
@@ -324,7 +354,9 @@
if (batch != null) {
if (!persistent) {
long count = writeCount.incrementAndGet();
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+ }
long offset = 0;
if (lobManager != null) {
for (List<?> tuple : batch.getTuples()) {
@@ -341,7 +373,9 @@
long[] info = new long[] {offset, size};
batchManager.physicalMapping.put(this.id, info);
}
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+ }
}
if (softCache) {
this.batchReference = new SoftReference<TupleBatch>(batch);
@@ -363,25 +397,17 @@
}
public void remove() {
- synchronized (activeBatches) {
- TupleBufferInfo tbi = activeBatches.get(batchManager.id);
- if (tbi != null && tbi.removeBatch(this.beginRow) != null) {
- if (tbi.batches.isEmpty()) {
- activeBatches.remove(batchManager.id);
- }
- }
- }
- long[] info = batchManager.physicalMapping.remove(id);
- if (info != null) {
- batchManager.unusedSpace.addAndGet(info[1]);
- }
- activeBatch = null;
- batchReference = null;
+ cleanupManagedBatch(batchManager, beginRow, id);
}
+
+ @Override
+ public CleanupHook getCleanupHook() {
+ return new CleanupHook(id, beginRow, batchManager);
+ }
@Override
public String toString() {
- return "ManagedBatch " + batchManager.id + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$
+ return "ManagedBatch " + batchManager.id + " " + this.beginRow + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -487,6 +513,21 @@
return tupleBuffer;
}
+ private void cleanupManagedBatch(BatchManagerImpl batchManager, int beginRow, long id) {
+ synchronized (activeBatches) {
+ TupleBufferInfo tbi = activeBatches.get(batchManager.id);
+ if (tbi != null && tbi.removeBatch(beginRow) != null) {
+ if (tbi.batches.isEmpty()) {
+ activeBatches.remove(batchManager.id);
+ }
+ }
+ }
+ long[] info = batchManager.physicalMapping.remove(id);
+ if (info != null) {
+ batchManager.unusedSpace.addAndGet(info[1]);
+ }
+ }
+
public STree createSTree(final List elements, String groupName, int keyLength) {
String newID = String.valueOf(this.tsId.getAndIncrement());
int[] lobIndexes = LobManager.getLobIndexes(elements);
@@ -496,13 +537,17 @@
for (int i = 1; i < compareIndexes.length; i++) {
compareIndexes[i] = i;
}
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+ }
return new STree(keyManager, bm, new ListNestedSortComparator(compareIndexes), getProcessorBatchSize(), keyLength, TupleBuffer.getTypeNames(elements));
}
@Override
public FileStore createFileStore(String name) {
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ }
return this.diskMgr.createFileStore(name);
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -25,7 +25,10 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.query.QueryPlugin;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
@@ -52,14 +55,14 @@
tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedTable());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, srcCaps.supportsInnerJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
+ setSupports(connectorID, tgtCaps, Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins(), Capability.QUERY_FROM_GROUP_ALIAS);
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
+ setSupports(connectorID, tgtCaps, Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews(), Capability.QUERY_FROM_GROUP_ALIAS);
tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, srcCaps.supportsCompareCriteriaOrdered());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE, srcCaps.supportsLikeCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
+ setSupports(connectorID, tgtCaps, Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter(), Capability.CRITERIA_LIKE);
tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN, srcCaps.supportsInCriteria());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_ISNULL, srcCaps.supportsIsNullCriteria());
@@ -99,12 +102,13 @@
tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, srcCaps.supportsOrderByNullOrdering());
tgtCaps.setCapabilitySupport(Capability.INSERT_WITH_ITERATOR, srcCaps.supportsInsertWithIterator());
tgtCaps.setCapabilitySupport(Capability.COMMON_TABLE_EXPRESSIONS, srcCaps.supportsCommonTableExpressions());
- tgtCaps.setCapabilitySupport(Capability.ADVANCED_OLAP, srcCaps.supportsAdvancedOlapOperations());
- tgtCaps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, srcCaps.supportsAdvancedOlapOperations());
- tgtCaps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, srcCaps.supportsWindowOrderByWithAggregates());
+ tgtCaps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, srcCaps.supportsElementaryOlapOperations());
+ setSupports(connectorID, tgtCaps, Capability.ADVANCED_OLAP, srcCaps.supportsAdvancedOlapOperations(), Capability.ELEMENTARY_OLAP);
+ setSupports(connectorID, tgtCaps, Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, srcCaps.supportsWindowOrderByWithAggregates(), Capability.ELEMENTARY_OLAP);
tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_ARRAY, srcCaps.supportsArrayAgg());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_SIMILAR, srcCaps.supportsSimilarTo());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_REGEX, srcCaps.supportsLikeRegex());
+ setSupports(connectorID, tgtCaps, Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES, srcCaps.supportsWindowDistinctAggregates(), Capability.ELEMENTARY_OLAP, Capability.QUERY_AGGREGATES_DISTINCT);
List<String> functions = srcCaps.getSupportedFunctions();
if(functions != null && functions.size() > 0) {
@@ -130,4 +134,17 @@
return tgtCaps;
}
+ private static void setSupports(Object connectorID, BasicSourceCapabilities tgtCaps, Capability cap, boolean supports, Capability... required) {
+ if (!supports) {
+ return;
+ }
+ for (Capability capability : required) {
+ if (!tgtCaps.supportsCapability(capability)) {
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, QueryPlugin.Util.getString("support_required", cap, capability, connectorID)); //$NON-NLS-1$
+ supports = false;
+ }
+ }
+ tgtCaps.setCapabilitySupport(cap, supports);
+ }
+
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -230,6 +230,7 @@
}
}
item.setSubquery(translate(withQueryCommand.getCommand()));
+ items.add(item);
}
result.setItems(items);
return result;
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -41,7 +41,7 @@
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.optimizer.relational.RelationalPlanner;
-import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.util.CommandContext;
/**
@@ -117,17 +117,17 @@
}
VDBMetaData vdb = DQPWorkContext.getWorkContext().getVDB();
TransformationMetadata tm = vdb.getAttachment(TransformationMetadata.class);
- TempTableStore globalStore = vdb.getAttachment(TempTableStore.class);
+ GlobalTableStore globalStore = vdb.getAttachment(GlobalTableStore.class);
if (!externalNames.isEmpty()) {
this.objectsAccessed = new HashSet<Object>(externalNames.size());
for (List<String> key : this.externalNames) {
if (key.size() == 1) {
String matTableName = key.get(0);
- TempMetadataID id = globalStore.getMetadataStore().getTempGroupID(matTableName);
+ TempMetadataID id = globalStore.getTempTableStore().getMetadataStore().getTempGroupID(matTableName);
if (id == null) {
//if the id is null, then create a local instance
String viewFullName = matTableName.substring(RelationalPlanner.MAT_PREFIX.length());
- id = globalStore.getGlobalTempTableMetadataId(tm.getGroupID(viewFullName), tm);
+ id = globalStore.getGlobalTempTableMetadataId(tm.getGroupID(viewFullName));
}
this.objectsAccessed.add(id);
} else {
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -28,7 +28,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.FutureTask;
@@ -44,10 +43,8 @@
import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.TransactionMetadata;
-import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.cache.CacheConfiguration;
-import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.cache.CacheFactory;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
@@ -60,33 +57,28 @@
import org.teiid.client.xa.XidImpl;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.Streamable;
-import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.dqp.internal.process.ThreadReuseExecutor.PrioritizedRunnable;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.BufferService;
import org.teiid.dqp.service.TransactionContext;
-import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.dqp.service.TransactionService;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.events.EventDistributor;
import org.teiid.logging.CommandLogMessage;
-import org.teiid.logging.CommandLogMessage.Event;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.logging.CommandLogMessage.Event;
import org.teiid.metadata.MetadataRepository;
import org.teiid.query.QueryPlugin;
-import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.metadata.TempMetadataAdapter;
-import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
-
/**
* Implements the core DQP processing.
*/
@@ -212,8 +204,6 @@
private LinkedList<RequestWorkItem> waitingPlans = new LinkedList<RequestWorkItem>();
private CacheFactory cacheFactory;
- private SessionAwareCache<CachedResults> matTables;
-
private AuthorizationValidator authorizationValidator;
/**
@@ -246,7 +236,7 @@
}
ClientState state = clientState.get(key);
if (state == null && create) {
- state = new ClientState(new TempTableStore(key));
+ state = new ClientState(new TempTableStore(key, TransactionMode.ISOLATE_WRITES));
clientState.put(key, state);
}
return state;
@@ -629,9 +619,6 @@
clearResultSetCache(vdbName, version);
break;
}
- if (this.matTables != null) {
- this.matTables.clearForVDB(vdbName, version);
- }
}
public Collection<TransactionMetadata> getTransactions() {
@@ -731,102 +718,15 @@
this.userRequestSourceConcurrency = Math.min(config.getMaxThreads(), 2*config.getMaxThreads()/this.maxActivePlans);
}
- if (cacheFactory.isReplicated()) {
- matTables = new SessionAwareCache<CachedResults>(this.cacheFactory, SessionAwareCache.Type.RESULTSET, new CacheConfiguration(Policy.EXPIRATION, -1, -1, "MaterilizationTables")); //$NON-NLS-1$
- matTables.setBufferManager(this.bufferManager);
- }
-
DataTierManagerImpl processorDataManager = new DataTierManagerImpl(this,this.bufferService, this.config.isDetectingChangeEvents());
processorDataManager.setEventDistributor(eventDistributor);
processorDataManager.setMetadataRepository(metadataRepository);
- dataTierMgr = new TempTableDataManager(processorDataManager, this.bufferManager, this.processWorkerPool, this.rsCache, this.matTables, this.cacheFactory);
+ dataTierMgr = new TempTableDataManager(processorDataManager, this.bufferManager, this.processWorkerPool, this.rsCache);
dataTierMgr.setEventDistributor(eventDistributor);
LogManager.logDetail(LogConstants.CTX_DQP, "DQPCore started maxThreads", this.config.getMaxThreads(), "maxActivePlans", this.maxActivePlans, "source concurrency", this.userRequestSourceConcurrency); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void synchronizeInternalMaterializedViews(final ContextProvider contextProvider) {
- if (!cacheFactory.isReplicated() || matTables == null) {
- return;
- }
- Set<CacheID> keys = this.matTables.replicatableKeys();
- for (final CacheID key:keys) {
- refreshMatView(contextProvider, key.getVDBKey().getName(), key.getVDBKey().getVersion(), key.getSql());
- }
- }
-
- public void refreshMatView(final ContextProvider contextProvider, final String vdbName, final int vdbVersion, final String viewName) {
- if (!cacheFactory.isReplicated() || matTables == null) {
- return;
- }
-
- final DQPWorkContext context = contextProvider.getContext(vdbName, vdbVersion);
-
- final VDBMetaData vdb = context.getVDB();
- if (vdb == null) {
- return;
- }
-
- final TempTableStore globalStore = vdb.getAttachment(TempTableStore.class);
- if (globalStore == null) {
- return;
- }
- DQPWorkContext.setWorkContext(context);
-
- Runnable work = new Runnable() {
- @Override
- public void run() {
- QueryMetadataInterface metadata = vdb.getAttachment(QueryMetadataInterface.class);
- TempTableStore tempStore = new TempTableStore("internal"); //$NON-NLS-1$
- TempMetadataAdapter tma = new TempMetadataAdapter(metadata, tempStore.getMetadataStore());
- try {
- dataTierMgr.refreshMatView(vdb.getName(), vdb.getVersion(), viewName, tma, globalStore);
- } catch (TeiidException e) {
- LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("error_refresh", viewName )); //$NON-NLS-1$
- }
- }
- };
- addWork(work);
- }
-
- public void updateMatViewRow(final ContextProvider contextProvider, final String vdbName, final int vdbVersion, final String schema,
- final String viewName, final List<?> tuple, final boolean delete) {
-
- if (!cacheFactory.isReplicated() || matTables == null) {
- return;
- }
-
- final DQPWorkContext context = contextProvider.getContext(vdbName, vdbVersion);
-
- final VDBMetaData vdb = context.getVDB();
- if (vdb == null) {
- return;
- }
-
- final TempTableStore globalStore = vdb.getAttachment(TempTableStore.class);
- if (globalStore == null) {
- return;
- }
-
- Runnable work = new Runnable() {
- @Override
- public void run() {
- context.runInContext(new Runnable() {
- @Override
- public void run() {
- try {
- dataTierMgr.updateMatViewRow(globalStore, RelationalPlanner.MAT_PREFIX + (schema + '.' + viewName).toUpperCase(), tuple, delete);
- } catch (TeiidException e) {
- LogManager.logError(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("DQPCore.unable_to_process_event")); //$NON-NLS-1$
- }
- }
- });
- }
- };
- addWork(work);
-
- }
-
public void setBufferService(BufferService service) {
this.bufferService = service;
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -207,7 +207,7 @@
DQPWorkContext.setWorkContext(this);
boolean associated = false;
if (securityHelper != null && this.getSubject() != null) {
- associated = securityHelper.assosiateSecurityContext(this.getSecurityDomain(), this.getSecurityContext());
+ associated = securityHelper.associateSecurityContext(this.getSecurityDomain(), this.getSecurityContext());
}
return associated;
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,3 +1,25 @@
+/*
+ * 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.Collections;
@@ -49,13 +71,20 @@
@Override
public boolean isTempAccessable(PermissionType action, String resource,
Context context, CommandContext commandContext) {
+ Boolean result = null;
for(DataPolicy p:commandContext.getAllowedDataPolicies().values()) {
DataPolicyMetadata policy = (DataPolicyMetadata)p;
if (policy.isAllowCreateTemporaryTables() != null) {
- return policy.isAllowCreateTemporaryTables();
+ if (policy.isAllowCreateTemporaryTables()) {
+ return true;
+ }
+ result = policy.isAllowCreateTemporaryTables();
}
}
+ if (result != null) {
+ return result;
+ }
return allowCreateTemporaryTablesByDefault;
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -89,8 +89,8 @@
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
-import org.teiid.query.tempdata.TempTableStore;
-import org.teiid.query.tempdata.TempTableStore.MatTableInfo;
+import org.teiid.query.tempdata.GlobalTableStore;
+import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
import org.teiid.query.util.CommandContext;
/**
@@ -243,13 +243,13 @@
Integer cardinaltity = null;
Boolean valid = null;
if (table.getMaterializedTable() == null) {
- TempTableStore globalStore = context.getGlobalTableStore();
+ GlobalTableStore globalStore = context.getGlobalTableStore();
matTableName = RelationalPlanner.MAT_PREFIX+table.getFullName().toUpperCase();
MatTableInfo info = globalStore.getMatTableInfo(matTableName);
valid = info.isValid();
state = info.getState().name();
updated = info.getUpdateTime()==-1?null:new Timestamp(info.getUpdateTime());
- TempMetadataID id = globalStore.getMetadataStore().getTempGroupID(matTableName);
+ TempMetadataID id = globalStore.getTempTableStore().getMetadataStore().getTempGroupID(matTableName);
if (id != null) {
cardinaltity = id.getCardinality();
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -116,11 +116,9 @@
TempTableStore tempTableStore = null;
if(requestManager != null) {
- if (workItem != null) {
- ClientState state = requestManager.getClientState(workContext.getSessionId(), false);
- if (state != null) {
- tempTableStore = state.sessionTables;
- }
+ ClientState state = requestManager.getClientState(workContext.getSessionId(), false);
+ if (state != null) {
+ tempTableStore = state.sessionTables;
}
}
if(tempTableStore != null) {
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -83,6 +83,7 @@
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.ContextProperties;
@@ -128,7 +129,7 @@
protected Command userCommand;
protected boolean returnsUpdateCount;
- private TempTableStore globalTables;
+ private GlobalTableStore globalTables;
private SessionAwareCache<PreparedPlan> planCache;
private boolean resultSetCacheEnabled = true;
private int userRequestConcurrency;
@@ -185,7 +186,7 @@
VDBMetaData vdbMetadata = workContext.getVDB();
metadata = vdbMetadata.getAttachment(QueryMetadataInterface.class);
- globalTables = vdbMetadata.getAttachment(TempTableStore.class);
+ globalTables = vdbMetadata.getAttachment(GlobalTableStore.class);
if (metadata == null) {
throw new TeiidComponentException(QueryPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", this.vdbName, this.vdbVersion)); //$NON-NLS-1$
@@ -355,13 +356,14 @@
if (startAutoWrapTxn) {
try {
- tc = transactionService.begin(tc);
+ transactionService.begin(tc);
} catch (XATransactionException err) {
throw new TeiidComponentException(err);
}
}
}
+ tc.setIsolationLevel(requestMsg.getTransactionIsolation());
this.transactionContext = tc;
this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager);
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -38,6 +38,7 @@
import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.logging.LogConstants;
@@ -238,6 +239,7 @@
}
public CacheID(ParseInfo pi, String sql, String vdbName, int vdbVersion, String sessionId, String userName){
+ Assertion.isNotNull(sql);
this.sql = sql;
this.vdbInfo = new VDBKey(vdbName, vdbVersion);
this.pi = pi;
@@ -285,10 +287,6 @@
return true;
}
- public String getSql() {
- return sql;
- }
-
void setUserName(String name) {
this.userName = name;
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -462,31 +462,28 @@
/**
* Request level transaction
*/
- public TransactionContext begin(TransactionContext context) throws XATransactionException{
+ public void begin(TransactionContext context) throws XATransactionException{
if (context.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
beginDirect(context);
context.setTransactionType(TransactionContext.Scope.REQUEST);
- return context;
}
/**
* Request level transaction
*/
- public TransactionContext commit(TransactionContext context) throws XATransactionException {
+ public void commit(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
commitDirect(context);
- return context;
}
/**
* Request level transaction
*/
- public TransactionContext rollback(TransactionContext context) throws XATransactionException {
+ public void rollback(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
rollbackDirect(context);
- return context;
}
public void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException {
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -23,7 +23,6 @@
package org.teiid.dqp.service;
import java.util.Collection;
-import java.util.List;
import java.util.Properties;
import javax.security.auth.Subject;
@@ -149,5 +148,5 @@
String getKrb5SecurityDomain();
- void assosiateSubjectInContext(String securityDomain, Subject subject);
+ void associateSubjectInContext(String securityDomain, Subject subject);
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -46,7 +46,16 @@
private long creationTime;
private Transaction transaction;
private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
+ private int isolationLevel;
+
+ public int getIsolationLevel() {
+ return isolationLevel;
+ }
+ public void setIsolationLevel(int isolationLevel) {
+ this.isolationLevel = isolationLevel;
+ }
+
public long getCreationTime() {
return creationTime;
}
Modified: branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -40,11 +40,11 @@
public interface TransactionService {
// processor level methods
- TransactionContext begin(TransactionContext context) throws XATransactionException;
+ void begin(TransactionContext context) throws XATransactionException;
- TransactionContext commit(TransactionContext context) throws XATransactionException;
+ void commit(TransactionContext context) throws XATransactionException;
- TransactionContext rollback(TransactionContext context) throws XATransactionException;
+ void rollback(TransactionContext context) throws XATransactionException;
TransactionContext getOrCreateTransactionContext(String threadId);
Copied: branches/as7/engine/src/main/java/org/teiid/query/ObjectReplicator.java (from rev 3450, trunk/engine/src/main/java/org/teiid/query/ObjectReplicator.java)
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/ObjectReplicator.java (rev 0)
+++ branches/as7/engine/src/main/java/org/teiid/query/ObjectReplicator.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query;
+
+public interface ObjectReplicator {
+
+ public <T, S> T replicate(String id, Class<T> iface, S object, long startTimeout) throws Exception;
+
+ public void stop(Object o);
+
+}
Copied: branches/as7/engine/src/main/java/org/teiid/query/ReplicatedObject.java (from rev 3450, trunk/engine/src/main/java/org/teiid/query/ReplicatedObject.java)
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/ReplicatedObject.java (rev 0)
+++ branches/as7/engine/src/main/java/org/teiid/query/ReplicatedObject.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,78 @@
+/*
+ * 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.query;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Collection;
+
+/**
+ * Optional interface to be implemented by a replicated object to support full and partial state transfer.
+ *
+ */
+public interface ReplicatedObject {
+
+ /**
+ * Allows an application to write a state through a provided OutputStream.
+ *
+ * @param ostream the OutputStream
+ */
+ void getState(OutputStream ostream);
+
+ /**
+ * Allows an application to write a partial state through a provided OutputStream.
+ *
+ * @param state_id id of the partial state requested
+ * @param ostream the OutputStream
+ */
+ void getState(String state_id, OutputStream ostream);
+
+ /**
+ * Allows an application to read a state through a provided InputStream.
+ *
+ * @param istream the InputStream
+ */
+ void setState(InputStream istream);
+
+ /**
+ * Allows an application to read a partial state through a provided InputStream.
+ *
+ * @param state_id id of the partial state requested
+ * @param istream the InputStream
+ */
+ void setState(String state_id, InputStream istream);
+
+ /**
+ * Allows the replicator to set the local address from the channel
+ * @param address
+ */
+ void setLocalAddress(Serializable address);
+
+ /**
+ * Called when members are dropped
+ * @param addresses
+ */
+ void droppedMembers(Collection<Serializable> addresses);
+
+}
Property changes on: branches/as7/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java:3149-3171
/trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java:3149-3171
/trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java:3188-3450
Property changes on: branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java:3149-3171
/trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java:3149-3171
/trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -25,6 +25,7 @@
public interface SourceCapabilities {
public enum Capability {
+
/**
* Support indicates connector can accept queries with SELECT DISTINCT
*/
@@ -38,7 +39,7 @@
*
* @since 3.1 SP2
*/
- QUERY_FROM_GROUP_ALIAS,
+ QUERY_FROM_GROUP_ALIAS("TableAlias"), //$NON-NLS-1$
/**
* Max number of groups appearing in a from clause
*/
@@ -64,7 +65,7 @@
*
* @since 3.1 SP2
*/
- QUERY_FROM_JOIN_SELFJOIN,
+ QUERY_FROM_JOIN_SELFJOIN("SelfJoins"), //$NON-NLS-1$
/**
* Support indicates connector can accept right or left outer joins
*
@@ -76,7 +77,7 @@
*
* @since 4.1
*/
- QUERY_FROM_INLINE_VIEWS,
+ QUERY_FROM_INLINE_VIEWS("InlineViews"), //$NON-NLS-1$
/**
* Support indicates connector can accept full outer joins
*
@@ -101,13 +102,13 @@
*
* @since 3.1 SP2
*/
- CRITERIA_LIKE,
+ CRITERIA_LIKE("LikeCriteria"), //$NON-NLS-1$
/**
* Support indicates connector accepts criteria of form (element LIKE constant ESCAPE char) - CURRENTLY NOT USED
*
* @since 3.1 SP2
*/
- CRITERIA_LIKE_ESCAPE,
+ CRITERIA_LIKE_ESCAPE("LikeCriteriaEscapeCharacter"), //$NON-NLS-1$
/**
* Support indicates connector accepts criteria of form (element IN set)
*
@@ -226,7 +227,7 @@
*
* @since 3.1 SP2
*/
- QUERY_AGGREGATES_DISTINCT,
+ QUERY_AGGREGATES_DISTINCT("AggregatesDistinct"),
/**
* Support indicates connector can accept scalar subqueries in the SELECT, WHERE, and HAVING clauses
*
@@ -321,12 +322,29 @@
INSERT_WITH_ITERATOR,
COMMON_TABLE_EXPRESSIONS,
MAX_DEPENDENT_PREDICATES,
- ADVANCED_OLAP,
+ ADVANCED_OLAP("AdvancedOLAP"), //$NON-NLS-1$
QUERY_AGGREGATES_ARRAY,
- ELEMENTARY_OLAP,
- WINDOW_FUNCTION_ORDER_BY_AGGREGATES,
+ ELEMENTARY_OLAP("ElementaryOLAP"), //$NON-NLS-1$
+ WINDOW_FUNCTION_ORDER_BY_AGGREGATES("WindowOrderByAggregates"), //$NON-NLS-1$
CRITERIA_SIMILAR,
- CRITERIA_LIKE_REGEX
+ CRITERIA_LIKE_REGEX,
+ WINDOW_FUNCTION_DISTINCT_AGGREGATES("WindowDistinctAggregates"); //$NON-NLS-1$
+
+
+ private final String toString;
+
+ Capability(String toString) {
+ this.toString = toString;
+ }
+
+ Capability() {
+ this.toString = name();
+ }
+
+ public String toString() {
+ return toString;
+ }
+
}
public enum Scope {
Property changes on: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java:3149-3217
/trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java:3149-3217
/trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1216,7 +1216,7 @@
CacheHint hint = null;
boolean isImplicitGlobal = matMetadataId == null;
if (isImplicitGlobal) {
- TempMetadataID tid = context.getGlobalTableStore().getGlobalTempTableMetadataId(metadataID, metadata);
+ TempMetadataID tid = context.getGlobalTableStore().getGlobalTempTableMetadataId(metadataID);
matTableName = tid.getID();
hint = tid.getCacheHint();
if (hint != null) {
Property changes on: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java:3149-3217
/trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java:3149-3217
/trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -54,6 +54,9 @@
}
public static final PlanNode findNodePreOrder(PlanNode root, int types, int stopTypes) {
+ if (root == null) {
+ return null;
+ }
if((types & root.getType()) == root.getType()) {
return root;
} else if((stopTypes & root.getType()) == root.getType()) {
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -30,6 +30,7 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.metadata.Schema;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -38,6 +39,7 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.Constant;
@@ -462,4 +464,35 @@
}
return true;
}
+
+ static boolean supportsNullOrdering(QueryMetadataInterface metadata,
+ CapabilitiesFinder capFinder, Object modelID, OrderByItem symbol)
+ throws QueryMetadataException, TeiidComponentException {
+ boolean supportsNullOrdering = CapabilitiesUtil.supports(Capability.QUERY_ORDERBY_NULL_ORDERING, modelID, metadata, capFinder);
+ NullOrder defaultNullOrder = CapabilitiesUtil.getDefaultNullOrder(modelID, metadata, capFinder);
+ if (symbol.getNullOrdering() != null) {
+ if (!supportsNullOrdering) {
+ if (symbol.getNullOrdering() == NullOrdering.FIRST) {
+ if (defaultNullOrder != NullOrder.FIRST && !(symbol.isAscending() && defaultNullOrder == NullOrder.LOW)
+ && !(!symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)) {
+ return false;
+ }
+ } else if (defaultNullOrder != NullOrder.LAST && !(symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)
+ && !(!symbol.isAscending() && defaultNullOrder == NullOrder.LOW)) {
+ return false;
+ }
+ symbol.setNullOrdering(null);
+ }
+ } else if (supportsNullOrdering && defaultNullOrder != NullOrder.LOW) {
+ //try to match the expected default of low
+ if (symbol.isAscending()) {
+ if (defaultNullOrder != NullOrder.FIRST) {
+ symbol.setNullOrdering(NullOrdering.FIRST);
+ }
+ } else if (defaultNullOrder != NullOrder.LAST) {
+ symbol.setNullOrdering(NullOrdering.LAST);
+ }
+ }
+ return true;
+ }
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -51,6 +51,7 @@
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.MatchCriteria;
import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.SetCriteria;
@@ -176,8 +177,36 @@
markInvalid(windowFunction, "Window function order by with aggregate not supported by source"); //$NON-NLS-1$
return;
}
+ if (!this.caps.supportsCapability(Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES)
+ && windowFunction.getFunction().isDistinct()) {
+ markInvalid(windowFunction, "Window function distinct aggregate not supported by source"); //$NON-NLS-1$
+ return;
+ }
+ try {
+ if (!CapabilitiesUtil.checkElementsAreSearchable(windowFunction.getWindowSpecification().getPartition(), metadata, SupportConstants.Element.SEARCHABLE_COMPARE)) {
+ markInvalid(windowFunction, "not all source columns support search type"); //$NON-NLS-1$
+ }
+ } catch(QueryMetadataException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
+ handleException(e);
+ }
}
+ @Override
+ public void visit(OrderByItem obj) {
+ try {
+ checkElementsAreSearchable(obj.getSymbol(), SupportConstants.Element.SEARCHABLE_COMPARE);
+ if (!CapabilitiesUtil.supportsNullOrdering(this.metadata, this.capFinder, this.modelID, obj)) {
+ markInvalid(obj, "Desired null ordering is not supported by source"); //$NON-NLS-1$
+ }
+ } catch(QueryMetadataException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
+ handleException(e);
+ }
+ }
+
public void visit(CaseExpression obj) {
if(! this.caps.supportsCapability(Capability.QUERY_CASE)) {
markInvalid(obj, "CaseExpression pushdown not supported by source"); //$NON-NLS-1$
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -223,7 +223,7 @@
PlanNode sortNode = createSortNode(new ArrayList<SingleElementSymbol>(orderSymbols), outputSymbols);
boolean distinct = false;
- if (sourceNode.getType() == NodeConstants.Types.SOURCE && outputSymbols.size() == expressions.size() && outputSymbols.containsAll(expressions)) {
+ if (sourceNode.getFirstChild() != null && sourceNode.getType() == NodeConstants.Types.SOURCE && outputSymbols.size() == expressions.size() && outputSymbols.containsAll(expressions)) {
PlanNode setOp = NodeEditor.findNodePreOrder(sourceNode.getFirstChild(), NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
if (setOp != null) {
if (setOp.hasBooleanProperty(NodeConstants.Info.USE_ALL)) {
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -466,7 +466,9 @@
}
JoinType jt = (JoinType)root.getProperty(NodeConstants.Info.JOIN_TYPE);
- boolean treatJoinAsSource = jt.isOuter() || root.getProperty(NodeConstants.Info.ACCESS_PATTERNS) != null || root.hasProperty(NodeConstants.Info.MAKE_DEP) || root.hasProperty(NodeConstants.Info.MAKE_IND);
+ boolean treatJoinAsSource = jt.isOuter() || root.getProperty(NodeConstants.Info.ACCESS_PATTERNS) != null
+ || root.hasProperty(NodeConstants.Info.MAKE_DEP) || root.hasProperty(NodeConstants.Info.MAKE_IND)
+ || !root.getExportedCorrelatedReferences().isEmpty();
if (treatJoinAsSource) {
currentRegion.addJoinSourceNode(root);
Modified: branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -32,7 +32,6 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.core.TeiidComponentException;
-import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.SupportConstants;
@@ -58,7 +57,6 @@
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.util.CommandContext;
-import org.teiid.translator.ExecutionFactory.NullOrder;
import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
@@ -356,30 +354,8 @@
if(! canPushSymbol(symbol.getSymbol(), true, modelID, metadata, capFinder, record)) {
return false;
}
- boolean supportsNullOrdering = CapabilitiesUtil.supports(Capability.QUERY_ORDERBY_NULL_ORDERING, modelID, metadata, capFinder);
- NullOrder defaultNullOrder = CapabilitiesUtil.getDefaultNullOrder(modelID, metadata, capFinder);
- if (symbol.getNullOrdering() != null) {
- if (!supportsNullOrdering) {
- if (symbol.getNullOrdering() == NullOrdering.FIRST) {
- if (defaultNullOrder != NullOrder.FIRST && !(symbol.isAscending() && defaultNullOrder == NullOrder.LOW)
- && !(!symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)) {
- return false;
- }
- } else if (defaultNullOrder != NullOrder.LAST && !(symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)
- && !(!symbol.isAscending() && defaultNullOrder == NullOrder.LOW)) {
- return false;
- }
- symbol.setNullOrdering(null);
- }
- } else if (supportsNullOrdering && defaultNullOrder != NullOrder.LOW) {
- //try to match the expected default of low
- if (symbol.isAscending()) {
- if (defaultNullOrder != NullOrder.FIRST) {
- symbol.setNullOrdering(NullOrdering.FIRST);
- }
- } else if (defaultNullOrder != NullOrder.LAST) {
- symbol.setNullOrdering(NullOrdering.LAST);
- }
+ if (!CapabilitiesUtil.supportsNullOrdering(metadata, capFinder, modelID, symbol)) {
+ return false;
}
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -120,11 +120,12 @@
private TupleBuffer buffer;
private boolean forwardOnly;
- public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext context, boolean fowardOnly) throws TeiidComponentException {
+ public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext context, boolean forwardOnly) throws TeiidComponentException {
this.sourceNode = sourceNode;
+ this.forwardOnly = forwardOnly;
if (!this.sourceNode.hasFinalBuffer()) {
this.buffer = bm.createTupleBuffer(sourceNode.getOutputElements(), context.getConnectionID(), TupleSourceType.PROCESSOR);
- this.buffer.setForwardOnly(fowardOnly);
+ this.buffer.setForwardOnly(forwardOnly);
}
}
Property changes on: branches/as7/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java:3220-3275,3340-3349
/trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java:3220-3275,3340-3349
/trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/proc/Program.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -29,6 +29,7 @@
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.sql.proc.Statement.Labeled;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
/**
@@ -113,7 +114,7 @@
*/
public void reset(String sessionId){
counter = 0;
- this.tempTables = new TempTableStore(sessionId);
+ this.tempTables = new TempTableStore(sessionId, TransactionMode.ISOLATE_WRITES);
this.startedTxn = false;
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -39,7 +39,6 @@
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.aggregate.AggregateFunction;
@@ -235,12 +234,8 @@
functions[i] = new StatsFunction(function);
}
- if(aggSymbol.isDistinct() && !function.equals(NonReserved.MIN) && !function.equals(NonReserved.MAX)) {
- SortingFilter filter = new SortingFilter(functions[i], getBufferManager(), getConnectionID(), true);
- ElementSymbol element = new ElementSymbol("val"); //$NON-NLS-1$
- element.setType(inputType);
- filter.setElements(Arrays.asList(element));
- functions[i] = filter;
+ if(aggSymbol.isDistinct()) {
+ functions[i] = handleDistinct(functions[i], inputType, getBufferManager(), getConnectionID());
} else if (aggSymbol.getOrderBy() != null) { //handle the xmlagg case
int[] orderIndecies = new int[aggSymbol.getOrderBy().getOrderByItems().size()];
List<OrderByItem> orderByItems = new ArrayList<OrderByItem>(orderIndecies.length);
@@ -277,6 +272,14 @@
}
}
+ static SortingFilter handleDistinct(AggregateFunction af, Class<?> inputType, BufferManager bm, String cid) {
+ SortingFilter filter = new SortingFilter(af, bm, cid, true);
+ ElementSymbol element = new ElementSymbol("val"); //$NON-NLS-1$
+ element.setType(inputType);
+ filter.setElements(Arrays.asList(element));
+ return filter;
+ }
+
private int collectExpression(Expression ex) {
int index = this.collectedExpressions.indexOf(ex);
if(index == -1) {
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -46,7 +46,6 @@
import org.teiid.query.processor.BatchCollector.BatchProducer;
import org.teiid.query.sql.symbol.AliasSymbol;
import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.util.CommandContext;
@@ -358,7 +357,7 @@
/**
* Helper method for all the node that will filter the elements needed for the next node.
*/
- public static int[] getProjectionIndexes(Map<SingleElementSymbol, Integer> tupleElements, List<? extends Expression> projectElements) {
+ public static int[] getProjectionIndexes(Map<? extends Expression, Integer> tupleElements, List<? extends Expression> projectElements) {
int[] result = new int[projectElements.size()];
int i = 0;
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -108,6 +108,11 @@
}
return true;
}
+
+ if (query.hasAggregates() && query.getGroupBy() == null) {
+ return true;
+ }
+
break;
case Command.TYPE_INSERT:
Insert insert = (Insert) command;
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -46,6 +46,7 @@
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.WithQueryCommand;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
/**
@@ -87,7 +88,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
if (this.with != null) {
context = context.clone();
- tempTableStore = new TempTableStore(context.getConnectionID());
+ tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
for (WithQueryCommand withCommand : this.with) {
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -133,7 +133,9 @@
public void closeDirect() {
if(this.output != null) {
- this.output.remove();
+ if (!usingOutput) {
+ this.output.remove();
+ }
this.output = null;
}
this.outputTs = null;
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -50,6 +50,8 @@
/**
* Implements several modes of a multi-pass sort.
+ *
+ * TODO: could consider using an index for dup_removal and maintaining a separate output buffer
*/
public class SortUtility {
@@ -324,7 +326,7 @@
while (sublists.size() > 0) {
SortedSublist sortedSublist = sublists.remove(sublists.size() - 1);
merged.addTuple(sortedSublist.tuple);
- if (this.output != null && sortedSublist.index > masterSortIndex) {
+ if (this.output != null && masterSortIndex < maxSortIndex && sortedSublist.index != masterSortIndex) {
this.output.addTuple(sortedSublist.tuple); //a new distinct row
}
incrementWorkingTuple(sublists, sortedSublist);
@@ -339,7 +341,7 @@
}
merged.saveBatch();
this.activeTupleBuffers.add(merged);
- masterSortIndex = masterSortIndex - maxSortIndex + 1;
+ masterSortIndex = masterSortIndex - maxSortIndex;
if (masterSortIndex < 0) {
masterSortIndex = this.activeTupleBuffers.size() - 1;
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -181,14 +181,16 @@
index = nameIndexes.get(col.getName());
}
if (index >= vals.size()) {
- throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.no_value", col.getName(), textLine, systemId)); //$NON-NLS-1$
+ //throw new TeiidProcessingException(QueryPlugin.Util.getString("TextTableNode.no_value", col.getName(), textLine, systemId)); //$NON-NLS-1$
+ tuple.add(null);
+ } else {
+ val = vals.get(index);
+ try {
+ tuple.add(DataTypeManager.transformValue(val, table.getColumns().get(output).getSymbol().getType()));
+ } catch (TransformationException e) {
+ throw new TeiidProcessingException(e, QueryPlugin.Util.getString("TextTableNode.conversion_error", col.getName(), textLine, systemId)); //$NON-NLS-1$
+ }
}
- val = vals.get(index);
- try {
- tuple.add(DataTypeManager.transformValue(val, table.getColumns().get(output).getSymbol().getType()));
- } catch (TransformationException e) {
- throw new TeiidProcessingException(e, QueryPlugin.Util.getString("TextTableNode.conversion_error", col.getName(), textLine, systemId)); //$NON-NLS-1$
- }
}
addBatchRow(tuple);
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -462,6 +462,10 @@
af = new StatsFunction(function);
}
+ if(aggSymbol.isDistinct()) {
+ af = GroupingNode.handleDistinct(af, inputType, getBufferManager(), getConnectionID());
+ }
+
af.setExpressionIndex(wfi.expressionIndex);
af.setConditionIndex(wfi.conditionIndex);
af.initialize(outputType, inputType);
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -95,7 +95,9 @@
public void closeDirect() {
super.closeDirect();
if(this.buffer != null) {
- this.buffer.remove();
+ if (!usingOutput) {
+ this.buffer.remove();
+ }
this.buffer = null;
}
reset();
Modified: branches/as7/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -60,6 +60,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
@@ -110,7 +111,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
context = context.clone();
setContext(context);
- TempTableStore tempTableStore = new TempTableStore(context.getConnectionID());
+ TempTableStore tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
this.dataMgr = dataMgr;
Modified: branches/as7/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -2256,9 +2256,13 @@
expression.setAggregateFunction(Type.MAX);
}
}
- if ((expression.getAggregateFunction() == Type.MAX || expression.getAggregateFunction() == Type.MIN)
- && rewriteAggs && expression.getExpression() != null && EvaluatableVisitor.willBecomeConstant(expression.getExpression())) {
- return expression.getExpression();
+ if ((expression.getAggregateFunction() == Type.MAX || expression.getAggregateFunction() == Type.MIN)) {
+ if (expression.isDistinct()) {
+ expression.setDistinct(false);
+ }
+ if (rewriteAggs && expression.getExpression() != null && EvaluatableVisitor.willBecomeConstant(expression.getExpression())) {
+ return expression.getExpression();
+ }
}
if (expression.getExpression() != null && expression.getCondition() != null && !expression.respectsNulls()) {
Expression cond = expression.getCondition();
Property changes on: branches/as7/engine/src/main/java/org/teiid/query/sql/LanguageObject.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/main/java/org/teiid/query/sql/LanguageObject.java:3149-3217
/trunk/engine/src/main/java/org/teiid/query/sql/LanguageObject.java:3188-3382
+ /branches/7.4.x/engine/src/main/java/org/teiid/query/sql/LanguageObject.java:3149-3217
/trunk/engine/src/main/java/org/teiid/query/sql/LanguageObject.java:3188-3450
Modified: branches/as7/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -156,6 +156,10 @@
public boolean isDistinct() {
return this.distinct;
}
+
+ public void setDistinct(boolean distinct) {
+ this.distinct = distinct;
+ }
/**
* Get the type of the symbol, which depends on the aggregate function and the
Modified: branches/as7/engine/src/main/java/org/teiid/query/tempdata/AlterTempTable.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/tempdata/AlterTempTable.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/tempdata/AlterTempTable.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,12 +1,3 @@
-package org.teiid.query.tempdata;
-
-import java.util.List;
-
-import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
-
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
@@ -29,6 +20,15 @@
* 02110-1301 USA.
*/
+package org.teiid.query.tempdata;
+
+import java.util.List;
+
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
public class AlterTempTable extends Command {
private String tempTable;
Copied: branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java (from rev 3450, trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java)
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java (rev 0)
+++ branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.tempdata;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.teiid.Replicated;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
+
+public interface GlobalTableStore {
+
+ TempMetadataID getGlobalTempTableMetadataId(Object groupID) throws QueryMetadataException, TeiidComponentException, QueryResolverException, QueryValidatorException;
+
+ TempMetadataID getCodeTableMetadataId(String codeTableName,
+ String returnElementName, String keyElementName,
+ String matTableName) throws TeiidComponentException,
+ QueryMetadataException;
+
+ MatTableInfo getMatTableInfo(String matTableName);
+
+ TempTableStore getTempTableStore();
+
+ Serializable getLocalAddress();
+
+ List<?> updateMatViewRow(String matTableName, List<?> tuple, boolean delete) throws TeiidComponentException;
+
+ TempTable createMatTable(String tableName, GroupSymbol group)
+ throws TeiidComponentException, QueryMetadataException, TeiidProcessingException;
+
+ @Replicated
+ void failedLoad(String matTableName);
+
+ @Replicated(asynch=false, timeout=5000)
+ boolean needsLoading(String matTableName, Serializable loadingAddress,
+ boolean firstPass, boolean refresh, boolean invalidate);
+
+ @Replicated(replicateState=true)
+ void loaded(String matTableName, TempTable table);
+
+}
Copied: branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java (from rev 3450, trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java)
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java (rev 0)
+++ branches/as7/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,488 @@
+/*
+ * 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.query.tempdata;
+
+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.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SQLConstants;
+import org.teiid.language.SQLConstants.Reserved;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.query.ReplicatedObject;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.CacheHint;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
+
+public class GlobalTableStoreImpl implements GlobalTableStore, ReplicatedObject {
+
+ public enum MatState {
+ NEEDS_LOADING,
+ LOADING,
+ FAILED_LOAD,
+ LOADED
+ }
+
+ public class MatTableInfo {
+ private long updateTime = -1;
+ private MatState state = MatState.NEEDS_LOADING;
+ private Serializable loadingAddress;
+ private long ttl = -1;
+ private boolean valid;
+
+ protected MatTableInfo() {}
+
+ private synchronized boolean shouldLoad(Serializable possibleLoadingAddress, boolean firstPass, boolean refresh, boolean invalidate) {
+ if (invalidate) {
+ LogManager.logDetail(LogConstants.CTX_MATVIEWS, this, "invalidating"); //$NON-NLS-1$
+ valid = false;
+ }
+ switch (state) {
+ case NEEDS_LOADING:
+ case FAILED_LOAD:
+ if (!firstPass) {
+ this.loadingAddress = possibleLoadingAddress;
+ setState(MatState.LOADING, null);
+ }
+ return true;
+ case LOADING:
+ if (!firstPass && localAddress instanceof Comparable<?> && ((Comparable)localAddress).compareTo(possibleLoadingAddress) < 0) {
+ this.loadingAddress = possibleLoadingAddress; //ties go to the lowest address
+ return true;
+ }
+ return false;
+ case LOADED:
+ if (!firstPass
+ || refresh
+ || ttl >= 0 && System.currentTimeMillis() - updateTime - ttl > 0) {
+ if (firstPass) {
+ setState(MatState.NEEDS_LOADING, null);
+ } else {
+ this.loadingAddress = possibleLoadingAddress;
+ setState(MatState.LOADING, null);
+ }
+ return true;
+ }
+ return false;
+ }
+ throw new AssertionError();
+ }
+
+ private synchronized void setState(MatState state, Boolean valid) {
+ MatState oldState = this.state;
+ long timestamp = System.currentTimeMillis();
+ LogManager.logDetail(LogConstants.CTX_MATVIEWS, this, "setting matState to", state, valid, timestamp, "old values", oldState, this.valid); //$NON-NLS-1$ //$NON-NLS-2$
+ if (valid != null) {
+ this.valid = valid;
+ }
+ this.state = state;
+ this.updateTime = System.currentTimeMillis();
+ notifyAll();
+ }
+
+ public synchronized void setTtl(long ttl) {
+ this.ttl = ttl;
+ }
+
+ public synchronized long getUpdateTime() {
+ return updateTime;
+ }
+
+ public synchronized MatState getState() {
+ return state;
+ }
+
+ public synchronized boolean isUpToDate() {
+ return isValid() && (ttl < 0 || System.currentTimeMillis() - updateTime - ttl <= 0);
+ }
+
+ public synchronized boolean isValid() {
+ return valid;
+ }
+
+ public synchronized long getTtl() {
+ return ttl;
+ }
+
+ }
+
+ private ConcurrentHashMap<String, MatTableInfo> matTables = new ConcurrentHashMap<String, MatTableInfo>();
+ private TempTableStore tableStore = new TempTableStore("SYSTEM", TransactionMode.ISOLATE_READS); //$NON-NLS-1$
+ private BufferManager bufferManager;
+ private QueryMetadataInterface metadata;
+ private Serializable localAddress;
+
+ public GlobalTableStoreImpl(BufferManager bufferManager, QueryMetadataInterface metadata) {
+ this.bufferManager = bufferManager;
+ this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
+ }
+
+ public synchronized MatTableInfo getMatTableInfo(final String tableName) {
+ MatTableInfo info = matTables.get(tableName);
+ if (info == null) {
+ info = new MatTableInfo();
+ matTables.put(tableName, info);
+ }
+ return info;
+ }
+
+ @Override
+ public void failedLoad(String matTableName) {
+ MatTableInfo info = getMatTableInfo(matTableName);
+ synchronized (info) {
+ if (info.state != MatState.LOADED) {
+ info.setState(MatState.FAILED_LOAD, null);
+ }
+ }
+ }
+
+ @Override
+ public boolean needsLoading(String matTableName, Serializable loadingAddress, boolean firstPass, boolean refresh, boolean invalidate) {
+ MatTableInfo info = getMatTableInfo(matTableName);
+ return info.shouldLoad(loadingAddress, firstPass, refresh, invalidate);
+ }
+
+ @Override
+ public TempMetadataID getGlobalTempTableMetadataId(Object viewId)
+ throws QueryMetadataException, TeiidComponentException, QueryResolverException, QueryValidatorException {
+ String matViewName = metadata.getFullName(viewId);
+ String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
+ GroupSymbol group = new GroupSymbol(matViewName);
+ group.setMetadataID(viewId);
+ TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName);
+ //define the table preserving the key/index information and ensure that only a single instance exists
+ if (id == null) {
+ synchronized (viewId) {
+ id = tableStore.getMetadataStore().getTempGroupID(matTableName);
+ if (id == null) {
+ id = tableStore.getMetadataStore().addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
+ id.setQueryNode(metadata.getVirtualPlan(viewId));
+ id.setCardinality(metadata.getCardinality(viewId));
+ id.setOriginalMetadataID(viewId);
+
+ Object pk = metadata.getPrimaryKey(viewId);
+ if (pk != null) {
+ ArrayList<TempMetadataID> primaryKey = resolveIndex(metadata, id, pk);
+ id.setPrimaryKey(primaryKey);
+ }
+ Collection keys = metadata.getUniqueKeysInGroup(viewId);
+ for (Object key : keys) {
+ id.addUniqueKey(resolveIndex(metadata, id, key));
+ }
+ Collection indexes = metadata.getIndexesInGroup(viewId);
+ for (Object index : indexes) {
+ id.addIndex(resolveIndex(metadata, id, index));
+ }
+ }
+ }
+ }
+ updateCacheHint(viewId, group, id);
+ return id;
+ }
+
+ @Override
+ public TempMetadataID getCodeTableMetadataId(
+ String codeTableName, String returnElementName,
+ String keyElementName, String matTableName) throws TeiidComponentException,
+ QueryMetadataException {
+ ElementSymbol keyElement = new ElementSymbol(matTableName + ElementSymbol.SEPARATOR + keyElementName);
+ ElementSymbol returnElement = new ElementSymbol(matTableName + ElementSymbol.SEPARATOR + returnElementName);
+ keyElement.setType(DataTypeManager.getDataTypeClass(metadata.getElementType(metadata.getElementID(codeTableName + ElementSymbol.SEPARATOR + keyElementName))));
+ returnElement.setType(DataTypeManager.getDataTypeClass(metadata.getElementType(metadata.getElementID(codeTableName + ElementSymbol.SEPARATOR + returnElementName))));
+ TempMetadataID id = this.getTempTableStore().getMetadataStore().getTempGroupID(matTableName);
+ if (id == null) {
+ synchronized (this) {
+ id = this.getTempTableStore().getMetadataStore().addTempGroup(matTableName, Arrays.asList(keyElement, returnElement), false, true);
+ String queryString = Reserved.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + Reserved.FROM + ' ' + codeTableName; //$NON-NLS-1$
+ id.setQueryNode(new QueryNode(queryString));
+ id.setPrimaryKey(id.getElements().subList(0, 1));
+ CacheHint hint = new CacheHint(true, null);
+ id.setCacheHint(hint);
+ }
+ }
+ return id;
+ }
+
+ private void updateCacheHint(Object viewId, GroupSymbol group,
+ TempMetadataID id) throws TeiidComponentException,
+ QueryMetadataException, QueryResolverException,
+ QueryValidatorException {
+ Command c = QueryResolver.resolveView(group, metadata.getVirtualPlan(viewId), SQLConstants.Reserved.SELECT, metadata).getCommand();
+ CacheHint hint = c.getCacheHint();
+ id.setCacheHint(hint);
+ }
+
+ static ArrayList<TempMetadataID> resolveIndex(
+ QueryMetadataInterface metadata, TempMetadataID id, Object pk)
+ throws TeiidComponentException, QueryMetadataException {
+ List cols = metadata.getElementIDsInKey(pk);
+ ArrayList<TempMetadataID> primaryKey = new ArrayList<TempMetadataID>(cols.size());
+ for (Object coldId : cols) {
+ int pos = metadata.getPosition(coldId) - 1;
+ primaryKey.add(id.getElements().get(pos));
+ }
+ return primaryKey;
+ }
+
+ @Override
+ public void loaded(String matTableName, TempTable table) {
+ swapTempTable(matTableName, table);
+ this.getMatTableInfo(matTableName).setState(MatState.LOADED, true);
+ }
+
+ private void swapTempTable(String tempTableName, TempTable tempTable) {
+ this.tableStore.getTempTables().put(tempTableName, tempTable);
+ }
+
+ @Override
+ public List<?> updateMatViewRow(String matTableName, List<?> tuple,
+ boolean delete) throws TeiidComponentException {
+ TempTable tempTable = tableStore.getTempTable(matTableName);
+ if (tempTable != null) {
+ TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName);
+ synchronized (id) {
+ boolean clone = tempTable.getActiveReaders().get() != 0;
+ if (clone) {
+ tempTable = tempTable.clone();
+ }
+ List<?> result = tempTable.updateTuple(tuple, delete);
+ if (clone) {
+ swapTempTable(matTableName, tempTable);
+ }
+ return result;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public TempTableStore getTempTableStore() {
+ return this.tableStore;
+ }
+
+ @Override
+ public TempTable createMatTable(final String tableName, GroupSymbol group) throws TeiidComponentException,
+ QueryMetadataException, TeiidProcessingException {
+ Create create = new Create();
+ create.setTable(group);
+ List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
+ create.setElementSymbolsAsColumns(allColumns);
+ Object pk = metadata.getPrimaryKey(group.getMetadataID());
+ if (pk != null) {
+ List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk);
+ create.getPrimaryKey().addAll(pkColumns);
+ }
+ TempTable table = getTempTableStore().addTempTable(tableName, create, bufferManager, false, null);
+ table.setUpdatable(false);
+ CacheHint hint = table.getCacheHint();
+ if (hint != null) {
+ table.setPreferMemory(hint.getPrefersMemory());
+ if (hint.getTtl() != null) {
+ getMatTableInfo(tableName).setTtl(hint.getTtl());
+ }
+ if (pk != null) {
+ table.setUpdatable(hint.isUpdatable());
+ }
+ }
+ return table;
+ }
+
+ /**
+ * Return a list of ElementSymbols for the given index/key object
+ */
+ public static List<ElementSymbol> resolveIndex(QueryMetadataInterface metadata, List<ElementSymbol> allColumns, Object pk)
+ throws TeiidComponentException, QueryMetadataException {
+ Collection<?> pkIds = metadata.getElementIDsInKey(pk);
+ List<ElementSymbol> pkColumns = new ArrayList<ElementSymbol>(pkIds.size());
+ for (Object col : pkIds) {
+ pkColumns.add(allColumns.get(metadata.getPosition(col)-1));
+ }
+ return pkColumns;
+ }
+
+ //begin replication methods
+
+ @Override
+ public void setLocalAddress(Serializable address) {
+ this.localAddress = address;
+ }
+
+ @Override
+ public Serializable getLocalAddress() {
+ return localAddress;
+ }
+
+ @Override
+ public void getState(OutputStream ostream) {
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(ostream);
+ for (Map.Entry<String, TempTable> entry : tableStore.getTempTables().entrySet()) {
+ sendTable(entry.getKey(), oos, true);
+ }
+ oos.writeObject(null);
+ oos.close();
+ } catch (IOException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void setState(InputStream istream) {
+ try {
+ ObjectInputStream ois = new ObjectInputStream(istream);
+ while (true) {
+ String tableName = (String)ois.readObject();
+ if (tableName == null) {
+ break;
+ }
+ loadTable(tableName, ois);
+ }
+ ois.close();
+ } catch (Exception e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void getState(String stateId, OutputStream ostream) {
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(ostream);
+ sendTable(stateId, oos, false);
+ oos.close();
+ } catch (IOException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ private void sendTable(String stateId, ObjectOutputStream oos, boolean writeName)
+ throws IOException, TeiidComponentException {
+ TempTable tempTable = this.tableStore.getTempTable(stateId);
+ if (tempTable == null) {
+ return;
+ }
+ MatTableInfo info = getMatTableInfo(stateId);
+ if (!info.isValid()) {
+ return;
+ }
+ if (writeName) {
+ oos.writeObject(stateId);
+ }
+ oos.writeLong(info.updateTime);
+ oos.writeObject(info.loadingAddress);
+ oos.writeObject(info.state);
+ tempTable.writeTo(oos);
+ }
+
+ @Override
+ public void setState(String stateId, InputStream istream) {
+ try {
+ ObjectInputStream ois = new ObjectInputStream(istream);
+ loadTable(stateId, ois);
+ ois.close();
+ } catch (Exception e) {
+ MatTableInfo info = this.getMatTableInfo(stateId);
+ info.setState(MatState.FAILED_LOAD, null);
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ private void loadTable(String stateId, ObjectInputStream ois)
+ throws TeiidComponentException, QueryMetadataException,
+ IOException,
+ ClassNotFoundException, TeiidProcessingException {
+ LogManager.logDetail(LogConstants.CTX_DQP, "loading table from remote stream", stateId); //$NON-NLS-1$
+ long updateTime = ois.readLong();
+ Serializable loadingAddress = (Serializable) ois.readObject();
+ MatState state = (MatState)ois.readObject();
+ GroupSymbol group = new GroupSymbol(stateId);
+ if (stateId.startsWith(RelationalPlanner.MAT_PREFIX)) {
+ String viewName = stateId.substring(RelationalPlanner.MAT_PREFIX.length());
+ Object viewId = this.metadata.getGroupID(viewName);
+ group.setMetadataID(getGlobalTempTableMetadataId(viewId));
+ } else {
+ String viewName = stateId.substring(TempTableDataManager.CODE_PREFIX.length());
+ int index = viewName.lastIndexOf('.');
+ String returnElementName = viewName.substring(index + 1);
+ viewName = viewName.substring(0, index);
+ index = viewName.lastIndexOf('.');
+ String keyElementName = viewName.substring(index + 1);
+ viewName = viewName.substring(0, index);
+ group.setMetadataID(getCodeTableMetadataId(viewName, returnElementName, keyElementName, stateId));
+ }
+ TempTable tempTable = this.createMatTable(stateId, group);
+ tempTable.readFrom(ois);
+ MatTableInfo info = this.getMatTableInfo(stateId);
+ synchronized (info) {
+ swapTempTable(stateId, tempTable);
+ info.setState(state, true);
+ info.updateTime = updateTime;
+ info.loadingAddress = loadingAddress;
+ }
+ }
+
+ @Override
+ public void droppedMembers(Collection<Serializable> addresses) {
+ for (MatTableInfo info : this.matTables.values()) {
+ synchronized (info) {
+ if (info.getState() == MatState.LOADING
+ && addresses.contains(info.loadingAddress)) {
+ info.setState(MatState.FAILED_LOAD, null);
+ }
+ }
+ }
+ }
+
+}
Modified: branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,6 +22,9 @@
package org.teiid.query.tempdata;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -48,6 +51,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -72,16 +76,16 @@
* TODO: in this implementation blocked exceptions will not happen
* allowing for subquery evaluation though would cause pauses
*/
-class TempTable {
+public class TempTable implements Cloneable {
private final class InsertUpdateProcessor extends UpdateProcessor {
private boolean addRowId;
private int[] indexes;
- private InsertUpdateProcessor(TupleSource ts, boolean addRowId, int[] indexes)
+ private InsertUpdateProcessor(TupleSource ts, boolean addRowId, int[] indexes, boolean canUndo)
throws TeiidComponentException {
- super(null, ts);
+ super(null, ts, canUndo);
this.addRowId = addRowId;
this.indexes = indexes;
}
@@ -114,14 +118,14 @@
currentTuple = tuple;
for (int i : notNull) {
if (tuple.get(i) == null) {
- throw new TeiidProcessingException(QueryPlugin.Util.getString("TempTable.not_null", columns.get(i)));
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("TempTable.not_null", columns.get(i))); //$NON-NLS-1$
}
}
insertTuple(tuple, addRowId);
}
@Override
- protected void undo(List tuple) throws TeiidComponentException,
+ protected void undo(List<?> tuple) throws TeiidComponentException,
TeiidProcessingException {
deleteTuple(tuple);
}
@@ -194,18 +198,20 @@
private abstract class UpdateProcessor {
private TupleSource ts;
- protected final Evaluator eval;
- private final Criteria crit;
+ protected Evaluator eval;
+ private Criteria crit;
protected int updateCount = 0;
protected List currentTuple;
protected TupleBuffer undoLog;
- UpdateProcessor(Criteria crit, TupleSource ts) throws TeiidComponentException {
+ UpdateProcessor(Criteria crit, TupleSource ts, boolean canUndo) throws TeiidComponentException {
this.ts = ts;
this.eval = new Evaluator(columnMap, null, null);
this.crit = crit;
- this.undoLog = bm.createTupleBuffer(columns, sessionID, TupleSourceType.PROCESSOR);
+ if (canUndo) {
+ this.undoLog = bm.createTupleBuffer(columns, sessionID, TupleSourceType.PROCESSOR);
+ }
}
int process() throws ExpressionEvaluationException, TeiidComponentException, TeiidProcessingException {
@@ -218,7 +224,9 @@
if (crit == null || eval.evaluate(crit, currentTuple)) {
tuplePassed(currentTuple);
updateCount++;
- undoLog.addTuple(currentTuple);
+ if (undoLog != null) {
+ undoLog.addTuple(currentTuple);
+ }
}
currentTuple = null;
}
@@ -227,19 +235,21 @@
success();
success = true;
} finally {
- bm.releaseBuffers(reserved);
try {
- if (!success) {
+ if (!success && undoLog != null) {
undoLog.setFinal(true);
TupleSource undoTs = undoLog.createIndexedTupleSource();
List<?> tuple = null;
while ((tuple = undoTs.nextTuple()) != null) {
- undo(tuple);
+ try {
+ undo(tuple);
+ } catch (TeiidException e) {
+ LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage());
+ }
}
}
- } catch (TeiidException e) {
- LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage());
} finally {
+ bm.releaseBuffers(reserved);
if (!held) {
lock.writeLock().unlock();
}
@@ -254,15 +264,20 @@
protected abstract void tuplePassed(List tuple) throws BlockedException, TeiidComponentException, TeiidProcessingException;
- protected abstract void undo(List tuple) throws TeiidComponentException, TeiidProcessingException;
+ protected abstract void undo(List<?> tuple) throws TeiidComponentException, TeiidProcessingException;
public void close() {
ts.closeSource();
- undoLog.remove();
+ ts = null;
+ if (undoLog != null) {
+ undoLog.remove();
+ }
}
}
+ private static AtomicInteger ID_GENERATOR = new AtomicInteger();
+ private int id = ID_GENERATOR.getAndIncrement();
private STree tree;
private AtomicInteger rowId;
private List<ElementSymbol> columns;
@@ -275,11 +290,13 @@
private int keyBatchSize;
private int leafBatchSize;
- private Map columnMap;
+ private Map<ElementSymbol, Integer> columnMap;
private List<Integer> notNull = new LinkedList<Integer>();
private Map<Integer, AtomicInteger> sequences;
private int uniqueColIndex;
+
+ private AtomicInteger activeReaders = new AtomicInteger();
TempTable(TempMetadataID tid, BufferManager bm, List<ElementSymbol> columns, int primaryKeyLength, String sessionID) {
this.tid = tid;
@@ -321,13 +338,49 @@
this.leafBatchSize = bm.getSchemaSize(columns.subList(0, primaryKeyLength));
}
+ public TempTable clone() {
+ lock.readLock().lock();
+ try {
+ TempTable clone = (TempTable) super.clone();
+ clone.lock = new ReentrantReadWriteLock();
+ if (clone.indexTables != null) {
+ clone.indexTables = new LinkedHashMap<List<ElementSymbol>, TempTable>(clone.indexTables);
+ for (Map.Entry<List<ElementSymbol>, TempTable> entry : clone.indexTables.entrySet()) {
+ TempTable indexClone = entry.getValue().clone();
+ indexClone.lock = clone.lock;
+ entry.setValue(indexClone);
+ }
+ }
+ clone.tree = tree.clone();
+ clone.activeReaders = new AtomicInteger();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException();
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ public AtomicInteger getActiveReaders() {
+ return activeReaders;
+ }
+
void addIndex(List<ElementSymbol> indexColumns, boolean unique) throws TeiidComponentException, TeiidProcessingException {
List<ElementSymbol> keyColumns = columns.subList(0, tree.getKeyLength());
if (keyColumns.equals(indexColumns) || (indexTables != null && indexTables.containsKey(indexColumns))) {
return;
}
+ TempTable indexTable = createIndexTable(indexColumns, unique);
+ //TODO: ordered insert optimization
+ TupleSource ts = createTupleSource(indexTable.getColumns(), null, null);
+ indexTable.insert(ts, indexTable.getColumns(), false);
+ indexTable.getTree().compact();
+ }
+
+ private TempTable createIndexTable(List<ElementSymbol> indexColumns,
+ boolean unique) {
List<ElementSymbol> allColumns = new ArrayList<ElementSymbol>(indexColumns);
- for (ElementSymbol elementSymbol : keyColumns) {
+ for (ElementSymbol elementSymbol : columns.subList(0, tree.getKeyLength())) {
if (allColumns.indexOf(elementSymbol) < 0) {
allColumns.add(elementSymbol);
}
@@ -342,10 +395,8 @@
indexTables = new LinkedHashMap<List<ElementSymbol>, TempTable>();
indexTables.put(indexColumns, indexTable);
}
- //TODO: ordered insert optimization
- TupleSource ts = createTupleSource(allColumns, null, null);
- indexTable.insert(ts, allColumns);
- indexTable.getTree().compact();
+ indexTable.setUpdatable(this.updatable);
+ return indexTable;
}
private int reserveBuffers() {
@@ -481,17 +532,22 @@
return tree.getRowCount();
}
- public int truncate() {
+ public int truncate(boolean force) {
this.tid.getTableData().dataModified(tree.getRowCount());
- return tree.truncate();
+ return tree.truncate(force);
}
public void remove() {
- tree.remove();
- if (this.indexTables != null) {
- for (TempTable indexTable : this.indexTables.values()) {
- indexTable.remove();
+ lock.writeLock().lock();
+ try {
+ tree.remove();
+ if (this.indexTables != null) {
+ for (TempTable indexTable : this.indexTables.values()) {
+ indexTable.remove();
+ }
}
+ } finally {
+ lock.writeLock().unlock();
}
}
@@ -502,7 +558,7 @@
return columns;
}
- public TupleSource insert(TupleSource tuples, final List<ElementSymbol> variables) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
+ public TupleSource insert(TupleSource tuples, final List<ElementSymbol> variables, boolean canUndo) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
List<ElementSymbol> cols = getColumns();
final int[] indexes = new int[cols.size()];
boolean shouldProject = false;
@@ -510,7 +566,7 @@
indexes[i] = variables.indexOf(cols.get(i));
shouldProject |= (indexes[i] != i);
}
- UpdateProcessor up = new InsertUpdateProcessor(tuples, rowId != null, shouldProject?indexes:null);
+ UpdateProcessor up = new InsertUpdateProcessor(tuples, rowId != null, shouldProject?indexes:null, canUndo);
int updateCount = up.process();
tid.setCardinality(tree.getRowCount());
tid.getTableData().dataModified(updateCount);
@@ -520,7 +576,7 @@
public TupleSource update(Criteria crit, final SetClauseList update) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
final boolean primaryKeyChangePossible = canChangePrimaryKey(update);
final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
- UpdateProcessor up = new UpdateProcessor(crit, browser) {
+ UpdateProcessor up = new UpdateProcessor(crit, browser, true) {
protected TupleBuffer changeSet;
protected UpdateProcessor changeSetProcessor;
@@ -531,7 +587,7 @@
BlockedException, TeiidComponentException {
List<Object> newTuple = new ArrayList<Object>(tuple);
for (Map.Entry<ElementSymbol, Expression> entry : update.getClauseMap().entrySet()) {
- newTuple.set((Integer)columnMap.get(entry.getKey()), eval.evaluate(entry.getValue(), tuple));
+ newTuple.set(columnMap.get(entry.getKey()), eval.evaluate(entry.getValue(), tuple));
}
if (primaryKeyChangePossible) {
browser.removed();
@@ -546,7 +602,7 @@
}
@Override
- protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
+ protected void undo(List<?> tuple) throws TeiidComponentException, TeiidProcessingException {
if (primaryKeyChangePossible) {
insertTuple(tuple, false);
} else {
@@ -560,7 +616,7 @@
//changeSet contains possible updates
if (primaryKeyChangePossible) {
if (changeSetProcessor == null) {
- changeSetProcessor = new InsertUpdateProcessor(changeSet.createIndexedTupleSource(true), false, null);
+ changeSetProcessor = new InsertUpdateProcessor(changeSet.createIndexedTupleSource(true), false, null, true);
}
changeSetProcessor.process(); //when this returns, we're up to date
}
@@ -569,11 +625,10 @@
@Override
public void close() {
super.close();
- if (changeSetProcessor != null) {
- changeSetProcessor.close(); // causes a revert of the change set
- }
+ changeSetProcessor = null;
if (changeSet != null) {
changeSet.remove();
+ changeSet = null;
}
}
@@ -596,7 +651,7 @@
public TupleSource delete(Criteria crit) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
- UpdateProcessor up = new UpdateProcessor(crit, browser) {
+ UpdateProcessor up = new UpdateProcessor(crit, browser, true) {
@Override
protected void tuplePassed(List tuple)
throws ExpressionEvaluationException,
@@ -606,7 +661,7 @@
}
@Override
- protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
+ protected void undo(List<?> tuple) throws TeiidComponentException, TeiidProcessingException {
insertTuple(tuple, false);
}
};
@@ -628,6 +683,44 @@
}
}
+ void writeTo(ObjectOutputStream oos) throws TeiidComponentException, IOException {
+ this.lock.readLock().lock();
+ try {
+ this.tree.writeValuesTo(oos);
+ if (this.indexTables == null) {
+ oos.writeInt(0);
+ } else {
+ oos.writeInt(this.indexTables.size());
+ for (Map.Entry<List<ElementSymbol>, TempTable> entry : this.indexTables.entrySet()) {
+ oos.writeBoolean(entry.getValue().uniqueColIndex > 0);
+ oos.writeInt(entry.getKey().size());
+ for (ElementSymbol es : entry.getKey()) {
+ oos.writeInt(this.columnMap.get(es));
+ }
+ entry.getValue().writeTo(oos);
+ }
+ }
+ } finally {
+ this.lock.readLock().unlock();
+ }
+ }
+
+ void readFrom(ObjectInputStream ois) throws TeiidComponentException, IOException, ClassNotFoundException {
+ this.tree.readValuesFrom(ois);
+ int numIdx = ois.readInt();
+ for (int i = 0; i < numIdx; i++) {
+ boolean unique = ois.readBoolean();
+ int numCols = ois.readInt();
+ ArrayList<ElementSymbol> indexColumns = new ArrayList<ElementSymbol>(numCols);
+ for (int j = 0; j < numCols; j++) {
+ int colIndex = ois.readInt();
+ indexColumns.add(this.columns.get(colIndex));
+ }
+ TempTable tt = this.createIndexTable(indexColumns, unique);
+ tt.readFrom(ois);
+ }
+ }
+
List<?> updateTuple(List<?> tuple, boolean remove) throws TeiidComponentException {
try {
lock.writeLock().lock();
@@ -698,7 +791,7 @@
return tid.getID() + " (" + columns + ")\n"; //$NON-NLS-1$ //$NON-NLS-2$
}
- Map getColumnMap() {
+ Map<ElementSymbol, Integer> getColumnMap() {
return this.columnMap;
}
@@ -709,5 +802,26 @@
public TempMetadataID getMetadataId() {
return tid;
}
+
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TempTable)) {
+ return false;
+ }
+ TempTable other = (TempTable)obj;
+ return id == other.id;
+ }
}
\ No newline at end of file
Modified: branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,10 +22,8 @@
package org.teiid.query.tempdata;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -37,10 +35,6 @@
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.QueryValidatorException;
-import org.teiid.cache.Cache;
-import org.teiid.cache.CacheConfiguration;
-import org.teiid.cache.CacheFactory;
-import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBuffer;
@@ -49,7 +43,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.util.HashCodeUtil;
+import org.teiid.core.util.Assertion;
import org.teiid.core.util.StringUtil;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
@@ -62,8 +56,8 @@
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.Evaluator;
-import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.parser.ParseInfo;
@@ -92,10 +86,8 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
-import org.teiid.query.tempdata.TempTableStore.MatState;
-import org.teiid.query.tempdata.TempTableStore.MatTableInfo;
+import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
import org.teiid.query.util.CommandContext;
-import org.teiid.vdb.runtime.VDBKey;
/**
* This proxy ProcessorDataManager is used to handle temporary tables.
@@ -107,57 +99,21 @@
private static final String REFRESHMATVIEWROW = ".refreshmatviewrow"; //$NON-NLS-1$
private static final String REFRESHMATVIEW = ".refreshmatview"; //$NON-NLS-1$
- private static final String CODE_PREFIX = "#CODE_"; //$NON-NLS-1$
+ public static final String CODE_PREFIX = "#CODE_"; //$NON-NLS-1$
private ProcessorDataManager processorDataManager;
private BufferManager bufferManager;
private SessionAwareCache<CachedResults> cache;
private Executor executor;
- private static class MatTableKey implements Serializable {
- private static final long serialVersionUID = 5481692896572663992L;
- String name;
- VDBKey vdb;
-
- @Override
- public int hashCode() {
- return HashCodeUtil.hashCode(name.hashCode(), vdb);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof MatTableKey)) {
- return false;
- }
- MatTableKey other = (MatTableKey)obj;
- return this.name.equals(other.name) && this.vdb.equals(other.vdb);
- }
- }
-
- private static class MatTableEntry implements Serializable {
- private static final long serialVersionUID = 8559613701442751579L;
- long lastUpdate = System.currentTimeMillis();
- boolean valid;
- }
-
- private Cache<MatTableKey, MatTableEntry> tables;
- private SessionAwareCache<CachedResults> distributedCache;
private EventDistributor eventDistributor;
public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager,
- Executor executor, SessionAwareCache<CachedResults> cache, SessionAwareCache<CachedResults> distibutedCache, CacheFactory cacheFactory){
+ Executor executor, SessionAwareCache<CachedResults> cache){
this.processorDataManager = processorDataManager;
this.bufferManager = bufferManager;
this.executor = executor;
this.cache = cache;
- this.distributedCache = distibutedCache;
- if (distibutedCache != null) {
- CacheConfiguration cc = new CacheConfiguration(Policy.LRU, -1, -1, "MaterializationUpdates"); //$NON-NLS-1$
- tables = cacheFactory.get(cc.getLocation(), cc);
- }
}
public void setEventDistributor(EventDistributor eventDistributor) {
@@ -185,6 +141,9 @@
TempTableStore contextStore = context.getTempTableStore();
if (command instanceof Query) {
Query query = (Query)command;
+ if (modelName != null && !modelName.equals(TempMetadataAdapter.TEMP_MODEL.getID())) {
+ return null;
+ }
return registerQuery(context, contextStore, query);
}
if (command instanceof ProcedureContainer) {
@@ -206,7 +165,7 @@
return null;
}
final String groupKey = group.getNonCorrelationName().toUpperCase();
- final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true);
+ final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true, true, context);
if (command instanceof Insert) {
Insert insert = (Insert)command;
TupleSource ts = insert.getTupleSource();
@@ -217,7 +176,7 @@
}
ts = new CollectionTupleSource(Arrays.asList(values).iterator());
}
- return table.insert(ts, insert.getVariables());
+ return table.insert(ts, insert.getVariables(), true);
}
if (command instanceof Update) {
final Update update = (Update)command;
@@ -228,8 +187,8 @@
final Delete delete = (Delete)command;
final Criteria crit = delete.getCriteria();
if (crit == null) {
- //because we are non-transactional, just use a truncate
- int rows = table.truncate();
+ //TODO: we'll add a real truncate later
+ int rows = table.truncate(false);
return CollectionTupleSource.createUpdateCountTupleSource(rows);
}
return table.delete(crit);
@@ -241,17 +200,18 @@
if (contextStore.hasTempTable(tempTableName)) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
}
- contextStore.addTempTable(tempTableName, create, bufferManager, true);
+ contextStore.addTempTable(tempTableName, create, bufferManager, true, context);
return CollectionTupleSource.createUpdateCountTupleSource(0);
}
if (command instanceof Drop) {
String tempTableName = ((Drop)command).getTable().getCanonicalName();
- contextStore.removeTempTableByName(tempTableName);
+ contextStore.removeTempTableByName(tempTableName, context);
return CollectionTupleSource.createUpdateCountTupleSource(0);
}
if (command instanceof AlterTempTable) {
AlterTempTable att = (AlterTempTable)command;
- TempTable tt = contextStore.getOrCreateTempTable(att.getTempTable().toUpperCase(), command, bufferManager, true);
+ TempTable tt = contextStore.getTempTable(att.getTempTable().toUpperCase());
+ Assertion.isNotNull(tt, "Table doesn't exist"); //$NON-NLS-1$
tt.setUpdatable(false);
if (att.getIndexColumns() != null) {
tt.addIndex(att.getIndexColumns(), false);
@@ -316,37 +276,21 @@
QueryValidatorException, TeiidProcessingException,
ExpressionEvaluationException {
QueryMetadataInterface metadata = context.getMetadata();
- TempTableStore globalStore = context.getGlobalTableStore();
+ GlobalTableStore globalStore = context.getGlobalTableStore();
if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEW)) {
Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(1).getExpression()).getValue());
- Object matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID, metadata);
+ Object matTableId = globalStore.getGlobalTempTableMetadataId(groupID);
String matViewName = metadata.getFullName(groupID);
String matTableName = metadata.getFullName(matTableId);
LogManager.logDetail(LogConstants.CTX_MATVIEWS, "processing refreshmatview for", matViewName); //$NON-NLS-1$
- MatTableInfo info = globalStore.getMatTableInfo(matTableName);
- Long loadTime = null;
- boolean useCache = false;
- if (this.distributedCache != null) {
- MatTableKey key = new MatTableKey();
- key.name = matTableName;
- key.vdb = new VDBKey(context.getVdbName(),context.getVdbVersion());
- MatTableEntry entry = this.tables.get(key);
- useCache = (entry != null && entry.valid && entry.lastUpdate > info.getUpdateTime());
- if (useCache) {
- loadTime = entry.lastUpdate;
- }
- }
boolean invalidate = Boolean.TRUE.equals(((Constant)proc.getParameter(2).getExpression()).getValue());
- if (invalidate) {
- touchTable(context, matTableName, false, System.currentTimeMillis());
- }
- MatState oldState = info.setState(MatState.NEEDS_LOADING, invalidate?Boolean.FALSE:null, null);
- if (oldState == MatState.LOADING) {
+ boolean needsLoading = globalStore.needsLoading(matTableName, globalStore.getLocalAddress(), true, true, invalidate);
+ if (!needsLoading) {
return CollectionTupleSource.createUpdateCountTupleSource(-1);
}
GroupSymbol matTable = new GroupSymbol(matTableName);
matTable.setMetadataID(matTableId);
- int rowCount = loadGlobalTable(context, matTable, matTableName, matViewName, globalStore, info, invalidate?null:loadTime, !invalidate && useCache);
+ int rowCount = loadGlobalTable(context, matTable, matTableName, globalStore);
return CollectionTupleSource.createUpdateCountTupleSource(rowCount);
} else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROW)) {
Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(1).getExpression()).getValue());
@@ -364,7 +308,7 @@
if (!info.isValid()) {
return CollectionTupleSource.createUpdateCountTupleSource(-1);
}
- TempTable tempTable = globalStore.getOrCreateTempTable(matTableName, new Query(), bufferManager, false);
+ TempTable tempTable = globalStore.getTempTableStore().getTempTable(matTableName);
if (!tempTable.isUpdatable()) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_updatable", matViewName)); //$NON-NLS-1$
}
@@ -381,10 +325,11 @@
if (tuple == null) {
delete = true;
tuple = Arrays.asList(key.getValue());
+ } else {
+ tuple = new ArrayList<Object>(tuple); //ensure the list is serializable
}
- List<?> result = updateMatViewRow(globalStore, matTableName, tuple, delete);
- if (result != null && eventDistributor != null) {
- result = new ArrayList<Object>(result); //ensure the list is serializable
+ List<?> result = globalStore.updateMatViewRow(matTableName, tuple, delete);
+ if (eventDistributor != null) {
this.eventDistributor.updateMatViewRow(context.getVdbName(), context.getVdbVersion(), metadata.getName(metadata.getModelID(groupID)), metadata.getName(groupID), tuple, delete);
}
return CollectionTupleSource.createUpdateCountTupleSource(result != null ? 1 : 0);
@@ -392,36 +337,6 @@
return null;
}
- public List<?> updateMatViewRow(TempTableStore globalStore,
- String matTableName, List<?> tuple, boolean delete)
- throws QueryProcessingException, TeiidComponentException {
- TempTable tempTable = globalStore.getOrCreateTempTable(matTableName, new Query(), bufferManager, false);
- return tempTable.updateTuple(tuple, delete);
- }
-
- public void refreshMatView(String vdbName, int vdbVersion, String viewName,
- QueryMetadataInterface metadata, TempTableStore globalStore)
- throws QueryProcessingException, TeiidComponentException, TeiidProcessingException {
-
- Object groupID = validateMatView(metadata, viewName);
- Object matTableId = globalStore.getGlobalTempTableMetadataId(groupID, metadata);
- String matViewName = metadata.getFullName(groupID);
- String matTableName = metadata.getFullName(matTableId);
- LogManager.logDetail(LogConstants.CTX_MATVIEWS, "processing refreshmatview for", matViewName); //$NON-NLS-1$
- MatTableInfo info = globalStore.getMatTableInfo(matTableName);
-
- MatState oldState = info.setState(MatState.NEEDS_LOADING, Boolean.FALSE, null);
- if (oldState == MatState.LOADING) {
- return;
- }
- GroupSymbol matTable = new GroupSymbol(matTableName);
- matTable.setMetadataID(matTableId);
- CommandContext context = new CommandContext(new Object(), "internal", "internal", vdbName, vdbVersion); //$NON-NLS-1$ //$NON-NLS-2$
- context.setMetadata(metadata);
- context.setGlobalTableStore(globalStore);
- loadGlobalTable(context, matTable, matTableName, matViewName, globalStore, info, null, true);
- }
-
private Object validateMatView(QueryMetadataInterface metadata, String viewName) throws TeiidComponentException,
TeiidProcessingException {
try {
@@ -444,47 +359,41 @@
if (!group.isTempGroupSymbol()) {
return null;
}
- String viewName = null;
final String tableName = group.getNonCorrelationName().toUpperCase();
boolean remapColumns = !tableName.equalsIgnoreCase(group.getName());
- TempMetadataID groupID = (TempMetadataID)group.getMetadataID();
- if (groupID.getOriginalMetadataID() != null) {
- viewName = context.getMetadata().getFullName(groupID.getOriginalMetadataID());
- }
TempTable table = null;
if (group.isGlobalTable()) {
- final TempTableStore globalStore = context.getGlobalTableStore();
+ final GlobalTableStore globalStore = context.getGlobalTableStore();
final MatTableInfo info = globalStore.getMatTableInfo(tableName);
- Long loadTime = null;
- if (this.distributedCache != null) {
- MatTableKey key = new MatTableKey();
- key.name = tableName;
- key.vdb = new VDBKey(context.getVdbName(), context.getVdbVersion());
-
- MatTableEntry entry = this.tables.get(key);
- boolean notValid = !info.isValid();
- if (entry != null && entry.lastUpdate > info.getUpdateTime()
- && info.getState() != MatState.LOADING
- //TODO: use extension metadata or a config parameter to make this skew configurable
- && !(!notValid && entry.valid && info.getState() == MatState.LOADED && entry.lastUpdate < info.getUpdateTime() + 30000)) {
- //trigger a remote load due to the cache being more up to date than the local copy
- info.setState(MatState.NEEDS_LOADING, notValid?false:entry.valid, null);
- loadTime = entry.lastUpdate;
+ boolean load = false;
+ while (!info.isUpToDate()) {
+ load = globalStore.needsLoading(tableName, globalStore.getLocalAddress(), true, false, false);
+ if (load) {
+ load = globalStore.needsLoading(tableName, globalStore.getLocalAddress(), false, false, false);
+ if (load) {
+ break;
+ }
}
+ synchronized (info) {
+ try {
+ info.wait(30000);
+ } catch (InterruptedException e) {
+ throw new TeiidComponentException(e);
+ }
+ }
}
- boolean load = info.shouldLoad();
if (load) {
if (!info.isValid()) {
//blocking load
- loadGlobalTable(context, group, tableName, viewName, globalStore, info, loadTime, true);
+ loadGlobalTable(context, group, tableName, globalStore);
} else {
- loadAsynch(context, group, tableName, viewName, globalStore, info, loadTime);
+ loadAsynch(context, group, tableName, globalStore);
}
}
- table = globalStore.getOrCreateTempTable(tableName, query, bufferManager, false);
+ table = globalStore.getTempTableStore().getOrCreateTempTable(tableName, query, bufferManager, false, false, context);
context.accessedDataObject(group.getMetadataID());
} else {
- table = contextStore.getOrCreateTempTable(tableName, query, bufferManager, true);
+ table = contextStore.getOrCreateTempTable(tableName, query, bufferManager, true, false, context);
if (context.getDataObjects() != null) {
Object id = RelationalPlanner.getTrackableGroup(group, context.getMetadata());
if (id != null) {
@@ -511,13 +420,11 @@
}
private void loadAsynch(final CommandContext context,
- final GroupSymbol group, final String tableName, final String viewName,
- final TempTableStore globalStore, final MatTableInfo info,
- final Long loadTime) {
+ final GroupSymbol group, final String tableName, final GlobalTableStore globalStore) {
Callable<Integer> toCall = new Callable<Integer>() {
@Override
public Integer call() throws Exception {
- return loadGlobalTable(context, group, tableName, viewName, globalStore, info, loadTime, true);
+ return loadGlobalTable(context, group, tableName, globalStore);
}
};
FutureTask<Integer> task = new FutureTask<Integer>(toCall);
@@ -525,89 +432,38 @@
}
private int loadGlobalTable(CommandContext context,
- GroupSymbol group, final String tableName, final String viewName,
- TempTableStore globalStore, MatTableInfo info, Long loadTime, boolean useCache)
+ GroupSymbol group, final String tableName, GlobalTableStore globalStore)
throws TeiidComponentException, TeiidProcessingException {
LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryPlugin.Util.getString("TempTableDataManager.loading", tableName)); //$NON-NLS-1$
QueryMetadataInterface metadata = context.getMetadata();
- Create create = new Create();
- create.setTable(group);
List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
- create.setElementSymbolsAsColumns(allColumns);
- Object pk = metadata.getPrimaryKey(group.getMetadataID());
- if (pk != null) {
- List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk);
- create.getPrimaryKey().addAll(pkColumns);
- }
- TempTable table = globalStore.addTempTable(tableName, create, bufferManager, false);
+ TempTable table = globalStore.createMatTable(tableName, group);
table.setUpdatable(false);
- CacheHint hint = table.getCacheHint();
- boolean updatable = false;
- if (hint != null) {
- table.setPreferMemory(hint.getPrefersMemory());
- if (hint.getTtl() != null) {
- info.setTtl(hint.getTtl());
- }
- if (pk != null) {
- updatable = hint.isUpdatable();
- }
- }
int rowCount = -1;
- boolean viewFetched = false;
try {
String fullName = metadata.getFullName(group.getMetadataID());
- TupleSource ts = null;
- CacheID cid = null;
- if (distributedCache != null) {
- cid = new CacheID(new ParseInfo(), viewName, context.getVdbName(),
- context.getVdbVersion(), context.getConnectionID(), context.getUserName());
- if (useCache) {
- CachedResults cr = this.distributedCache.get(cid);
- if (cr != null) {
- ts = cr.getResults().createIndexedTupleSource();
- LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryPlugin.Util.getString("TempTableDataManager.cache_load", tableName)); //$NON-NLS-1$
- }
- }
- }
+ String transformation = metadata.getVirtualPlan(group.getMetadataID()).getQuery();
+ QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(transformation, fullName, context);
+ qp.setNonBlocking(true);
+ qp.getContext().setDataObjects(null);
+ TupleSource ts = new BatchCollector.BatchProducerTupleSource(qp);
- List<ElementSymbol> variables = table.getColumns();
-
- if (ts == null) {
- variables = allColumns;
- //TODO: coordinate a distributed load
- //TODO: order by primary key nulls first - then have an insert ordered optimization
- String transformation = metadata.getVirtualPlan(group.getMetadataID()).getQuery();
- QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(transformation, fullName, context);
- qp.setNonBlocking(true);
- qp.getContext().setDataObjects(null);
- if (distributedCache != null) {
- CachedResults cr = new CachedResults();
- BatchCollector bc = qp.createBatchCollector();
- TupleBuffer tb = bc.collectTuples();
- cr.setResults(tb, qp.getProcessorPlan());
- touchTable(context, fullName, true, info.getUpdateTime());
- this.distributedCache.put(cid, Determinism.VDB_DETERMINISTIC, cr, info.getTtl());
- ts = tb.createIndexedTupleSource();
- viewFetched = true;
- } else {
- ts = new BatchCollector.BatchProducerTupleSource(qp);
- }
- }
-
- //TODO: if this insert fails, it's unnecessary to do the undo processing
- table.insert(ts, variables);
+ table.insert(ts, allColumns, false);
table.getTree().compact();
rowCount = table.getRowCount();
//TODO: could pre-process indexes to remove overlap
for (Object index : metadata.getIndexesInGroup(group.getMetadataID())) {
- List<ElementSymbol> columns = resolveIndex(metadata, allColumns, index);
+ List<ElementSymbol> columns = GlobalTableStoreImpl.resolveIndex(metadata, allColumns, index);
table.addIndex(columns, false);
}
for (Object key : metadata.getUniqueKeysInGroup(group.getMetadataID())) {
- List<ElementSymbol> columns = resolveIndex(metadata, allColumns, key);
+ List<ElementSymbol> columns = GlobalTableStoreImpl.resolveIndex(metadata, allColumns, key);
table.addIndex(columns, true);
}
- table.setUpdatable(updatable);
+ CacheHint hint = table.getCacheHint();
+ if (hint != null && table.getPkLength() > 0) {
+ table.setUpdatable(hint.isUpdatable());
+ }
} catch (TeiidComponentException e) {
LogManager.logError(LogConstants.CTX_MATVIEWS, e, QueryPlugin.Util.getString("TempTableDataManager.failed_load", tableName)); //$NON-NLS-1$
throw e;
@@ -616,66 +472,30 @@
throw e;
} finally {
if (rowCount == -1) {
- info.setState(MatState.FAILED_LOAD, null, null);
+ globalStore.failedLoad(tableName);
} else {
- globalStore.swapTempTable(tableName, table);
- info.setState(MatState.LOADED, true, loadTime);
- if (viewFetched & viewName != null && this.eventDistributor != null) {
- this.eventDistributor.refreshMatView(context.getVdbName(), context.getVdbVersion(), viewName);
- }
+ globalStore.loaded(tableName, table);
LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryPlugin.Util.getString("TempTableDataManager.loaded", tableName, rowCount)); //$NON-NLS-1$
}
}
return rowCount;
}
- private void touchTable(CommandContext context, String fullName, boolean valid, long loadtime) {
- MatTableKey key = new MatTableKey();
- key.name = fullName;
- key.vdb = new VDBKey(context.getVdbName(), context.getVdbVersion());
- MatTableEntry matTableEntry = new MatTableEntry();
- matTableEntry.valid = valid;
- matTableEntry.lastUpdate = loadtime;
- tables.put(key, matTableEntry, null);
- }
-
- /**
- * Return a list of ElementSymbols for the given index/key object
- */
- private List<ElementSymbol> resolveIndex(QueryMetadataInterface metadata,
- List<ElementSymbol> allColumns, Object pk)
- throws TeiidComponentException, QueryMetadataException {
- Collection<?> pkIds = metadata.getElementIDsInKey(pk);
- List<ElementSymbol> pkColumns = new ArrayList<ElementSymbol>(pkIds.size());
- for (Object col : pkIds) {
- pkColumns.add(allColumns.get(metadata.getPosition(col)-1));
- }
- return pkColumns;
- }
-
public Object lookupCodeValue(CommandContext context, String codeTableName,
String returnElementName, String keyElementName, Object keyValue)
throws BlockedException, TeiidComponentException,
TeiidProcessingException {
String matTableName = CODE_PREFIX + (codeTableName + ElementSymbol.SEPARATOR + keyElementName + ElementSymbol.SEPARATOR + returnElementName).toUpperCase();
+ QueryMetadataInterface metadata = context.getMetadata();
+ TempMetadataID id = context.getGlobalTableStore().getCodeTableMetadataId(codeTableName,
+ returnElementName, keyElementName, matTableName);
+
ElementSymbol keyElement = new ElementSymbol(matTableName + ElementSymbol.SEPARATOR + keyElementName);
ElementSymbol returnElement = new ElementSymbol(matTableName + ElementSymbol.SEPARATOR + returnElementName);
-
- QueryMetadataInterface metadata = context.getMetadata();
-
keyElement.setType(DataTypeManager.getDataTypeClass(metadata.getElementType(metadata.getElementID(codeTableName + ElementSymbol.SEPARATOR + keyElementName))));
returnElement.setType(DataTypeManager.getDataTypeClass(metadata.getElementType(metadata.getElementID(codeTableName + ElementSymbol.SEPARATOR + returnElementName))));
- TempMetadataID id = context.getGlobalTableStore().getMetadataStore().getTempGroupID(matTableName);
- if (id == null) {
- id = context.getGlobalTableStore().getMetadataStore().addTempGroup(matTableName, Arrays.asList(keyElement, returnElement), false, true);
- String queryString = Reserved.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + Reserved.FROM + ' ' + codeTableName; //$NON-NLS-1$
- id.setQueryNode(new QueryNode(queryString));
- id.setPrimaryKey(id.getElements().subList(0, 1));
- CacheHint hint = new CacheHint(true, null);
- id.setCacheHint(hint);
- }
Query query = RelationalPlanner.createMatViewQuery(id, matTableName, Arrays.asList(returnElement), true);
query.setCriteria(new CompareCriteria(keyElement, CompareCriteria.EQ, new Constant(keyValue)));
Modified: branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,152 +22,166 @@
package org.teiid.query.tempdata;
+import java.sql.Connection;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.teiid.api.exception.query.QueryMetadataException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+
import org.teiid.api.exception.query.QueryProcessingException;
-import org.teiid.api.exception.query.QueryResolverException;
-import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
-import org.teiid.language.SQLConstants;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.QueryPlugin;
-import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
-import org.teiid.query.optimizer.relational.RelationalPlanner;
-import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.resolver.command.TempTableResolver;
-import org.teiid.query.resolver.util.ResolverUtil;
-import org.teiid.query.sql.lang.CacheHint;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
+/**
+ * TempTableStores are transactional, but do not act as full resource manager.
+ * This means we are effectively 1PC and don't allow any heuristic exceptions
+ * on commit.
+ *
+ * Table state snapshoting and a {@link Synchronization} are used to
+ * perform the appropriate commit/rollback actions.
+ *
+ * Full row level MVCC would be a good next step as it would remove the
+ * cost of state cloning and would allow for concurrent read/write transactions.
+ */
public class TempTableStore {
- public enum MatState {
- NEEDS_LOADING,
- LOADING,
- FAILED_LOAD,
- LOADED
- }
-
- public static class MatTableInfo {
- private long updateTime = -1;
- private MatState state = MatState.NEEDS_LOADING;
- private long ttl = -1;
- private boolean valid;
-
- synchronized boolean shouldLoad() throws TeiidComponentException {
- for (;;) {
- switch (state) {
- case NEEDS_LOADING:
- case FAILED_LOAD:
- setState(MatState.LOADING);
- return true;
- case LOADING:
- if (valid) {
- return false;
- }
- try {
- wait();
- } catch (InterruptedException e) {
- throw new TeiidComponentException(e);
- }
- continue;
- case LOADED:
- if (ttl >= 0 && System.currentTimeMillis() - updateTime - ttl > 0) {
- setState(MatState.LOADING);
- return true;
- }
- return false;
+ public interface TransactionCallback {
+ void commit();
+ void rollback();
+ }
+
+ public enum TransactionMode {
+ ISOLATE_READS, //for matviews that have atomic updates
+ ISOLATE_WRITES, //for session/procedure stores that need rollback support - this is effectively READ_UNCOMMITTED
+ NONE
+ }
+
+ public class TempTableSynchronization implements Synchronization {
+
+ private String id;
+ Set<Integer> existingTables = new HashSet<Integer>();
+ ConcurrentHashMap<String, TempTable> tables = new ConcurrentHashMap<String, TempTable>();
+ private List<TransactionCallback> callbacks = new LinkedList<TransactionCallback>();
+
+ private boolean completed;
+
+ public TempTableSynchronization(final String id) {
+ this.id = id;
+ for (TempTable tempTable : tempTables.values()) {
+ existingTables.add(tempTable.getId());
+ }
+ if (transactionMode == TransactionMode.ISOLATE_WRITES) {
+ addCallback(new TransactionCallback() {
+ private Map<String, TempMetadataID> clonedMetadata = new ConcurrentHashMap<String, TempMetadataID>(tempMetadataStore.getData());
+ private Map<String, TempTable> clonedTables = new ConcurrentHashMap<String, TempTable>(tempTables);
+
+ @Override
+ public void rollback() {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Rolling back txn", id, "restoring", clonedTables.keySet(), "using rollback tables", tables); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ //remove any tables created in the scope of this txn
+ tempTables.values().removeAll(clonedTables.values());
+ for (TempTable table : tempTables.values()) {
+ table.remove();
+ }
+
+ //restore the state
+ tempMetadataStore.getData().clear();
+ tempMetadataStore.getData().putAll(clonedMetadata);
+ tempTables.clear();
+ tempTables.putAll(clonedTables);
+
+ //overlay the rollback tables
+ tempTables.putAll(tables);
+ }
+
+ @Override
+ public void commit() {
+ //remove any original tables that were removed in this txn
+ clonedTables.values().removeAll(tempTables.values());
+ for (TempTable table : clonedTables.values()) {
+ table.remove();
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public synchronized void afterCompletion(int status) {
+ //TODO: cleanup tables
+ completed = true;
+ synchronizations.remove(id);
+ for (TransactionCallback callback : callbacks) {
+ if (status == Status.STATUS_COMMITTED) {
+ callback.commit();
+ } else {
+ callback.rollback();
+ }
}
+ callbacks.clear();
+ }
+
+ @Override
+ public void beforeCompletion() {
+
+ }
+
+ public synchronized boolean addCallback(TransactionCallback callback) {
+ if (!completed) {
+ callbacks.add(0, callback);
}
- }
-
- public synchronized MatState setState(MatState state, Boolean valid, Long timestamp) {
- MatState oldState = this.state;
- LogManager.logDetail(LogConstants.CTX_MATVIEWS, this, "setting matState to", state, valid, timestamp, "old values", oldState, this.valid); //$NON-NLS-1$ //$NON-NLS-2$
- if (valid != null) {
- this.valid = valid;
- }
- setState(state);
- if (timestamp != null) {
- this.updateTime = timestamp;
- }
- notifyAll();
- return oldState;
- }
-
- private void setState(MatState state) {
- this.state = state;
- this.updateTime = System.currentTimeMillis();
- }
-
- public synchronized void setTtl(long ttl) {
- this.ttl = ttl;
- }
-
- public synchronized long getUpdateTime() {
- return updateTime;
- }
-
- public synchronized MatState getState() {
- return state;
- }
-
- public synchronized boolean isValid() {
- return valid;
- }
-
- public synchronized long getTtl() {
- return ttl;
- }
-
- }
+ return !completed;
+ }
+ }
+
+ private Map<String, TempTableSynchronization> synchronizations = new ConcurrentHashMap<String, TempTableSynchronization>();
+ private TransactionMode transactionMode = TransactionMode.NONE;
- private ConcurrentHashMap<String, MatTableInfo> matTables = new ConcurrentHashMap<String, MatTableInfo>();
-
private TempMetadataStore tempMetadataStore = new TempMetadataStore(new ConcurrentHashMap<String, TempMetadataID>());
- private Map<String, TempTable> groupToTupleSourceID = new ConcurrentHashMap<String, TempTable>();
+ private Map<String, TempTable> tempTables = new ConcurrentHashMap<String, TempTable>();
private String sessionID;
private TempTableStore parentTempTableStore;
- public TempTableStore(String sessionID) {
+ public TempTableStore(String sessionID, TransactionMode transactionMode) {
this.sessionID = sessionID;
+ this.transactionMode = transactionMode;
}
- public MatTableInfo getMatTableInfo(final String tableName) {
- MatTableInfo newInfo = new MatTableInfo();
- MatTableInfo info = matTables.putIfAbsent(tableName, newInfo);
- if (info == null) {
- info = newInfo;
- }
- return info;
- }
-
public void setParentTempTableStore(TempTableStore parentTempTableStore) {
this.parentTempTableStore = parentTempTableStore;
}
public boolean hasTempTable(String tempTableName) {
- return groupToTupleSourceID.containsKey(tempTableName);
+ return tempTables.containsKey(tempTableName);
}
- TempTable addTempTable(String tempTableName, Create create, BufferManager buffer, boolean add) {
+ TempTable addTempTable(final String tempTableName, Create create, BufferManager buffer, boolean add, CommandContext context) throws TeiidProcessingException {
List<ElementSymbol> columns = create.getColumnSymbols();
TempMetadataID id = tempMetadataStore.getTempGroupID(tempTableName);
+ getSynchronization(context);
if (id == null) {
//add metadata
id = tempMetadataStore.addTempGroup(tempTableName, columns, false, true);
@@ -180,44 +194,83 @@
columns.removeAll(primaryKey);
columns.addAll(0, primaryKey);
}
- TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
+ final TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
if (add) {
- groupToTupleSourceID.put(tempTableName, tempTable);
+ tempTables.put(tempTableName, tempTable);
}
return tempTable;
}
- void swapTempTable(String tempTableName, TempTable tempTable) {
- groupToTupleSourceID.put(tempTableName, tempTable);
+ public void removeTempTableByName(final String tempTableName, CommandContext context) throws TeiidProcessingException {
+ TempTableSynchronization synch = getSynchronization(context);
+ tempMetadataStore.removeTempGroup(tempTableName);
+ final TempTable table = this.tempTables.remove(tempTableName);
+ if (table == null) {
+ return;
+ }
+ if (transactionMode != TransactionMode.ISOLATE_WRITES || synch == null || !synch.existingTables.contains(table.getId())) {
+ table.remove();
+ }
}
- public void removeTempTableByName(String tempTableName) {
- tempMetadataStore.removeTempGroup(tempTableName);
- TempTable table = this.groupToTupleSourceID.remove(tempTableName);
- if(table != null) {
- table.remove();
- }
- }
-
+ private TempTableSynchronization getSynchronization(CommandContext context) throws TeiidProcessingException {
+ TempTableSynchronization synch = null;
+ if (context == null || transactionMode == TransactionMode.NONE) {
+ return null;
+ }
+ TransactionContext tc = context.getTransactionContext();
+ if (tc == null || tc.getTransactionType() == Scope.NONE) {
+ return null;
+ }
+ String transactionId = tc.getTransactionId();
+ synch = synchronizations.get(transactionId);
+ if (synch == null) {
+ boolean success = false;
+ try {
+ synch = new TempTableSynchronization(transactionId);
+ synchronizations.put(transactionId, synch);
+ tc.getTransaction().registerSynchronization(synch);
+ success = true;
+ } catch (RollbackException e) {
+ throw new TeiidProcessingException(e);
+ } catch (SystemException e) {
+ throw new TeiidProcessingException(e);
+ } finally {
+ if (!success) {
+ synchronizations.remove(transactionId);
+ }
+ }
+ }
+ return synch;
+ }
+
public TempMetadataStore getMetadataStore() {
return tempMetadataStore;
}
- public void removeTempTables() {
- for (String name : groupToTupleSourceID.keySet()) {
- removeTempTableByName(name);
+ public void removeTempTables() throws TeiidComponentException {
+ for (String name : tempTables.keySet()) {
+ try {
+ removeTempTableByName(name, null);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidComponentException(e);
+ }
}
}
public void setUpdatable(String name, boolean updatable) {
- TempTable table = groupToTupleSourceID.get(name);
+ TempTable table = tempTables.get(name);
if (table != null) {
table.setUpdatable(updatable);
}
}
- TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager buffer, boolean delegate) throws QueryProcessingException{
- TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate);
+ TempTable getTempTable(String tempTableID) {
+ return this.tempTables.get(tempTableID);
+ }
+
+ TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context) throws TeiidProcessingException{
+ TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
if (tempTable != null) {
return tempTable;
}
@@ -237,83 +290,73 @@
Create create = new Create();
create.setTable(new GroupSymbol(tempTableID));
create.setElementSymbolsAsColumns(columns);
- return addTempTable(tempTableID, create, buffer, true);
+ return addTempTable(tempTableID, create, buffer, true, context);
}
private TempTable getTempTable(String tempTableID, Command command,
- BufferManager buffer, boolean delegate)
- throws QueryProcessingException {
- TempTable tsID = groupToTupleSourceID.get(tempTableID);
- if(tsID != null) {
- return tsID;
+ BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context)
+ throws TeiidProcessingException {
+ final TempTable tempTable = tempTables.get(tempTableID);
+ if(tempTable != null) {
+ //isolate if needed
+ if (forUpdate) {
+ if (transactionMode == TransactionMode.ISOLATE_WRITES) {
+ TransactionContext tc = context.getTransactionContext();
+ if (tc != null) {
+ TempTableSynchronization synch = getSynchronization(context);
+ if (synch != null && synch.existingTables.contains(tempTable.getId())) {
+ TempTable result = synch.tables.get(tempTableID);
+ if (result == null) {
+ synch.tables.put(tempTableID, tempTable.clone());
+ }
+ return tempTable;
+ }
+ }
+ }
+ } else if (transactionMode == TransactionMode.ISOLATE_READS) {
+ TransactionContext tc = context.getTransactionContext();
+ if (tc != null && tc.getIsolationLevel() > Connection.TRANSACTION_READ_COMMITTED) {
+ TempTableSynchronization synch = getSynchronization(context);
+ if (synch != null) {
+ TempTable result = synch.tables.get(tempTableID);
+ if (result == null) {
+ synch.tables.put(tempTableID, tempTable);
+ result = tempTable;
+ result.getActiveReaders().getAndIncrement();
+ TransactionCallback callback = new TransactionCallback() {
+
+ @Override
+ public void rollback() {
+ tempTable.getActiveReaders().getAndDecrement();
+ }
+
+ @Override
+ public void commit() {
+ tempTable.getActiveReaders().getAndDecrement();
+ }
+ };
+ if (!synch.addCallback(callback)) {
+ callback.rollback();
+ }
+ }
+ return result;
+ }
+ }
+ }
+ return tempTable;
}
if(delegate && this.parentTempTableStore != null){
- return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate);
+ return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
}
return null;
}
public Set<String> getAllTempTables() {
- return new HashSet<String>(this.groupToTupleSourceID.keySet());
+ return new HashSet<String>(this.tempTables.keySet());
}
-
- public TempMetadataID getGlobalTempTableMetadataId(Object viewId, QueryMetadataInterface metadata)
- throws QueryMetadataException, TeiidComponentException, QueryResolverException, QueryValidatorException {
- String matViewName = metadata.getFullName(viewId);
- String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
- GroupSymbol group = new GroupSymbol(matViewName);
- group.setMetadataID(viewId);
- TempMetadataID id = tempMetadataStore.getTempGroupID(matTableName);
- //define the table preserving the key/index information and ensure that only a single instance exists
- if (id == null) {
- synchronized (viewId) {
- id = tempMetadataStore.getTempGroupID(matTableName);
- if (id == null) {
- id = tempMetadataStore.addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
- id.setQueryNode(metadata.getVirtualPlan(viewId));
- id.setCardinality(metadata.getCardinality(viewId));
- id.setOriginalMetadataID(viewId);
-
- Object pk = metadata.getPrimaryKey(viewId);
- if (pk != null) {
- ArrayList<TempMetadataID> primaryKey = resolveIndex(metadata, id, pk);
- id.setPrimaryKey(primaryKey);
- }
- Collection keys = metadata.getUniqueKeysInGroup(viewId);
- for (Object key : keys) {
- id.addUniqueKey(resolveIndex(metadata, id, key));
- }
- Collection indexes = metadata.getIndexesInGroup(viewId);
- for (Object index : indexes) {
- id.addIndex(resolveIndex(metadata, id, index));
- }
- }
- }
- }
- updateCacheHint(viewId, metadata, group, id);
- return id;
+
+ Map<String, TempTable> getTempTables() {
+ return tempTables;
}
-
- private void updateCacheHint(Object viewId,
- QueryMetadataInterface metadata, GroupSymbol group,
- TempMetadataID id) throws TeiidComponentException,
- QueryMetadataException, QueryResolverException,
- QueryValidatorException {
- Command c = QueryResolver.resolveView(group, metadata.getVirtualPlan(viewId), SQLConstants.Reserved.SELECT, metadata).getCommand();
- CacheHint hint = c.getCacheHint();
- id.setCacheHint(hint);
- }
-
- static ArrayList<TempMetadataID> resolveIndex(
- QueryMetadataInterface metadata, TempMetadataID id, Object pk)
- throws TeiidComponentException, QueryMetadataException {
- List cols = metadata.getElementIDsInKey(pk);
- ArrayList<TempMetadataID> primaryKey = new ArrayList<TempMetadataID>(cols.size());
- for (Object coldId : cols) {
- int pos = metadata.getPosition(coldId) - 1;
- primaryKey.add(id.getElements().get(pos));
- }
- return primaryKey;
- }
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -58,6 +58,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.tempdata.TempTableStore;
/**
@@ -116,7 +117,7 @@
private BufferManager bufferManager;
- private TempTableStore globalTables;
+ private GlobalTableStore globalTables;
private SessionAwareCache<PreparedPlan> planCache;
@@ -484,11 +485,11 @@
globalState.bufferManager = bm;
}
- public TempTableStore getGlobalTableStore() {
+ public GlobalTableStore getGlobalTableStore() {
return globalState.globalTables;
}
- public void setGlobalTableStore(TempTableStore tempTableStore) {
+ public void setGlobalTableStore(GlobalTableStore tempTableStore) {
globalState.globalTables = tempTableStore;
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1234,7 +1234,7 @@
break;
}
validateNoSubqueriesOrOuterReferences(windowFunction);
- if (windowFunction.getFunction().getOrderBy() != null || windowFunction.getFunction().isDistinct()) {
+ if (windowFunction.getFunction().getOrderBy() != null || (windowFunction.getFunction().isDistinct() && windowFunction.getWindowSpecification().getOrderBy() != null)) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0042", new Object[] {windowFunction.getFunction(), windowFunction}), windowFunction); //$NON-NLS-1$
}
if (windowFunction.getWindowSpecification().getPartition() != null) {
@@ -1437,6 +1437,8 @@
if (item.getPrefix() != null) {
if (item.getPrefix().equals("xml") || item.getPrefix().equals("xmlns")) { //$NON-NLS-1$ //$NON-NLS-2$
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xml_namespaces_reserved"), obj); //$NON-NLS-1$
+ } else if (!Name11Checker.getInstance().isValidNCName(item.getPrefix())) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xml_namespaces_invalid", item.getPrefix()), obj); //$NON-NLS-1$
}
if (item.getUri().length() == 0) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xml_namespaces_null_uri"), obj); //$NON-NLS-1$
Modified: branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -90,6 +90,9 @@
@SuppressWarnings("serial")
public class SaxonXQueryExpression {
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ static final String DEFAULT_PREFIX = "-"; //$NON-NLS-1$
+
public static final Properties DEFAULT_OUTPUT_PROPERTIES = new Properties();
{
DEFAULT_OUTPUT_PROPERTIES.setProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
@@ -168,19 +171,19 @@
throws QueryResolverException {
config.setErrorListener(ERROR_LISTENER);
this.xQueryString = xQueryString;
- StaticQueryContext context = new StaticQueryContext(config);
+ StaticQueryContext context = config.newStaticQueryContext();
IndependentContext ic = new IndependentContext(config);
- namespaceMap.put("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ namespaceMap.put(EMPTY_STRING, EMPTY_STRING);
if (namespaces != null) {
for (NamespaceItem item : namespaces.getNamespaceItems()) {
if (item.getPrefix() == null) {
if (item.getUri() == null) {
- context.setDefaultElementNamespace(""); //$NON-NLS-1$
- ic.setDefaultElementNamespace(""); //$NON-NLS-1$
+ context.setDefaultElementNamespace(EMPTY_STRING);
+ ic.setDefaultElementNamespace(EMPTY_STRING);
} else {
context.setDefaultElementNamespace(item.getUri());
ic.setDefaultElementNamespace(item.getUri());
- namespaceMap.put("", item.getUri()); //$NON-NLS-1$
+ namespaceMap.put(EMPTY_STRING, item.getUri());
}
} else {
context.declareNamespace(item.getPrefix(), item.getUri());
@@ -189,6 +192,7 @@
}
}
}
+ namespaceMap.put(DEFAULT_PREFIX, namespaceMap.get(EMPTY_STRING));
for (DerivedColumn derivedColumn : passing) {
if (derivedColumn.getAlias() == null) {
continue;
@@ -238,7 +242,13 @@
}
}
this.contextRoot = null;
- PathMap map = this.xQuery.getPathMap();
+ //we'll use a new pathmap, since we don't want to modify the one associated with the xquery.
+ PathMap map = null;
+ if (columns == null) {
+ map = this.xQuery.getPathMap();
+ } else {
+ map = new PathMap(this.xQuery.getExpression());
+ }
PathMapRoot parentRoot;
try {
parentRoot = map.getContextRoot();
Modified: branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -82,7 +82,7 @@
"QName must not contain more than one colon: " //$NON-NLS-1$
+ "qname='" + localNames[i] + "', path='" + path + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (k <= 0) {
- fixedPath += " :"; //$NON-NLS-1$
+ fixedPath += SaxonXQueryExpression.DEFAULT_PREFIX+":"; //$NON-NLS-1$
} else {
String prefix = localNames[i].substring(0, k).trim();
if (k >= localNames[i].length() - 1)
Modified: branches/as7/engine/src/main/java/org/teiid/security/SecurityHelper.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/security/SecurityHelper.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/java/org/teiid/security/SecurityHelper.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -28,7 +28,7 @@
public interface SecurityHelper {
- boolean assosiateSecurityContext(String securityDomain, Object context);
+ boolean associateSecurityContext(String securityDomain, Object context);
void clearSecurityContext(String securityDomain);
Modified: branches/as7/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/as7/engine/src/main/resources/org/teiid/query/i18n.properties 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/main/resources/org/teiid/query/i18n.properties 2011-09-05 14:27:44 UTC (rev 3451)
@@ -210,7 +210,7 @@
ERR.015.012.0037 = {0} cannot be used outside of aggregate functions since they are not present in a GROUP BY clause.
ERR.015.012.0039 = Nested aggregate expressions are not allowed: {0}
ERR.015.012.0041 = The aggregate function {0} cannot be used with non-numeric expressions: {1}
-ERR.015.012.0042 = A windowed aggregate function {0} cannot use its own order by clause or be distinct: {1}
+ERR.015.012.0042 = A windowed aggregate function {0} cannot use its own order by clause or be distinct with an OVER ORDER BY: {1}
AggregateValidationVisitor.non_comparable = The aggregate function {0} cannot be used with non-comparable expressions: {1}
AggregateValidationVisitor.non_xml = The XMLAGG aggregate function {0} requires an expression of type XML: {1}
AggregateValidationVisitor.non_boolean=The boolean aggregate functions ANY, SOME, EVERY require a boolean expression.
@@ -721,6 +721,7 @@
ValidationVisitor.xml_namespaces=At most only one NO DEFAULT or DEFAULT namespace may be specified.
ValidationVisitor.xml_namespaces_reserved=The namespaces xmlns and xml are reserved.
ValidationVisitor.xml_namespaces_null_uri=The null uri, or empty string, is not allowed as the uri value.
+ValidationVisitor.xml_namespaces_invalid=The namespace prefix {0} is not a valid NCName
ValidationVisitor.xml_attributes_reserved=The namespace xmlns is reserved.
ValidationVisitor.xml_content_type=The expression "{0}" is of OBJECT or BLOB type, which cannot be used as an XML or TEXT content value.
ValidationVisitor.xml_invalid_qname=The qname "{0}" is invalid.
@@ -937,4 +938,6 @@
DdlPlan.event_not_exists={0} does not have an INSTEAD OF trigger defined for {1}.
DdlPlan.event_already_exists={0} already has an INSTEAD OF trigger defined for {1}.
-error_refresh=error occurred during refreshing the materialized view entries for view {0}
\ No newline at end of file
+error_refresh=error occurred during refreshing the materialized view entries for view {0}
+
+support_required=Without required support property {0}, pushdown will not be enabled for {1} on translator {2}.
\ No newline at end of file
Modified: branches/as7/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -65,6 +65,11 @@
public void setPrefersMemory(boolean prefers) {
}
+
+ @Override
+ public CleanupHook getCleanupHook() {
+ return null;
+ }
};
}
Modified: branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -170,7 +170,7 @@
return svc;
}
- private void helpTest(DataPolicyMetadata policy, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, TeiidComponentException {
+ private void helpTest(String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb, DataPolicyMetadata... roles) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -178,7 +178,9 @@
vdb.addAttchment(QueryMetadataInterface.class, metadata);
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
- policies.put(policy.getName(), policy);
+ for (DataPolicyMetadata dataPolicyMetadata : roles) {
+ policies.put(dataPolicyMetadata.getName(), dataPolicyMetadata);
+ }
this.context.getDQPWorkContext().setPolicies(policies);
DataRolePolicyDecider dataRolePolicyDecider = new DataRolePolicyDecider();
dataRolePolicyDecider.setAllowFunctionCallsByDefault(false);
@@ -206,125 +208,127 @@
@Test public void testTemp() throws Exception {
//allowed by default
- helpTest(exampleAuthSvc1(), "create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
//explicitly denied
- helpTest(exampleAuthSvc2(), "create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {"x"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {"x"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testFunction() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testInaccesibleElement() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT e2 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInaccesibleElement2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT lookup('pm1.g1', 'e1', 'e2', '1')", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest("SELECT e1 FROM pm1.g2", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Test public void testInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testInsertInaccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("UPDATE pm1.g1 SET e2 = 5", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testUpdateCriteriaInaccessibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdateCriteriaInaccessibleForRead1() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = cast(e1 as integer)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g2 SET e2 = cast(e1 as integer)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdateElementInaccessibleForUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDelete() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("DELETE FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testDeleteCriteriaInaccesibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("DELETE FROM pm1.g2 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDeleteInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", RealMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("DELETE FROM pm1.g3", RealMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testProc() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("EXEC pm1.sq1()", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testProcInaccesible() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", RealMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("EXEC pm1.sq2('xyz')", RealMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testSelectIntoEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm2.g2", "pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm2.g2", "pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Test public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm3.g2", "pm3.g2.e4", "pm3.g2.e3"},RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm3.g2", "pm3.g2.e4", "pm3.g2.e3"}, RealMetadataFactory.example1VDB(),exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Test public void testTempTableSelectInto() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2(), exampleAuthSvc1()); //$NON-NLS-1$
+
}
@Test public void testTempTableSelectInto1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT e1, e2 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTempTableInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testXMLAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testXMLInAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testAlter() throws Exception {
- helpTest(exampleAuthSvc1(), "alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(examplePolicyBQT(), "alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(exampleAuthSvc1(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(examplePolicyBQT(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -333,6 +333,37 @@
assertEquals(100, item.resultsBuffer.getRowCount());
}
+ @Test public void testBufferReuse1() throws Exception {
+ //the sql should return 100 rows
+ String sql = "SELECT IntKey FROM texttable('1112131415' columns intkey integer width 2 no row delimiter) t " +
+ "union " +
+ "SELECT IntKey FROM bqt1.smalla"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ String sessionid = "1"; //$NON-NLS-1$
+ agds.sleep = 500;
+ agds.setUseIntCounter(true);
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+ reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
+ DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
+ DQPWorkContext.getWorkContext().getSession().setUserName(userName);
+ BufferManagerImpl bufferManager = (BufferManagerImpl)core.getBufferManager();
+ bufferManager.setProcessorBatchSize(20);
+ Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
+ ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 6, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 11, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+ }
+
@Test public void testSourceConcurrency() throws Exception {
//setup default of 2
agds.setSleep(100);
Modified: branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -42,6 +42,7 @@
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.ContextProperties;
@@ -52,7 +53,7 @@
*/
public class TestRequest extends TestCase {
- private static final TempTableStore TEMP_TABLE_STORE = new TempTableStore("1"); //$NON-NLS-1$
+ private static final TempTableStore TEMP_TABLE_STORE = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
private final static String QUERY = "SELECT * FROM pm1.g1"; //$NON-NLS-1$
/**
Modified: branches/as7/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -59,13 +59,17 @@
public int sleep;
private final AtomicInteger executeCount = new AtomicInteger();
private final AtomicInteger closeCount = new AtomicInteger();
+ private boolean useIntCounter;
-
public AutoGenDataService() {
super("FakeConnector","FakeConnector"); //$NON-NLS-1$ //$NON-NLS-2$
caps = TestOptimizer.getTypicalCapabilities();
}
+ public void setUseIntCounter(boolean useIntCounter) {
+ this.useIntCounter = useIntCounter;
+ }
+
public void setSleep(int sleep) {
this.sleep = sleep;
}
@@ -151,7 +155,7 @@
while(iter.hasNext()) {
SingleElementSymbol symbol = (SingleElementSymbol) iter.next();
Class type = symbol.getType();
- row.add( getValue(type) );
+ row.add( getValue(type, i) );
}
rows[i] = row;
}
@@ -174,11 +178,11 @@
private static final java.sql.Time TIME_VAL = new java.sql.Time(0);
private static final java.sql.Timestamp TIMESTAMP_VAL = new java.sql.Timestamp(0);
- private Object getValue(Class<?> type) {
+ private Object getValue(Class<?> type, int row) {
if(type.equals(DataTypeManager.DefaultDataClasses.STRING)) {
return STRING_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.INTEGER)) {
- return INTEGER_VAL;
+ return useIntCounter?row:INTEGER_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.SHORT)) {
return SHORT_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.LONG)) {
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/function/TestFunction.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunction.java:3281-3325
/trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunction.java:3281-3325
/trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java:3149-3217,3281-3325
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java:3149-3217,3281-3325
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -37,7 +37,7 @@
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -151,7 +151,8 @@
Command command = helpGetCommand(userSql, metadata, null);
CommandContext cc = new CommandContext();
- cc.setGlobalTableStore(new TempTableStore("SYSTEM"));
+ GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata);
+ cc.setGlobalTableStore(gts);
ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
TestOptimizer.checkAtomicQueries(new String[] {"SELECT #MAT_MATVIEW.VGROUP2.x FROM #MAT_MATVIEW.VGROUP2"}, plan);
Collection<Annotation> annotations = analysis.getAnnotations();
@@ -168,7 +169,8 @@
Command command = helpGetCommand(userSql, metadata, null);
CommandContext cc = new CommandContext();
- cc.setGlobalTableStore(new TempTableStore("SYSTEM"));
+ GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata);
+ cc.setGlobalTableStore(gts);
RelationalPlan plan = (RelationalPlan)TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
assertEquals(1f, plan.getRootNode().getEstimateNodeCardinality());
TestOptimizer.checkAtomicQueries(new String[] {"SELECT #MAT_MATVIEW.VGROUP3.x, #MAT_MATVIEW.VGROUP3.y FROM #MAT_MATVIEW.VGROUP3 WHERE #MAT_MATVIEW.VGROUP3.x = 'foo'"}, plan);
@@ -186,7 +188,8 @@
Command command = helpGetCommand(userSql, metadata, null);
CommandContext cc = new CommandContext();
- cc.setGlobalTableStore(new TempTableStore("SYSTEM"));
+ GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata);
+ cc.setGlobalTableStore(gts);
ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
TestOptimizer.checkAtomicQueries(new String[] {"SELECT #MAT_MATVIEW.VGROUP4.x FROM #MAT_MATVIEW.VGROUP4"}, plan);
Collection<Annotation> annotations = analysis.getAnnotations();
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -25,24 +25,30 @@
import static org.junit.Assert.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
import org.junit.Before;
import org.junit.Test;
-import org.teiid.cache.DefaultCacheFactory;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.QueryProcessorFactoryImpl;
import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -52,20 +58,21 @@
private TempMetadataAdapter metadata;
private TempTableDataManager dataManager;
private TempTableStore tempStore;
- private TempTableStore globalStore;
+ private GlobalTableStoreImpl globalStore;
private ProcessorPlan previousPlan;
private HardcodedDataManager hdm;
@Before public void setUp() {
- tempStore = new TempTableStore("1"); //$NON-NLS-1$
- globalStore = new TempTableStore("SYSTEM");
- metadata = new TempMetadataAdapter(RealMetadataFactory.exampleMaterializedView(), tempStore.getMetadataStore());
+ tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ QueryMetadataInterface actualMetadata = RealMetadataFactory.exampleMaterializedView();
+ globalStore = new GlobalTableStoreImpl(bm, actualMetadata);
+ metadata = new TempMetadataAdapter(actualMetadata, tempStore.getMetadataStore());
hdm = new HardcodedDataManager();
hdm.addData("SELECT matsrc.x FROM matsrc", new List[] {Arrays.asList((String)null), Arrays.asList("one"), Arrays.asList("two"), Arrays.asList("three")});
hdm.addData("SELECT mattable.info.e1, mattable.info.e2 FROM mattable.info", new List[] {Arrays.asList("a", 1), Arrays.asList("a", 2)});
hdm.addData("SELECT mattable.info.e2, mattable.info.e1 FROM mattable.info", new List[] {Arrays.asList(1, "a"), Arrays.asList(2, "a")});
- BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>();
cache.setBufferManager(bm);
Executor executor = new Executor() {
@@ -74,7 +81,7 @@
command.run();
}
};
- dataManager = new TempTableDataManager(hdm, bm, executor, cache, cache, new DefaultCacheFactory());
+ dataManager = new TempTableDataManager(hdm, bm, executor, cache);
}
private void execute(String sql, List<?>... expectedResults) throws Exception {
@@ -95,6 +102,25 @@
assertEquals(1, hdm.getCommandHistory().size());
}
+ @Test public void testReadWrite() throws Exception {
+ execute("SELECT * from vgroup3 where x = 'one'", Arrays.asList("one", "zne"));
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ String matTableName = RelationalPlanner.MAT_PREFIX + "MATVIEW.VGROUP3";
+ this.globalStore.getState(matTableName, baos);
+ MatTableInfo matTableInfo = this.globalStore.getMatTableInfo(matTableName);
+ long time = matTableInfo.getUpdateTime();
+ this.globalStore.failedLoad(matTableName);
+ this.globalStore.setState(matTableName, new ByteArrayInputStream(baos.toByteArray()));
+ assertEquals(time, matTableInfo.getUpdateTime());
+ execute("SELECT * from vgroup3 where x = 'one'", Arrays.asList("one", "zne"));
+
+ execute("select lookup('mattable.info', 'e1', 'e2', 5)", Arrays.asList((String)null));
+ baos = new ByteArrayOutputStream();
+ String codeTableName = "#CODE_MATTABLE.INFO.E2.E1";
+ this.globalStore.getState(codeTableName, baos);
+ this.globalStore.setState(codeTableName, new ByteArrayInputStream(baos.toByteArray()));
+ }
+
@Test(expected=TeiidProcessingException.class) public void testCodeTableResponseException() throws Exception {
//duplicate key
execute("select lookup('mattable.info', 'e2', 'e1', 'a')");
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -93,8 +93,10 @@
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.util.VariableContext;
import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.CommandContext;
@@ -243,10 +245,11 @@
}
context.getNextRand(0);
if (context.getTempTableStore() == null) {
- context.setTempTableStore(new TempTableStore(context.getConnectionID()));
+ context.setTempTableStore(new TempTableStore(context.getConnectionID(), TransactionMode.ISOLATE_WRITES));
}
if (context.getGlobalTableStore() == null) {
- context.setGlobalTableStore(new TempTableStore("SYSTEM"));
+ GlobalTableStoreImpl gts = new GlobalTableStoreImpl(bufferMgr, context.getMetadata());
+ context.setGlobalTableStore(gts);
}
if (!(dataManager instanceof TempTableDataManager)) {
SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>();
@@ -257,7 +260,7 @@
command.run();
}
};
- dataManager = new TempTableDataManager(dataManager, bufferMgr, executor, cache, null, null);
+ dataManager = new TempTableDataManager(dataManager, bufferMgr, executor, cache);
}
if (context.getQueryProcessorFactory() == null) {
context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(bufferMgr, dataManager, new DefaultCapabilitiesFinder(), null, context.getMetadata()));
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3217,3220-3275
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -216,7 +216,11 @@
ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(), createCommandContext());
- helpProcess(plan, createCommandContext(), dataManager, expected);
+ helpProcess(plan, createCommandContext(), dataManager, expected);
+
+ plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(), createCommandContext());
+
+ doProcess(plan, dataManager, expected, createCommandContext());
}
@Test public void testXmlTableDefaultAndParent() throws Exception {
@@ -474,5 +478,17 @@
public static BlobType blobFromFile(final String file) {
return new BlobType(new BlobImpl(new InputStreamFactory.FileInputStreamFactory(UnitTestUtil.getTestDataFile(file))));
}
+
+ @Test public void testXmlTableWithDefault() throws Exception {
+ String sql = "select * from xmltable(XMLNAMESPACES(default 'http://x.y.com'), '/a/b' passing convert('<a xmlns=\"http://x.y.com\"><b>first</b><b x=\"attr\">second</b></a>', xml) columns x string path '@x', val string path '/.') as x"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ Arrays.asList(null, "first"),
+ Arrays.asList("attr", "second"),
+ };
+
+ process(sql, expected);
+ }
+
}
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java:3149-3217,3220-3275,3281-3325,3340-3349
/trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java:3149-3217,3220-3275,3281-3325,3340-3349
/trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -24,24 +24,38 @@
import static org.junit.Assert.*;
+import java.sql.Connection;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -52,6 +66,10 @@
private TempTableDataManager dataManager;
private TempTableStore tempStore;
+ private TransactionContext tc;
+ private Transaction txn;
+ private Synchronization synch;
+
private ProcessorPlan execute(String sql, List[] expectedResults) throws Exception {
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
execute(plan, expectedResults);
@@ -60,6 +78,7 @@
private void execute(ProcessorPlan processorPlan, List[] expectedResults) throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
+ cc.setTransactionContext(tc);
cc.setMetadata(metadata);
cc.setTempTableStore(tempStore);
TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
@@ -67,7 +86,7 @@
}
@Before public void setUp() {
- tempStore = new TempTableStore("1"); //$NON-NLS-1$
+ tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
metadata.setSession(true);
FakeDataManager fdm = new FakeDataManager();
@@ -81,9 +100,99 @@
command.run();
}
};
- dataManager = new TempTableDataManager(fdm, bm, executor, cache, null, null);
+ dataManager = new TempTableDataManager(fdm, bm, executor, cache);
}
+ @Test public void testRollbackNoExisting() throws Exception {
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+
+ Mockito.verify(txn).registerSynchronization((Synchronization) Mockito.anyObject());
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ try {
+ execute("select * from x", new List[] {});
+ fail();
+ } catch (Exception e) {
+
+ }
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ }
+
+ @Test public void testRollbackExisting() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ //execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(172)}); //$NON-NLS-1$
+
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ execute("select * from x", new List[] {});
+ }
+
+ @Test public void testRollbackExisting1() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ //execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(344)}); //$NON-NLS-1$
+
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+ this.tc = null;
+
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+
+ execute("delete from x", new List[] {Arrays.asList(516)});
+ }
+
+ @Test public void testIsolateReads() throws Exception {
+ GlobalTableStoreImpl gtsi = new GlobalTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), RealMetadataFactory.example1Cached());
+ tempStore = gtsi.getTempTableStore();
+ metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+ gtsi.updateMatViewRow("X", Arrays.asList(1), true);
+ tc=null;
+ //outside of the transaction we can see the row removed
+ execute("select count(*) from x", new List[] {Arrays.asList(515)});
+
+ //back in the transaction we see the original state
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+
+ synch.afterCompletion(Status.STATUS_COMMITTED);
+ }
+
+ private void setupTransaction(int isolation) throws RollbackException, SystemException {
+ txn = Mockito.mock(Transaction.class);
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ synch = (Synchronization)invocation.getArguments()[0];
+ return null;
+ }
+ }).when(txn).registerSynchronization((Synchronization)Mockito.anyObject());
+ Mockito.stub(txn.toString()).toReturn("txn");
+ tc = new TransactionContext();
+ tc.setTransaction(txn);
+ tc.setIsolationLevel(isolation);
+ tc.setTransactionType(Scope.REQUEST);
+ }
+
@Test public void testInsertWithQueryExpression() throws Exception {
execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,6 +22,7 @@
package org.teiid.query.processor;
+import static org.junit.Assert.*;
import static org.teiid.query.optimizer.TestOptimizer.*;
import static org.teiid.query.processor.TestProcessor.*;
@@ -43,6 +44,9 @@
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.NestedTableJoinStrategy;
+import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings({"unchecked", "nls"})
@@ -190,6 +194,17 @@
process(sql, expected);
}
+ @Test public void testMissingValues() throws Exception {
+ String sql = "select * from texttable('a,b\nc' COLUMNS c1 string, c2 string) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", "b"),
+ Arrays.asList("c", null),
+ };
+
+ process(sql, expected);
+ }
+
@Test public void testQuote() throws Exception {
String sql = "select * from texttable(' \" a\", \" \"\" \"' COLUMNS c1 string, c2 string) x"; //$NON-NLS-1$
@@ -266,8 +281,41 @@
};
process(sql, expected);
- }
+ }
+ @Test public void testTextTableJoin() throws Exception {
+ String sql = "select z.* from (select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string) x) as z, " +
+ "(select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string) x) as z1 where z.x = z1.x";
+
+ List[] expected = new List[] {
+ Arrays.asList("c"),
+ Arrays.asList("1"),
+ Arrays.asList("true"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ RelationalPlan plan = (RelationalPlan)helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
+ JoinNode join = (JoinNode) plan.getRootNode().getChildren()[0];
+ assertTrue(!(join.getJoinStrategy() instanceof NestedTableJoinStrategy));
+ helpProcess(plan, createCommandContext(), dataManager, expected);
+ }
+
+ @Test public void testTextTableJoin1() throws Exception {
+ String sql = "select e1, e2 from texttable('a' COLUMNS col string) x, pm1.g1 where col = e1";
+
+ List[] expected = new List[] {
+ Arrays.asList("a", 0),
+ Arrays.asList("a", 3),
+ Arrays.asList("a", 0),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ RelationalPlan plan = (RelationalPlan)helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
+ helpProcess(plan, createCommandContext(), dataManager, expected);
+ }
+
public static void process(String sql, List[] expectedResults) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java:3188-3450
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -34,6 +34,9 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.WindowFunctionProjectNode;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings({"nls", "unchecked"})
@@ -91,6 +94,49 @@
});
}
+ @Test public void testWindowFunctionPushdown2() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
+ caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ ProcessorPlan plan = TestOptimizer.helpPlan("select max(e1) over (order by e1 nulls first) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {1, 1, 1}, new Class<?>[] {AccessNode.class, WindowFunctionProjectNode.class, ProjectNode.class});
+
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
+ plan = TestOptimizer.helpPlan("select max(e1) over (order by e1 nulls first) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT MAX(g_0.e1) OVER (ORDER BY g_0.e1 NULLS FIRST) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testWindowFunctionPushdown3() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, true);
+ ProcessorPlan plan = TestOptimizer.helpPlan("select count(distinct e1) over (partition by e2) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {1, 1, 1}, new Class<?>[] {AccessNode.class, WindowFunctionProjectNode.class, ProjectNode.class});
+
+ caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES, true);
+ plan = TestOptimizer.helpPlan("select count(distinct e1) over (partition by e2) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT COUNT(DISTINCT g_0.e1) OVER (PARTITION BY g_0.e2) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+
@Test public void testRanking() throws Exception {
String sql = "select e1, row_number() over (order by e1), rank() over (order by e1), dense_rank() over (order by e1 nulls last) from pm1.g1";
@@ -236,4 +282,24 @@
helpProcess(plan, dataManager, expected);
}
+ @Test public void testPartitionedDistinctCount() throws Exception {
+ String sql = "select e1, e3, count(distinct e1) over (partition by e3) as r from pm1.g1 order by e1, e3";
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(null, Boolean.FALSE, 2),
+ Arrays.asList("a", Boolean.FALSE, 2),
+ Arrays.asList("a", Boolean.FALSE, 2),
+ Arrays.asList("a", Boolean.TRUE, 2),
+ Arrays.asList("b", Boolean.FALSE, 2),
+ Arrays.asList("c", Boolean.TRUE, 2),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+
}
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -64,10 +64,16 @@
String sql = "with a (x, y, z) as (select e1, e2, e3 from pm1.g1) SELECT a.x from a, a z"; //$NON-NLS-1$
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ List[] expected = new List[] {
+ Arrays.asList("a", 1, Boolean.FALSE),
+ };
+
+ dataManager.addData("WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1", expected);
- TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+
+ helpProcess(plan, dataManager, expected);
}
@Test public void testWithPushdownWithConstants() throws TeiidException {
Property changes on: branches/as7/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java:3188-3382
+ /branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java:3149-3217
/trunk/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java:3188-3450
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -124,4 +124,9 @@
Query query = (Query)QueryParser.getQueryParser().parseCommand("SELECT e1, e2 FROM pm1.g1 LIMIT 0"); //$NON-NLS-1$
assertFalse(RelationalNodeUtil.shouldExecute(query, false));
}
+
+ @Test public void testShouldExecuteAgg() throws Exception {
+ Query query = (Query)QueryParser.getQueryParser().parseCommand("SELECT count(*) FROM pm1.g1 where false"); //$NON-NLS-1$
+ assertTrue(RelationalNodeUtil.shouldExecute(query, false));
+ }
}
Modified: branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -46,7 +46,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
-
+@SuppressWarnings("unchecked")
public class TestSortNode {
public static final int BATCH_SIZE = 100;
@@ -321,4 +321,37 @@
assertEquals(Arrays.asList(2), ts.nextTuple());
}
+ @Test public void testDupRemoveLowMemory() throws Exception {
+ ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
+ es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ BufferManager bm = BufferManagerFactory.getTestBufferManager(0, 2);
+ TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1), "test", TupleSourceType.PROCESSOR); //$NON-NLS-1$
+ tsid.addTuple(Arrays.asList(1));
+ tsid.addTuple(Arrays.asList(2));
+ SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.DUP_REMOVE, bm, "test", tsid.getSchema()); //$NON-NLS-1$
+ TupleBuffer out = su.sort();
+ TupleSource ts = out.createIndexedTupleSource();
+ assertEquals(Arrays.asList(1), ts.nextTuple());
+ assertEquals(Arrays.asList(2), ts.nextTuple());
+ try {
+ ts.nextTuple();
+ fail();
+ } catch (BlockedException e) {
+
+ }
+ tsid.addTuple(Arrays.asList(3));
+ tsid.addTuple(Arrays.asList(4));
+ tsid.addTuple(Arrays.asList(5));
+ tsid.addTuple(Arrays.asList(6));
+ tsid.addTuple(Arrays.asList(6));
+ tsid.addTuple(Arrays.asList(6));
+ tsid.close();
+ su.sort();
+ ts.nextTuple();
+ ts.nextTuple();
+ assertNotNull(ts.nextTuple());
+ assertNotNull(ts.nextTuple());
+ assertNull(ts.nextTuple());
+ }
+
}
Modified: branches/as7/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1742,6 +1742,7 @@
public static Procedure createStoredProcedure(String name, Schema model, List<ProcedureParameter> params) {
Procedure proc = new Procedure();
proc.setName(name);
+ proc.setNameInSource(name);
if (params != null) {
int index = 1;
for (ProcedureParameter procedureParameter : params) {
Modified: branches/as7/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1779,6 +1779,10 @@
@Test public void testXMLNamespaces() {
helpValidate("select xmlforest(xmlnamespaces(no default, default 'http://foo'), e1 as \"table\") from pm1.g1", new String[] {"XMLNAMESPACES(NO DEFAULT, DEFAULT 'http://foo')"}, RealMetadataFactory.example1Cached());
}
+
+ @Test public void testXMLNamespacesInvalid() {
+ helpValidate("select xmlforest(xmlnamespaces('http://foo' as \"1\"), e1 as \"table\") from pm1.g1", new String[] {"XMLNAMESPACES('http://foo' AS \"1\")"}, RealMetadataFactory.example1Cached());
+ }
@Test public void testXMLNamespacesReserved() {
helpValidate("select xmlforest(xmlnamespaces('http://foo' as xmlns), e1 as \"table\") from pm1.g1", new String[] {"XMLNAMESPACES('http://foo' AS xmlns)"}, RealMetadataFactory.example1Cached());
@@ -1945,4 +1949,8 @@
helpValidate("select count(*) over () as y", new String[] {"COUNT(*) OVER ()"}, RealMetadataFactory.example1Cached());
}
+ @Test public void testWindowFunctionOrderedDistinct() {
+ helpValidate("select count(distinct e1) over (order by e2) as y from pm1.g1", new String[] {"COUNT(DISTINCT e1) OVER (ORDER BY e2)"}, RealMetadataFactory.example1Cached());
+ }
+
}
Property changes on: branches/as7/engine/src/test/resources/text/cdm_dos_win.txt
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/engine/src/test/resources/text/cdm_dos_win.txt:3149-3164,3172-3217
/trunk/engine/src/test/resources/text/cdm_dos_win.txt:3188-3382
+ /branches/7.4.x/engine/src/test/resources/text/cdm_dos_win.txt:3149-3164,3172-3217
/trunk/engine/src/test/resources/text/cdm_dos_win.txt:3188-3450
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -48,7 +48,7 @@
public static final String MAX_SOURCE_ROWS = "max-source-rows-allowed";//$NON-NLS-1$
public static final String EXCEPTION_ON_MAX_SOURCE_ROWS = "exception-on-max-source-rows";//$NON-NLS-1$
public static final String MAX_ODBC_LOB_SIZE_ALLOWED = "max-odbc-lob-size-allowed";//$NON-NLS-1$
- public static final String EVENT_DISTRIBUTOR_NAME = "event-distributor-name";//$NON-NLS-1$
+ public static final String OBJECT_REPLICATOR_NAME = "object-replicator-name";//$NON-NLS-1$
public static final String DETECTING_CHANGE_EVENTS = "detect-change-events";//$NON-NLS-1$
public static final String SECURITY_DOMAIN = "security-domain";//$NON-NLS-1$
public static final String MAX_SESSIONS_ALLOWED = "max-sessions-allowed";//$NON-NLS-1$
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -46,7 +46,7 @@
MAX_SOURCE_ROWS_ELEMENT(MAX_SOURCE_ROWS),
EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT(EXCEPTION_ON_MAX_SOURCE_ROWS),
MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT(MAX_ODBC_LOB_SIZE_ALLOWED),
- EVENT_DISTRIBUTOR_NAME_ELEMENT(EVENT_DISTRIBUTOR_NAME),
+ OBJECT_REPLICATOR_NAME_ELEMENT(OBJECT_REPLICATOR_NAME),
DETECTING_CHANGE_EVENTS_ELEMENT(DETECTING_CHANGE_EVENTS),
MAX_SESSIONS_ALLOWED_ELEMENT(MAX_SESSIONS_ALLOWED),
SESSION_EXPIRATION_TIME_LIMIT_ELEMENT(SESSION_EXPIRATION_TIME_LIMIT),
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -36,7 +36,7 @@
private static final long serialVersionUID = 3598997061994110254L;
@Override
- public boolean assosiateSecurityContext(String securityDomain, Object newContext) {
+ public boolean associateSecurityContext(String securityDomain, Object newContext) {
SecurityContext context = SecurityActions.getSecurityContext();
if (context == null || (!context.getSecurityDomain().equals(securityDomain) && newContext != null)) {
SecurityActions.setSecurityContext((SecurityContext)newContext);
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -99,7 +99,6 @@
// now build the engine
final RuntimeEngineDeployer engine = buildQueryEngine(engineName, operation);
engine.setSecurityHelper(new JBossSecurityHelper());
- engine.setContainerLifeCycleListener(shutdownListener);
// TODO: none of the caching is configured..
SocketConfiguration jdbc = null;
@@ -200,8 +199,8 @@
if (node.hasDefined(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED)) {
engine.setMaxODBCLobSizeAllowed(node.get(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED).asInt());
}
- if (node.hasDefined(Configuration.EVENT_DISTRIBUTOR_NAME)) {
- engine.setEventDistributorName(node.get(Configuration.EVENT_DISTRIBUTOR_NAME).asString());
+ if (node.hasDefined(Configuration.OBJECT_REPLICATOR_NAME)) {
+ engine.setObjectReplicatorName(node.get(Configuration.OBJECT_REPLICATOR_NAME).asString());
}
if (node.hasDefined(Configuration.DETECTING_CHANGE_EVENTS)) {
engine.setDetectingChangeEvents(node.get(Configuration.DETECTING_CHANGE_EVENTS).asBoolean());
@@ -296,7 +295,7 @@
addAttribute(node, Configuration.MAX_SOURCE_ROWS, type, bundle.getString(Configuration.MAX_SOURCE_ROWS+DESC), ModelType.INT, false, "-1"); //$NON-NLS-1$
addAttribute(node, Configuration.EXCEPTION_ON_MAX_SOURCE_ROWS, type, bundle.getString(Configuration.EXCEPTION_ON_MAX_SOURCE_ROWS+DESC), ModelType.BOOLEAN, false, "true"); //$NON-NLS-1$
addAttribute(node, Configuration.MAX_ODBC_LOB_SIZE_ALLOWED, type, bundle.getString(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED+DESC), ModelType.INT, false, "5242880"); //$NON-NLS-1$
- addAttribute(node, Configuration.EVENT_DISTRIBUTOR_NAME, type, bundle.getString(Configuration.EVENT_DISTRIBUTOR_NAME+DESC), ModelType.STRING, false, "teiid/event-distributor"); //$NON-NLS-1$
+ addAttribute(node, Configuration.OBJECT_REPLICATOR_NAME, type, bundle.getString(Configuration.OBJECT_REPLICATOR_NAME+DESC), ModelType.STRING, false, "teiid/event-distributor"); //$NON-NLS-1$
addAttribute(node, Configuration.DETECTING_CHANGE_EVENTS, type, bundle.getString(Configuration.DETECTING_CHANGE_EVENTS+DESC), ModelType.BOOLEAN, false, "true"); //$NON-NLS-1$
//session stuff
@@ -381,8 +380,8 @@
if (operation.hasDefined(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED)) {
model.get(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED).set(operation.get(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED).asInt());
}
- if (operation.hasDefined(Configuration.EVENT_DISTRIBUTOR_NAME)) {
- model.get(Configuration.EVENT_DISTRIBUTOR_NAME).set(operation.get(Configuration.EVENT_DISTRIBUTOR_NAME).asString());
+ if (operation.hasDefined(Configuration.OBJECT_REPLICATOR_NAME)) {
+ model.get(Configuration.OBJECT_REPLICATOR_NAME).set(operation.get(Configuration.OBJECT_REPLICATOR_NAME).asString());
}
if (operation.hasDefined(Configuration.SECURITY_DOMAIN)) {
List<ModelNode> domains = operation.get(Configuration.SECURITY_DOMAIN).asList();
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -121,7 +121,7 @@
writeElement(writer, Element.MAX_SOURCE_ROWS_ELEMENT, node);
writeElement(writer, Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT, node);
writeElement(writer, Element.MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT, node);
- writeElement(writer, Element.EVENT_DISTRIBUTOR_NAME_ELEMENT, node);
+ writeElement(writer, Element.OBJECT_REPLICATOR_NAME_ELEMENT, node);
writeElement(writer, Element.DETECTING_CHANGE_EVENTS_ELEMENT, node);
if (node.hasDefined(Element.SECURITY_DOMAIN_ELEMENT.getLocalName())) {
@@ -340,7 +340,7 @@
break;
//Strings
- case EVENT_DISTRIBUTOR_NAME_ELEMENT:
+ case OBJECT_REPLICATOR_NAME_ELEMENT:
node.get(reader.getLocalName()).set(reader.getElementText());
break;
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -47,7 +47,6 @@
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
-import org.jboss.netty.util.internal.ConcurrentHashMap;
import org.teiid.adminapi.Admin.Cache;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
@@ -66,6 +65,7 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.ApplicationInfo;
import org.teiid.core.util.LRUCache;
+import org.teiid.deployers.CompositeVDB;
import org.teiid.deployers.ContainerLifeCycleListener;
import org.teiid.deployers.VDBLifeCycleListener;
import org.teiid.deployers.VDBRepository;
@@ -84,8 +84,12 @@
import org.teiid.metadata.*;
import org.teiid.metadata.Table.TriggerEvent;
import org.teiid.net.TeiidURL;
+import org.teiid.query.ObjectReplicator;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.processor.DdlPlan;
+import org.teiid.query.tempdata.GlobalTableStore;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.security.SecurityHelper;
import org.teiid.services.BufferServiceImpl;
import org.teiid.services.SessionServiceImpl;
@@ -111,10 +115,10 @@
private long sessionMaxLimit = SessionService.DEFAULT_MAX_SESSIONS;
private long sessionExpirationTimeLimit = SessionService.DEFAULT_SESSION_EXPIRATION;
- private String eventDistributorName;
+ private transient ObjectReplicator objectReplicator;
+ private String objectReplicatorName;
private transient EventDistributor eventDistributor;
private transient EventDistributor eventDistributorProxy;
- private transient ContainerLifeCycleListener lifecycleListener;
private final InjectedValue<WorkManager> workManagerInjector = new InjectedValue<WorkManager>();
private final InjectedValue<XATerminator> xaTerminatorInjector = new InjectedValue<XATerminator>();
@@ -184,13 +188,18 @@
dqpCore.setTransactionService((TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, transactionServerImpl, new Class[] {TransactionService.class}, MessageLevel.DETAIL, Module.getCallerModule().getClassLoader()));
- if (this.eventDistributorName != null) {
+ if (this.objectReplicatorName != null) {
try {
InitialContext ic = new InitialContext();
- this.eventDistributor = (EventDistributor) ic.lookup(this.eventDistributorName);
+ this.objectReplicator = (ObjectReplicator) ic.lookup(this.objectReplicatorName);
+ try {
+ this.eventDistributor = this.objectReplicator.replicate(LocalServerConnection.TEIID_RUNTIME_CONTEXT+getName(), EventDistributor.class, this, 0);
+ } catch (Exception e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.getString("replication_failed", this)); //$NON-NLS-1$
+ }
} catch (NamingException ne) {
//log at a detail level since we may not be in the all profile
- LogManager.logDetail(LogConstants.CTX_RUNTIME, ne, IntegrationPlugin.Util.getString("jndi_failed", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, ne, IntegrationPlugin.Util.getString("jndi_failed", this.objectReplicatorName)); //$NON-NLS-1$
}
}
this.dqpCore.setMetadataRepository(this.vdbRepository.getMetadataRepository());
@@ -253,19 +262,31 @@
}
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_started", getRuntimeVersion(), new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
-
// add vdb life cycle listeners
this.vdbRepository.addListener(new VDBLifeCycleListener() {
private Set<VDBKey> recentlyRemoved = Collections.newSetFromMap(new LRUCache<VDBKey, Boolean>(10000));
@Override
- public void removed(String name, int version) {
+ public void removed(String name, int version, CompositeVDB vdb) {
recentlyRemoved.add(new VDBKey(name, version));
+ if (objectReplicator != null) {
+ GlobalTableStore gts = vdb.getVDB().getAttachment(GlobalTableStore.class);
+ objectReplicator.stop(gts);
+ }
}
@Override
- public void added(String name, int version) {
+ public void added(String name, int version, CompositeVDB vdb) {
+ GlobalTableStore gts = new GlobalTableStoreImpl(dqpCore.getBufferManager(), vdb.getVDB().getAttachment(TransformationMetadata.class));
+ if (objectReplicator != null) {
+ try {
+ gts = objectReplicator.replicate(name + version, GlobalTableStore.class, gts, 300000);
+ } catch (Exception e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.getString("replication_failed", gts)); //$NON-NLS-1$
+ }
+ }
+ vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
if (!recentlyRemoved.remove(new VDBKey(name, version))) {
return;
}
@@ -286,8 +307,6 @@
dqpCore.clearCache(Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString(), name, version);
}
});
-
- synchronizeMaterializeViews();
}
@Override
@@ -317,6 +336,10 @@
this.sessionService.stop();
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_stopped", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
+
+ if (this.objectReplicator != null && this.eventDistributor != null) {
+ this.objectReplicator.stop(this.eventDistributor);
+ }
}
private void createClientServices() {
@@ -588,26 +611,31 @@
return newResults;
}
- public String getEventDistributorName() {
- return eventDistributorName;
+ public String getObjectReplicatorName() {
+ return objectReplicatorName;
}
- public void setEventDistributorName(String eventDistributorName) {
- this.eventDistributorName = eventDistributorName;
+ public void setObjectReplicatorName(String eventDistributorName) {
+ this.objectReplicatorName = eventDistributorName;
}
@Override
public void updateMatViewRow(String vdbName, int vdbVersion, String schema,
String viewName, List<?> tuple, boolean delete) {
- this.dqpCore.updateMatViewRow(getContextProvider(), vdbName, vdbVersion, schema, viewName, tuple, delete);
+ VDBMetaData metadata = this.vdbRepository.getVDB(vdbName, vdbVersion);
+ if (metadata != null) {
+ GlobalTableStore gts = metadata.getAttachment(GlobalTableStore.class);
+ if (gts != null) {
+ try {
+ gts.updateMatViewRow((RelationalPlanner.MAT_PREFIX + schema + '.' + viewName).toUpperCase(), tuple, delete);
+ } catch (TeiidComponentException e) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.getString("replication_failed", "updateMatViewRow")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
}
@Override
- public void refreshMatView(final String vdbName, final int vdbVersion, final String viewName) {
- this.dqpCore.refreshMatView(getContextProvider(), vdbName, vdbVersion, viewName);
- }
-
- @Override
public void dataModification(String vdbName, int vdbVersion, String schema,
String... tableNames) {
updateModified(true, vdbName, vdbVersion, schema, tableNames);
@@ -739,18 +767,6 @@
return this.eventDistributorProxy;
}
- private void synchronizeMaterializeViews() {
- this.lifecycleListener.addListener(new ContainerLifeCycleListener.LifeCycleEventListener() {
- @Override
- public void onStartupFinish() {
- dqpCore.synchronizeInternalMaterializedViews(getContextProvider());
- }
- @Override
- public void onShutdownStart() {
- }
- });
- }
-
public String getRuntimeVersion() {
return ApplicationInfo.getInstance().getBuildNumber();
}
@@ -767,29 +783,6 @@
this.securityDomainNames.add(domain);
}
- private DQPCore.ContextProvider getContextProvider() {
- return new DQPCore.ContextProvider() {
- @Override
- public DQPWorkContext getContext(final String vdbName, final int vdbVersion) {
- return new DQPWorkContext() {
- public VDBMetaData getVDB() {
- return vdbRepository.getVDB(vdbName, vdbVersion);
- }
- public String getVdbName() {
- return vdbName;
- }
- public int getVdbVersion() {
- return vdbVersion;
- }
- };
- }
- };
- }
-
- public void setContainerLifeCycleListener(ContainerLifeCycleListener listener) {
- this.lifecycleListener = listener;
- }
-
public InjectedValue<CacheFactory> getCachefactoryInjector() {
return cachefactoryInjector;
}
Modified: branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-09-05 14:27:44 UTC (rev 3451)
@@ -44,7 +44,8 @@
class_not_found=Class {0} not found.
datasource_exists=Data source with name {0} already exists!
datasource_template_not_found=Template {0} for creating the data source is not found.
-jndi_failed=JNDI lookup failed.
+jndi_failed=JNDI lookup failed {0}.
+replication_failed=Could not replicate object {0}
distribute_failed=Deploy of the archive failed {0}
template_not_found=Template not found for {0}
admin_executing=JOPR admin {0} is executing command {1}
Modified: branches/as7/pom.xml
===================================================================
--- branches/as7/pom.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/pom.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -15,6 +15,7 @@
<scm>
<connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</connection>
<developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/trunk</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/teiid/trunk</url>
</scm>
<licenses>
<license>
@@ -109,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
+ <version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@@ -119,7 +120,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.9</version>
+ <version>2.9</version>
<configuration>
<includes>
<include>**/*TestCase.java</include>
@@ -194,7 +195,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
+ <version>2.8</version>
<configuration>
<aggregate>true</aggregate>
<maxmemory>512m</maxmemory>
@@ -451,7 +452,6 @@
<version>3.0.0.CR1</version>
</dependency>
- <!--
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
@@ -478,13 +478,6 @@
</exclusions>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- <version>2.1.0.SP1</version>
- <scope>provided</scope>
- </dependency>
- -->
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxonhe</artifactId>
@@ -530,9 +523,7 @@
<module>metadata</module>
<module>runtime</module>
<module>adminshell</module>
- <!--
<module>cache-jbosscache</module>
- -->
<module>hibernate-dialect</module>
<module>jboss-integration</module>
<module>test-integration</module>
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -44,7 +44,6 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.metadata.TransformationMetadata.Resource;
-import org.teiid.query.tempdata.TempTableStore;
import org.teiid.vdb.runtime.VDBKey;
@@ -95,8 +94,6 @@
TransformationMetadata metadata = buildTransformationMetaData(mergedVDB, getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions, this.additionalStores);
mergedVDB.addAttchment(QueryMetadataInterface.class, metadata);
mergedVDB.addAttchment(TransformationMetadata.class, metadata);
- TempTableStore globalTables = new TempTableStore("SYSTEM"); //$NON-NLS-1$
- mergedVDB.addAttchment(TempTableStore.class, globalTables);
}
private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) {
@@ -134,6 +131,13 @@
return this.mergedVDB;
}
+ public boolean hasChildVdb(VDBKey child) {
+ if (this.children != null) {
+ return this.children.containsKey(child);
+ }
+ return false;
+ }
+
private VDBMetaData buildVDB() {
VDBMetaData newMergedVDB = new VDBMetaData();
newMergedVDB.setName(this.vdb.getName());
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -329,7 +329,7 @@
}
private String paramTable(String notIn) {
- return "SELECT dt.oid as oid, pp.Position as position, pp.Type as type FROM ProcedureParams pp LEFT JOIN matpg_datatype dt ON pp.DataType=dt.Name " + //$NON-NLS-1$
+ return "SELECT case when pp.Type <> 'ResultSet' AND pp.DataType = 'object' then 2283 else dt.oid end as oid, pp.Position as position, pp.Type as type FROM ProcedureParams pp LEFT JOIN matpg_datatype dt ON pp.DataType=dt.Name " + //$NON-NLS-1$
"WHERE pp.ProcedureName = t1.Name AND pp.SchemaName = t1.SchemaName AND pp.Type NOT IN ("+notIn+")"; //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -389,79 +389,45 @@
addColumn("typrelid", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
addColumn("typelem", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
-
String transformation =
- "SELECT 16 as oid, 'boolean' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- //"SELECT 17 as oid, 'blob' as typname,(SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- //" union " + //$NON-NLS-1$
- "SELECT 1043 as oid, 'string' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 25 as oid, 'text' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1042 as oid, 'char' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 21 as oid, 'short' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(2, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 20 as oid, 'long' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(8, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 23 as oid, 'integer' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(4, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 26 as oid, 'oid' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typname, convert(4, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 700 as oid, 'float' as typname,(SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(4, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 701 as oid, 'double' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(8, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- //"SELECT 1009 as oid, 'clob' as typname,(SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- //" union " + //$NON-NLS-1$
- "SELECT 1082 as oid, 'date' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(4, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1083 as oid, 'datetime' as typname,(SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(8, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1114 as oid, 'timestamp' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(8, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1700 as oid, 'decimal' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 142 as oid, 'xml' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 14939 as oid, 'lo' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X"+//$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 2278 as oid, 'void' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(4, short) as typlen, convert('p', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 2249 as oid, 'record' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('p', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 0 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 30 as oid, 'oidvector' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 26 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1000 as oid, '_bool' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 16 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1002 as oid, '_char' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 18 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1005 as oid, '_int2' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 21 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1007 as oid, '_int4' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 23 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1009 as oid, '_text' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 25 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1028 as oid, '_oid' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 26 as typelem FROM (SELECT 1) X" + //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1014 as oid, '_bpchar' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1042 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1015 as oid, '_varchar' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1043 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1016 as oid, '_int8' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 20 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1021 as oid, '_float4' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 700 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1022 as oid, '_float8' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 701 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1115 as oid, '_timestamp' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1114 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1182 as oid, '_date' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1082 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 1183 as oid, '_time' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 1083 as typelem FROM (SELECT 1) X"+ //$NON-NLS-1$
- " union " + //$NON-NLS-1$
- "SELECT 2287 as oid, '_record' as typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, convert(-1, short) as typlen, convert('b', char) as typtype, 0 as typbasetype, -1 as typtypmod, 0 as typrelid, 2249 as typelem FROM (SELECT 1) X"; //$NON-NLS-1$
+ "select oid, typname, (SELECT OID FROM SYS.Schemas where Name = 'SYS') as typnamespace, typlen, typtype, typbasetype, typtypmod, typrelid, typelem from texttable('" + //$NON-NLS-1$
+ "16,boolean,1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "1043,string,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "25,text,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "1042,char,1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "21,short,2,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "20,long,8,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "23,integer,4,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "26,oid,4,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "700,float,4,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "701,double,8,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "705,unknown,-2,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "1082,date,4,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "1083,datetime,8,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "1114,timestamp,8,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "1700,decimal,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "142,xml,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "14939,lo,-1,b,0,-1,0,0\n" + //$NON-NLS-1$
+ "2278,void,4,p,0,-1,0,0\n" + //$NON-NLS-1$
+ "2249,record,-1,p,0,-1,0,0\n" + //$NON-NLS-1$
+ "30,oidvector,-1,b,0,-1,0,26\n" + //$NON-NLS-1$
+ "1000,_bool,-1,b,0,-1,0,16\n" + //$NON-NLS-1$
+ "1002,_char,-1,b,0,-1,0,18\n" + //$NON-NLS-1$
+ "1005,_int2,-1,b,0,-1,0,21\n" + //$NON-NLS-1$
+ "1007,_int4,-1,b,0,-1,0,23\n" + //$NON-NLS-1$
+ "1009,_text,-1,b,0,-1,0,25\n" + //$NON-NLS-1$
+ "1028,_oid,-1,b,0,-1,0,26\n" + //$NON-NLS-1$
+ "1014,_bpchar,-1,b,0,-1,0,1042\n" + //$NON-NLS-1$
+ "1015,_varchar,-1,b,0,-1,0,1043\n" + //$NON-NLS-1$
+ "1016,_int8,-1,b,0,-1,0,20\n" + //$NON-NLS-1$
+ "1021,_float4,-1,b,0,-1,0,700\n" + //$NON-NLS-1$
+ "1022,_float8,-1,b,0,-1,0,701\n" + //$NON-NLS-1$
+ "1115,_timestamp,-1,b,0,-1,0,1114\n" + //$NON-NLS-1$
+ "1182,_date,-1,b,0,-1,0,1082\n" + //$NON-NLS-1$
+ "1183,_time,-1,b,0,-1,0,1083\n" + //$NON-NLS-1$
+ "2287,_record,-1,b,0,-1,0,2249\n" + //$NON-NLS-1$
+ "2283,anyelement,4,p,0,-1,0,0" + //$NON-NLS-1$
+ "' columns oid integer, typname string, typlen short, typtype char, typbasetype integer, typtypmod integer, typrelid integer, typelem integer) AS t"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
return t;
}
@@ -544,6 +510,7 @@
"WHEN (Name = 'time' ) THEN 'datetime' " + //$NON-NLS-1$
"WHEN (Name = 'biginteger' ) THEN 'decimal' " +//$NON-NLS-1$
"WHEN (Name = 'bigdecimal' ) THEN 'decimal' " +//$NON-NLS-1$
+ "WHEN (Name = 'object' ) THEN 'unknown' " +//$NON-NLS-1$
"ELSE Name END) as pg_name, Name, UID from SYS.DataTypes) as t ON t.pg_name = pt.typname"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,6 +22,6 @@
package org.teiid.deployers;
public interface VDBLifeCycleListener {
- void added(String name, int version);
- void removed(String name, int version);
+ void added(String name, int version, CompositeVDB vdb);
+ void removed(String name, int version, CompositeVDB vdb);
}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -81,7 +81,7 @@
cvdb = new CompositeVDB(vdb, stores, visibilityMap, udf, this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore);
}
this.vdbRepo.put(vdbId(vdb), cvdb);
- notifyAdd(vdb.getName(), vdb.getVersion());
+ notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
}
private void updateFromMetadataRepository(CompositeVDB cvdb) {
@@ -250,9 +250,15 @@
if (removed != null) {
// if this VDB was part of another VDB; then remove them.
for (CompositeVDB other:this.vdbRepo.values()) {
- other.removeChild(key);
+ if (other.hasChildVdb(key)) {
+ notifyRemove(other.getVDB().getName(), other.getVDB().getVersion(), other);
+
+ other.removeChild(key);
+
+ notifyAdd(other.getVDB().getName(), other.getVDB().getVersion(), other);
+ }
}
- notifyRemove(key.getName(), key.getVersion());
+ notifyRemove(key.getName(), key.getVersion(), removed);
return true;
}
return false;
@@ -282,9 +288,12 @@
if (target == null) {
throw new AdminProcessingException(RuntimePlugin.Util.getString("vdb_not_found", sourceVDBName, sourceVDBVersion)); //$NON-NLS-1$
}
-
+
+ notifyRemove(targetVDBName, targetVDBVersion, target);
// merge them
target.addChild(source);
+
+ notifyAdd(targetVDBName, targetVDBVersion, target);
}
// this is called by mc
@@ -310,15 +319,15 @@
this.listeners.remove(listener);
}
- private void notifyAdd(String name, int version) {
+ private void notifyAdd(String name, int version, CompositeVDB vdb) {
for(VDBLifeCycleListener l:this.listeners) {
- l.added(name, version);
+ l.added(name, version, vdb);
}
}
- private void notifyRemove(String name, int version) {
+ private void notifyRemove(String name, int version, CompositeVDB vdb) {
for(VDBLifeCycleListener l:this.listeners) {
- l.removed(name, version);
+ l.removed(name, version, vdb);
}
}
Modified: branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -21,7 +21,6 @@
*/
package org.teiid.odbc;
-import java.io.IOException;
import java.sql.ParameterMetaData;
import java.util.List;
import java.util.Properties;
@@ -81,7 +80,7 @@
void sendMoveCursor(ResultSetImpl rs, int rowCount, ResultsFuture<Integer> results);
- void sendCommandComplete(String sql, int updateCount) throws IOException;
+ void sendCommandComplete(String sql, int updateCount);
// CommandComplete (B)
void sendUpdateCount(String sql, int updateCount);
Modified: branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -21,7 +21,7 @@
*/
package org.teiid.odbc;
-import static org.teiid.odbc.PGUtil.convertType;
+import static org.teiid.odbc.PGUtil.*;
import java.io.IOException;
import java.io.StringReader;
@@ -40,6 +40,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.teiid.client.RequestMessage.ResultsMode;
import org.teiid.client.security.ILogon;
import org.teiid.client.security.LogonException;
import org.teiid.client.security.LogonResult;
@@ -207,7 +208,7 @@
else if (authType.equals(AuthenticationType.KRB5)) {
byte[] serviceToken = data.readServiceToken();
LogonResult result = this.logon.neogitiateGssLogin(this.props, serviceToken, false);
- if ((Boolean)result.getProperty(ILogon.KRB5_ESTABLISHED)) {
+ if (!Boolean.TRUE.equals(result.getProperty(ILogon.KRB5_ESTABLISHED))) {
serviceToken = (byte[])result.getProperty(ILogon.KRB5TOKEN);
this.client.authenticationGSSContinue(serviceToken);
return;
@@ -245,121 +246,88 @@
}
private void cursorExecute(final String cursorName, final String sql, final ResultsFuture<Integer> completion) {
- if (this.connection != null) {
- if (sql != null) {
- try {
- // close if the name is already used or the unnamed prepare; otherwise
- // stmt is alive until session ends.
- Prepared previous = this.preparedMap.remove(cursorName);
- if (previous != null) {
- previous.stmt.close();
- }
-
- final PreparedStatementImpl stmt = this.connection.prepareStatement(sql);
- this.executionFuture = stmt.submitExecute();
- this.executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
- @Override
- public void onCompletion(ResultsFuture<Boolean> future) {
- executionFuture = null;
- try {
- if (future.get()) {
- List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
- cursorMap.put(cursorName, new Cursor(cursorName, sql, stmt, null, stmt.getResultSet(), cols));
- client.sendCommandComplete("DECLARE CURSOR", 0); //$NON-NLS-1$
- }
- else {
- errorOccurred(RuntimePlugin.Util.getString("execution_failed")); //$NON-NLS-1$
- }
- } catch (Throwable e) {
- errorOccurred(e);
- }
- completion.getResultsReceiver().receiveResults(1);
- }
- });
- } catch (SQLException e) {
- errorOccurred(e);
- completion.getResultsReceiver().receiveResults(1);
- }
- }
+ if (sql != null) {
+ try {
+ // close if the name is already used or the unnamed prepare; otherwise
+ // stmt is alive until session ends.
+ Prepared previous = this.preparedMap.remove(cursorName);
+ if (previous != null) {
+ previous.stmt.close();
+ }
+
+ final PreparedStatementImpl stmt = this.connection.prepareStatement(sql);
+ this.executionFuture = stmt.submitExecute(ResultsMode.RESULTSET);
+ this.executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
+ @Override
+ public void onCompletion(ResultsFuture<Boolean> future) {
+ executionFuture = null;
+ try {
+ List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
+ cursorMap.put(cursorName, new Cursor(cursorName, sql, stmt, null, stmt.getResultSet(), cols));
+ client.sendCommandComplete("DECLARE CURSOR", 0); //$NON-NLS-1$
+ completion.getResultsReceiver().receiveResults(0);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
+ }
+ });
+ } catch (SQLException e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("no_active_connection")); //$NON-NLS-1$
- completion.getResultsReceiver().receiveResults(1);
- }
-
}
- private void cursorFetch(String cursorName, int rows, final ResultsFuture<Integer> completion) {
+ private void cursorFetch(String cursorName, int rows, final ResultsFuture<Integer> completion) throws SQLException {
Cursor cursor = this.cursorMap.get(cursorName);
- if (cursor != null) {
- cursor.fetchSize = rows;
- ResultsFuture<Integer> result = new ResultsFuture<Integer>();
- this.client.sendCursorResults(cursor.rs, cursor.columnMetadata, result, rows);
- result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
- public void onCompletion(ResultsFuture<Integer> future) {
- int rowsSent = 0;
- try {
- rowsSent = future.get();
- client.sendCommandComplete("FETCH", rowsSent); //$NON-NLS-1$
- } catch (InterruptedException e) {
- throw new AssertionError(e);
- } catch (ExecutionException e) {
- errorOccurred(e.getCause());
- } catch (IOException e) {
- errorOccurred(e);
- }
- completion.getResultsReceiver().receiveResults(rowsSent);
- };
- });
+ if (cursor == null) {
+ throw new SQLException(RuntimePlugin.Util.getString("not_bound", cursorName)); //$NON-NLS-1$
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("not_bound", cursorName)); //$NON-NLS-1$
- completion.getResultsReceiver().receiveResults(1);
- }
+ cursor.fetchSize = rows;
+ ResultsFuture<Integer> result = new ResultsFuture<Integer>();
+ this.client.sendCursorResults(cursor.rs, cursor.columnMetadata, result, rows);
+ result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
+ public void onCompletion(ResultsFuture<Integer> future) {
+ try {
+ int rowsSent = future.get();
+ client.sendCommandComplete("FETCH", rowsSent); //$NON-NLS-1$
+ completion.getResultsReceiver().receiveResults(rowsSent);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
+ };
+ });
}
- private void cursorMove(String prepareName, int rows, final ResultsFuture<Integer> completion) {
+ private void cursorMove(String prepareName, int rows, final ResultsFuture<Integer> completion) throws SQLException {
// win odbc driver sending a move after close; and error is ending up in failure; since the below
// is not harmful it is ok to send empty move.
if (rows == 0) {
- try {
- client.sendCommandComplete("MOVE", 0); //$NON-NLS-1$
- } catch (IOException e) {
- errorOccurred(e);
- }
+ client.sendCommandComplete("MOVE", 0); //$NON-NLS-1$
completion.getResultsReceiver().receiveResults(0);
return;
}
Cursor cursor = this.cursorMap.get(prepareName);
- if (cursor != null) {
- ResultsFuture<Integer> result = new ResultsFuture<Integer>();
- this.client.sendMoveCursor(cursor.rs, rows, result);
- result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
- public void onCompletion(ResultsFuture<Integer> future) {
- int rowsMoved = 0;
- try {
- rowsMoved = future.get();
- client.sendCommandComplete("MOVE", rowsMoved); //$NON-NLS-1$
- } catch (InterruptedException e) {
- throw new AssertionError(e);
- } catch (ExecutionException e) {
- errorOccurred(e.getCause());
- } catch (IOException e) {
- errorOccurred(e);
- }
- completion.getResultsReceiver().receiveResults(rowsMoved);
- };
- });
+ if (cursor == null) {
+ throw new SQLException(RuntimePlugin.Util.getString("not_bound", prepareName)); //$NON-NLS-1$
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("not_bound", prepareName)); //$NON-NLS-1$
- completion.getResultsReceiver().receiveResults(1);
- }
+ ResultsFuture<Integer> result = new ResultsFuture<Integer>();
+ this.client.sendMoveCursor(cursor.rs, rows, result);
+ result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
+ public void onCompletion(ResultsFuture<Integer> future) {
+ try {
+ int rowsMoved = future.get();
+ client.sendCommandComplete("MOVE", rowsMoved); //$NON-NLS-1$
+ completion.getResultsReceiver().receiveResults(rowsMoved);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
+ };
+ });
}
- private void cursorClose(String prepareName) throws SQLException, IOException {
+ private void cursorClose(String prepareName) throws SQLException {
Cursor cursor = this.cursorMap.remove(prepareName);
if (cursor != null) {
cursor.rs.close();
@@ -379,15 +347,8 @@
try {
ResultsFuture<Integer> result = new ResultsFuture<Integer>();
if (future.get()) {
- if (stmt.getResultSet() != null) {
- List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
- client.sendResults(sql, stmt.getResultSet(), cols, result, true);
- }
- else {
- // handles the "SET" commands.
- client.sendUpdateCount(sql, 0);
- result.getResultsReceiver().receiveResults(1);
- }
+ List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
+ client.sendResults(sql, stmt.getResultSet(), cols, result, true);
} else {
client.sendUpdateCount(sql, stmt.getUpdateCount());
setEncoding();
@@ -396,16 +357,20 @@
result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
public void onCompletion(ResultsFuture<Integer> future) {
try {
- stmt.close();
- } catch (SQLException e) {
- LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing statement"); //$NON-NLS-1$
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing statement"); //$NON-NLS-1$
+ }
+ future.get();
+ completion.getResultsReceiver().receiveResults(1);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
}
- completion.getResultsReceiver().receiveResults(1);
}
});
} catch (Throwable e) {
- errorOccurred(e);
- completion.getResultsReceiver().receiveResults(1);
+ completion.getResultsReceiver().exceptionOccurred(e);
}
}
});
@@ -413,33 +378,27 @@
@Override
public void prepare(String prepareName, String sql, int[] paramType) {
- if (this.connection != null) {
-
- if (prepareName == null || prepareName.length() == 0) {
- prepareName = UNNAMED;
- }
-
- if (sql != null) {
- String modfiedSQL = fixSQL(sql);
- try {
- // close if the name is already used or the unnamed prepare; otherwise
- // stmt is alive until session ends.
- Prepared previous = this.preparedMap.remove(prepareName);
- if (previous != null) {
- previous.stmt.close();
- }
+ if (prepareName == null || prepareName.length() == 0) {
+ prepareName = UNNAMED;
+ }
- PreparedStatementImpl stmt = this.connection.prepareStatement(modfiedSQL);
- this.preparedMap.put(prepareName, new Prepared(prepareName, sql, stmt, paramType));
- this.client.prepareCompleted(prepareName);
- } catch (SQLException e) {
- errorOccurred(e);
+ if (sql != null) {
+ String modfiedSQL = fixSQL(sql);
+ try {
+ // close if the name is already used or the unnamed prepare; otherwise
+ // stmt is alive until session ends.
+ Prepared previous = this.preparedMap.remove(prepareName);
+ if (previous != null) {
+ previous.stmt.close();
}
+
+ PreparedStatementImpl stmt = this.connection.prepareStatement(modfiedSQL);
+ this.preparedMap.put(prepareName, new Prepared(prepareName, sql, stmt, paramType));
+ this.client.prepareCompleted(prepareName);
+ } catch (SQLException e) {
+ errorOccurred(e);
}
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("no_active_connection")); //$NON-NLS-1$
- }
}
@Override
@@ -518,7 +477,7 @@
stmt.setMaxRows(maxRows);
}
- this.executionFuture = stmt.submitExecute();
+ this.executionFuture = stmt.submitExecute(ResultsMode.EITHER);
executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
@Override
public void onCompletion(ResultsFuture<Boolean> future) {
@@ -529,7 +488,6 @@
List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
client.sendResults(query.sql, stmt.getResultSet(), cols, result, true);
} else {
- // null future
client.sendUpdateCount(query.sql, stmt.getUpdateCount());
setEncoding();
result.getResultsReceiver().receiveResults(1);
@@ -573,8 +531,6 @@
throw new AssertionError(e);
} catch (ExecutionException e) {
errorOccurred(e.getCause());
- } catch (IOException e) {
- errorOccurred(e);
}
};
});
@@ -670,7 +626,7 @@
}
@Override
- public void executeQuery(final String query) {
+ public void executeQuery(String query) {
if (beginExecution()) {
errorOccurred("Awaiting asynch result"); //$NON-NLS-1$
ready();
@@ -679,12 +635,12 @@
//46.2.3 Note that a simple Query message also destroys the unnamed portal.
this.portalMap.remove(UNNAMED);
this.preparedMap.remove(UNNAMED);
-
- if (query.trim().length() == 0) {
- this.client.emptyQueryReceived();
+ query = query.trim();
+ if (query.length() == 0) {
+ client.emptyQueryReceived();
ready();
- return;
}
+
QueryWorkItem r = new QueryWorkItem(query);
r.run();
}
@@ -914,6 +870,15 @@
private QueryWorkItem(String query) {
this.reader = new ScriptReader(new StringReader(query));
}
+
+ private void done(Throwable error) {
+ if (error != null) {
+ errorOccurred(error);
+ } else {
+ doneExecuting();
+ }
+ ready();
+ }
@Override
public void run() {
@@ -933,10 +898,14 @@
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (IOException e) {
- client.errorOccurred(e);
+ done(e);
return;
} catch (ExecutionException e) {
- client.errorOccurred(e.getCause());
+ Throwable cause = e;
+ while (cause instanceof ExecutionException && cause.getCause() != null && cause != cause.getCause()) {
+ cause = cause.getCause();
+ }
+ done(cause);
return;
}
QueryWorkItem.this.run(); //continue processing
@@ -982,20 +951,23 @@
}
return; //wait for the execution to finish
} catch (SQLException e) {
- errorOccurred(e);
- break;
+ done(e);
+ return;
}
}
} catch(IOException e) {
- errorOccurred(e);
+ done(e);
+ return;
}
- doneExecuting();
- ready();
+ done(null);
}
}
private List<PgColInfo> getPgColInfo(ResultSetMetaData meta)
throws SQLException {
+ if (meta == null) {
+ return null;
+ }
int columns = meta.getColumnCount();
final ArrayList<PgColInfo> result = new ArrayList<PgColInfo>(columns);
for (int i = 1; i < columns + 1; i++) {
Modified: branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -393,13 +393,13 @@
}
@Override
- public void assosiateSubjectInContext(String securityDomain, Subject subject) {
+ public void associateSubjectInContext(String securityDomain, Subject subject) {
Principal principal = null;
for(Principal p:subject.getPrincipals()) {
principal = p;
break;
}
- this.securityHelper.assosiateSecurityContext(securityDomain, this.securityHelper.createSecurityContext(securityDomain, principal, null, subject));
+ this.securityHelper.associateSecurityContext(securityDomain, this.securityHelper.createSecurityContext(securityDomain, principal, null, subject));
}
public void setKrb5SecurityDomain(String domain) {
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -173,7 +173,7 @@
LogManager.logDetail(LogConstants.CTX_SECURITY, "Kerberos context established"); //$NON-NLS-1$
//connProps.setProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, "true"); //$NON-NLS-1$
- service.assosiateSubjectInContext(securityDomain, subject);
+ service.associateSubjectInContext(securityDomain, subject);
return logon(connProps, result.serviceTicket);
} catch (LoginException e) {
throw new LogonException(e, RuntimePlugin.Util.getString("krb5_login_failed")); //$NON-NLS-1$
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -21,6 +21,7 @@
*/
package org.teiid.transport;
+import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -90,6 +91,7 @@
@Override
public void exceptionOccurred(Throwable t) {
+ LogManager.log(t instanceof IOException?MessageLevel.DETAIL:MessageLevel.ERROR, LogConstants.CTX_ODBC, t, "Unhandled exception, closing client instance"); //$NON-NLS-1$
server.terminate();
}
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -36,6 +36,7 @@
public class ODBCSocketListener extends SocketListener {
private AuthenticationType authType = AuthenticationType.CLEARTEXT;
+ private int maxBufferSize = Integer.parseInt(System.getProperty("org.teiid.ODBCPacketSize", "307200")); //$NON-NLS-1$ //$NON-NLS-2$
private int maxLobSize;
private TeiidDriver driver;
private ILogon logonService;
@@ -59,6 +60,10 @@
public void setDriver(TeiidDriver driver) {
this.driver = driver;
}
+
+ public void setMaxBufferSize(int maxBufferSize) {
+ this.maxBufferSize = maxBufferSize;
+ }
@Override
protected SSLAwareChannelHandler createChannelPipelineFactory(final SSLConfiguration config, final StorageManager storageManager) {
@@ -67,7 +72,7 @@
ChannelPipeline pipeline = new DefaultChannelPipeline();
pipeline.addLast("odbcFrontendProtocol", new PgFrontendProtocol(1 << 20)); //$NON-NLS-1$
- pipeline.addLast("odbcBackendProtocol", new PgBackendProtocol(maxLobSize, config)); //$NON-NLS-1$
+ pipeline.addLast("odbcBackendProtocol", new PgBackendProtocol(maxLobSize, maxBufferSize, config)); //$NON-NLS-1$
pipeline.addLast("handler", this); //$NON-NLS-1$
return pipeline;
}
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,4 +1,3 @@
-
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
@@ -21,30 +20,13 @@
* 02110-1301 USA.
*/package org.teiid.transport;
-import static org.teiid.odbc.PGUtil.PG_TYPE_BOOL;
-import static org.teiid.odbc.PGUtil.PG_TYPE_BPCHAR;
-import static org.teiid.odbc.PGUtil.PG_TYPE_BYTEA;
-import static org.teiid.odbc.PGUtil.PG_TYPE_CHARARRAY;
-import static org.teiid.odbc.PGUtil.PG_TYPE_DATE;
-import static org.teiid.odbc.PGUtil.PG_TYPE_FLOAT4;
-import static org.teiid.odbc.PGUtil.PG_TYPE_FLOAT8;
-import static org.teiid.odbc.PGUtil.PG_TYPE_INT2;
-import static org.teiid.odbc.PGUtil.PG_TYPE_INT4;
-import static org.teiid.odbc.PGUtil.PG_TYPE_INT8;
-import static org.teiid.odbc.PGUtil.PG_TYPE_NUMERIC;
-import static org.teiid.odbc.PGUtil.PG_TYPE_OIDARRAY;
-import static org.teiid.odbc.PGUtil.PG_TYPE_OIDVECTOR;
-import static org.teiid.odbc.PGUtil.PG_TYPE_TEXT;
-import static org.teiid.odbc.PGUtil.PG_TYPE_TEXTARRAY;
-import static org.teiid.odbc.PGUtil.PG_TYPE_TIME;
-import static org.teiid.odbc.PGUtil.PG_TYPE_TIMESTAMP_NO_TMZONE;
-import static org.teiid.odbc.PGUtil.PG_TYPE_UNKNOWN;
-import static org.teiid.odbc.PGUtil.PG_TYPE_VARCHAR;
+import static org.teiid.odbc.PGUtil.*;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
import java.io.StreamCorruptedException;
+import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
@@ -61,6 +43,7 @@
import javax.net.ssl.SSLEngine;
import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBufferOutputStream;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelDownstreamHandler;
import org.jboss.netty.channel.ChannelEvent;
@@ -72,7 +55,6 @@
import org.jboss.netty.handler.ssl.SslHandler;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.util.ObjectConverterUtil;
-import org.teiid.core.util.ReaderInputStream;
import org.teiid.core.util.ReflectionHelper;
import org.teiid.jdbc.ResultSetImpl;
import org.teiid.jdbc.TeiidSQLException;
@@ -108,9 +90,6 @@
}
}
- // 300k
- static int ODBC_SOCKET_BUFF_SIZE = Integer.parseInt(System.getProperty("ODBCPacketSize", "307200"));
-
private final class ResultsWorkItem implements Runnable {
private final List<PgColInfo> cols;
private final ResultSetImpl rs;
@@ -118,13 +97,14 @@
private int rows2Send;
private int rowsSent = 0;
private int rowsInBuffer = 0;
- private ChannelBuffer buffer = ChannelBuffers.directBuffer(ODBC_SOCKET_BUFF_SIZE);
+ String sql;
private ResultsWorkItem(List<PgColInfo> cols, ResultSetImpl rs, ResultsFuture<Integer> result, int rows2Send) {
this.cols = cols;
this.rs = rs;
this.result = result;
this.rows2Send = rows2Send;
+ initBuffer(maxBufferSize / 8);
}
@Override
@@ -160,7 +140,7 @@
boolean processNext = true;
try {
if (future.get()) {
- sendDataRow(rs, cols, buffer);
+ sendDataRow(rs, cols);
rowsSent++;
rowsInBuffer++;
boolean done = rowsSent == rows2Send;
@@ -170,7 +150,10 @@
result.getResultsReceiver().receiveResults(rowsSent);
}
} else {
- sendContents(buffer);
+ sendContents();
+ if (sql != null) {
+ sendCommandComplete(sql, 0);
+ }
result.getResultsReceiver().receiveResults(rowsSent);
processNext = false;
}
@@ -182,31 +165,33 @@
}
private void flushResults(boolean force) {
- int avgRowsize = buffer.readableBytes()/rowsInBuffer;
- if (force || buffer.writableBytes() < (avgRowsize*2)) {
- sendContents(buffer);
- buffer= ChannelBuffers.directBuffer(ODBC_SOCKET_BUFF_SIZE);
+ int avgRowsize = dataOut.writerIndex()/rowsInBuffer;
+ if (force || (maxBufferSize - dataOut.writerIndex()) < (avgRowsize*2)) {
+ sendContents();
+ initBuffer(maxBufferSize / 8);
rowsInBuffer = 0;
}
}
}
- private DataOutputStream dataOut;
- private ByteArrayOutputStream outBuffer;
- private char messageType;
+ private ChannelBuffer dataOut;
+ private OutputStreamWriter writer;
+
private Properties props;
private Charset encoding = Charset.forName("UTF-8");
private ReflectionHelper clientProxy = new ReflectionHelper(ODBCClientRemote.class);
private ChannelHandlerContext ctx;
private MessageEvent message;
private int maxLobSize = (2*1024*1024); // 2 MB
+ private final int maxBufferSize;
private volatile ResultsFuture<Boolean> nextFuture;
private SSLConfiguration config;
- public PgBackendProtocol(int maxLobSize, SSLConfiguration config) {
+ public PgBackendProtocol(int maxLobSize, int maxBufferSize, SSLConfiguration config) {
this.maxLobSize = maxLobSize;
+ this.maxBufferSize = maxBufferSize;
this.config = config;
}
@@ -255,51 +240,39 @@
@Override
public void useAuthenticationGSS() {
- try {
- sendAuthenticationGSS();
- } catch (IOException e) {
- terminate(e);
- }
+ sendAuthenticationGSS();
}
@Override
public void authenticationGSSContinue(byte[] serviceToken) {
- try {
- sendAuthenticationGSSContinue(serviceToken);
- } catch (IOException e) {
- terminate(e);
- }
+ sendAuthenticationGSSContinue(serviceToken);
}
@Override
public void authenticationSucess(int processId, int screctKey) {
- try {
- sendAuthenticationOk();
- // server_version, server_encoding, client_encoding, application_name,
- // is_superuser, session_authorization, DateStyle, IntervalStyle, TimeZone,
- // integer_datetimes, and standard_conforming_strings.
- // (server_encoding, TimeZone, and integer_datetimes were not reported
- // by releases before 8.0; standard_conforming_strings was not reported by
- // releases before 8.1; IntervalStyle was not reported by releases before 8.4;
- // application_name was not reported by releases before 9.0.)
-
- sendParameterStatus("client_encoding", PGCharsetConverter.getEncoding(this.encoding));
- sendParameterStatus("DateStyle", this.props.getProperty("DateStyle", "ISO"));
- sendParameterStatus("integer_datetimes", "off");
- sendParameterStatus("is_superuser", "off");
- sendParameterStatus("server_encoding", "SQL_ASCII");
- sendParameterStatus("server_version", "8.1.4");
- sendParameterStatus("session_authorization", this.props.getProperty("user"));
- sendParameterStatus("standard_conforming_strings", "off");
- sendParameterStatus("application_name", this.props.getProperty("application_name", "ODBCClient"));
-
- // TODO PostgreSQL TimeZone
- sendParameterStatus("TimeZone", "CET");
-
- sendBackendKeyData(processId, screctKey);
- } catch (IOException e) {
- terminate(e);
- }
+ sendAuthenticationOk();
+ // server_version, server_encoding, client_encoding, application_name,
+ // is_superuser, session_authorization, DateStyle, IntervalStyle, TimeZone,
+ // integer_datetimes, and standard_conforming_strings.
+ // (server_encoding, TimeZone, and integer_datetimes were not reported
+ // by releases before 8.0; standard_conforming_strings was not reported by
+ // releases before 8.1; IntervalStyle was not reported by releases before 8.4;
+ // application_name was not reported by releases before 9.0.)
+
+ sendParameterStatus("client_encoding", PGCharsetConverter.getEncoding(this.encoding));
+ sendParameterStatus("DateStyle", this.props.getProperty("DateStyle", "ISO"));
+ sendParameterStatus("integer_datetimes", "off");
+ sendParameterStatus("is_superuser", "off");
+ sendParameterStatus("server_encoding", "SQL_ASCII");
+ sendParameterStatus("server_version", "8.1.4");
+ sendParameterStatus("session_authorization", this.props.getProperty("user"));
+ sendParameterStatus("standard_conforming_strings", "off");
+ sendParameterStatus("application_name", this.props.getProperty("application_name", "ODBCClient"));
+
+ // TODO PostgreSQL TimeZone
+ sendParameterStatus("TimeZone", "CET");
+
+ sendBackendKeyData(processId, screctKey);
}
@Override
@@ -314,29 +287,17 @@
@Override
public void errorOccurred(String msg) {
- try {
- sendErrorResponse(msg);
- } catch (IOException e) {
- terminate(e);
- }
+ sendErrorResponse(msg);
}
@Override
public void errorOccurred(Throwable t) {
- try {
- sendErrorResponse(t);
- } catch (IOException e) {
- terminate(e);
- }
+ sendErrorResponse(t);
}
@Override
public void ready(boolean inTransaction, boolean failedTransaction) {
- try {
- sendReadyForQuery(inTransaction, failedTransaction);
- } catch (IOException e) {
- terminate(e);
- }
+ sendReadyForQuery(inTransaction, failedTransaction);
}
public void setEncoding(String value) {
@@ -349,47 +310,35 @@
@Override
public void sendParameterDescription(ParameterMetaData meta, int[] paramType) {
try {
- try {
- int count = meta.getParameterCount();
- startMessage('t');
- writeShort(count);
- for (int i = 0; i < count; i++) {
- int type;
- if (paramType != null && paramType[i] != 0) {
- type = paramType[i];
- } else {
- type = convertType(meta.getParameterType(i+1));
- }
- writeInt(type);
+ int count = meta.getParameterCount();
+ startMessage('t');
+ writeShort(count);
+ for (int i = 0; i < count; i++) {
+ int type;
+ if (paramType != null && paramType[i] != 0) {
+ type = paramType[i];
+ } else {
+ type = convertType(meta.getParameterType(i+1));
}
- sendMessage();
- } catch (SQLException e) {
- sendErrorResponse(e);
- }
- } catch (IOException e) {
- terminate(e);
- }
+ writeInt(type);
+ }
+ sendMessage();
+ } catch (SQLException e) {
+ sendErrorResponse(e);
+ }
}
@Override
public void sendResultSetDescription(List<PgColInfo> cols) {
- try {
- sendRowDescription(cols);
- } catch (IOException e) {
- terminate(e);
- }
+ sendRowDescription(cols);
}
@Override
public void sendCursorResults(ResultSetImpl rs, List<PgColInfo> cols, ResultsFuture<Integer> result, int rowCount) {
- try {
- sendRowDescription(cols);
+ sendRowDescription(cols);
- ResultsWorkItem r = new ResultsWorkItem(cols, rs, result, rowCount);
- r.run();
- } catch (IOException e) {
- terminate(e);
- }
+ ResultsWorkItem r = new ResultsWorkItem(cols, rs, result, rowCount);
+ r.run();
}
@Override
@@ -401,48 +350,36 @@
@Override
public void sendMoveCursor(ResultSetImpl rs, int rowCount, ResultsFuture<Integer> results) {
try {
- try {
- int rowsMoved = 0;
- for (int i = 0; i < rowCount; i++) {
- if (!rs.next()) {
- break;
- }
- rowsMoved++;
- }
- results.getResultsReceiver().receiveResults(rowsMoved);
- } catch (SQLException e) {
- sendErrorResponse(e);
- }
- } catch (IOException e) {
- terminate(e);
+ int rowsMoved = 0;
+ for (int i = 0; i < rowCount; i++) {
+ if (!rs.next()) {
+ break;
+ }
+ rowsMoved++;
+ }
+ results.getResultsReceiver().receiveResults(rowsMoved);
+ } catch (SQLException e) {
+ sendErrorResponse(e);
}
}
@Override
public void sendResults(final String sql, final ResultSetImpl rs, List<PgColInfo> cols, ResultsFuture<Integer> result, boolean describeRows) {
- try {
- if (nextFuture != null) {
- sendErrorResponse(new IllegalStateException("Pending results have not been sent")); //$NON-NLS-1$
- }
-
- if (describeRows) {
- sendRowDescription(cols);
- }
- ResultsWorkItem r = new ResultsWorkItem(cols, rs, result, -1);
- r.run();
- sendCommandComplete(sql, 0);
- } catch (IOException e) {
- terminate(e);
+ if (nextFuture != null) {
+ sendErrorResponse(new IllegalStateException("Pending results have not been sent")); //$NON-NLS-1$
}
+
+ if (describeRows) {
+ sendRowDescription(cols);
+ }
+ ResultsWorkItem r = new ResultsWorkItem(cols, rs, result, -1);
+ r.sql = sql;
+ r.run();
}
@Override
public void sendUpdateCount(String sql, int updateCount) {
- try {
- sendCommandComplete(sql, updateCount);
- } catch (IOException e) {
- terminate(e);
- }
+ sendCommandComplete(sql, updateCount);
}
@Override
@@ -453,24 +390,16 @@
@Override
public void terminated() {
- try {
- trace("channel being terminated");
- this.sendNoticeResponse("Connection closed");
- this.ctx.getChannel().close();
- } catch (IOException e) {
- trace(e.getMessage());
- }
+ trace("channel being terminated");
+ this.sendNoticeResponse("Connection closed");
+ this.ctx.getChannel().close();
}
@Override
public void flush() {
- try {
- this.dataOut.flush();
- this.dataOut = null;
- Channels.write(this.ctx.getChannel(), null);
- } catch (IOException e) {
- terminate(e);
- }
+ this.dataOut = null;
+ this.writer = null;
+ Channels.write(this.ctx.getChannel(), null);
}
@Override
@@ -489,7 +418,7 @@
}
@Override
- public void sendCommandComplete(String sql, int updateCount) throws IOException {
+ public void sendCommandComplete(String sql, int updateCount) {
startMessage('C');
sql = sql.trim().toUpperCase();
// TODO remove remarks at the beginning
@@ -526,32 +455,24 @@
sendMessage();
}
- private void sendDataRow(ResultSet rs, List<PgColInfo> cols, ChannelBuffer buffer) throws SQLException, IOException {
- startMessage('D');
+ private void sendDataRow(ResultSet rs, List<PgColInfo> cols) throws SQLException, IOException {
+ startMessage('D', -1);
+ int lengthIndex = this.dataOut.writerIndex() - 4;
writeShort(cols.size());
for (int i = 0; i < cols.size(); i++) {
- byte[] bytes = getContent(rs, cols.get(i), i+1);
- if (bytes == null) {
- writeInt(-1);
- } else {
- writeInt(bytes.length);
- write(bytes);
+ int dataBytesIndex = this.dataOut.writerIndex();
+ writeInt(-1);
+ getContent(rs, cols.get(i), i+1);
+ writer.flush();
+ if (!rs.wasNull()) {
+ int bytes = this.dataOut.writerIndex() - dataBytesIndex - 4;
+ this.dataOut.setInt(dataBytesIndex, bytes);
}
}
-
- byte[] buff = outBuffer.toByteArray();
- int len = buff.length;
- this.outBuffer = null;
- this.dataOut = null;
-
- // now build the wire contents.
- buffer.writeByte((byte)this.messageType);
- buffer.writeInt(len+4);
- buffer.writeBytes(buff);
+ this.dataOut.setInt(lengthIndex, this.dataOut.writerIndex() - lengthIndex);
}
- private byte[] getContent(ResultSet rs, PgColInfo col, int column) throws SQLException, TeiidSQLException, IOException {
- byte[] bytes = null;
+ private void getContent(ResultSet rs, PgColInfo col, int column) throws SQLException, TeiidSQLException, IOException {
switch (col.type) {
case PG_TYPE_BOOL:
case PG_TYPE_BPCHAR:
@@ -567,14 +488,19 @@
case PG_TYPE_VARCHAR:
String value = rs.getString(column);
if (value != null) {
- bytes = value.getBytes(this.encoding);
+ writer.write(value);
}
break;
case PG_TYPE_TEXT:
Clob clob = rs.getClob(column);
if (clob != null) {
- bytes = ObjectConverterUtil.convertToByteArray(new ReaderInputStream(clob.getCharacterStream(), this.encoding), this.maxLobSize);
+ Reader r = clob.getCharacterStream();
+ try {
+ ObjectConverterUtil.write(writer, r, this.maxLobSize, false);
+ } finally {
+ r.close();
+ }
}
break;
@@ -582,7 +508,8 @@
Blob blob = rs.getBlob(column);
if (blob != null) {
try {
- bytes = PGbytea.toPGString(ObjectConverterUtil.convertToByteArray(blob.getBinaryStream(), this.maxLobSize)).getBytes(this.encoding);
+ String blobString = PGbytea.toPGString(ObjectConverterUtil.convertToByteArray(blob.getBinaryStream(), this.maxLobSize));
+ writer.write(blobString);
} catch(OutOfMemoryError e) {
throw new StreamCorruptedException("data too big: " + e.getMessage()); //$NON-NLS-1$
}
@@ -595,25 +522,25 @@
{
Object[] obj = (Object[])rs.getObject(column);
if (obj != null) {
- StringBuilder sb = new StringBuilder();
- sb.append("{");
+ writer.append("{");
boolean first = true;
for (Object o:obj) {
if (!first) {
- sb.append(",");
+ writer.append(",");
}
else {
first = false;
}
- if (col.type == PG_TYPE_TEXTARRAY) {
- escapeQuote(sb, o.toString());
+ if (o != null) {
+ if (col.type == PG_TYPE_TEXTARRAY) {
+ escapeQuote(writer, o.toString());
+ }
+ else {
+ writer.append(o.toString());
+ }
}
- else {
- sb.append(o.toString());
- }
}
- sb.append("}");
- bytes = sb.toString().getBytes(this.encoding);
+ writer.append("}");
}
}
break;
@@ -622,18 +549,18 @@
{
Object[] obj = (Object[])rs.getObject(column);
if (obj != null) {
- StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object o:obj) {
if (!first) {
- sb.append(" ");
+ writer.append(" ");
}
else {
first = false;
}
- sb.append(o);
+ if (o != null) {
+ writer.append(o.toString());
+ }
}
- bytes = sb.toString().getBytes(this.encoding);
}
}
break;
@@ -641,10 +568,9 @@
default:
throw new TeiidSQLException("unknown datatype failed to convert");
}
- return bytes;
}
- public static void escapeQuote(StringBuilder sb, String s) {
+ public static void escapeQuote(Writer sb, String s) throws IOException {
sb.append('"');
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
@@ -667,7 +593,7 @@
} catch (GeneralSecurityException e) {
LogManager.logError(LogConstants.CTX_ODBC, e, RuntimePlugin.Util.getString("PgBackendProtocol.ssl_error"));
}
- ChannelBuffer buffer = ChannelBuffers.directBuffer(1);
+ ChannelBuffer buffer = ctx.getChannel().getConfig().getBufferFactory().getBuffer(1);
if (engine == null) {
buffer.writeByte('N');
} else {
@@ -677,7 +603,7 @@
Channels.write(this.ctx, this.message.getFuture(), buffer, this.message.getRemoteAddress());
}
- private void sendErrorResponse(Throwable t) throws IOException {
+ private void sendErrorResponse(Throwable t) {
trace(t.getMessage());
SQLException e = TeiidSQLException.create(t);
startMessage('E');
@@ -693,7 +619,13 @@
sendMessage();
}
- private void sendRowDescription(List<PgColInfo> cols) throws IOException {
+ private void sendRowDescription(List<PgColInfo> cols) {
+ if (cols == null) {
+ //send NoData
+ startMessage('n');
+ sendMessage();
+ return;
+ }
startMessage('T');
writeShort(cols.size());
for (PgColInfo info : cols) {
@@ -723,7 +655,7 @@
}
}
- private void sendErrorResponse(String message) throws IOException {
+ private void sendErrorResponse(String message) {
trace("Exception:", message);
startMessage('E');
write('S');
@@ -736,7 +668,7 @@
sendMessage();
}
- private void sendNoticeResponse(String message) throws IOException {
+ private void sendNoticeResponse(String message) {
trace("notice:", message);
startMessage('N');
write('S');
@@ -768,26 +700,26 @@
sendMessage();
}
- private void sendAuthenticationGSS() throws IOException {
+ private void sendAuthenticationGSS() {
startMessage('R');
writeInt(7);
sendMessage();
}
- private void sendAuthenticationGSSContinue(byte[] serviceToken) throws IOException {
+ private void sendAuthenticationGSSContinue(byte[] serviceToken) {
startMessage('R');
writeInt(8);
write(serviceToken);
sendMessage();
}
- private void sendAuthenticationOk() throws IOException {
+ private void sendAuthenticationOk() {
startMessage('R');
writeInt(0);
sendMessage();
}
- private void sendReadyForQuery(boolean inTransaction, boolean failedTransaction) throws IOException {
+ private void sendReadyForQuery(boolean inTransaction, boolean failedTransaction) {
startMessage('Z');
char c;
if (failedTransaction) {
@@ -807,14 +739,14 @@
sendMessage();
}
- private void sendBackendKeyData(int processId, int screctKey) throws IOException {
+ private void sendBackendKeyData(int processId, int screctKey) {
startMessage('K');
writeInt(processId);
writeInt(screctKey);
sendMessage();
}
- private void sendParameterStatus(String param, String value) throws IOException {
+ private void sendParameterStatus(String param, String value) {
startMessage('S');
writeString(param);
writeString(value);
@@ -823,76 +755,75 @@
@Override
public void functionCallResponse(byte[] data) {
- try {
- startMessage('V');
- if (data == null) {
- writeInt(-1);
- }
- else {
- writeInt(data.length);
- write(data);
- }
- sendMessage();
- } catch (IOException e) {
- terminate(e);
- }
+ startMessage('V');
+ if (data == null) {
+ writeInt(-1);
+ }
+ else {
+ writeInt(data.length);
+ write(data);
+ }
+ sendMessage();
}
@Override
public void functionCallResponse(int data) {
- try {
- startMessage('V');
- writeInt(4);
- writeInt(data);
- sendMessage();
- } catch (IOException e) {
- terminate(e);
- }
+ startMessage('V');
+ writeInt(4);
+ writeInt(data);
+ sendMessage();
}
- private void writeString(String s) throws IOException {
+ private void writeString(String s) {
write(s.getBytes(this.encoding));
write(0);
}
- private void writeInt(int i) throws IOException {
+ private void writeInt(int i) {
dataOut.writeInt(i);
}
- private void writeShort(int i) throws IOException {
+ private void writeShort(int i) {
dataOut.writeShort(i);
}
- private void write(byte[] data) throws IOException {
- dataOut.write(data);
+ private void write(byte[] data) {
+ dataOut.writeBytes(data);
}
- private void write(int b) throws IOException {
- dataOut.write(b);
+ private void write(int b) {
+ dataOut.writeByte(b);
}
private void startMessage(char newMessageType) {
- this.messageType = newMessageType;
- this.outBuffer = new ByteArrayOutputStream();
- this.dataOut = new DataOutputStream(this.outBuffer);
+ startMessage(newMessageType, 32);
}
+ private void startMessage(char newMessageType, int estimatedLength) {
+ if (estimatedLength > -1) {
+ initBuffer(estimatedLength);
+ }
+ this.dataOut.writeByte((byte)newMessageType);
+ this.dataOut.writerIndex(this.dataOut.writerIndex() + 4);
+ }
+
+ private void initBuffer(int estimatedLength) {
+ this.dataOut = ChannelBuffers.dynamicBuffer(estimatedLength);
+ ChannelBufferOutputStream cbos = new ChannelBufferOutputStream(this.dataOut);
+ this.writer = new OutputStreamWriter(cbos, this.encoding);
+ }
+
private void sendMessage() {
- byte[] buff = outBuffer.toByteArray();
- int len = buff.length;
- this.outBuffer = null;
- this.dataOut = null;
-
- // now build the wire contents.
- ChannelBuffer buffer = ChannelBuffers.directBuffer(len+5);
- buffer.writeByte((byte)this.messageType);
- buffer.writeInt(len+4);
- buffer.writeBytes(buff);
- Channels.write(this.ctx, this.message.getFuture(), buffer, this.message.getRemoteAddress());
+ int pos = this.dataOut.writerIndex();
+ this.dataOut.setInt(1, pos - 1);
+ sendContents();
}
- private void sendContents(ChannelBuffer buffer) {
- Channels.write(this.ctx, this.message.getFuture(), buffer, this.message.getRemoteAddress());
+ private void sendContents() {
+ ChannelBuffer cb = this.dataOut;
+ this.dataOut = null;
+ this.writer = null;
+ Channels.write(this.ctx, this.message.getFuture(), cb, this.message.getRemoteAddress());
}
private static void trace(String... msg) {
Modified: branches/as7/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- branches/as7/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-09-05 14:27:44 UTC (rev 3451)
@@ -82,7 +82,6 @@
name_not_found=Translator property "name" not defined for the deployment "{0}"
translator_type_not_found=The parent translator defined not found in configuration "{0}"
failed_to_load_odbc_metadata=Failed to load the ODBC metadata repository.
-no_active_connection=No active connection found
bad_binding=Binding on a statement, that has not been prepared:{0}
not_bound=No bound statement found with name {0}
no_stmt_found=No prepared statement found with name {0}
@@ -92,7 +91,6 @@
ambigious_name=Ambiguous VDB name specified. Only single occurrence of the "." is allowed in the VDB name. Also, when version based vdb name is specified, then a separate "version" connection option is not allowed:{0}.{1}
lo_not_supported=LO functions are not supported
SSLConfiguration.no_anonymous=The anonymous cipher suite TLS_DH_anon_WITH_AES_128_CBC_SHA is not available. Please change the transport to be non-SSL or use non-anonymous SSL.
-execution_failed=Cursor execution failed
PgBackendProtocol.ssl_error=Could not initialize ODBC SSL. non-SSL connections will still be allowed.
wrong_logon_type_jaas = Wrong logon method is being used. Server is not set up for JAAS based authentication. Correct your client's 'AuthenticationType' property.
Modified: branches/as7/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
===================================================================
--- branches/as7/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -149,8 +149,13 @@
@Test public void testRemoveChild() throws Exception {
CompositeVDB vdb = createCompositeVDB(RealMetadataFactory.exampleBQTStore(), "bqt");
- vdb.removeChild(new VDBKey("foo", 1));
+ VDBKey child = new VDBKey("foo", 1);
+ vdb.removeChild(child);
assertNotNull(vdb.getVDB());
+ assertFalse(vdb.hasChildVdb(child));
+ vdb.addChild(createCompositeVDB(RealMetadataFactory.example1Store(), "foo"));
+ assertTrue(vdb.hasChildVdb(child));
+ assertNotNull(vdb.getVDB());
}
}
Modified: branches/as7/test-integration/common/pom.xml
===================================================================
--- branches/as7/test-integration/common/pom.xml 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/test-integration/common/pom.xml 2011-09-05 14:27:44 UTC (rev 3451)
@@ -20,6 +20,18 @@
<artifactId>h2</artifactId>
<version>1.2.147</version>
</dependency>
+ <dependency>
+ <artifactId>teiid-cache-jbosscache</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ </dependency>
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: branches/as7/test-integration/common/src/test/java/org/teiid/cdk/api/TestTranslationUtility.java
===================================================================
--- branches/as7/test-integration/common/src/test/java/org/teiid/cdk/api/TestTranslationUtility.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/test-integration/common/src/test/java/org/teiid/cdk/api/TestTranslationUtility.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -22,16 +22,15 @@
package org.teiid.cdk.api;
+import static org.junit.Assert.assertEquals;
import junit.framework.TestCase;
-import org.teiid.cdk.api.TranslationUtility;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.language.Command;
import org.teiid.language.NamedTable;
import org.teiid.language.Select;
import org.teiid.metadata.AbstractMetadataRecord;
-
public class TestTranslationUtility extends TestCase {
/**
Modified: branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -23,12 +23,7 @@
import java.io.File;
import java.security.Principal;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
import javax.security.auth.Subject;
@@ -44,10 +39,7 @@
import org.teiid.cache.DefaultCacheFactory;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
-import org.teiid.deployers.MetadataStoreGroup;
-import org.teiid.deployers.UDFMetaData;
-import org.teiid.deployers.VDBRepository;
-import org.teiid.deployers.VirtualDatabaseException;
+import org.teiid.deployers.*;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.FakeTransactionService;
@@ -62,10 +54,14 @@
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.function.SystemFunctionManager;
+import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.metadata.TransformationMetadata.Resource;
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.SecurityHelper;
import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.ClientServiceRegistry;
@@ -82,11 +78,16 @@
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) {
Map<String, SecurityDomainContext> securityDomainMap = new HashMap<String, SecurityDomainContext>();
@@ -123,7 +124,26 @@
sessionService.setSecurityDomains(Arrays.asList("somedomain"), securityDomainMap);
this.logon = new LogonImpl(sessionService, null);
-
+ this.repo.addListener(new VDBLifeCycleListener() {
+
+ @Override
+ public void removed(String name, int version, CompositeVDB vdb) {
+
+ }
+
+ @Override
+ public void added(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();
Copied: branches/as7/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewReplication.java (from rev 3450, trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewReplication.java)
===================================================================
--- branches/as7/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewReplication.java (rev 0)
+++ branches/as7/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewReplication.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -0,0 +1,141 @@
+/*
+ * 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.systemmodel;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jgroups.JChannelFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.jdbc.FakeServer;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.Determinism;
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.replication.jboss.JGroupsObjectReplicator;
+
+@SuppressWarnings("nls")
+public class TestMatViewReplication {
+
+ private static final String MATVIEWS = "matviews";
+ private static final boolean DEBUG = false;
+
+ @BeforeClass public static void oneTimeSetup() {
+ System.setProperty("jgroups.bind_addr", "127.0.0.1");
+ }
+
+ @Test public void testReplication() throws Exception {
+ if (DEBUG) {
+ Logger logger = Logger.getLogger("org.teiid");
+ logger.setLevel(Level.FINEST);
+ for (Handler h : logger.getHandlers()) {
+ h.setLevel(Level.FINEST);
+ }
+ /*org.apache.log4j.Logger l = LogManager.getLogger("org.jgroups");
+ l.setLevel(org.apache.log4j.Level.TRACE);
+ ConsoleAppender ca = new ConsoleAppender(new PatternLayout());
+ ca.setName("x");
+ l.addAppender(ca);*/
+ }
+
+ FakeServer server1 = createServer();
+
+ Connection c1 = server1.createConnection("jdbc:teiid:matviews");
+ Statement stmt = c1.createStatement();
+ stmt.execute("select * from TEST.RANDOMVIEW");
+ ResultSet rs = stmt.getResultSet();
+ assertTrue(rs.next());
+ double d1 = rs.getDouble(1);
+ double d2 = rs.getDouble(2);
+
+ FakeServer server2 = createServer();
+ Connection c2 = server2.createConnection("jdbc:teiid:matviews");
+ Statement stmt2 = c2.createStatement();
+ ResultSet rs2 = stmt2.executeQuery("select * from matviews where name = 'RandomView'");
+ assertTrue(rs2.next());
+ assertEquals("LOADED", rs2.getString("loadstate"));
+ assertEquals(true, rs2.getBoolean("valid"));
+ stmt2.execute("select * from TEST.RANDOMVIEW");
+ rs2 = stmt2.getResultSet();
+ assertTrue(rs2.next());
+ assertEquals(d1, rs2.getDouble(1), 0);
+ assertEquals(d2, rs2.getDouble(2), 0);
+
+ rs2 = stmt2.executeQuery("select * from (call refreshMatView('TEST.RANDOMVIEW', false)) p");
+
+ Thread.sleep(1000);
+
+ //make sure we're still valid and the same
+ stmt.execute("select * from TEST.RANDOMVIEW");
+ rs = stmt.getResultSet();
+ assertTrue(rs.next());
+ d1 = rs.getDouble(1);
+ d2 = rs.getDouble(2);
+ stmt2.execute("select * from TEST.RANDOMVIEW");
+ rs2 = stmt2.getResultSet();
+ assertTrue(rs2.next());
+ assertEquals(d1, rs2.getDouble(1), 0);
+ assertEquals(d2, rs2.getDouble(2), 0);
+
+ //ensure a lookup is usable on each side
+ rs2 = stmt2.executeQuery("select lookup('sys.schemas', 'VDBName', 'name', 'SYS')");
+ Thread.sleep(1000);
+
+ rs = stmt.executeQuery("select lookup('sys.schemas', 'VDBName', 'name', 'SYS')");
+ rs.next();
+ assertEquals("matviews", rs.getString(1));
+
+ server1.stop();
+ server2.stop();
+ }
+
+ private FakeServer createServer() throws Exception {
+ FakeServer server = new FakeServer();
+
+ JGroupsObjectReplicator jor = new JGroupsObjectReplicator();
+ jor.setClusterName("demo");
+ jor.setMultiplexerStack("tcp");
+ JChannelFactory jcf = new JChannelFactory();
+ jcf.setMultiplexerConfig(this.getClass().getClassLoader().getResource("stacks.xml")); //$NON-NLS-1$
+ jor.setChannelFactory(jcf);
+
+ server.setReplicator(jor);
+ 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), false, Determinism.NONDETERMINISTIC)));
+ server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", udfs);
+ return server;
+ }
+
+}
Modified: branches/as7/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
--- branches/as7/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2011-09-05 14:27:44 UTC (rev 3451)
@@ -130,7 +130,7 @@
config.setBindAddress(addr.getHostName());
config.setPortNumber(0);
odbcTransport = new ODBCSocketListener(config, BufferManagerFactory.getStandaloneBufferManager(), 0, 100000, Mockito.mock(ILogon.class));
-
+ odbcTransport.setMaxBufferSize(1000); //set to a small size to ensure buffering over the limit works
FakeServer server = new FakeServer();
server.setUseCallingThread(false);
server.deployVDB("parts", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
@@ -181,6 +181,18 @@
TestMMDatabaseMetaData.compareResultSet(s.getResultSet());
}
+ @Test public void testMultibatchSelect() throws Exception {
+ Statement s = conn.createStatement();
+ assertTrue(s.execute("select * from tables, columns"));
+ ResultSet rs = s.getResultSet();
+ int i = 0;
+ while (rs.next()) {
+ i++;
+ rs.getString(1);
+ }
+ assertEquals(7812, i);
+ }
+
@Test public void testBlob() throws Exception {
Statement s = conn.createStatement();
assertTrue(s.execute("select to_bytes('abc', 'UTF-16')"));
@@ -199,6 +211,16 @@
String clob = rs.getString(1);
assertEquals("abc", clob);
}
+
+ @Test public void testLargeClob() throws Exception {
+ Statement s = conn.createStatement();
+ assertTrue(s.execute("select cast(repeat('_', 3000) as clob)"));
+ ResultSet rs = s.getResultSet();
+ assertTrue(rs.next());
+ //getting as a clob is unsupported, since it uses the lo logic
+ String clob = rs.getString(1);
+ assertEquals(3000, clob.length());
+ }
@Test public void testTransactionCycle() throws Exception {
//TODO: drill in to ensure that the underlying statement has been set to autocommit false
@@ -276,6 +298,14 @@
rs.next();
}
+ @Test public void testPreparedUpdate() throws Exception {
+ Statement stmt = conn.createStatement();
+ assertFalse(stmt.execute("create local temporary table x (y string)"));
+ PreparedStatement ps = conn.prepareStatement("delete from x");
+ assertFalse(ps.execute());
+ assertNull(ps.getMetaData());
+ }
+
@Test public void testSelectSsl() throws Exception {
conn.close();
Driver d = new Driver();
Property changes on: branches/as7/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java:3149-3217,3281-3325
/trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java:3188-3382
+ /branches/7.4.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java:3149-3217,3281-3325
/trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java:3188-3450
Modified: branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
===================================================================
--- branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2011-09-05 14:27:44 UTC (rev 3451)
@@ -209,10 +209,10 @@
207 25 proretset 16 1 3 4 false false false
208 25 prorettype 23 4 4 4 false false false
209 25 pronargs 21 2 5 4 false false false
-210 25 proargtypes <null> <null> 6 4 false false false
-211 25 proargnames <null> <null> 7 4 false false false
-212 25 proargmodes <null> <null> 8 4 false false false
-213 25 proallargtypes <null> <null> 9 4 false false false
+210 25 proargtypes 705 -2 6 4 false false false
+211 25 proargnames 705 -2 7 4 false false false
+212 25 proargmodes 705 -2 8 4 false false false
+213 25 proallargtypes 705 -2 9 4 false false false
214 25 pronamespace 23 4 10 4 false false false
215 26 oid 23 4 1 4 false false false
216 26 tgconstrrelid 23 4 2 4 false false false
@@ -232,8 +232,8 @@
230 28 encoding 23 4 3 4 false false false
231 28 datlastsysoid 23 4 4 4 false false false
232 28 datallowconn 1042 1 5 4 false false false
-233 28 datconfig <null> <null> 6 4 false false false
-234 28 datacl <null> <null> 7 4 false false false
+233 28 datconfig 705 -2 6 4 false false false
+234 28 datacl 705 -2 7 4 false false false
235 28 datdba 23 4 8 4 false false false
236 28 dattablespace 23 4 9 4 false false false
237 29 oid 23 4 1 4 false false false
Modified: branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_TYPE.expected
===================================================================
--- branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_TYPE.expected 2011-09-03 22:46:04 UTC (rev 3450)
+++ branches/as7/test-integration/common/src/test/resources/TestODBCSchema/test_PG_TYPE.expected 2011-09-05 14:27:44 UTC (rev 3451)
@@ -1,40 +1,42 @@
integer string integer short char integer integer integer integer
oid typname typnamespace typlen typtype typbasetype typtypmod typrelid typelem
16 boolean 3 1 b 0 -1 0 0
+1043 string 3 -1 b 0 -1 0 0
+25 text 3 -1 b 0 -1 0 0
+1042 char 3 1 b 0 -1 0 0
+21 short 3 2 b 0 -1 0 0
20 long 3 8 b 0 -1 0 0
-21 short 3 2 b 0 -1 0 0
23 integer 3 4 b 0 -1 0 0
-25 text 3 -1 b 0 -1 0 0
26 oid 3 4 b 0 -1 0 0
-30 oidvector 3 -1 b 0 -1 0 26
-142 xml 3 -1 b 0 -1 0 0
700 float 3 4 b 0 -1 0 0
701 double 3 8 b 0 -1 0 0
+705 unknown 3 -2 b 0 -1 0 0
+1082 date 3 4 b 0 -1 0 0
+1083 datetime 3 8 b 0 -1 0 0
+1114 timestamp 3 8 b 0 -1 0 0
+1700 decimal 3 -1 b 0 -1 0 0
+142 xml 3 -1 b 0 -1 0 0
+14939 lo 3 -1 b 0 -1 0 0
+2278 void 3 4 p 0 -1 0 0
+2249 record 3 -1 p 0 -1 0 0
+30 oidvector 3 -1 b 0 -1 0 26
1000 _bool 3 -1 b 0 -1 0 16
1002 _char 3 -1 b 0 -1 0 18
1005 _int2 3 -1 b 0 -1 0 21
1007 _int4 3 -1 b 0 -1 0 23
1009 _text 3 -1 b 0 -1 0 25
+1028 _oid 3 -1 b 0 -1 0 26
1014 _bpchar 3 -1 b 0 -1 0 1042
1015 _varchar 3 -1 b 0 -1 0 1043
1016 _int8 3 -1 b 0 -1 0 20
1021 _float4 3 -1 b 0 -1 0 700
1022 _float8 3 -1 b 0 -1 0 701
-1028 _oid 3 -1 b 0 -1 0 26
-1042 char 3 1 b 0 -1 0 0
-1043 string 3 -1 b 0 -1 0 0
-1082 date 3 4 b 0 -1 0 0
-1083 datetime 3 8 b 0 -1 0 0
-1114 timestamp 3 8 b 0 -1 0 0
1115 _timestamp 3 -1 b 0 -1 0 1114
1182 _date 3 -1 b 0 -1 0 1082
1183 _time 3 -1 b 0 -1 0 1083
-1700 decimal 3 -1 b 0 -1 0 0
-2249 record 3 -1 p 0 -1 0 0
-2278 void 3 4 p 0 -1 0 0
2287 _record 3 -1 b 0 -1 0 2249
-14939 lo 3 -1 b 0 -1 0 0
-Row Count : 34
+2283 anyelement 3 4 p 0 -1 0 0
+Row Count : 36
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_type 11 10 0 false false false false 2 true true false false
typname 12 PartsSupplier java.lang.String typname string pg_catalog pg_type 4000 4000 0 false false false false 2 true true false false
Property changes on: branches/as7/test-integration/common/src/test/resources/TestODBCSocketTransport/testPk.expected
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/test-integration/common/src/test/resources/TestODBCSocketTransport/testPk.expected:3281-3325
/trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPk.expected:3188-3382
+ /branches/7.4.x/test-integration/common/src/test/resources/TestODBCSocketTransport/testPk.expected:3281-3325
/trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPk.expected:3188-3450
Property changes on: branches/as7/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected:3281-3325
/trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected:3188-3382
+ /branches/7.4.x/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected:3281-3325
/trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected:3188-3450
Property changes on: branches/as7/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedureParams.expected
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedureParams.expected:3220-3275
/trunk/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedureParams.expected:3188-3382
+ /branches/7.4.x/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedureParams.expected:3220-3275
/trunk/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedureParams.expected:3188-3450
Property changes on: branches/as7/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedures.expected
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/7.4.x/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedures.expected:3220-3275
/trunk/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedures.expected:3188-3382
+ /branches/7.4.x/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedures.expected:3220-3275
/trunk/test-integration/common/src/test/resources/TestSystemVirtualModel/testProcedures.expected:3188-3450
14 years, 5 months
teiid SVN: r3450 - branches/as7/admin.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-03 18:46:04 -0400 (Sat, 03 Sep 2011)
New Revision: 3450
Modified:
branches/as7/admin/
Log:
TEIID-1720: add ignore to target
Property changes on: branches/as7/admin
___________________________________________________________________
Modified: svn:ignore
- .classpath
.project
.settings
+ .classpath
.project
.settings
target
14 years, 5 months
teiid SVN: r3449 - branches/as7/admin.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-03 18:39:45 -0400 (Sat, 03 Sep 2011)
New Revision: 3449
Removed:
branches/as7/admin/target/
Log:
TEIID-1720: delete the target accidentally checked in
14 years, 5 months
teiid SVN: r3448 - in trunk: documentation/caching-guide/src/main/docbook/en-US/content and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-02 21:59:26 -0400 (Fri, 02 Sep 2011)
New Revision: 3448
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml
trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-942 adding increased transaction support for temp tables
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-09-03 01:59:26 UTC (rev 3448)
@@ -29,6 +29,7 @@
<LI><B>Procedure language features</B> - Added support for compound/block statements, BEGIN [[NOT] ATOMIC], loop/block labels, and the leave statement. See the reference for more.
<LI><B>File Enhancements</B> - the file translator can now optionally (via the ExceptionIfFileNotFound property) throw an exception if the path refers to a file that doesn't exist. The file resource adapter can be configured to map file names and can prevent parent path .. references. See the Admin Guide or the file-ds.xml template for more.
<LI><B>TEXTTABLE Enhancements</B> - TEXTTABLE can now parse fixed width files that do not use a row delimiter and can optionally produce fixed values that haven't been trimmed.
+ <LI><B>Temp table transactions</B> - Internal materialized views and temp table usage from a session and within procedures can take advantage of greater transaction support.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-09-03 01:59:26 UTC (rev 3448)
@@ -104,6 +104,7 @@
Internal materialization also provides more built-in facilities for refreshing and monitoring.</para>
<para>The cache hint, when used in the context of an internal materialized view transformation query, provides the ability to fine tune the materialized table.
The pref_mem option also applies to internal materialized views. Internal table index pages already have a memory preference, so the perf_mem option indicates that the data pages should prefer memory as well.</para>
+ <para>All internal materialized view refresh and updates happen atomically. Internal materialized views support READ_COMMITTED (used also for READ_UNCOMMITED) and SERIALIZABLE (used also for REPEATABLE_READ) transaction isolation levels.</para>
<section>
<title>Loading And Refreshing</title>
<para>An internal materialized view table is initially in an invalid state (there is no data). The first user query will trigger an implicit loading of the data.
@@ -120,22 +121,6 @@
subsequent refreshes performed with <code>refreshMatView</code> will use dependent materialized view tables if they exist. Only one load may occur at a time. If a load is already in progress when
the <code>SYSADMIN.refreshMatView</code> procedure is called, it will return -1 immediately rather than preempting the current load.
</para>
- <para>
- When Teiid is running clustered mode, after of loading of internal materialized view contents, an event will be sent to all
- the other participating nodes in the cluster to refresh the contents from the original node in asynchronus fashion.
- During this remote node loading process, if the node that is reading the contents gets a request from user to serve the
- results of that view, then the current results in cache will be served. If no results were available at that node, then
- request will be blocked until load process is finished.
- </para>
- <para>
- When a Teiid node joins the cluster, at the end of start-up cycle, an asynchronus job
- will be started to fetch all the previously cached internal materialized views at other nodes
- for the deployed VDBs. The query request behaviour during this load process is same as above.
- </para>
- <note><para>In the clustered mode, the "invalidate=true" flag in the "SYSADMIN.refreshMatView" procedure
- will only apply to the node that is refreshing the contents from source. All other nodes, will still serve the
- old contents during the refresh process.</para>
- </note>
<section>
<title>TTL Snapshot Refresh</title>
<para>The <link linkend="cache-hint">cache hint</link> may be used to automatically trigger a full snapshot refresh after a specified time to live (ttl).
@@ -198,12 +183,9 @@
<section>
<title>Clustering Considerations</title>
<para>Each member in a cluster maintains its own copy of each materialized table and associated indexes.
- With cache clustering enabled, an additional snapshot copy of the table is maintained for loading by other members.
An attempt is made to ensure each member receives the same full refresh events as the others.
Full consistency for updatable materialized views however is not guaranteed.
Periodic full refreshes of updatable materialized view tables helps ensure consistency among members.
- <note><para>Loads of materialized tables are not coordinated across the cluster. It is possible for the same ttl expiration to trigger a load at each member.</para></note>
- In many clustered scenarios using external materialization is advantageous to fully control the loading of the tables and to have materialized data that is durable.
</para>
</section>
</section>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml 2011-09-03 01:59:26 UTC (rev 3448)
@@ -77,7 +77,7 @@
</para>
</listitem>
<listitem>
- <para>Only local temporary tables are supported. This implies that the scope of temp table will be either to the sesssion or the block of a virtual procedure that creates it.
+ <para>Only local temporary tables are supported. This implies that the scope of temp table will be either to the session or the block of a virtual procedure that creates it.
</para>
</listitem>
<listitem>
@@ -85,7 +85,9 @@
</para>
</listitem>
<listitem>
- <para>Temp tables are non-transactional.
+ <para>Temp tables support a READ_UNCOMMITED transaction isolation level. There are no locking mechanisms available to support higher isolation levels and the result of a rollback may be inconsistent across multiple transactions.
+ If concurrent transactions are not associated with the same local temporary table or session, then the transaction isolation level is effectively SERIALIZABLE.
+ If you want full constency with local temporary tables, then only use a connection with 1 transaction at a time. This mode of operation is ensured by connection pooling that tracking connections by transaction.
</para>
</listitem>
<listitem>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2011-09-03 01:59:26 UTC (rev 3448)
@@ -341,11 +341,6 @@
connector, however this isolation level is fixed and cannot be
changed at runtime for specific connections/commands.</para>
</listitem>
- <listitem>
- <para>Temporary tables are not transactional. For example,
- a global temporary table will retain all inserts performed during a
- local transaction that was rolled back.</para>
- </listitem>
<!-- <listitem>
<para>Connectors may be set to immutable to prevent their
participation in transactions. This is useful in situations where
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -26,6 +26,12 @@
public interface BatchManager {
+ public interface CleanupHook {
+
+ void cleanup();
+
+ }
+
public interface ManagedBatch {
TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException;
@@ -34,6 +40,13 @@
void setPrefersMemory(boolean prefers);
+ /**
+ * Get an object that can cleaup the {@link ManagedBatch}, but does not hold a hard reference to
+ * the {@link ManagedBatch} or the {@link BatchManager}
+ * @return
+ */
+ CleanupHook getCleanupHook();
+
}
ManagedBatch createManagedBatch(TupleBatch batch, boolean softCache) throws TeiidComponentException;
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -22,24 +22,34 @@
package org.teiid.common.buffer;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Set;
+import org.teiid.common.buffer.BatchManager.CleanupHook;
import org.teiid.common.buffer.BatchManager.ManagedBatch;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
/**
* A linked list Page entry in the tree
*
* TODO: return the tuplebatch from getvalues, since that is what we're tracking
*
+ * State cloning allows a single storage reference to be shared in many trees.
+ * A phantom reference is used for proper cleanup once cloned.
+ *
+ * TODO: a better purging strategy for managedbatchs.
+ *
*/
@SuppressWarnings("unchecked")
-class SPage {
+class SPage implements Cloneable {
static final int MIN_PERSISTENT_SIZE = 16;
@@ -54,24 +64,75 @@
}
}
- private static AtomicInteger counter = new AtomicInteger();
-
+ private static final Set<PhantomReference<Object>> REFERENCES = Collections.newSetFromMap(new IdentityHashMap<PhantomReference<Object>, Boolean>());
+ private static ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
+ static class CleanupReference extends PhantomReference<Object> {
+
+ private CleanupHook batch;
+
+ public CleanupReference(Object referent, CleanupHook batch) {
+ super(referent, QUEUE);
+ this.batch = batch;
+ }
+
+ public void cleanup() {
+ try {
+ this.batch.cleanup();
+ } finally {
+ this.clear();
+ }
+ }
+ }
+
STree stree;
+ private int id;
protected SPage next;
protected SPage prev;
protected ManagedBatch managedBatch;
+ private Object trackingObject;
protected TupleBatch values;
protected ArrayList<SPage> children;
+ //TODO: could track cloning more completely, which would allow for earlier batch removal
+ private boolean cloned;
SPage(STree stree, boolean leaf) {
this.stree = stree;
- this.values = new TupleBatch(counter.getAndIncrement(), new ArrayList(stree.pageSize/4));
+ this.id = stree.counter.getAndIncrement();
+ stree.pages.put(this.id, this);
+ //TODO: this counter is a hack. need a better idea of a storage id
+ this.values = new TupleBatch(id, new ArrayList(stree.pageSize/4));
if (!leaf) {
children = new ArrayList<SPage>(stree.pageSize/4);
}
}
+ public SPage clone(STree tree) {
+ try {
+ if (this.managedBatch != null && trackingObject == null) {
+ cloned = true;
+ this.trackingObject = new Object();
+ CleanupReference managedBatchReference = new CleanupReference(trackingObject, managedBatch.getCleanupHook());
+ REFERENCES.add(managedBatchReference);
+ }
+ SPage clone = (SPage) super.clone();
+ clone.stree = tree;
+ if (children != null) {
+ clone.children = new ArrayList<SPage>(children);
+ }
+ if (values != null) {
+ clone.values = new TupleBatch(stree.counter.getAndIncrement(), new ArrayList<List<?>>(values.getTuples()));
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ public int getId() {
+ return id;
+ }
+
static SearchResult search(SPage page, List k, LinkedList<SearchResult> parent) throws TeiidComponentException {
TupleBatch previousValues = null;
for (;;) {
@@ -121,7 +182,7 @@
}
protected void setValues(TupleBatch values) throws TeiidComponentException {
- if (managedBatch != null) {
+ if (managedBatch != null && !cloned) {
managedBatch.remove();
}
if (values.getTuples().size() < MIN_PERSISTENT_SIZE) {
@@ -134,17 +195,25 @@
} else {
values.setDataTypes(stree.types);
}
+ if (cloned) {
+ values.setRowOffset(stree.counter.getAndIncrement());
+ cloned = false;
+ trackingObject = null;
+ }
if (children != null) {
managedBatch = stree.keyManager.createManagedBatch(values, true);
} else {
managedBatch = stree.leafManager.createManagedBatch(values, stree.preferMemory);
}
}
-
- protected void remove() {
+
+ protected void remove(boolean force) {
if (managedBatch != null) {
- managedBatch.remove();
+ if (force || !cloned) {
+ managedBatch.remove();
+ }
managedBatch = null;
+ trackingObject = null;
}
values = null;
children = null;
@@ -157,6 +226,14 @@
if (managedBatch == null) {
throw new AssertionError("Batch removed"); //$NON-NLS-1$
}
+ for (int i = 0; i < 10; i++) {
+ CleanupReference ref = (CleanupReference)QUEUE.poll();
+ if (ref == null) {
+ break;
+ }
+ REFERENCES.remove(ref);
+ ref.cleanup();
+ }
if (children != null) {
return managedBatch.getBatch(true, stree.keytypes);
}
@@ -173,7 +250,7 @@
if (current.children != null) {
current.children.addAll(current.next.children);
}
- current.next.remove();
+ current.next.remove(false);
current.next = current.next.next;
if (current.next != null) {
current.next.prev = current;
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -29,13 +29,16 @@
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import org.teiid.client.BatchSerializer;
import org.teiid.common.buffer.SPage.SearchResult;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.query.processor.relational.ListNestedSortComparator;
/**
@@ -44,7 +47,7 @@
* but with fewer updates.
*/
@SuppressWarnings("unchecked")
-public class STree {
+public class STree implements Cloneable {
public enum InsertMode {ORDERED, NEW, UPDATE}
@@ -53,7 +56,9 @@
protected int randomSeed;
private int mask = 1;
private int shift = 1;
-
+
+ protected AtomicInteger counter = new AtomicInteger();
+ protected ConcurrentHashMap<Integer, SPage> pages = new ConcurrentHashMap<Integer, SPage>();
protected volatile SPage[] header = new SPage[] {new SPage(this, true)};
protected BatchManager keyManager;
protected BatchManager leafManager;
@@ -91,6 +96,47 @@
this.keytypes = Arrays.copyOf(types, keyLength);
}
+ public STree clone() {
+ updateLock.lock();
+ try {
+ STree clone = (STree) super.clone();
+ clone.updateLock = new ReentrantLock();
+ clone.rowCount = new AtomicInteger(rowCount.get());
+ //clone the pages
+ clone.pages = new ConcurrentHashMap<Integer, SPage>(pages);
+ for (Map.Entry<Integer, SPage> entry : clone.pages.entrySet()) {
+ entry.setValue(entry.getValue().clone(clone));
+ }
+ //reset the pointers
+ for (Map.Entry<Integer, SPage> entry : clone.pages.entrySet()) {
+ SPage clonePage = entry.getValue();
+ clonePage.next = clone.getPage(clonePage.next);
+ clonePage.prev = clone.getPage(clonePage.prev);
+ if (clonePage.children != null) {
+ for (int i = 0; i < clonePage.children.size(); i++) {
+ clonePage.children.set(i, clone.getPage(clonePage.children.get(i)));
+ }
+ }
+ }
+ clone.header = Arrays.copyOf(header, header.length);
+ for (int i = 0; i < header.length; i++) {
+ clone.header[i] = clone.pages.get(header[i].getId());
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ } finally {
+ updateLock.unlock();
+ }
+ }
+
+ private SPage getPage(SPage page) {
+ if (page == null) {
+ return page;
+ }
+ return pages.get(page.getId());
+ }
+
public void writeValuesTo(ObjectOutputStream oos) throws TeiidComponentException, IOException {
SPage page = header[0];
oos.writeInt(this.rowCount.get());
@@ -357,7 +403,7 @@
int size = searchResult.values.getTuples().size();
if (size == 0) {
if (header[i] != searchResult.page) {
- searchResult.page.remove();
+ searchResult.page.remove(false);
if (searchResult.page.next != null) {
searchResult.page.next.prev = searchResult.page.prev;
}
@@ -366,7 +412,7 @@
searchResult.page.prev = null;
continue;
}
- header[i].remove();
+ header[i].remove(false);
if (header[i].next != null) {
header[i] = header[i].next;
header[i].prev = null;
@@ -401,7 +447,7 @@
}
public void remove() {
- truncate();
+ truncate(false);
this.keyManager.remove();
this.leafManager.remove();
}
@@ -410,12 +456,12 @@
return this.rowCount.get();
}
- public int truncate() {
+ public int truncate(boolean force) {
int oldSize = rowCount.getAndSet(0);
for (int i = 0; i < header.length; i++) {
SPage page = header[i];
while (page != null) {
- page.remove();
+ page.remove(force);
page = page.next;
}
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -92,6 +92,28 @@
private static final int IO_BUFFER_SIZE = 1 << 14;
private static final int COMPACTION_THRESHOLD = 1 << 25; //start checking at 32 megs
+ private final class CleanupHook implements org.teiid.common.buffer.BatchManager.CleanupHook {
+
+ private long id;
+ private int beginRow;
+ private WeakReference<BatchManagerImpl> ref;
+
+ CleanupHook(long id, int beginRow, BatchManagerImpl batchManager) {
+ this.id = id;
+ this.beginRow = beginRow;
+ this.ref = new WeakReference<BatchManagerImpl>(batchManager);
+ }
+
+ public void cleanup() {
+ BatchManagerImpl batchManager = ref.get();
+ if (batchManager == null) {
+ return;
+ }
+ cleanupManagedBatch(batchManager, beginRow, id);
+ }
+
+ }
+
private final class BatchManagerImpl implements BatchManager {
private final String id;
private volatile FileStore store;
@@ -163,7 +185,9 @@
store = newStore;
long oldOffset = offset;
offset = store.getLength();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
return offset;
} finally {
this.compactionLock.writeLock().unlock();
@@ -213,7 +237,9 @@
this.lobManager = new LobManager();
}
sizeEstimate = (int) Math.max(1, manager.sizeUtility.getBatchSize(batch) / 1024);
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
@Override
@@ -249,7 +275,9 @@
@Override
public TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException {
long reads = readAttempts.incrementAndGet();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
synchronized (activeBatches) {
TupleBufferInfo tbi = activeBatches.remove(batchManager.id);
if (tbi != null) {
@@ -286,7 +314,9 @@
}
}
long count = readCount.incrementAndGet();
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+ }
try {
this.batchManager.compactionLock.readLock().lock();
long[] info = batchManager.physicalMapping.get(this.id);
@@ -324,7 +354,9 @@
if (batch != null) {
if (!persistent) {
long count = writeCount.incrementAndGet();
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+ }
long offset = 0;
if (lobManager != null) {
for (List<?> tuple : batch.getTuples()) {
@@ -341,7 +373,9 @@
long[] info = new long[] {offset, size};
batchManager.physicalMapping.put(this.id, info);
}
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+ }
}
if (softCache) {
this.batchReference = new SoftReference<TupleBatch>(batch);
@@ -363,25 +397,17 @@
}
public void remove() {
- synchronized (activeBatches) {
- TupleBufferInfo tbi = activeBatches.get(batchManager.id);
- if (tbi != null && tbi.removeBatch(this.beginRow) != null) {
- if (tbi.batches.isEmpty()) {
- activeBatches.remove(batchManager.id);
- }
- }
- }
- long[] info = batchManager.physicalMapping.remove(id);
- if (info != null) {
- batchManager.unusedSpace.addAndGet(info[1]);
- }
- activeBatch = null;
- batchReference = null;
+ cleanupManagedBatch(batchManager, beginRow, id);
}
+
+ @Override
+ public CleanupHook getCleanupHook() {
+ return new CleanupHook(id, beginRow, batchManager);
+ }
@Override
public String toString() {
- return "ManagedBatch " + batchManager.id + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$
+ return "ManagedBatch " + batchManager.id + " " + this.beginRow + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -487,6 +513,21 @@
return tupleBuffer;
}
+ private void cleanupManagedBatch(BatchManagerImpl batchManager, int beginRow, long id) {
+ synchronized (activeBatches) {
+ TupleBufferInfo tbi = activeBatches.get(batchManager.id);
+ if (tbi != null && tbi.removeBatch(beginRow) != null) {
+ if (tbi.batches.isEmpty()) {
+ activeBatches.remove(batchManager.id);
+ }
+ }
+ }
+ long[] info = batchManager.physicalMapping.remove(id);
+ if (info != null) {
+ batchManager.unusedSpace.addAndGet(info[1]);
+ }
+ }
+
public STree createSTree(final List elements, String groupName, int keyLength) {
String newID = String.valueOf(this.tsId.getAndIncrement());
int[] lobIndexes = LobManager.getLobIndexes(elements);
@@ -496,13 +537,17 @@
for (int i = 1; i < compareIndexes.length; i++) {
compareIndexes[i] = i;
}
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+ }
return new STree(keyManager, bm, new ListNestedSortComparator(compareIndexes), getProcessorBatchSize(), keyLength, TupleBuffer.getTypeNames(elements));
}
@Override
public FileStore createFileStore(String name) {
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ }
return this.diskMgr.createFileStore(name);
}
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 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -76,6 +76,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
/**
@@ -235,7 +236,7 @@
}
ClientState state = clientState.get(key);
if (state == null && create) {
- state = new ClientState(new TempTableStore(key));
+ state = new ClientState(new TempTableStore(key, TransactionMode.ISOLATE_WRITES));
clientState.put(key, state);
}
return state;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -356,13 +356,14 @@
if (startAutoWrapTxn) {
try {
- tc = transactionService.begin(tc);
+ transactionService.begin(tc);
} catch (XATransactionException err) {
throw new TeiidComponentException(err);
}
}
}
+ tc.setIsolationLevel(requestMsg.getTransactionIsolation());
this.transactionContext = tc;
this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -462,31 +462,28 @@
/**
* Request level transaction
*/
- public TransactionContext begin(TransactionContext context) throws XATransactionException{
+ public void begin(TransactionContext context) throws XATransactionException{
if (context.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
beginDirect(context);
context.setTransactionType(TransactionContext.Scope.REQUEST);
- return context;
}
/**
* Request level transaction
*/
- public TransactionContext commit(TransactionContext context) throws XATransactionException {
+ public void commit(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
commitDirect(context);
- return context;
}
/**
* Request level transaction
*/
- public TransactionContext rollback(TransactionContext context) throws XATransactionException {
+ public void rollback(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
rollbackDirect(context);
- return context;
}
public void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException {
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -46,7 +46,16 @@
private long creationTime;
private Transaction transaction;
private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
+ private int isolationLevel;
+
+ public int getIsolationLevel() {
+ return isolationLevel;
+ }
+ public void setIsolationLevel(int isolationLevel) {
+ this.isolationLevel = isolationLevel;
+ }
+
public long getCreationTime() {
return creationTime;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -39,11 +39,11 @@
public interface TransactionService {
// processor level methods
- TransactionContext begin(TransactionContext context) throws XATransactionException;
+ void begin(TransactionContext context) throws XATransactionException;
- TransactionContext commit(TransactionContext context) throws XATransactionException;
+ void commit(TransactionContext context) throws XATransactionException;
- TransactionContext rollback(TransactionContext context) throws XATransactionException;
+ void rollback(TransactionContext context) throws XATransactionException;
TransactionContext getOrCreateTransactionContext(String threadId);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -29,6 +29,7 @@
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.sql.proc.Statement.Labeled;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
/**
@@ -113,7 +114,7 @@
*/
public void reset(String sessionId){
counter = 0;
- this.tempTables = new TempTableStore(sessionId);
+ this.tempTables = new TempTableStore(sessionId, TransactionMode.ISOLATE_WRITES);
this.startedTxn = false;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -46,6 +46,7 @@
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.WithQueryCommand;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
/**
@@ -87,7 +88,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
if (this.with != null) {
context = context.clone();
- tempTableStore = new TempTableStore(context.getConnectionID());
+ tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
for (WithQueryCommand withCommand : this.with) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -60,6 +60,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
@@ -110,7 +111,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
context = context.clone();
setContext(context);
- TempTableStore tempTableStore = new TempTableStore(context.getConnectionID());
+ TempTableStore tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
this.dataMgr = dataMgr;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -30,6 +30,7 @@
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
@@ -52,7 +53,7 @@
List<?> updateMatViewRow(String matTableName, List<?> tuple, boolean delete) throws TeiidComponentException;
TempTable createMatTable(String tableName, GroupSymbol group)
- throws TeiidComponentException, QueryMetadataException, QueryResolverException, QueryValidatorException;
+ throws TeiidComponentException, QueryMetadataException, TeiidProcessingException;
@Replicated
void failedLoad(String matTableName);
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -40,6 +40,7 @@
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.language.SQLConstants;
@@ -60,6 +61,7 @@
import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
public class GlobalTableStoreImpl implements GlobalTableStore, ReplicatedObject {
@@ -154,7 +156,7 @@
}
private ConcurrentHashMap<String, MatTableInfo> matTables = new ConcurrentHashMap<String, MatTableInfo>();
- private TempTableStore tableStore = new TempTableStore("SYSTEM"); //$NON-NLS-1$
+ private TempTableStore tableStore = new TempTableStore("SYSTEM", TransactionMode.ISOLATE_READS); //$NON-NLS-1$
private BufferManager bufferManager;
private QueryMetadataInterface metadata;
private Serializable localAddress;
@@ -196,13 +198,13 @@
String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
GroupSymbol group = new GroupSymbol(matViewName);
group.setMetadataID(viewId);
- TempMetadataID id = tableStore.tempMetadataStore.getTempGroupID(matTableName);
+ TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName);
//define the table preserving the key/index information and ensure that only a single instance exists
if (id == null) {
synchronized (viewId) {
- id = tableStore.tempMetadataStore.getTempGroupID(matTableName);
+ id = tableStore.getMetadataStore().getTempGroupID(matTableName);
if (id == null) {
- id = tableStore.tempMetadataStore.addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
+ id = tableStore.getMetadataStore().addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
id.setQueryNode(metadata.getVirtualPlan(viewId));
id.setCardinality(metadata.getCardinality(viewId));
id.setOriginalMetadataID(viewId);
@@ -273,16 +275,31 @@
@Override
public void loaded(String matTableName, TempTable table) {
- this.tableStore.swapTempTable(matTableName, table);
+ swapTempTable(matTableName, table);
this.getMatTableInfo(matTableName).setState(MatState.LOADED, true);
}
+
+ private void swapTempTable(String tempTableName, TempTable tempTable) {
+ this.tableStore.getTempTables().put(tempTableName, tempTable);
+ }
@Override
public List<?> updateMatViewRow(String matTableName, List<?> tuple,
boolean delete) throws TeiidComponentException {
TempTable tempTable = tableStore.getTempTable(matTableName);
if (tempTable != null) {
- return tempTable.updateTuple(tuple, delete);
+ TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName);
+ synchronized (id) {
+ boolean clone = tempTable.getActiveReaders().get() != 0;
+ if (clone) {
+ tempTable = tempTable.clone();
+ }
+ List<?> result = tempTable.updateTuple(tuple, delete);
+ if (clone) {
+ swapTempTable(matTableName, tempTable);
+ }
+ return result;
+ }
}
return null;
}
@@ -294,7 +311,7 @@
@Override
public TempTable createMatTable(final String tableName, GroupSymbol group) throws TeiidComponentException,
- QueryMetadataException, QueryResolverException, QueryValidatorException {
+ QueryMetadataException, TeiidProcessingException {
Create create = new Create();
create.setTable(group);
List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
@@ -304,7 +321,7 @@
List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk);
create.getPrimaryKey().addAll(pkColumns);
}
- TempTable table = getTempTableStore().addTempTable(tableName, create, bufferManager, false);
+ TempTable table = getTempTableStore().addTempTable(tableName, create, bufferManager, false, null);
table.setUpdatable(false);
CacheHint hint = table.getCacheHint();
if (hint != null) {
@@ -424,8 +441,8 @@
private void loadTable(String stateId, ObjectInputStream ois)
throws TeiidComponentException, QueryMetadataException,
- QueryResolverException, QueryValidatorException, IOException,
- ClassNotFoundException {
+ IOException,
+ ClassNotFoundException, TeiidProcessingException {
LogManager.logDetail(LogConstants.CTX_DQP, "loading table from remote stream", stateId); //$NON-NLS-1$
long updateTime = ois.readLong();
Serializable loadingAddress = (Serializable) ois.readObject();
@@ -449,7 +466,7 @@
tempTable.readFrom(ois);
MatTableInfo info = this.getMatTableInfo(stateId);
synchronized (info) {
- this.tableStore.swapTempTable(stateId, tempTable);
+ swapTempTable(stateId, tempTable);
info.setState(state, true);
info.updateTime = updateTime;
info.loadingAddress = loadingAddress;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -51,6 +51,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -75,7 +76,7 @@
* TODO: in this implementation blocked exceptions will not happen
* allowing for subquery evaluation though would cause pauses
*/
-public class TempTable {
+public class TempTable implements Cloneable {
private final class InsertUpdateProcessor extends UpdateProcessor {
@@ -274,7 +275,9 @@
}
}
+ private static AtomicInteger ID_GENERATOR = new AtomicInteger();
+ private int id = ID_GENERATOR.getAndIncrement();
private STree tree;
private AtomicInteger rowId;
private List<ElementSymbol> columns;
@@ -292,6 +295,8 @@
private List<Integer> notNull = new LinkedList<Integer>();
private Map<Integer, AtomicInteger> sequences;
private int uniqueColIndex;
+
+ private AtomicInteger activeReaders = new AtomicInteger();
TempTable(TempMetadataID tid, BufferManager bm, List<ElementSymbol> columns, int primaryKeyLength, String sessionID) {
this.tid = tid;
@@ -333,6 +338,33 @@
this.leafBatchSize = bm.getSchemaSize(columns.subList(0, primaryKeyLength));
}
+ public TempTable clone() {
+ lock.readLock().lock();
+ try {
+ TempTable clone = (TempTable) super.clone();
+ clone.lock = new ReentrantReadWriteLock();
+ if (clone.indexTables != null) {
+ clone.indexTables = new LinkedHashMap<List<ElementSymbol>, TempTable>(clone.indexTables);
+ for (Map.Entry<List<ElementSymbol>, TempTable> entry : clone.indexTables.entrySet()) {
+ TempTable indexClone = entry.getValue().clone();
+ indexClone.lock = clone.lock;
+ entry.setValue(indexClone);
+ }
+ }
+ clone.tree = tree.clone();
+ clone.activeReaders = new AtomicInteger();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException();
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ public AtomicInteger getActiveReaders() {
+ return activeReaders;
+ }
+
void addIndex(List<ElementSymbol> indexColumns, boolean unique) throws TeiidComponentException, TeiidProcessingException {
List<ElementSymbol> keyColumns = columns.subList(0, tree.getKeyLength());
if (keyColumns.equals(indexColumns) || (indexTables != null && indexTables.containsKey(indexColumns))) {
@@ -500,9 +532,9 @@
return tree.getRowCount();
}
- public int truncate() {
+ public int truncate(boolean force) {
this.tid.getTableData().dataModified(tree.getRowCount());
- return tree.truncate();
+ return tree.truncate(force);
}
public void remove() {
@@ -770,5 +802,26 @@
public TempMetadataID getMetadataId() {
return tid;
}
+
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TempTable)) {
+ return false;
+ }
+ TempTable other = (TempTable)obj;
+ return id == other.id;
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -43,6 +43,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
import org.teiid.core.util.StringUtil;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
@@ -164,7 +165,7 @@
return null;
}
final String groupKey = group.getNonCorrelationName().toUpperCase();
- final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true);
+ final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true, true, context);
if (command instanceof Insert) {
Insert insert = (Insert)command;
TupleSource ts = insert.getTupleSource();
@@ -186,8 +187,8 @@
final Delete delete = (Delete)command;
final Criteria crit = delete.getCriteria();
if (crit == null) {
- //because we are non-transactional, just use a truncate
- int rows = table.truncate();
+ //TODO: we'll add a real truncate later
+ int rows = table.truncate(false);
return CollectionTupleSource.createUpdateCountTupleSource(rows);
}
return table.delete(crit);
@@ -199,17 +200,18 @@
if (contextStore.hasTempTable(tempTableName)) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
}
- contextStore.addTempTable(tempTableName, create, bufferManager, true);
+ contextStore.addTempTable(tempTableName, create, bufferManager, true, context);
return CollectionTupleSource.createUpdateCountTupleSource(0);
}
if (command instanceof Drop) {
String tempTableName = ((Drop)command).getTable().getCanonicalName();
- contextStore.removeTempTableByName(tempTableName);
+ contextStore.removeTempTableByName(tempTableName, context);
return CollectionTupleSource.createUpdateCountTupleSource(0);
}
if (command instanceof AlterTempTable) {
AlterTempTable att = (AlterTempTable)command;
- TempTable tt = contextStore.getOrCreateTempTable(att.getTempTable().toUpperCase(), command, bufferManager, true);
+ TempTable tt = contextStore.getTempTable(att.getTempTable().toUpperCase());
+ Assertion.isNotNull(tt, "Table doesn't exist"); //$NON-NLS-1$
tt.setUpdatable(false);
if (att.getIndexColumns() != null) {
tt.addIndex(att.getIndexColumns(), false);
@@ -388,10 +390,10 @@
loadAsynch(context, group, tableName, globalStore);
}
}
- table = globalStore.getTempTableStore().getOrCreateTempTable(tableName, query, bufferManager, false);
+ table = globalStore.getTempTableStore().getOrCreateTempTable(tableName, query, bufferManager, false, false, context);
context.accessedDataObject(group.getMetadataID());
} else {
- table = contextStore.getOrCreateTempTable(tableName, query, bufferManager, true);
+ table = contextStore.getOrCreateTempTable(tableName, query, bufferManager, true, false, context);
if (context.getDataObjects() != null) {
Object id = RelationalPlanner.getTrackableGroup(group, context.getMetadata());
if (id != null) {
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -22,15 +22,26 @@
package org.teiid.query.tempdata;
+import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.QueryPlugin;
@@ -42,16 +53,121 @@
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
+/**
+ * TempTableStores are transactional, but do not act as full resource manager.
+ * This means we are effectively 1PC and don't allow any heuristic exceptions
+ * on commit.
+ *
+ * Table state snapshoting and a {@link Synchronization} are used to
+ * perform the appropriate commit/rollback actions.
+ *
+ * Full row level MVCC would be a good next step as it would remove the
+ * cost of state cloning and would allow for concurrent read/write transactions.
+ */
public class TempTableStore {
- TempMetadataStore tempMetadataStore = new TempMetadataStore(new ConcurrentHashMap<String, TempMetadataID>());
+ public interface TransactionCallback {
+ void commit();
+ void rollback();
+ }
+
+ public enum TransactionMode {
+ ISOLATE_READS, //for matviews that have atomic updates
+ ISOLATE_WRITES, //for session/procedure stores that need rollback support - this is effectively READ_UNCOMMITTED
+ NONE
+ }
+
+ public class TempTableSynchronization implements Synchronization {
+
+ private String id;
+ Set<Integer> existingTables = new HashSet<Integer>();
+ ConcurrentHashMap<String, TempTable> tables = new ConcurrentHashMap<String, TempTable>();
+ private List<TransactionCallback> callbacks = new LinkedList<TransactionCallback>();
+
+ private boolean completed;
+
+ public TempTableSynchronization(final String id) {
+ this.id = id;
+ for (TempTable tempTable : tempTables.values()) {
+ existingTables.add(tempTable.getId());
+ }
+ if (transactionMode == TransactionMode.ISOLATE_WRITES) {
+ addCallback(new TransactionCallback() {
+ private Map<String, TempMetadataID> clonedMetadata = new ConcurrentHashMap<String, TempMetadataID>(tempMetadataStore.getData());
+ private Map<String, TempTable> clonedTables = new ConcurrentHashMap<String, TempTable>(tempTables);
+
+ @Override
+ public void rollback() {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Rolling back txn", id, "restoring", clonedTables.keySet(), "using rollback tables", tables); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ //remove any tables created in the scope of this txn
+ tempTables.values().removeAll(clonedTables.values());
+ for (TempTable table : tempTables.values()) {
+ table.remove();
+ }
+
+ //restore the state
+ tempMetadataStore.getData().clear();
+ tempMetadataStore.getData().putAll(clonedMetadata);
+ tempTables.clear();
+ tempTables.putAll(clonedTables);
+
+ //overlay the rollback tables
+ tempTables.putAll(tables);
+ }
+
+ @Override
+ public void commit() {
+ //remove any original tables that were removed in this txn
+ clonedTables.values().removeAll(tempTables.values());
+ for (TempTable table : clonedTables.values()) {
+ table.remove();
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public synchronized void afterCompletion(int status) {
+ //TODO: cleanup tables
+ completed = true;
+ synchronizations.remove(id);
+ for (TransactionCallback callback : callbacks) {
+ if (status == Status.STATUS_COMMITTED) {
+ callback.commit();
+ } else {
+ callback.rollback();
+ }
+ }
+ callbacks.clear();
+ }
+
+ @Override
+ public void beforeCompletion() {
+
+ }
+
+ public synchronized boolean addCallback(TransactionCallback callback) {
+ if (!completed) {
+ callbacks.add(0, callback);
+ }
+ return !completed;
+ }
+ }
+
+ private Map<String, TempTableSynchronization> synchronizations = new ConcurrentHashMap<String, TempTableSynchronization>();
+ private TransactionMode transactionMode = TransactionMode.NONE;
+
+ private TempMetadataStore tempMetadataStore = new TempMetadataStore(new ConcurrentHashMap<String, TempMetadataID>());
private Map<String, TempTable> tempTables = new ConcurrentHashMap<String, TempTable>();
private String sessionID;
private TempTableStore parentTempTableStore;
- public TempTableStore(String sessionID) {
+ public TempTableStore(String sessionID, TransactionMode transactionMode) {
this.sessionID = sessionID;
+ this.transactionMode = transactionMode;
}
public void setParentTempTableStore(TempTableStore parentTempTableStore) {
@@ -62,9 +178,10 @@
return tempTables.containsKey(tempTableName);
}
- TempTable addTempTable(String tempTableName, Create create, BufferManager buffer, boolean add) {
+ TempTable addTempTable(final String tempTableName, Create create, BufferManager buffer, boolean add, CommandContext context) throws TeiidProcessingException {
List<ElementSymbol> columns = create.getColumnSymbols();
TempMetadataID id = tempMetadataStore.getTempGroupID(tempTableName);
+ getSynchronization(context);
if (id == null) {
//add metadata
id = tempMetadataStore.addTempGroup(tempTableName, columns, false, true);
@@ -77,32 +194,67 @@
columns.removeAll(primaryKey);
columns.addAll(0, primaryKey);
}
- TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
+ final TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
if (add) {
tempTables.put(tempTableName, tempTable);
}
return tempTable;
}
- void swapTempTable(String tempTableName, TempTable tempTable) {
- tempTables.put(tempTableName, tempTable);
+ public void removeTempTableByName(final String tempTableName, CommandContext context) throws TeiidProcessingException {
+ TempTableSynchronization synch = getSynchronization(context);
+ tempMetadataStore.removeTempGroup(tempTableName);
+ final TempTable table = this.tempTables.remove(tempTableName);
+ if (table == null) {
+ return;
+ }
+ if (transactionMode != TransactionMode.ISOLATE_WRITES || synch == null || !synch.existingTables.contains(table.getId())) {
+ table.remove();
+ }
}
- public void removeTempTableByName(String tempTableName) {
- tempMetadataStore.removeTempGroup(tempTableName);
- TempTable table = this.tempTables.remove(tempTableName);
- if(table != null) {
- table.remove();
- }
- }
-
+ private TempTableSynchronization getSynchronization(CommandContext context) throws TeiidProcessingException {
+ TempTableSynchronization synch = null;
+ if (context == null || transactionMode == TransactionMode.NONE) {
+ return null;
+ }
+ TransactionContext tc = context.getTransactionContext();
+ if (tc == null || tc.getTransactionType() == Scope.NONE) {
+ return null;
+ }
+ String transactionId = tc.getTransactionId();
+ synch = synchronizations.get(transactionId);
+ if (synch == null) {
+ boolean success = false;
+ try {
+ synch = new TempTableSynchronization(transactionId);
+ synchronizations.put(transactionId, synch);
+ tc.getTransaction().registerSynchronization(synch);
+ success = true;
+ } catch (RollbackException e) {
+ throw new TeiidProcessingException(e);
+ } catch (SystemException e) {
+ throw new TeiidProcessingException(e);
+ } finally {
+ if (!success) {
+ synchronizations.remove(transactionId);
+ }
+ }
+ }
+ return synch;
+ }
+
public TempMetadataStore getMetadataStore() {
return tempMetadataStore;
}
- public void removeTempTables() {
+ public void removeTempTables() throws TeiidComponentException {
for (String name : tempTables.keySet()) {
- removeTempTableByName(name);
+ try {
+ removeTempTableByName(name, null);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidComponentException(e);
+ }
}
}
@@ -117,8 +269,8 @@
return this.tempTables.get(tempTableID);
}
- TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager buffer, boolean delegate) throws QueryProcessingException{
- TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate);
+ TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context) throws TeiidProcessingException{
+ TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
if (tempTable != null) {
return tempTable;
}
@@ -138,18 +290,63 @@
Create create = new Create();
create.setTable(new GroupSymbol(tempTableID));
create.setElementSymbolsAsColumns(columns);
- return addTempTable(tempTableID, create, buffer, true);
+ return addTempTable(tempTableID, create, buffer, true, context);
}
private TempTable getTempTable(String tempTableID, Command command,
- BufferManager buffer, boolean delegate)
- throws QueryProcessingException {
- TempTable tsID = tempTables.get(tempTableID);
- if(tsID != null) {
- return tsID;
+ BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context)
+ throws TeiidProcessingException {
+ final TempTable tempTable = tempTables.get(tempTableID);
+ if(tempTable != null) {
+ //isolate if needed
+ if (forUpdate) {
+ if (transactionMode == TransactionMode.ISOLATE_WRITES) {
+ TransactionContext tc = context.getTransactionContext();
+ if (tc != null) {
+ TempTableSynchronization synch = getSynchronization(context);
+ if (synch != null && synch.existingTables.contains(tempTable.getId())) {
+ TempTable result = synch.tables.get(tempTableID);
+ if (result == null) {
+ synch.tables.put(tempTableID, tempTable.clone());
+ }
+ return tempTable;
+ }
+ }
+ }
+ } else if (transactionMode == TransactionMode.ISOLATE_READS) {
+ TransactionContext tc = context.getTransactionContext();
+ if (tc != null && tc.getIsolationLevel() > Connection.TRANSACTION_READ_COMMITTED) {
+ TempTableSynchronization synch = getSynchronization(context);
+ if (synch != null) {
+ TempTable result = synch.tables.get(tempTableID);
+ if (result == null) {
+ synch.tables.put(tempTableID, tempTable);
+ result = tempTable;
+ result.getActiveReaders().getAndIncrement();
+ TransactionCallback callback = new TransactionCallback() {
+
+ @Override
+ public void rollback() {
+ tempTable.getActiveReaders().getAndDecrement();
+ }
+
+ @Override
+ public void commit() {
+ tempTable.getActiveReaders().getAndDecrement();
+ }
+ };
+ if (!synch.addCallback(callback)) {
+ callback.rollback();
+ }
+ }
+ return result;
+ }
+ }
+ }
+ return tempTable;
}
if(delegate && this.parentTempTableStore != null){
- return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate);
+ return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
}
return null;
}
Modified: trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -65,6 +65,11 @@
public void setPrefersMemory(boolean prefers) {
}
+
+ @Override
+ public CleanupHook getCleanupHook() {
+ return null;
+ }
};
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -42,6 +42,7 @@
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.ContextProperties;
@@ -52,7 +53,7 @@
*/
public class TestRequest extends TestCase {
- private static final TempTableStore TEMP_TABLE_STORE = new TempTableStore("1"); //$NON-NLS-1$
+ private static final TempTableStore TEMP_TABLE_STORE = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
private final static String QUERY = "SELECT * FROM pm1.g1"; //$NON-NLS-1$
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -48,6 +48,7 @@
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -62,7 +63,7 @@
private HardcodedDataManager hdm;
@Before public void setUp() {
- tempStore = new TempTableStore("1"); //$NON-NLS-1$
+ tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
QueryMetadataInterface actualMetadata = RealMetadataFactory.exampleMaterializedView();
globalStore = new GlobalTableStoreImpl(bm, actualMetadata);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -96,6 +96,7 @@
import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.CommandContext;
@@ -244,7 +245,7 @@
}
context.getNextRand(0);
if (context.getTempTableStore() == null) {
- context.setTempTableStore(new TempTableStore(context.getConnectionID()));
+ context.setTempTableStore(new TempTableStore(context.getConnectionID(), TransactionMode.ISOLATE_WRITES));
}
if (context.getGlobalTableStore() == null) {
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(bufferMgr, context.getMetadata());
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -24,24 +24,38 @@
import static org.junit.Assert.*;
+import java.sql.Connection;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -52,6 +66,10 @@
private TempTableDataManager dataManager;
private TempTableStore tempStore;
+ private TransactionContext tc;
+ private Transaction txn;
+ private Synchronization synch;
+
private ProcessorPlan execute(String sql, List[] expectedResults) throws Exception {
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
execute(plan, expectedResults);
@@ -60,6 +78,7 @@
private void execute(ProcessorPlan processorPlan, List[] expectedResults) throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
+ cc.setTransactionContext(tc);
cc.setMetadata(metadata);
cc.setTempTableStore(tempStore);
TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
@@ -67,7 +86,7 @@
}
@Before public void setUp() {
- tempStore = new TempTableStore("1"); //$NON-NLS-1$
+ tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
metadata.setSession(true);
FakeDataManager fdm = new FakeDataManager();
@@ -84,6 +103,96 @@
dataManager = new TempTableDataManager(fdm, bm, executor, cache);
}
+ @Test public void testRollbackNoExisting() throws Exception {
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+
+ Mockito.verify(txn).registerSynchronization((Synchronization) Mockito.anyObject());
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ try {
+ execute("select * from x", new List[] {});
+ fail();
+ } catch (Exception e) {
+
+ }
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ }
+
+ @Test public void testRollbackExisting() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ //execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(172)}); //$NON-NLS-1$
+
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ execute("select * from x", new List[] {});
+ }
+
+ @Test public void testRollbackExisting1() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ //execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(344)}); //$NON-NLS-1$
+
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+ this.tc = null;
+
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+
+ execute("delete from x", new List[] {Arrays.asList(516)});
+ }
+
+ @Test public void testIsolateReads() throws Exception {
+ GlobalTableStoreImpl gtsi = new GlobalTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), RealMetadataFactory.example1Cached());
+ tempStore = gtsi.getTempTableStore();
+ metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+ gtsi.updateMatViewRow("X", Arrays.asList(1), true);
+ tc=null;
+ //outside of the transaction we can see the row removed
+ execute("select count(*) from x", new List[] {Arrays.asList(515)});
+
+ //back in the transaction we see the original state
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+
+ synch.afterCompletion(Status.STATUS_COMMITTED);
+ }
+
+ private void setupTransaction(int isolation) throws RollbackException, SystemException {
+ txn = Mockito.mock(Transaction.class);
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ synch = (Synchronization)invocation.getArguments()[0];
+ return null;
+ }
+ }).when(txn).registerSynchronization((Synchronization)Mockito.anyObject());
+ Mockito.stub(txn.toString()).toReturn("txn");
+ tc = new TransactionContext();
+ tc.setTransaction(txn);
+ tc.setIsolationLevel(isolation);
+ tc.setTransactionType(Scope.REQUEST);
+ }
+
@Test public void testInsertWithQueryExpression() throws Exception {
execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
14 years, 5 months
teiid SVN: r3447 - in branches/as7/client/src: main/java/org/teiid/adminapi/impl and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 17:01:40 -0400 (Fri, 02 Sep 2011)
New Revision: 3447
Removed:
branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java
branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java
branches/as7/client/src/main/java/org/teiid/adminapi/Model.java
branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java
branches/as7/client/src/main/java/org/teiid/adminapi/Request.java
branches/as7/client/src/main/java/org/teiid/adminapi/Session.java
branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java
branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java
branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java
branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
Log:
TEIID-1720: Removing the admin classes from client
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,298 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Properties;
-import java.util.Set;
-
-import org.teiid.adminapi.VDB.ConnectionType;
-
-public interface Admin {
-
- public enum Cache {PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE};
-
- /**
- * Assign a {@link Translator} and Data source to a {@link VDB}'s Model
- *
- * @param vdbName Name of the VDB
- * @param vdbVersion Version of the VDB
- * @param modelName Name of the Model to map Connection Factory
- * @param sourceName sourceName for the model
- * @param translatorName
- * @param dsName data source name that can found in the JNDI map.
- * @throws AdminException
- */
- void assignToModel(String vdbName, int vdbVersion, String modelName, String sourceName, String translatorName, String dsName) throws AdminException;
-
- /**
- * Change the {@link ConnectionType} of the {@link VDB}.
- * @param vdbName Name of the VDB
- * @param vdbVersion Version of the VDB
- * @param type
- * @throws AdminException
- */
- void changeVDBConnectionType(String vdbName, int vdbVersion, ConnectionType type) throws AdminException;
-
- /**
- * Deploy a {@link VDB} file.
- * @param name Name of the VDB file to save under
- * @param VDB VDB.
- * @throws AdminException
- *
- * @return the {@link VDB} representing the current property values and runtime state.
- */
- public void deployVDB(String fileName, InputStream vdb) throws AdminException;
-
-
- /**
- * Delete the VDB with the given name and version
- * @param vdbName
- * @param version
- * @throws AdminException
- */
- void deleteVDB(String vdbName, int vdbVersion) throws AdminException;
-
- /**
- * Get the VDBs that currently deployed in the system
- *
- * @return Collection of {@link VDB}s. There could be multiple VDBs with the
- * same name in the Collection but they will differ by VDB version.
- * @throws AdminException
- */
- Set<VDB> getVDBs() throws AdminException;
-
- /**
- * Get the VDB
- * @param vdbName
- * @param vbdVersion
- * @throws AdminException
- * @return
- */
- VDB getVDB(String vdbName, int vbdVersion) throws AdminException;
-
- /**
- * Get the translators that are available in the configuration
- *
- * @return Collection of {@link Translator}
- * @throws AdminException
- */
- Collection<Translator> getTranslators() throws AdminException;
-
- /**
- * Get the translator by the given the deployed name.
- * @param deployedName - name of the deployed translator
- * @return null if not found
- * @throws AdminException
- */
- Translator getTranslator(String deployedName) throws AdminException;
-
- /**
- * Get the Worker Pool statistics in runtime engine.
- *
- * @return {@link WorkerPoolStatistics}
- * @throws AdminException
- */
- WorkerPoolStatistics getWorkerPoolStats() throws AdminException;
-
- /**
- * Get the Caches that correspond to the specified identifier pattern
- * @return Collection of {@link String}
- * @throws AdminException
- */
- Collection<String> getCacheTypes() throws AdminException;
-
- /**
- * Get all the current Sessions.
- * @return Collection of {@link Session}
- * @throws AdminException
- */
- Collection<Session> getSessions() throws AdminException;
-
- /**
- * Get the all Requests that are currently in process
- * @return Collection of {@link Request}
- * @throws AdminException
- */
- Collection<Request> getRequests() throws AdminException;
-
- /**
- * Get the Requests for the given session
- * @return Collection of {@link Request}
- * @throws AdminException
- */
- Collection<Request> getRequestsForSession(String sessionId) throws AdminException;
-
-
- /**
- * Get all of the available configuration Properties for the specified connector
- * @param templateName - Name of the connector
- * @return
- * @throws AdminException
- */
- Collection<PropertyDefinition> getTemplatePropertyDefinitions(String templateName) throws AdminException;
-
-
- /**
- * Get all transaction matching the identifier.
- * @return
- * @throws AdminException
- */
- Collection<Transaction> getTransactions() throws AdminException;
-
- /**
- * Clear the cache or caches specified by the cacheIdentifier.
- * @param cacheType Cache Type
- * No wild cards currently supported, must be explicit
- * @throws AdminException
- */
- void clearCache(String cacheType) throws AdminException;
-
- /**
- * Clear the cache of the given VDB for provided cache type
- * @param cacheType Cache Type
- * No wild cards currently supported, must be explicit
- * @param vdbName - Name of the VDB
- * @param vdbVersion - VDB version
- * @throws AdminException
- */
- void clearCache(String cacheType, String vdbName, int vdbVersion) throws AdminException;
-
-
- /**
- * Get the Cache Statistics for the given type
- * @param cacheType Cache Type
- * @return {@link CacheStatistics}
- * @throws AdminException
- */
- CacheStatistics getCacheStats(String cacheType) throws AdminException;
-
- /**
- * Terminate the Session
- *
- * @param identifier Session Identifier {@link org.teiid.adminapi.Session}.
- * No wild cards currently supported, must be explicit
- * @throws AdminException
- */
- void terminateSession(String sessionId) throws AdminException;
-
- /**
- * Cancel Request
- *
- * @param sessionId session Identifier for the request.
- * @param executionId request Identifier
- *
- * @throws AdminException
- */
- void cancelRequest(String sessionId, long executionId) throws AdminException;
-
- /**
- * Mark the given global transaction as rollback only.
- * @param transactionId
- * @throws AdminException
- */
- void terminateTransaction(String transactionId) throws AdminException;
-
- /**
- * Closes the admin connection
- */
- void close();
-
- /**
- * Assign a Role name to the Data Role in a given VDB
- *
- * @param vdbName
- * @param vdbVersion
- * @param dataRole
- * @param mappedRoleName
- */
- void addDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
-
- /**
- * Remove a Role name to the Data Role in a given VDB
- *
- * @param vdbName
- * @param vdbVersion
- * @param dataRole
- * @param mappedRoleName
- */
- void removeDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
-
- /**
- * Set the any authenticated flag on the Data Role in a given VDB
- *
- * @param vdbName
- * @param vdbVersion
- * @param dataRole
- * @param anyAuthenticated
- */
- void setAnyAuthenticatedForDataRole(String vdbName, int vdbVersion, String dataRole, boolean anyAuthenticated) throws AdminException;
-
- /**
- * Merge the Source VDB into Target VDB. Both Source and Target VDBs must be present for this method to
- * succeed. The changes will not be persistent between server restarts.
- * @param sourceVDBName
- * @param sourceVDBVersion
- * @param targetVDBName
- * @param targetVDBVersion
- */
- void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
-
-
- /**
- * Creates a JCA data source
- * @param deploymentName - name of the source
- * @param templateName - template of data source
- * @param properties - properties
- * @throws AdminException
- */
- void createDataSource(String deploymentName, String templateName, Properties properties) throws AdminException;
-
- /**
- * Delete data source.
- * @param deployedName
- * @throws AdminException
- */
- void deleteDataSource(String deployedName) throws AdminException;
-
- /**
- * Returns the all names of all the data sources available in the configuration.
- */
- Collection<String> getDataSourceNames() throws AdminException;
-
- /**
- * Get the Datasource templates available in the configuration.
- *
- * @return Set of template names.
- * @throws AdminException
- */
- Set<String> getDataSourceTemplateNames() throws AdminException;
-
- /**
- * Tell the engine that the given source is available. Pending dynamic vdb metadata loads will be resumed.
- * @param jndiName
- * @throws AdminException
- */
- void markDataSourceAvailable(String jndiName) throws AdminException;
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-/**
- * An <code>AdminComponentException</code> is thrown when an error occurs as a
- * result of an internal component error.
- *
- * <p>This exception class is capable of containing multiple exceptions. See
- * {@link AdminException} for details.
- */
-public final class AdminComponentException extends AdminException {
-
- private static final long serialVersionUID = 7117721841515240902L;
-
-
- public AdminComponentException() {
- super();
- }
-
- /**
- * Construct with a message.
- * @param msg the error message.
- * @since 4.3
- */
- public AdminComponentException(String msg) {
- super(msg);
- }
-
- public AdminComponentException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Construct with an optional error code and a message.
- * @param code an optional error code
- * @param msg the error message.
- * @since 4.3
- */
- public AdminComponentException(int code, String msg) {
- super(code, msg);
- }
-
- public AdminComponentException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public AdminComponentException(int code, String msg, Throwable cause) {
- super(code, msg, cause);
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.teiid.core.TeiidException;
-
-
-/**
- * <code>AdminException</code> is the base exception for the admin package. Many *Admin methods throw this
- * exception. Instances will be one of the concrete subtypes:
- * {@link AdminComponentException} or {@link AdminProcessingException}</p>
- *
- * <p><code>AdminException</code>s may contain multiple child exceptions. An example
- * of this could be when performing an admin action results in multiple failures. Admin
- * clients should be aware of this and use the {@link #hasMultiple()} method to
- * determine if they need to check the child exceptions.</p>
- */
-public abstract class AdminException extends TeiidException {
-
- private static final long serialVersionUID = -4446936145500241358L;
- // List of Admin exceptions in
- // case of multiple failure
- private List children;
-
- /**
- * No-arg ctor.
- *
- * @since 4.3
- */
- AdminException() {
- super();
- }
-
- /**
- * Construct with a message.
- * @param msg the error message.
- * @since 4.3
- */
- AdminException(String msg) {
- super(msg);
- }
-
- AdminException(Throwable cause) {
- this(cause.getMessage(), cause);
- }
-
- /**
- * Construct with an optional error code and a message.
- * @param code an optional error code
- * @param msg the error message.
- * @since 4.3
- */
- AdminException(int code, String msg) {
- super(Integer.toString(code), msg);
- }
-
- AdminException(String msg, Throwable cause) {
- super(cause, msg);
- }
-
- AdminException(int code, String msg, Throwable cause) {
- super(cause, Integer.toString(code),msg);
- }
-
- /**
- * Determine whether this exception is representing
- * mutliple component failures.
- * @return <code>true</code> iff this exception contains multiple
- * component failure exceptions.
- * @since 4.3
- */
- public boolean hasMultiple() {
- return (children != null && children.size() > 0);
- }
-
- /**
- * Returns a non-null list of failures (<code>AdminException</code>s), one for each
- * component that failed.
- *
- * <p>The list will have members when {@link #hasMultiple()} returns <code>true</code>.</p>
- * @return The non-null list of failures.
- * @since 4.3
- */
- public List getChildren() {
- return (children != null ? children : Collections.EMPTY_LIST);
- }
-
- /**
- * Add a child <code>AdminException</code> for a particular failure
- * if and action resulted in multiple failures.
- *
- * @param child a specific failure
- * @since 4.3
- */
- public void addChild(AdminException child) {
- if ( children == null ) {
- children = new ArrayList();
- }
- children.add(child);
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,343 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.security.auth.callback.*;
-import javax.security.sasl.RealmCallback;
-import javax.security.sasl.RealmChoiceCallback;
-
-import org.jboss.as.cli.Util;
-import org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress;
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.teiid.adminapi.VDB.ConnectionType;
-
-
-/**
- * Singleton factory for class for creating Admin connections to the Teiid
- */
-public class AdminFactory {
- private static AdminFactory INSTANCE = new AdminFactory();
-
- public static AdminFactory getInstance() {
- return INSTANCE;
- }
- /**
- * Creates a ServerAdmin with the specified connection properties.
- * @param userName
- * @param password
- * @param serverURL
- * @param applicationName
- * @return
- * @throws AdminException
- */
- public Admin createAdmin(String host, int port, String userName, char[] password) throws AdminException {
- if(host == null) {
- host = "localhost"; //$NON-NLS-1$
- }
-
- if(port < 0) {
- port = 9990;
- }
-
- try {
- CallbackHandler cbh = new AuthenticationCallbackHandler(userName, password);
- ModelControllerClient newClient = ModelControllerClient.Factory.create(host, port, cbh);
-
- List<String> nodeTypes = Util.getNodeTypes(newClient, new DefaultOperationRequestAddress());
- if (!nodeTypes.isEmpty()) {
- boolean domainMode = nodeTypes.contains("server-group"); //$NON-NLS-1$
- System.out.println("Connected to " //$NON-NLS-1$
- + (domainMode ? "domain controller at " : "standalone controller at ") //$NON-NLS-1$ //$NON-NLS-2$
- + host + ":" + port); //$NON-NLS-1$
- return new AdminImpl(newClient);
- }
- System.out.println("The controller is not available at " + host + ":" + port); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (UnknownHostException e) {
- System.out.println("Failed to resolve host '" + host + "': " + e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return null;
- }
-
- private class AuthenticationCallbackHandler implements CallbackHandler {
- private boolean realmShown = false;
- private String userName = null;
- private char[] password = null;
-
- public AuthenticationCallbackHandler(String user, char[] password) {
- this.userName = user;
- this.password = password;
- }
-
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- // Special case for anonymous authentication to avoid prompting user for their name.
- if (callbacks.length == 1 && callbacks[0] instanceof NameCallback) {
- ((NameCallback)callbacks[0]).setName("anonymous CLI user"); //$NON-NLS-1$
- return;
- }
-
- for (Callback current : callbacks) {
- if (current instanceof RealmCallback) {
- RealmCallback rcb = (RealmCallback) current;
- String defaultText = rcb.getDefaultText();
- rcb.setText(defaultText); // For now just use the realm suggested.
- if (realmShown == false) {
- realmShown = true;
- }
- } else if (current instanceof RealmChoiceCallback) {
- throw new UnsupportedCallbackException(current, "Realm choice not currently supported."); //$NON-NLS-1$
- } else if (current instanceof NameCallback) {
- NameCallback ncb = (NameCallback) current;
- ncb.setName(userName);
- } else if (current instanceof PasswordCallback) {
- PasswordCallback pcb = (PasswordCallback) current;
- pcb.setPassword(password);
- } else {
- throw new UnsupportedCallbackException(current);
- }
- }
- }
-
- }
-
- private class AdminImpl implements Admin{
- public AdminImpl (ModelControllerClient connection) {
-
- }
-
- @Override
- public void addDataRoleMapping(String vdbName, int vdbVersion,
- String dataRole, String mappedRoleName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void assignToModel(String vdbName, int vdbVersion,
- String modelName, String sourceName, String translatorName,
- String dsName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void cancelRequest(String sessionId, long executionId)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void changeVDBConnectionType(String vdbName, int vdbVersion,
- ConnectionType type) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void clearCache(String cacheType) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void clearCache(String cacheType, String vdbName, int vdbVersion)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void close() {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void createDataSource(String deploymentName,
- String templateName, Properties properties)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void deleteDataSource(String deployedName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void deleteVDB(String vdbName, int vdbVersion)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void deployVDB(String fileName, InputStream vdb)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public CacheStatistics getCacheStats(String cacheType)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<String> getCacheTypes() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<String> getDataSourceNames() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<String> getDataSourceTemplateNames() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Request> getRequests() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Request> getRequestsForSession(String sessionId)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Session> getSessions() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<PropertyDefinition> getTemplatePropertyDefinitions(
- String templateName) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Transaction> getTransactions() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Translator getTranslator(String deployedName)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Translator> getTranslators() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public VDB getVDB(String vdbName, int vbdVersion) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<VDB> getVDBs() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public WorkerPoolStatistics getWorkerPoolStats() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void markDataSourceAvailable(String jndiName)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
- String targetVDBName, int targetVDBVersion)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void removeDataRoleMapping(String vdbName, int vdbVersion,
- String dataRole, String mappedRoleName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void setAnyAuthenticatedForDataRole(String vdbName,
- int vdbVersion, String dataRole, boolean anyAuthenticated)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void terminateSession(String sessionId) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void terminateTransaction(String transactionId)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * Base interface of client side admin objects. Specifies behaviors and properties common to all administrative objects.
- * <p>
- * Unique identifiers are available for all <code>AdminObject</code>s and their forms are specific to each object. See
- * the javadoc on the individual object for its particular identifier pattern required.
- * </p>
- * <p>
- * This interface need not be used directly by clients except when coding to constants.
- * </p>
- *
- * @since 4.3
- */
-public interface AdminObject extends Serializable {
-
- /**
- * The character that delimits the atomic components of the identifier.
- * @see #DELIMITER
- */
- public static final char DELIMITER_CHAR = '|';
-
- /**
- * The character (as a <code>String</code>) that delimits the atomic components of the identifier.
- *
- * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>DELIMITER</code>
- * rather than hard-coding a delimiter character in admin code. Doing this eliminates the possibility
- * of admin client code breaking if/when the delimiter character must be changed.</p>
- */
- public static final String DELIMITER = new String(new char[] {DELIMITER_CHAR});
-
- /**
- * The delimiter character as a <code>String</code> escaped.
- * @see #DELIMITER
- */
- public static final String ESCAPED_DELIMITER = "\\" + DELIMITER; //$NON-NLS-1$
-
- /**
- * The wildcard character (as a <code>String</code>) that can be used in may identifier patterns
- * to indicate <i>"anything"</i> or, more specifically, replace <i>"zero or more"</i>
- * identifier components.
- *
- * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>WILDCARD</code>
- * rather than hard-coding a wildcard character in admin code. Doing this eliminates the possibility
- * of admin client code breaking if/when the wildcard character must be changed.</p>
- */
- public static final String WILDCARD = "*"; //$NON-NLS-1$
-
- /**
- * The wildcard character as a <code>String</code> escaped.
- * @see #WILDCARD
- */
- public static final String ESCAPED_WILDCARD = "\\" + WILDCARD; //$NON-NLS-1$
-
- /**
- * Get the name for this AdminObject, usually the last component of the identifier.
- *
- * @return String Name
- * @since 4.3
- */
- String getName();
-
- /**
- * Get the Configuration Properties that defines this process
- *
- * @return Properties
- * @since 4.3
- */
- Properties getProperties();
-
- /**
- * Searches for the property with the specified key in this Admin Object. If the key is not found the method returns
- * <code>null</code>.
- *
- * @param name
- * the property key.
- * @return the value in this Admin Object with the specified key value.
- * @since 4.3
- */
-
- String getPropertyValue(String name);
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.ResourceBundle;
-
-import org.teiid.core.BundleUtil;
-
-public class AdminPlugin {
- public static final String PLUGIN_ID = "org.teiid.adminapi" ; //$NON-NLS-1$
- public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-/**
- * An <code>AdminProcessingException</code> indicates that an error occured during processing as a result
- * of user input. This exception is the result of handling an invalid user
- * request, not the result of an internal error.</p>
- *
- * <p>This exception class is capable of containing multiple exceptions. See
- * {@link AdminException} for details.
- */
-public final class AdminProcessingException extends AdminException {
-
- private static final long serialVersionUID = -878521636838205857L;
-
- /**
- * No-arg ctor.
- *
- * @since 4.3
- */
- public AdminProcessingException() {
- super();
- }
-
- /**
- * Construct with a message.
- * @param msg the error message.
- * @since 4.3
- */
- public AdminProcessingException(String msg) {
- super(msg);
- }
-
- public AdminProcessingException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Construct with an optional error code and a message.
- * @param code an optional error code
- * @param msg the error message.
- * @since 4.3
- */
- public AdminProcessingException(int code, String msg) {
- super(code, msg);
- }
-
- public AdminProcessingException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public AdminProcessingException(int code, String msg, Throwable cause) {
- super(code, msg, cause);
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-public interface CacheStatistics extends AdminObject {
-
- double getHitRatio();
-
- int getTotalEntries();
-
- int getRequestCount();
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-import java.util.List;
-
-public interface DataPolicy {
-
- public enum Context {
- CREATE,
- DROP,
- QUERY,
- INSERT,
- UPDATE,
- DELETE,
- FUNCTION,
- ALTER,
- STORED_PROCEDURE;
- }
-
- public enum PermissionType {CREATE, READ, UPDATE, DELETE, ALTER, EXECUTE, DROP};
-
- /**
- * Get the Name of the Data Policy
- * @return
- */
- String getName();
-
- /**
- * Get the description of the Data Policy
- * @return
- */
- String getDescription();
-
- /**
- * Get the List of Permissions for this Data Policy.
- * @return
- */
- List<DataPermission> getPermissions();
-
- /**
- * Mapped Container Role names for this Data Policy
- * @return
- */
- List<String> getMappedRoleNames();
-
- /**
- * If the policy applies to any authenticated user
- * @return
- */
- boolean isAnyAuthenticated();
-
- /**
- * If the policy allows for temporary table usage
- * @return
- */
- Boolean isAllowCreateTemporaryTables();
-
- interface DataPermission {
- /**
- * Get the Resource Name that Data Permission representing
- * @return
- */
- String getResourceName();
-
- /**
- * Is "CREATE" allowed?
- * @return
- */
- Boolean getAllowCreate();
-
- /**
- * Is "SELECT" allowed?
- * @return
- */
- Boolean getAllowRead();
-
- /**
- * Is "INSERT/UPDATE" allowed?
- * @return
- */
- Boolean getAllowUpdate();
-
- /**
- * Is "DELETE" allowed?
- * @return
- */
- Boolean getAllowDelete();
-
- /**
- * Is "ALTER" allowed?
- * @return
- */
- Boolean getAllowAlter();
-
- /**
- * Is "EXECUTE" allowed?
- * @return
- */
- Boolean getAllowExecute();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Model.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Model.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Model.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.List;
-
-
-/**
- * Represents a metadata model in the Teiid system.
- *
- * @since 4.3
- */
-public interface Model extends AdminObject {
-
- enum Type {PHYSICAL, VIRTUAL, FUNCTION, OTHER};
-
- /**
- * Description about the model
- * @return
- */
- String getDescription();
-
- /**
- * Determine if this model is a Source model.
- *
- * @return <code>true</code> if it contains physical group(s).
- */
- boolean isSource();
-
- /**
- * Determine whether this model is exposed for querying.
- *
- * @return <code>true</code> if the model is visible
- * for querying.
- */
- boolean isVisible();
-
- /**
- * Retrieve the model type.
- * @return model type
- */
- Type getModelType();
-
- /**
- * Determine whether this model can support more than one source.
- *
- * @return <code>true</code> if this model supports multiple sources
- */
- boolean isSupportsMultiSourceBindings();
-
- /**
- * Associated Source Names for the Models
- * @return String
- */
- List<String> getSourceNames();
-
- /**
- * Get the configured JNDI name for the given source name.
- * @param sourceName - name of the source
- * @return null if none configured.
- */
- String getSourceConnectionJndiName(String sourceName);
-
-
- /**
- * Get the configured translator name for the given source
- * @param sourceName
- * @return
- */
- String getSourceTranslatorName(String sourceName);
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.Collection;
-
-/**
- * Information about a property of an AdminObject
- */
-public interface PropertyDefinition extends AdminObject {
-
- public enum RestartType {
- NONE,
- SERVICE,
- PROCESS,
- ALL_PROCESSES,
- CLUSTER
- }
- /**
- * The value of the maximum multiplicity if the multiplicity is considered unbounded.
- */
- public static final int UNBOUNDED_VALUE = Integer.MAX_VALUE;
-
-
- /**
- * Get the localized display name of this property.
- * @return the displayable name for this property
- */
- String getDisplayName();
-
- /**
- * Get the description of this property.
- * @return the description for this property
- */
- String getDescription();
-
-
- /**
- * Get the name of the java class that best represents the property type.
- * @return the name of the java class that best represents the property type.
- */
- String getPropertyTypeClassName();
-
-
- /**
- * Get the default value for values of this property, or an empty String if
- * there is no default value.
- * @return the default value for this property, or an empty String
- * if there is no default value.
- */
- Object getDefaultValue();
-
- /**
- * Get the allowed values for this property.
- * @return the list of allowed values for this property, or an empty
- * set if the values do not have to conform to a fixed set.
- */
- Collection getAllowedValues();
-
- /**
- * Get whether this property requires the system to be restarted before it takes effect.
- * @return true if this property requires the system to be restarted before it takes effect.
- */
- public RestartType getRequiresRestart();
-
- /**
- * The modifiable flag is used to identify features that may not be changed once
- * they are set.
- * @return true if this property is marked with the modifyable
- * flag, or false otherwise.
- */
- boolean isModifiable();
-
- /**
- * Return whether the value or values for this property are constrained to be only
- * those in the AllowedValues list.
- * @see #getAllowedValues
- * @return true if this property's value must be with the list of AllowedValues.
- */
- boolean isConstrainedToAllowedValues();
-
- /**
- * The "expert" flag is used to distinguish between features that are
- * intended for expert users from those that are intended for normal users.
- * @return true if this property is to be marked with the expert flag,
- * or false otherwise.
- */
- boolean isAdvanced();
- /**
- * The "required" flag is used to identify features that require at least
- * one value (possibly a default value) by the consumer of the property. Whether
- * a property definition is required or not can be determined entirely from the
- * multiplicity: if the multiplicity includes '0', then the property is
- * not required.
- * <p>
- * Whether a property is required by the consumer is unrelated to whether
- * there is a default value, which only simplifies the task of the property
- * provider. A property may be required, meaning it must have at least one
- * value, but that same property definition may or may not have a default.
- * The combination of required and whether it has a default will determine
- * whether the user must supply a value.
- * @return true if this property requires at least one value.
- */
- boolean isRequired();
- /**
- * The "masked" flag is used to tell whether the value should be masked
- * when displayed to users.
- * @return true if this property value is to be masked,
- * or false otherwise.
- */
- boolean isMasked();
-
-
-
-}
-
-
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Request.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Request.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-
-
-/**
- * When a user submits a SQL command to the system for processing, usually that represents
- * a single request. A single request might have one or more source
- * requests (the requests that are being processed on the physical data sources) as part
- * of original request.
- *
- * <p>A request is identified by a numbers separated by '|'. usually in they are arranged
- * in the pattern [session]|[request] or [session]|[request]|[source request] </p>
- */
-public interface Request extends AdminObject {
-
- public enum ProcessingState {
- PROCESSING,
- DONE,
- CANCELED
- }
-
- public enum ThreadState {
- RUNNING,
- QUEUED,
- IDLE
- }
-
- /**
- * Get the ExecutionId for a Request
- * @return ExecutionId
- */
- public long getExecutionId();
-
- /**
- * Get the SessionID for a Request
- *
- * @return String SessionID
- */
- public String getSessionId();
-
- /**
- * Get the SQL Command sent to the Server for a Request
- *
- * @return SQL Command
- */
- public String getCommand();
-
- /**
- * Get when the processing began for this Request
- * @return Date processing began
- */
- public long getStartTime();
-
- /**
- * Get the TransactionID of the Request
- *
- * @return String of TransactionID if in a transaction
- */
- public String getTransactionId();
-
- /**
- * @return Returns whether this is a Source Request.
- */
- public boolean sourceRequest();
-
- /**
- * @return In the case that this is a source request this represents the node id. Otherwise null
- */
- public Integer getNodeId();
-
- /**
- * @return The request state
- */
- ProcessingState getState();
-
- /**
- * @return The thread state
- */
- ThreadState getThreadState();
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Session.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Session.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-/**
- * A Session represents a single connection between a client and the server.
- *
- * A user is allowed to have multiple sessions active simultaneously.
- */
-public interface Session extends AdminObject {
-
- /**
- * Get the Last time Client has check to see if the server is still available
- *
- * @return Date of the last ping to the server.
- */
- public long getLastPingTime();
-
-
- /**
- * Get the Application Name
- *
- * @return String of the Application Name
- */
- public String getApplicationName();
-
- /**
- * Get the unique Teiid session
- * within a given Teiid System
- *
- * @return String of the Session ID
- */
- public String getSessionId();
-
- /**
- * Get User Name for this Session
- *
- * @return String of UserName
- */
- public String getUserName();
-
- /**
- * Get the VDB Name for this Session
- *
- * @return String name of the VDB
- */
- public String getVDBName();
-
- /**
- * Get the VDB Version for this Session
- *
- * @return String name/number of the VDB Version
- */
- public int getVDBVersion();
-
- /**
- * Get the IPAddress for this Session. Note this value is reported from the client.
- * @return
- */
- public String getIPAddress();
-
-
- /**
- * Get the host name of the machine the client is
- * accessing from. Note this value is reported from the client.
- * @return
- */
- public String getClientHostName();
-
- /**
- * Get the client hardware (typically MAC) address. Note this value is reported from the client.
- * @return the hardware address as a hex string or null if not available.
- */
- public String getClientHardwareAddress();
-
- /**
- * Get the time the {@link Session} was created.
- * @return
- */
- public long getCreatedTime();
-
-
- /**
- * Security Domain user logged into currently
- * @return
- */
- public String getSecurityDomain();
-
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-public interface Transaction extends AdminObject {
-
- /**
- * Get the session associated with the this transaction.
- * May be null for an unassociated Global transaction.
- * @return
- */
- String getAssociatedSession();
-
- /**
- * Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
- * @return
- */
- String getScope();
-
- /**
- * Returns the Xid string for GLOBAL transactions or the Transaction id string LOCAL/REQUEST.
- * @return
- */
- String getId();
-
-
- /**
- * Get the local creation time.
- * @return
- */
- long getCreatedTime();
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-
-public interface Translator extends AdminObject{
- public static final String EXECUTION_FACTORY_CLASS = "execution-factory-class"; //$NON-NLS-1$
- public static final String TRANSLATOR_PROPERTY = "property"; //$NON-NLS-1$
-
- /**
- * Get the Translator type
- * @return
- */
- public String getType();
-
- /**
- * Get the Translator description
- * @return
- */
- public String getDescription();
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.List;
-
-/**
- * Represents a Virtual Database in the Teiid System.
- * <br>A VDB has a name and a version.</br>
- *
- * <p>The identifier pattern for a VDB is <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>,
- * where the name of the VDB and its version represent its unique identifier in the Teiid system.
- * There are no spaces allowed in a given VDB name, and VDB name must start with a letter.
- * A version number is automatically assigned to a VDB when it is deployed into
- * a system. A VDB is uniquely identified by <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>.
- * For example: <CODE>"Accounts<{@link #DELIMITER_CHAR}>1"</CODE>, <CODE>"UnifiedSales<{@link #DELIMITER_CHAR}>4</CODE>" etc.
- * </p>
- *
- * @since 4.3
- */
-public interface VDB extends AdminObject {
-
- public static enum Status{INACTIVE, ACTIVE};
-
- public enum ConnectionType {NONE, BY_VERSION, ANY}
-
- /**
- * @return Collection of Teiid Models
- */
- public List<Model> getModels();
-
- /**
- * @return the status
- */
- public Status getStatus();
-
- /**
- * @return the connection status
- */
- public ConnectionType getConnectionType();
-
- /**
- * @return the VDB version
- */
- public int getVersion();
-
- /**
- * Get the URL for the VDB
- * @return
- */
- public String getUrl();
-
- /**
- * Get the description of the VDB
- * @return
- */
- public String getDescription();
-
- /**
- * Shows any validity errors present in the VDB
- * @return
- */
- public List<String> getValidityErrors();
-
- /**
- * Shows if VDB is a valid entity
- * @return
- */
- public boolean isValid();
-
- /**
- * Get the data roles defined on this VDB
- * @return
- */
- public List<DataPolicy> getDataPolicies();
-
- /**
- * Get the list of translators defined in the VDB
- * @return
- */
- public List<Translator> getOverrideTranslators();
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-public interface WorkerPoolStatistics extends AdminObject {
-
- /**
- * Current active thread count
- * @return
- */
- public int getActiveThreads();
-
- /**
- * Highest Active threads recorded so far
- * @return
- */
- public int getHighestActiveThreads();
-
-
- /**
- * Queue Name
- * @return
- */
- public String getQueueName();
-
-
- /**
- * Max number of active threads allowed
- * @return
- */
- public int getMaxThreads();
-
- /**
- * @return Returns the number of requests queued.
- * @since 4.3
- */
- public int getQueued();
-
- /**
- * @return The number of completed tasks
- */
- long getTotalCompleted();
-
-
- /**
- * @return The number of submitted tasks
- */
- long getTotalSubmitted();
-
- /**
- * @return Returns the highest queue size
- */
- public int getHighestQueued();
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,187 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-
-import org.teiid.adminapi.AdminObject;
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-public abstract class AdminObjectImpl implements AdminObject, Serializable {
-
- private static final long serialVersionUID = -6381303538713462682L;
-
- private String name;
-
- private ListOverMap<PropertyMetadata> properties = new ListOverMap<PropertyMetadata>(new KeyBuilder<PropertyMetadata>() {
- private static final long serialVersionUID = 3687928367250819142L;
-
- @Override
- public String getKey(PropertyMetadata entry) {
- return entry.getName();
- }
- });
-
- private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
-
- @Override
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public Properties getProperties() {
- Properties props = new Properties();
- for (PropertyMetadata p:this.properties.getMap().values()) {
- props.setProperty(p.getName(), p.getValue());
- }
- return props;
- }
-
- public void setProperties(Properties props) {
- this.properties.clear();
- if (props != null) {
- for (String key:props.stringPropertyNames()) {
- addProperty(key, props.getProperty(key));
- }
- }
- }
-
- public List<PropertyMetadata> getJAXBProperties(){
- return properties;
- }
-
- public void setJAXBProperties(List<PropertyMetadata> props){
- this.properties.clear();
- if (props != null) {
- for (PropertyMetadata prop:props) {
- addProperty(prop.getName(), prop.getValue());
- }
- }
- }
-
- @Override
- public String getPropertyValue(String name) {
- PropertyMetadata prop = this.properties.getMap().get(name);
- if (prop == null) {
- return null;
- }
- return prop.getValue();
- }
-
- public void addProperty(String key, String value) {
- this.properties.getMap().put(key, new PropertyMetadata(key, value));
- }
-
- /**
- * Add attachment
- *
- * @param <T> the expected type
- * @param attachment the attachment
- * @param type the type
- * @return any previous attachment
- * @throws IllegalArgumentException for a null name, attachment or type
- * @throws UnsupportedOperationException when not supported by the implementation
- */
- public <T> T addAttchment(Class<T> type, T attachment) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.put(type.getName(), attachment);
- if (result == null)
- return null;
- return type.cast(result);
-
- }
-
- public Object addAttchment(String key, Object attachment) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.put(key, attachment);
- if (result == null)
- return null;
- return result;
- }
-
- /**
- * Remove attachment
- *
- * @param <T> the expected type
- * @return the attachment or null if not present
- * @param type the type
- * @throws IllegalArgumentException for a null name or type
- */
- public <T> T removeAttachment(Class<T> type) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.remove(type.getName());
- if (result == null)
- return null;
- return type.cast(result);
- }
-
- public Object removeAttachment(String key) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.remove(key);
- if (result == null)
- return null;
- return result;
- }
- /**
- * Get attachment
- *
- * @param <T> the expected type
- * @param type the type
- * @return the attachment or null if not present
- * @throws IllegalArgumentException for a null name or type
- */
- public <T> T getAttachment(Class<T> type) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.get(type.getName());
- if (result == null)
- return null;
- return type.cast(result);
- }
-
- public Object getAttachment(String key) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.get(key);
- if (result == null)
- return null;
- return result;
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import org.teiid.adminapi.CacheStatistics;
-
-public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
-
- private static final long serialVersionUID = -3514505497661004560L;
-
- private double hitRatio;
- private int totalEntries;
- private int requestCount;
-
- @Override
- public int getRequestCount() {
- return requestCount;
- }
-
- public void setRequestCount(int count) {
- this.requestCount = count;
- }
-
- @Override
- public double getHitRatio() {
- return this.hitRatio;
- }
-
- @Override
- public int getTotalEntries() {
- return this.totalEntries;
- }
-
- public void setHitRatio(double value) {
- this.hitRatio = value;
- }
-
- public void setTotalEntries(int value) {
- this.totalEntries = value;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("hitRatio=").append(hitRatio);//$NON-NLS-1$
- sb.append("; totalEntries=").append(totalEntries); //$NON-NLS-1$
- sb.append("; requestCount=").append(requestCount); //$NON-NLS-1$
- return sb.toString();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.teiid.adminapi.AdminException;
-
-
-public interface DQPManagement {
- List<RequestMetadata> getRequestsForSession(String sessionId) ;
- List<RequestMetadata> getRequests();
- WorkerPoolStatisticsMetadata getWorkerPoolStatistics();
- void terminateSession(String terminateeId);
- boolean cancelRequest(String sessionId, long requestId) throws AdminException;
- Collection<String> getCacheTypes();
- void clearCache(String cacheType);
- void clearCache(String cacheType, String vdbName, int version);
- Collection<SessionMetadata> getActiveSessions() throws AdminException;
- int getActiveSessionsCount() throws AdminException;
- Collection<TransactionMetadata> getTransactions();
- void terminateTransaction(String xid) throws AdminException ;
- void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
- List<RequestMetadata> getLongRunningRequests();
- List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) throws AdminException;
- CacheStatisticsMetadata getCacheStatistics(String cacheType);
- List<List> executeQuery(String vdbName, int version, String command, long timoutInMilli) throws AdminException;
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,291 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.*;
-
-import org.teiid.adminapi.DataPolicy;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "permissions",
- "mappedRoleNames"
-})
-public class DataPolicyMetadata implements DataPolicy, Serializable {
- private static final long serialVersionUID = -4119646357275977190L;
-
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlElement(name = "description")
- protected String description;
- @XmlAttribute(name = "any-authenticated")
- protected boolean anyAuthenticated;
- @XmlAttribute(name = "allow-create-temporary-tables")
- protected Boolean allowCreateTemporaryTables;
-
- @XmlElement(name = "permission")
- protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
- private static final long serialVersionUID = -6992984146431492449L;
- @Override
- public String getKey(PermissionMetaData entry) {
- return entry.getResourceName().toLowerCase();
- }
- });
-
- @XmlElement(name = "mapped-role-name")
- protected List<String> mappedRoleNames = new ArrayList<String>();
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String value) {
- this.name = value;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String value) {
- this.description = value;
- }
-
- @Override
- public List<DataPermission> getPermissions() {
- return new ArrayList<DataPermission>(this.permissions.getMap().values());
- }
-
- public void setPermissions(List<DataPermission> permissions) {
- this.permissions.getMap().clear();
- for (DataPermission permission:permissions) {
- this.permissions.add((PermissionMetaData)permission);
- }
- }
-
- public void addPermission(PermissionMetaData... permissions) {
- for (PermissionMetaData permission:permissions) {
- this.permissions.add(permission);
- }
- }
-
- @Override
- public List<String> getMappedRoleNames() {
- return mappedRoleNames;
- }
-
- public void setMappedRoleNames(List<String> names) {
- this.mappedRoleNames.clear();
- this.mappedRoleNames.addAll(names);
- }
-
- public void addMappedRoleName(String name) {
- this.mappedRoleNames.add(name);
- }
-
- public boolean allows(String resourceName, DataPolicy.PermissionType type) {
- resourceName = resourceName.toLowerCase();
- while (resourceName.length() > 0) {
- PermissionMetaData p = this.permissions.getMap().get(resourceName);
- if (p != null) {
- Boolean allowed = p.allows(type);
- if (allowed != null) {
- return allowed;
- }
- }
- resourceName = resourceName.substring(0, Math.max(0, resourceName.lastIndexOf('.')));
- }
- return false;
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "resourceName",
- "allowCreate",
- "allowRead",
- "allowUpdate",
- "allowDelete",
- "allowExecute",
- "allowAlter"
- })
- public static class PermissionMetaData implements DataPermission, Serializable {
- private static final long serialVersionUID = 7034744531663164277L;
-
- // XML based fields
- private String resourceName;
- @XmlElement(name = "allow-create")
- protected Boolean allowCreate;
- @XmlElement(name = "allow-read")
- protected Boolean allowRead;
- @XmlElement(name = "allow-update")
- protected Boolean allowUpdate;
- @XmlElement(name = "allow-delete")
- protected Boolean allowDelete;
- @XmlElement(name = "allow-execute")
- protected Boolean allowExecute;
- @XmlElement(name = "allow-alter")
- protected Boolean allowAlter;
-
- @Override
- @XmlElement(name = "resource-name", required = true)
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String value) {
- this.resourceName = value;
- }
-
- @Override
- public Boolean getAllowCreate() {
- return allowCreate;
- }
-
- public void setAllowCreate(Boolean value) {
- this.allowCreate = value;
- }
-
- @Override
- public Boolean getAllowRead() {
- return allowRead;
- }
-
- public void setAllowRead(Boolean value) {
- this.allowRead = value;
- }
-
- @Override
- public Boolean getAllowUpdate() {
- return allowUpdate;
- }
-
- public void setAllowUpdate(Boolean value) {
- this.allowUpdate = value;
- }
-
- @Override
- public Boolean getAllowDelete() {
- return allowDelete;
- }
-
- public void setAllowDelete(Boolean value) {
- this.allowDelete = value;
- }
-
- public String getType() {
- StringBuilder sb = new StringBuilder();
- if (Boolean.TRUE.equals(getAllowCreate())) {
- sb.append("C");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowRead())) {
- sb.append("R");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowUpdate())) {
- sb.append("U");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowDelete())) {
- sb.append("D");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowExecute())) {
- sb.append("E");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowAlter())) {
- sb.append("A");//$NON-NLS-1$
- }
- return sb.toString();
- }
-
- public Boolean allows(PermissionType type) {
- switch (type) {
- case ALTER:
- return getAllowAlter();
- case CREATE:
- return getAllowCreate();
- case EXECUTE:
- if (getAllowExecute() != null) {
- return getAllowExecute();
- }
- case READ:
- return getAllowRead();
- case UPDATE:
- return getAllowUpdate();
- case DELETE:
- return getAllowDelete();
- }
- throw new AssertionError();
- }
-
- @Override
- public Boolean getAllowAlter() {
- return allowAlter;
- }
-
- @Override
- public Boolean getAllowExecute() {
- return allowExecute;
- }
-
- public void setAllowAlter(Boolean allowAlter) {
- this.allowAlter = allowAlter;
- }
-
- public void setAllowExecute(Boolean allowExecute) {
- this.allowExecute = allowExecute;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(getResourceName());
- sb.append("["); //$NON-NLS-1$
- sb.append(getType());
- sb.append("]");//$NON-NLS-1$
- return sb.toString();
- }
- }
-
- public Boolean isAllowCreateTemporaryTables() {
- return allowCreateTemporaryTables;
- }
-
- public void setAllowCreateTemporaryTables(Boolean allowCreateTemporaryTables) {
- this.allowCreateTemporaryTables = allowCreateTemporaryTables;
- }
-
- @Override
- public boolean isAnyAuthenticated() {
- return this.anyAuthenticated;
- }
-
- public void setAnyAuthenticated(boolean anyAuthenticated) {
- this.anyAuthenticated = anyAuthenticated;
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.AbstractList;
-import java.util.LinkedHashMap;
-import java.util.Set;
-
-class ListOverMap<E> extends AbstractList<E> implements Serializable {
-
- private static final long serialVersionUID = 5171741731121210240L;
-
- protected LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
- protected KeyBuilder<E> builder;
-
- public ListOverMap(KeyBuilder<E> builder) {
- this.builder = builder;
- }
-
- public LinkedHashMap<String, E> getMap() {
- return map;
- }
-
- @Override
- public void add(int index, E element) {
- this.map.put(builder.getKey(element), element);
- }
-
- @Override
- public E remove(int index) {
- String key = getKey(index);
- if (key == null) {
- throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return this.map.remove(key);
- }
-
- @Override
- public E get(int index) {
- String key = getKey(index);
- if (key == null) {
- throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return this.map.get(key);
- }
-
- private String getKey(int index) {
- Set<String> keys = this.map.keySet();
- int i = 0;
- for (String key:keys) {
- if (i == index) {
- return key;
- }
- i++;
- }
- return null;
- }
-
- @Override
- public int size() {
- return this.map.size();
- }
-}
-
-interface KeyBuilder<E> extends Serializable {
- String getKey(E entry);
-}
-
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,1071 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-import org.teiid.adminapi.AdminPlugin;
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.Request.ProcessingState;
-import org.teiid.adminapi.Request.ThreadState;
-import org.teiid.adminapi.VDB.ConnectionType;
-import org.teiid.adminapi.VDB.Status;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-
-
-public class MetadataMapper {
- private static final String VDBNAME = "vdb-name"; //$NON-NLS-1$
- private static final String CONNECTIONTYPE = "connection-type"; //$NON-NLS-1$
- private static final String STATUS = "status"; //$NON-NLS-1$
- private static final String VERSION = "vdb-version"; //$NON-NLS-1$
- private static final String URL = "url"; //$NON-NLS-1$
- private static final String MODELS = "models"; //$NON-NLS-1$
- private static final String OVERRIDE_TRANSLATORS = "override-translators"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String DYNAMIC = "dynamic"; //$NON-NLS-1$
- private static final String DATA_POLICIES = "data-policies"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(VDBMetaData vdb, ModelNode node) {
- if (vdb == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(VDBNAME).set(vdb.getName());
- node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
- node.get(STATUS).set(vdb.getStatus().toString());
- node.get(VERSION).set(vdb.getVersion());
- if (vdb.getUrl() != null) {
- }
- if (vdb.getDescription() != null) {
- node.get(DESCRIPTION).set(vdb.getDescription());
- }
- node.get(DYNAMIC).set(vdb.isDynamic());
-
- //PROPERTIES
- List<PropertyMetadata> properties = vdb.getJAXBProperties();
- if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
- }
- }
-
- // MODELS
- Map<String, ModelMetaData> models = vdb.getModelMetaDatas();
- if (models != null && !models.isEmpty()) {
- ModelNode modelNodes = node.get(CHILDREN, MODELS);
- for(ModelMetaData model:models.values()) {
- modelNodes.add(ModelMetadataMapper.wrap(model, new ModelNode()));
- }
- }
-
- // OVERRIDE_TRANSLATORS
- List<Translator> translators = vdb.getOverrideTranslators();
- if (translators != null && !translators.isEmpty()) {
- ModelNode translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
- for (Translator translator:translators) {
- translatorNodes.add(VDBTranslatorMetaDataMapper.wrap((VDBTranslatorMetaData)translator, new ModelNode()));
- }
- }
-
- // DATA_POLICIES
- List<DataPolicy> policies = vdb.getDataPolicies();
- if (policies != null && !policies.isEmpty()) {
- ModelNode dataPoliciesNodes = node.get(CHILDREN, DATA_POLICIES);
- for (DataPolicy policy:policies) {
- dataPoliciesNodes.add(DataPolicyMetadataMapper.wrap((DataPolicyMetadata)policy, new ModelNode()));
- }
- }
- return node;
- }
-
- public static VDBMetaData unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- VDBMetaData vdb = new VDBMetaData();
- if (node.has(VDBNAME)) {
- vdb.setName(node.get(VDBNAME).asString());
- }
- if (node.has(CONNECTIONTYPE)) {
- vdb.setConnectionType(node.get(CONNECTIONTYPE).asString());
- }
- if (node.has(STATUS)) {
- vdb.setStatus(node.get(STATUS).asString());
- }
- if (node.has(VERSION)) {
- vdb.setVersion(node.get(VERSION).asInt());
- }
- if (node.has(URL)) {
- vdb.setUrl(node.get(URL).asString());
- }
- if(node.has(DESCRIPTION)) {
- vdb.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(DYNAMIC)) {
- vdb.setDynamic(node.get(DYNAMIC).asBoolean());
- }
-
- //PROPERTIES
- if (node.get(CHILDREN, PROPERTIES).isDefined()) {
- List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
- for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
- if (prop != null) {
- vdb.addProperty(prop.getName(), prop.getValue());
- }
- }
- }
-
- // MODELS
- if (node.get(CHILDREN, MODELS).isDefined()) {
- List<ModelNode> modelNodes = node.get(CHILDREN, MODELS).asList();
- for(ModelNode modelNode:modelNodes) {
- ModelMetaData model = ModelMetadataMapper.unwrap(modelNode);
- if (model != null) {
- vdb.addModel(model);
- }
- }
- }
-
- // OVERRIDE_TRANSLATORS
- if (node.get(CHILDREN, OVERRIDE_TRANSLATORS).isDefined()) {
- List<ModelNode> translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS).asList();
- for (ModelNode translatorNode:translatorNodes) {
- VDBTranslatorMetaData translator = VDBTranslatorMetaDataMapper.unwrap(translatorNode);
- if (translator != null) {
- vdb.addOverideTranslator(translator);
- }
- }
- }
-
- // DATA_POLICIES
- if (node.get(CHILDREN, DATA_POLICIES).isDefined()) {
- List<ModelNode> policiesNodes = node.get(CHILDREN, DATA_POLICIES).asList();
- for (ModelNode policyNode:policiesNodes) {
- DataPolicyMetadata policy = DataPolicyMetadataMapper.unwrap(policyNode);
- if (policy != null) {
- vdb.addDataPolicy(policy);
- }
-
- }
- }
- return vdb;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, VDBNAME, ModelType.STRING, true);
-
- ModelNode connectionsAllowed = new ModelNode();
- connectionsAllowed.add(ConnectionType.NONE.toString());
- connectionsAllowed.add(ConnectionType.ANY.toString());
- connectionsAllowed.add(ConnectionType.BY_VERSION.toString());
- addAttribute(node, CONNECTIONTYPE, ModelType.STRING, false).get(ALLOWED).set(connectionsAllowed);
-
- ModelNode statusAllowed = new ModelNode();
- statusAllowed.add(Status.ACTIVE.toString());
- statusAllowed.add(Status.INACTIVE.toString());
- addAttribute(node, STATUS, ModelType.STRING, true).get(ALLOWED).set(statusAllowed);
-
- addAttribute(node, VERSION, ModelType.INT, true);
- addAttribute(node, URL, ModelType.STRING, false);
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
-
- ModelNode props = node.get(CHILDREN, PROPERTIES);
- props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
- PropertyMetaDataMapper.describe(props);
-
- ModelNode models = node.get(CHILDREN, MODELS);
- ModelMetadataMapper.describe(models);
- models.get(DESCRIPTION).set(AdminPlugin.Util.getString(MODELS+DOT_DESC));
- models.get(MIN_OCCURS).set(1);
-
- ModelNode translators = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
- translators.get(DESCRIPTION).set(AdminPlugin.Util.getString(OVERRIDE_TRANSLATORS+DOT_DESC));
- VDBTranslatorMetaDataMapper.describe(translators);
-
- ModelNode dataPolicies = node.get(CHILDREN, DATA_POLICIES);
- dataPolicies.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_POLICIES+DOT_DESC));
- DataPolicyMetadataMapper.describe(dataPolicies);
- return node;
- }
-
- /**
- * model metadata mapper
- */
- public static class ModelMetadataMapper {
- private static final String MODEL_NAME = "model-name"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String VISIBLE = "visible"; //$NON-NLS-1$
- private static final String MODEL_TYPE = "model-type"; //$NON-NLS-1$
- private static final String MODELPATH = "model-path"; //$NON-NLS-1$
- private static final String PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String SOURCE_MAPPINGS = "source-mappings"; //$NON-NLS-1$
- private static final String VALIDITY_ERRORS = "validity-errors"; //$NON-NLS-1$
-
- public static ModelNode wrap(ModelMetaData model, ModelNode node) {
- if (model == null) {
- return null;
- }
- node.get(TYPE).set(ModelType.OBJECT);
-
- node.get(MODEL_NAME).set(model.getName());
- if (model.getDescription() != null) {
- node.get(DESCRIPTION).set(model.getDescription());
- }
- node.get(VISIBLE).set(model.isVisible());
- node.get(MODEL_TYPE).set(model.getModelType().toString());
- if (model.getPath() != null) {
- node.get(MODELPATH).set(model.getPath());
- }
-
- List<PropertyMetadata> properties = model.getJAXBProperties();
- if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
- }
- }
-
- List<SourceMappingMetadata> sources = model.getSourceMappings();
- if (sources != null && !sources.isEmpty()) {
- ModelNode sourceMappingNode = node.get(CHILDREN, SOURCE_MAPPINGS);
- for(SourceMappingMetadata source:sources) {
- sourceMappingNode.add(SourceMappingMetadataMapper.wrap(source, new ModelNode()));
- }
- }
-
- List<ValidationError> errors = model.getErrors();
- if (errors != null && !errors.isEmpty()) {
- ModelNode errorsNode = node.get(CHILDREN, VALIDITY_ERRORS);
- for (ValidationError error:errors) {
- errorsNode.add(ValidationErrorMapper.wrap(error));
- }
- }
- return node;
- }
-
- public static ModelMetaData unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
-
- ModelMetaData model = new ModelMetaData();
- if (node.has(MODEL_NAME)) {
- model.setName(node.get(MODEL_NAME).asString());
- }
- if (node.has(DESCRIPTION)) {
- model.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(VISIBLE)) {
- model.setVisible(node.get(VISIBLE).asBoolean());
- }
- if(node.has(MODEL_TYPE)) {
- model.setModelType(node.get(MODEL_TYPE).asString());
- }
- if(node.has(MODELPATH)) {
- model.setPath(node.get(MODELPATH).asString());
- }
-
- if (node.get(CHILDREN, PROPERTIES).isDefined()) {
- List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
- for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
- if (prop != null) {
- model.addProperty(prop.getName(), prop.getValue());
- }
- }
- }
-
- if (node.get(CHILDREN, SOURCE_MAPPINGS).isDefined()) {
- List<ModelNode> sourceMappingNodes = node.get(CHILDREN, SOURCE_MAPPINGS).asList();
- for (ModelNode sourceMapping:sourceMappingNodes) {
- SourceMappingMetadata source = SourceMappingMetadataMapper.unwrap(sourceMapping);
- if (source != null) {
- model.addSourceMapping(source);
- }
- }
- }
-
- if (node.get(CHILDREN, VALIDITY_ERRORS).isDefined()) {
- List<ModelNode> errorNodes = node.get(CHILDREN, VALIDITY_ERRORS).asList();
- for(ModelNode errorNode:errorNodes) {
- ValidationError error = ValidationErrorMapper.unwrap(errorNode);
- if (error != null) {
- model.addError(error);
- }
- }
- }
- return model;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
-
- ModelNode modelTypes = new ModelNode();
- modelTypes.add(Model.Type.PHYSICAL.toString());
- modelTypes.add(Model.Type.VIRTUAL.toString());
- modelTypes.add(Model.Type.FUNCTION.toString());
- modelTypes.add(Model.Type.OTHER.toString());
- addAttribute(node, MODEL_NAME, ModelType.STRING, true).get(ALLOWED).set(modelTypes);
-
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, VISIBLE, ModelType.BOOLEAN, false);
- addAttribute(node, MODEL_TYPE, ModelType.STRING, true);
- addAttribute(node, MODELPATH, ModelType.STRING, false);
-
- ModelNode props = node.get(CHILDREN, PROPERTIES);
- props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
- PropertyMetaDataMapper.describe(props);
-
- ModelNode source = node.get(CHILDREN, SOURCE_MAPPINGS);
- source.get(DESCRIPTION).set(AdminPlugin.Util.getString(SOURCE_MAPPINGS+DOT_DESC));
- SourceMappingMetadataMapper.describe(source);
-
- ModelNode errors = node.get(CHILDREN, VALIDITY_ERRORS);
- errors.get(DESCRIPTION).set(AdminPlugin.Util.getString(VALIDITY_ERRORS+DOT_DESC));
- ValidationErrorMapper.describe(errors);
-
- return node;
- }
- }
-
- /**
- * validation error mapper
- */
- public static class ValidationErrorMapper {
- private static final String ERROR_PATH = "error-path"; //$NON-NLS-1$
- private static final String SEVERITY = "severity"; //$NON-NLS-1$
- private static final String MESSAGE = "message"; //$NON-NLS-1$
-
- public static ModelNode wrap(ValidationError error) {
- if (error == null) {
- return null;
- }
-
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.OBJECT);
- if (error.getPath() != null) {
- node.get(ERROR_PATH).set(error.getPath());
- }
- node.get(SEVERITY).set(error.getSeverity());
- node.get(MESSAGE).set(error.getValue());
-
- return node;
- }
-
- public static ValidationError unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
-
- ValidationError error = new ValidationError();
- if (node.has(ERROR_PATH)) {
- error.setPath(node.get(ERROR_PATH).asString());
- }
- if (node.has(SEVERITY)) {
- error.setSeverity(node.get(SEVERITY).asString());
- }
- if(node.has(MESSAGE)) {
- error.setValue(node.get(MESSAGE).asString());
- }
- return error;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, ERROR_PATH, ModelType.STRING, false);
- addAttribute(node, SEVERITY, ModelType.STRING, true);
- addAttribute(node, MESSAGE, ModelType.STRING, true);
- return node;
- }
- }
-
- /**
- * Source Mapping Metadata mapper
- */
- public static class SourceMappingMetadataMapper {
- private static final String SOURCE_NAME = "source-name"; //$NON-NLS-1$
- private static final String JNDI_NAME = "jndi-name"; //$NON-NLS-1$
- private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
-
- public static ModelNode wrap(SourceMappingMetadata source, ModelNode node) {
- if (source == null) {
- return null;
- }
-
- node.get(TYPE).set(ModelType.OBJECT);
-
- node.get(SOURCE_NAME).set(source.getName());
- node.get(JNDI_NAME).set(source.getConnectionJndiName());
- node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
- return node;
- }
-
- public static SourceMappingMetadata unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
- SourceMappingMetadata source = new SourceMappingMetadata();
- if (node.has(SOURCE_NAME)) {
- source.setName(node.get(SOURCE_NAME).asString());
- }
- if (node.has(JNDI_NAME)) {
- source.setConnectionJndiName(node.get(JNDI_NAME).asString());
- }
- if (node.has(TRANSLATOR_NAME)) {
- source.setTranslatorName(node.get(TRANSLATOR_NAME).asString());
- }
- return source;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, SOURCE_NAME, ModelType.STRING, true);
- addAttribute(node, JNDI_NAME, ModelType.STRING, true);
- addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
- return node;
- }
- }
-
- /**
- * Source Mapping Metadata mapper
- */
- public static class VDBTranslatorMetaDataMapper {
- private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
- private static final String BASETYPE = "base-type"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String MODULE_NAME = "module-name"; //$NON-NLS-1$
-
- public static ModelNode wrap(VDBTranslatorMetaData translator, ModelNode node) {
- if (translator == null) {
- return null;
- }
- node.get(TYPE).set(ModelType.OBJECT);
-
- node.get(TRANSLATOR_NAME).set(translator.getName());
- if (translator.getType() != null) {
- node.get(BASETYPE).set(translator.getType());
- }
- if (translator.getDescription() != null) {
- node.get(DESCRIPTION).set(translator.getDescription());
- }
-
- if (translator.getModuleName() != null) {
- node.get(MODULE_NAME).set(translator.getModuleName());
- }
-
- List<PropertyMetadata> properties = translator.getJAXBProperties();
- if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
- }
- }
- return node;
- }
-
- public static VDBTranslatorMetaData unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
- VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
- if (node.has(TRANSLATOR_NAME)) {
- translator.setName(node.get(TRANSLATOR_NAME).asString());
- }
- if (node.has(BASETYPE)) {
- translator.setType(node.get(BASETYPE).asString());
- }
- if (node.has(DESCRIPTION)) {
- translator.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(MODULE_NAME)) {
- translator.setModuleName(node.get(MODULE_NAME).asString());
- }
-
- if (node.get(CHILDREN,PROPERTIES).isDefined()) {
- List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
- for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
- if (prop != null) {
- translator.addProperty(prop.getName(), prop.getValue());
- }
- }
- }
- return translator;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
- addAttribute(node, BASETYPE, ModelType.STRING, true);
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, MODULE_NAME, ModelType.STRING, false);
-
- ModelNode props = node.get(CHILDREN, PROPERTIES);
- props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
- PropertyMetaDataMapper.describe(props);
- return node;
- }
- }
-
- /**
- * Property Metadata mapper
- */
- public static class PropertyMetaDataMapper {
- private static final String PROPERTY_NAME = "property-name"; //$NON-NLS-1$
- private static final String PROPERTY_VALUE = "property-value"; //$NON-NLS-1$
-
- public static ModelNode wrap(PropertyMetadata property, ModelNode node) {
- if (property == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(PROPERTY_NAME).set(property.getName());
- node.get(PROPERTY_VALUE).set(property.getValue());
-
- return node;
- }
-
- public static PropertyMetadata unwrap(ModelNode node) {
- if(node == null) {
- return null;
- }
- PropertyMetadata property = new PropertyMetadata();
- if (node.has(PROPERTY_NAME)) {
- property.setName(node.get(PROPERTY_NAME).asString());
- }
- if(node.has(PROPERTY_VALUE)) {
- property.setValue(node.get(PROPERTY_VALUE).asString());
- }
- return property;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, PROPERTY_NAME, ModelType.STRING, true);
- addAttribute(node, PROPERTY_VALUE, ModelType.STRING, true);
- return node;
- }
- }
-
- /**
- * DataPolicy Metadata mapper
- */
- public static class DataPolicyMetadataMapper {
- private static final String POLICY_NAME = "policy-name"; //$NON-NLS-1$
- private static final String DATA_PERMISSIONS = "data-permissions"; //$NON-NLS-1$
- private static final String MAPPED_ROLE_NAMES = "mapped-role-names"; //$NON-NLS-1$
- private static final String ALLOW_CREATE_TEMP_TABLES = "allow-create-temp-tables"; //$NON-NLS-1$
- private static final String ANY_AUTHENTICATED = "any-authenticated"; //$NON-NLS-1$
-
- public static ModelNode wrap(DataPolicyMetadata policy, ModelNode node) {
- if (policy == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(POLICY_NAME).set(policy.getName());
- if (policy.getDescription() != null) {
- node.get(DESCRIPTION).set(policy.getDescription());
- }
- if (policy.isAllowCreateTemporaryTables() != null) {
- node.get(ALLOW_CREATE_TEMP_TABLES).set(policy.isAllowCreateTemporaryTables());
- }
- node.get(ANY_AUTHENTICATED).set(policy.isAnyAuthenticated());
-
- //DATA_PERMISSIONS
- List<DataPolicy.DataPermission> permissions = policy.getPermissions();
- if (permissions != null && !permissions.isEmpty()) {
- ModelNode permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS);
- for (DataPolicy.DataPermission dataPermission:permissions) {
- permissionNodes.add(PermissionMetaDataMapper.wrap((PermissionMetaData)dataPermission, new ModelNode()));
- }
- }
-
- //MAPPED_ROLE_NAMES
- if (policy.getMappedRoleNames() != null && !policy.getMappedRoleNames().isEmpty()) {
- ModelNode mappedRoleNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES);
- for (String role:policy.getMappedRoleNames()) {
- mappedRoleNodes.add(role);
- }
- }
- return node;
- }
-
- public static DataPolicyMetadata unwrap(ModelNode node) {
- if(node == null) {
- return null;
- }
- DataPolicyMetadata policy = new DataPolicyMetadata();
- if (node.has(POLICY_NAME)) {
- policy.setName(node.get(POLICY_NAME).asString());
- }
- if (node.has(DESCRIPTION)) {
- policy.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(ALLOW_CREATE_TEMP_TABLES)) {
- policy.setAllowCreateTemporaryTables(node.get(ALLOW_CREATE_TEMP_TABLES).asBoolean());
- }
- if (node.has(ANY_AUTHENTICATED)) {
- policy.setAnyAuthenticated(node.get(ANY_AUTHENTICATED).asBoolean());
- }
-
- //DATA_PERMISSIONS
- if (node.get(CHILDREN, DATA_PERMISSIONS).isDefined()) {
- List<ModelNode> permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS).asList();
- for (ModelNode permissionNode:permissionNodes) {
- PermissionMetaData permission = PermissionMetaDataMapper.unwrap(permissionNode);
- if (permission != null) {
- policy.addPermission(permission);
- }
- }
- }
-
- //MAPPED_ROLE_NAMES
- if (node.get(CHILDREN, MAPPED_ROLE_NAMES).isDefined()) {
- List<ModelNode> roleNameNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES).asList();
- for (ModelNode roleNameNode:roleNameNodes) {
- policy.addMappedRoleName(roleNameNode.asString());
- }
- }
- return policy;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, POLICY_NAME, ModelType.STRING, true);
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, ALLOW_CREATE_TEMP_TABLES, ModelType.BOOLEAN, false);
- addAttribute(node, ANY_AUTHENTICATED, ModelType.BOOLEAN, false);
-
- ModelNode permissions = node.get(CHILDREN, DATA_PERMISSIONS);
- PropertyMetaDataMapper.describe(permissions);
- permissions.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_PERMISSIONS+DOT_DESC));
- permissions.get(MIN_OCCURS).set(1);
-
- ModelNode roleNames = node.get(CHILDREN, MAPPED_ROLE_NAMES);
- roleNames.get(TYPE).set(ModelType.LIST);
- roleNames.get(DESCRIPTION).set(AdminPlugin.Util.getString(MAPPED_ROLE_NAMES+DOT_DESC));
- roleNames.get("value-type").set(ModelType.STRING); //$NON-NLS-1$
- return node;
- }
- }
-
- public static class PermissionMetaDataMapper{
- private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
- private static final String ALLOW_CREATE = "allow-create"; //$NON-NLS-1$
- private static final String ALLOW_DELETE = "allow-delete"; //$NON-NLS-1$
- private static final String ALLOW_UPADTE = "allow-update"; //$NON-NLS-1$
- private static final String ALLOW_READ = "allow-read"; //$NON-NLS-1$
- private static final String ALLOW_EXECUTE = "allow-execute"; //$NON-NLS-1$
- private static final String ALLOW_ALTER = "allow-alter"; //$NON-NLS-1$
-
-
-
- public static ModelNode wrap(PermissionMetaData permission, ModelNode node) {
- if (permission == null) {
- return null;
- }
-
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(RESOURCE_NAME).set(permission.getResourceName());
- if (permission.getAllowCreate() != null) {
- node.get(ALLOW_CREATE).set(permission.getAllowCreate().booleanValue());
- }
- if (permission.getAllowDelete() != null) {
- node.get(ALLOW_DELETE).set(permission.getAllowDelete().booleanValue());
- }
- if (permission.getAllowUpdate() != null) {
- node.get(ALLOW_UPADTE).set(permission.getAllowUpdate().booleanValue());
- }
- if (permission.getAllowRead() != null) {
- node.get(ALLOW_READ).set(permission.getAllowRead().booleanValue());
- }
- if (permission.getAllowExecute() != null) {
- node.get(ALLOW_EXECUTE).set(permission.getAllowExecute().booleanValue());
- }
- if(permission.getAllowAlter() != null) {
- node.get(ALLOW_ALTER).set(permission.getAllowAlter().booleanValue());
- }
- return node;
- }
-
- public static PermissionMetaData unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
-
- PermissionMetaData permission = new PermissionMetaData();
- if (node.get(RESOURCE_NAME) != null) {
- permission.setResourceName(node.get(RESOURCE_NAME).asString());
- }
- if (node.has(ALLOW_CREATE)) {
- permission.setAllowCreate(node.get(ALLOW_CREATE).asBoolean());
- }
- if (node.has(ALLOW_DELETE)) {
- permission.setAllowDelete(node.get(ALLOW_DELETE).asBoolean());
- }
- if (node.has(ALLOW_UPADTE)) {
- permission.setAllowUpdate(node.get(ALLOW_UPADTE).asBoolean());
- }
- if (node.has(ALLOW_READ)) {
- permission.setAllowRead(node.get(ALLOW_READ).asBoolean());
- }
- if (node.has(ALLOW_EXECUTE)) {
- permission.setAllowExecute(node.get(ALLOW_EXECUTE).asBoolean());
- }
- if (node.has(ALLOW_ALTER)) {
- permission.setAllowAlter(node.get(ALLOW_ALTER).asBoolean());
- }
- return permission;
- }
- public static ModelNode describe(ModelNode node) {
- addAttribute(node, RESOURCE_NAME, ModelType.STRING, true);
- addAttribute(node, ALLOW_CREATE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_DELETE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_UPADTE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_READ, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_EXECUTE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_ALTER, ModelType.BOOLEAN, false);
- return node;
- }
- }
-
- public static class CacheStatisticsMetadataMapper {
- private static final String HITRATIO = "hitRatio"; //$NON-NLS-1$
- private static final String TOTAL_ENTRIES = "totalEntries"; //$NON-NLS-1$
- private static final String REQUEST_COUNT = "requestCount"; //$NON-NLS-1$
-
- public static ModelNode wrap(CacheStatisticsMetadata object, ModelNode node) {
- if (object == null)
- return null;
-
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(TOTAL_ENTRIES).set(object.getTotalEntries());
- node.get(HITRATIO).set(object.getHitRatio());
- node.get(REQUEST_COUNT).set(object.getRequestCount());
-
- return node;
- }
-
- public static CacheStatisticsMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
- cache.setTotalEntries(node.get(TOTAL_ENTRIES).asInt());
- cache.setHitRatio(node.get(HITRATIO).asDouble());
- cache.setRequestCount(node.get(REQUEST_COUNT).asInt());
- return cache;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, TOTAL_ENTRIES, ModelType.STRING, true);
- addAttribute(node, HITRATIO, ModelType.STRING, true);
- addAttribute(node, REQUEST_COUNT, ModelType.STRING, true);
- return node;
- }
- }
-
- public static class RequestMetadataMapper {
- private static final String TRANSACTION_ID = "transaction-id"; //$NON-NLS-1$
- private static final String NODE_ID = "node-id"; //$NON-NLS-1$
- private static final String SOURCE_REQUEST = "source-request"; //$NON-NLS-1$
- private static final String COMMAND = "command"; //$NON-NLS-1$
- private static final String START_TIME = "start-time"; //$NON-NLS-1$
- private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
- private static final String EXECUTION_ID = "execution-id"; //$NON-NLS-1$
- private static final String STATE = "processing-state"; //$NON-NLS-1$
- private static final String THREAD_STATE = "thread-state"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(RequestMetadata request, ModelNode node) {
- if (request == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(EXECUTION_ID).set(request.getExecutionId());
- node.get(SESSION_ID).set(request.getSessionId());
- node.get(START_TIME).set(request.getStartTime());
- node.get(COMMAND).set(request.getCommand());
- node.get(SOURCE_REQUEST).set(request.sourceRequest());
- if (request.getNodeId() != null) {
- node.get(NODE_ID).set(request.getNodeId());
- }
- if (request.getTransactionId() != null) {
- node.get(TRANSACTION_ID).set(request.getTransactionId());
- }
- node.get(STATE).set(request.getState().name());
- node.get(THREAD_STATE).set(request.getThreadState().name());
- return node;
- }
-
- public static RequestMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- RequestMetadata request = new RequestMetadata();
- request.setExecutionId(node.get(EXECUTION_ID).asLong());
- request.setSessionId(node.get(SESSION_ID).asString());
- request.setStartTime(node.get(START_TIME).asLong());
- request.setCommand(node.get(COMMAND).asString());
- request.setSourceRequest(node.get(SOURCE_REQUEST).asBoolean());
- if (node.has(NODE_ID)) {
- request.setNodeId(node.get(NODE_ID).asInt());
- }
- if (node.has(TRANSACTION_ID)) {
- request.setTransactionId(node.get(TRANSACTION_ID).asString());
- }
- request.setState(ProcessingState.valueOf(node.get(STATE).asString()));
- request.setThreadState(ThreadState.valueOf(node.get(THREAD_STATE).asString()));
- return request;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, EXECUTION_ID, ModelType.LONG, true);
- addAttribute(node, SESSION_ID, ModelType.STRING, true);
- addAttribute(node, START_TIME, ModelType.LONG, true);
- addAttribute(node, COMMAND, ModelType.STRING, true);
- addAttribute(node, SOURCE_REQUEST, ModelType.BOOLEAN, true);
- addAttribute(node, NODE_ID, ModelType.INT, false);
- addAttribute(node, TRANSACTION_ID, ModelType.STRING, false);
- addAttribute(node, STATE, ModelType.STRING, true);
- addAttribute(node, THREAD_STATE, ModelType.STRING, true);
- return node;
- }
- }
-
- public static class SessionMetadataMapper {
- private static final String SECURITY_DOMAIN = "security-domain"; //$NON-NLS-1$
- private static final String VDB_VERSION = "vdb-version"; //$NON-NLS-1$
- private static final String VDB_NAME = "vdb-name"; //$NON-NLS-1$
- private static final String USER_NAME = "user-name"; //$NON-NLS-1$
- private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
- private static final String LAST_PING_TIME = "last-ping-time"; //$NON-NLS-1$
- private static final String IP_ADDRESS = "ip-address"; //$NON-NLS-1$
- private static final String CLIENT_HOST_NAME = "client-host-address"; //$NON-NLS-1$
- private static final String CREATED_TIME = "created-time"; //$NON-NLS-1$
- private static final String APPLICATION_NAME = "application-name"; //$NON-NLS-1$
- private static final String CLIENT_HARDWARE_ADRESS = "client-hardware-address"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(SessionMetadata session, ModelNode node) {
- if (session == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- if (session.getApplicationName() != null) {
- node.get(APPLICATION_NAME).set(session.getApplicationName());
- }
- node.get(CREATED_TIME).set(session.getCreatedTime());
- node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
- node.get(IP_ADDRESS).set(session.getIPAddress());
- node.get(LAST_PING_TIME).set(session.getLastPingTime());
- node.get(SESSION_ID).set(session.getSessionId());
- node.get(USER_NAME).set(session.getUserName());
- node.get(VDB_NAME).set(session.getVDBName());
- node.get(VDB_VERSION).set(session.getVDBVersion());
- if (session.getSecurityDomain() != null){
- node.get(SECURITY_DOMAIN).set(session.getSecurityDomain());
- }
- if (session.getClientHardwareAddress() != null) {
- node.get(CLIENT_HARDWARE_ADRESS).set(session.getClientHardwareAddress());
- }
- return node;
- }
-
- public static SessionMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- SessionMetadata session = new SessionMetadata();
- if (node.has(APPLICATION_NAME)) {
- session.setApplicationName(node.get(APPLICATION_NAME).asString());
- }
- session.setCreatedTime(node.get(CREATED_TIME).asLong());
- session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
- session.setIPAddress(node.get(IP_ADDRESS).asString());
- session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
- session.setSessionId(node.get(SESSION_ID).asString());
- session.setUserName(node.get(USER_NAME).asString());
- session.setVDBName(node.get(VDB_NAME).asString());
- session.setVDBVersion(node.get(VDB_VERSION).asInt());
- if (node.has(SECURITY_DOMAIN)) {
- session.setSecurityDomain(node.get(SECURITY_DOMAIN).asString());
- }
- if (node.has(CLIENT_HARDWARE_ADRESS)) {
- session.setClientHardwareAddress(node.get(CLIENT_HARDWARE_ADRESS).asString());
- }
- return session;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, APPLICATION_NAME, ModelType.STRING, false);
- addAttribute(node, CREATED_TIME, ModelType.LONG, true);
- addAttribute(node, CLIENT_HOST_NAME, ModelType.LONG, true);
- addAttribute(node, IP_ADDRESS, ModelType.STRING, true);
- addAttribute(node, LAST_PING_TIME, ModelType.LONG, true);
- addAttribute(node, SESSION_ID, ModelType.STRING, true);
- addAttribute(node, USER_NAME, ModelType.STRING, true);
- addAttribute(node, VDB_NAME, ModelType.STRING, true);
- addAttribute(node, VDB_VERSION, ModelType.INT, true);
- addAttribute(node, SECURITY_DOMAIN, ModelType.STRING, false);
- return node;
- }
- }
-
- public static class TransactionMetadataMapper {
- private static final String ID = "txn-id"; //$NON-NLS-1$
- private static final String SCOPE = "txn-scope"; //$NON-NLS-1$
- private static final String CREATED_TIME = "txn-created-time"; //$NON-NLS-1$
- private static final String ASSOCIATED_SESSION = "session-id"; //$NON-NLS-1$
-
- public static ModelNode wrap(TransactionMetadata object, ModelNode transaction) {
- if (object == null)
- return null;
-
- transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
- transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
- transaction.get(CREATED_TIME).set(object.getCreatedTime());
- transaction.get(SCOPE).set(object.getScope());
- transaction.get(ID).set(object.getId());
-
- return transaction;
- }
-
- public static TransactionMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- TransactionMetadata transaction = new TransactionMetadata();
- transaction.setAssociatedSession(node.get(ASSOCIATED_SESSION).asString());
- transaction.setCreatedTime(node.get(CREATED_TIME).asLong());
- transaction.setScope(node.get(SCOPE).asString());
- transaction.setId(node.get(ID).asString());
- return transaction;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, ASSOCIATED_SESSION, ModelType.STRING, true);
- addAttribute(node, CREATED_TIME, ModelType.LONG, true);
- addAttribute(node, SCOPE, ModelType.LONG, true);
- addAttribute(node, ID, ModelType.STRING, true);
- return node;
- }
- }
-
- public static class WorkerPoolStatisticsMetadataMapper {
- private static final String MAX_THREADS = "max-threads"; //$NON-NLS-1$
- private static final String HIGHEST_QUEUED = "highest-queued"; //$NON-NLS-1$
- private static final String QUEUED = "queued"; //$NON-NLS-1$
- private static final String QUEUE_NAME = "queue-name"; //$NON-NLS-1$
- private static final String TOTAL_SUBMITTED = "total-submitted"; //$NON-NLS-1$
- private static final String TOTAL_COMPLETED = "total-completed"; //$NON-NLS-1$
- private static final String HIGHEST_ACTIVE_THREADS = "highest-active-threads"; //$NON-NLS-1$
- private static final String ACTIVE_THREADS = "active-threads"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(WorkerPoolStatisticsMetadata stats, ModelNode node) {
- if (stats == null)
- return null;
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(ACTIVE_THREADS).set(stats.getActiveThreads());
- node.get(HIGHEST_ACTIVE_THREADS).set(stats.getHighestActiveThreads());
- node.get(TOTAL_COMPLETED).set(stats.getTotalCompleted());
- node.get(TOTAL_SUBMITTED).set(stats.getTotalSubmitted());
- node.get(QUEUE_NAME).set(stats.getQueueName());
- node.get(QUEUED).set(stats.getQueued());
- node.get(HIGHEST_QUEUED).set(stats.getHighestQueued());
- node.get(MAX_THREADS).set(stats.getMaxThreads());
-
- return node;
- }
-
- public static WorkerPoolStatisticsMetadata unwrapMetaValue(ModelNode node) {
- if (node == null)
- return null;
-
- WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
- stats.setActiveThreads(node.get(ACTIVE_THREADS).asInt());
- stats.setHighestActiveThreads(node.get(HIGHEST_ACTIVE_THREADS).asInt());
- stats.setTotalCompleted(node.get(TOTAL_COMPLETED).asLong());
- stats.setTotalSubmitted(node.get(TOTAL_SUBMITTED).asLong());
- stats.setQueueName(node.get(QUEUE_NAME).asString());
- stats.setQueued(node.get(QUEUED).asInt());
- stats.setHighestQueued(node.get(HIGHEST_QUEUED).asInt());
- stats.setMaxThreads(node.get(MAX_THREADS).asInt());
- return stats;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, ACTIVE_THREADS, ModelType.INT, true);
- addAttribute(node, HIGHEST_ACTIVE_THREADS, ModelType.INT, true);
- addAttribute(node, TOTAL_COMPLETED, ModelType.LONG, true);
- addAttribute(node, TOTAL_SUBMITTED, ModelType.LONG, true);
- addAttribute(node, QUEUE_NAME, ModelType.STRING, true);
- addAttribute(node, QUEUED, ModelType.INT, true);
- addAttribute(node, HIGHEST_QUEUED, ModelType.INT, true);
- addAttribute(node, MAX_THREADS, ModelType.INT, true);
- return node;
- }
- }
-
- private static final String CHILDREN = "children"; //$NON-NLS-1$
- private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
- private static final String DOT_DESC = ".describe"; //$NON-NLS-1$
- private static final String TYPE = "type"; //$NON-NLS-1$
- private static final String MIN_OCCURS = "min-occurs"; //$NON-NLS-1$
- private static final String REQUIRED = "required"; //$NON-NLS-1$
- private static final String ALLOWED = "allowed"; //$NON-NLS-1$
- static ModelNode addAttribute(ModelNode node, String name, ModelType dataType, boolean required) {
- node.get(ATTRIBUTES, name, TYPE).set(dataType);
- node.get(ATTRIBUTES, name, DESCRIPTION).set(AdminPlugin.Util.getString(name+DOT_DESC));
- node.get(ATTRIBUTES, name, REQUIRED).set(required);
- return node;
- }
-}
-
-
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,321 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.xml.bind.annotation.*;
-
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "sources",
- "errors"
-})
-public class ModelMetaData extends AdminObjectImpl implements Model {
-
- private static final int DEFAULT_ERROR_HISTORY = 10;
- private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY = "supports-multi-source-bindings"; //$NON-NLS-1$
- private static final long serialVersionUID = 3714234763056162230L;
-
- @XmlElement(name = "source")
- protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
- private static final long serialVersionUID = 2273673984691112369L;
-
- @Override
- public String getKey(SourceMappingMetadata entry) {
- return entry.getName();
- }
- });
-
- @XmlAttribute(name = "type")
- protected String modelType = Type.PHYSICAL.name();
-
- @XmlElement(name = "description")
- protected String description;
-
- @XmlAttribute(name = "path")
- protected String path;
-
- @XmlAttribute(name = "visible")
- protected Boolean visible = true;
-
- @XmlElement(name = "validation-error")
- protected List<ValidationError> errors;
-
- @XmlAttribute(name = "name", required = true)
- public String getName() {
- return super.getName();
- }
-
- // This is needed by JAXB
- public void setName(String name) {
- super.setName(name);
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @Override
- public boolean isSource() {
- return getModelType() == Model.Type.PHYSICAL;
- }
-
- @Override
- public boolean isVisible() {
- return this.visible;
- }
-
- @Override
- public Type getModelType() {
- try {
- return Type.valueOf(modelType.toUpperCase());
- } catch(IllegalArgumentException e) {
- return Type.OTHER;
- }
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public boolean isSupportsMultiSourceBindings() {
- String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
- return Boolean.parseBoolean(supports);
- }
-
- @Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
- public void setSupportsMultiSourceBindings(boolean supports) {
- addProperty(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY, Boolean.toString(supports));
- }
-
- public void setModelType(Model.Type modelType) {
- this.modelType = modelType.name();
- }
-
- public void setModelType(String modelType) {
- this.modelType = modelType;
- }
-
- public String toString() {
- return getName() + this.sources;
- }
-
- public void setVisible(Boolean value) {
- this.visible = value;
- }
-
- public List<SourceMappingMetadata> getSourceMappings(){
- return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
- }
-
- public void setSourceMappings(List<SourceMappingMetadata> sources){
- for (SourceMappingMetadata source: sources) {
- addSourceMapping(source.getName(), source.getTranslatorName(), source.getConnectionJndiName());
- }
- }
-
- @Override
- public List<String> getSourceNames() {
- return new ArrayList<String>(this.sources.getMap().keySet());
- }
-
- @Override
- public String getSourceConnectionJndiName(String sourceName) {
- SourceMappingMetadata s = this.sources.getMap().get(sourceName);
- if (s == null) {
- return null;
- }
- return s.getConnectionJndiName();
- }
-
- @Override
- public String getSourceTranslatorName(String sourceName) {
- SourceMappingMetadata s = this.sources.getMap().get(sourceName);
- if (s == null) {
- return null;
- }
- return s.getTranslatorName();
- }
-
- public void addSourceMapping(String name, String translatorName, String connJndiName) {
- this.sources.getMap().put(name, new SourceMappingMetadata(name, translatorName, connJndiName));
- }
-
- public void addSourceMapping(SourceMappingMetadata source) {
- this.sources.getMap().put(source.getName(), new SourceMappingMetadata(source.getName(), source.getTranslatorName(), source.getConnectionJndiName()));
- }
-
- public List<ValidationError> getErrors(){
- return getValidationErrors(Severity.ERROR);
- }
-
- public void setErrors(List<ValidationError> errors){
- this.errors = errors;
- }
-
- public synchronized List<ValidationError> getValidationErrors(ValidationError.Severity severity){
- if (this.errors == null) {
- return Collections.emptyList();
- }
- List<ValidationError> list = new ArrayList<ValidationError>();
- for (ValidationError ve: this.errors) {
- if (Severity.valueOf(ve.severity) == severity) {
- list.add(ve);
- }
- }
- return list;
- }
-
- public synchronized ValidationError addError(String severity, String message) {
- if (this.errors == null) {
- this.errors = new LinkedList<ValidationError>();
- }
- ValidationError ve = new ValidationError(severity, message);
- this.errors.add(ve);
- if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
- this.errors.remove(0);
- }
- return ve;
- }
-
- public synchronized ValidationError addError(ValidationError ve) {
- if (this.errors == null) {
- this.errors = new LinkedList<ValidationError>();
- }
- this.errors.add(ve);
- if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
- this.errors.remove(0);
- }
- return ve;
- }
-
-
- public synchronized boolean removeError(ValidationError remove) {
- if (this.errors == null) {
- return false;
- }
- return this.errors.remove(remove);
- }
-
- public synchronized void clearErrors() {
- this.errors.clear();
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "value"
- })
- public static class ValidationError implements Serializable{
- private static final long serialVersionUID = 2044197069467559527L;
-
- public enum Severity {ERROR, WARNING};
-
- @XmlValue
- protected String value;
-
- @XmlAttribute(name = "severity", required = true)
- protected String severity;
-
- @XmlAttribute(name = "path")
- protected String path;
-
- public ValidationError() {};
-
- public ValidationError(String severity, String msg) {
- this.severity = severity;
- this.value = msg;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getSeverity() {
- return severity;
- }
-
- public void setSeverity(String severity) {
- this.severity = severity;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ValidationError other = (ValidationError) obj;
- if (severity == null) {
- if (other.severity != null)
- return false;
- } else if (!severity.equals(other.severity))
- return false;
- if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
- return true;
- }
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-
-public class ModelNodeConstants {
- public static final String TYPE = "type";//$NON-NLS-1$
- public static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
- public static final String DESCRIPTION = "description"; //$NON-NLS-1$
-
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-
-public class PermissionMap extends ListOverMap<PermissionMetaData> {
-
- private static final long serialVersionUID = -1170556665834875267L;
-
- public PermissionMap(KeyBuilder<PermissionMetaData> builder) {
- super(builder);
- }
-
- @Override
- public void add(int index, PermissionMetaData element) {
- PermissionMetaData previous = this.map.get(builder.getKey(element));
- if (previous != null) {
- if (element.allowCreate != null) {
- previous.setAllowCreate(element.allowCreate);
- }
- if (element.allowRead != null) {
- previous.setAllowRead(element.allowRead);
- }
- if (element.allowUpdate != null) {
- previous.setAllowUpdate(element.allowUpdate);
- }
- if (element.allowDelete != null) {
- previous.setAllowDelete(element.allowDelete);
- }
- }
- else {
- super.add(index, element);
- }
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,214 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.teiid.adminapi.PropertyDefinition;
-
-
-
-public class PropertyDefinitionMetadata extends AdminObjectImpl implements PropertyDefinition {
- private static final long serialVersionUID = 6612838530524627205L;
- private Collection allowedValues = new ArrayList();
- private Object defaultValue = null;
- private String description = null;
- private String displayName = null;
- private String propertyTypeClassName = String.class.getName();
- private RestartType requiresRestart = RestartType.NONE;
- private boolean advanced = false;
- private boolean masked = false;
- private boolean modifiable = true;
- private boolean required = false;
-
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append("Display Name:").append(getDisplayName()); //$NON-NLS-1$
- result.append(" Description:").append(getDescription()); //$NON-NLS-1$
- result.append(" Property Type Classname:").append(getPropertyTypeClassName()); //$NON-NLS-1$
- result.append(" Default Value:").append(getDefaultValue()); //$NON-NLS-1$
- result.append(" Constrained To Allow Values:").append(isConstrainedToAllowedValues()); //$NON-NLS-1$
- result.append(" Allowed Values:").append(getAllowedValues()); //$NON-NLS-1$
- result.append(" Required:").append(isRequired()); //$NON-NLS-1$
- result.append(" Expert:").append(isAdvanced()); //$NON-NLS-1$
- result.append(" Masked:").append(isMasked()); //$NON-NLS-1$
- result.append(" Modifiable:").append(isModifiable()); //$NON-NLS-1$
- result.append(" RequiresRestart:").append(getRequiresRestart()); //$NON-NLS-1$
- return result.toString();
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getAllowedValues()
- */
- public Collection getAllowedValues() {
- return allowedValues;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getDefaultValue()
- */
- public Object getDefaultValue() {
- return defaultValue;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getDescription()
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getDisplayName()
- */
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getPropertyTypeClassName()
- */
- public String getPropertyTypeClassName() {
- return propertyTypeClassName;
- }
-
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getRequiresRestart()
- */
- public RestartType getRequiresRestart() {
- return requiresRestart;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isExpert()
- * @since 4.3
- */
- public boolean isAdvanced() {
- return advanced;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isMasked()
- */
- public boolean isMasked() {
- return masked;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isModifiable()
- */
- public boolean isModifiable() {
- return modifiable;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isRequired()
- */
- public boolean isRequired() {
- return required;
- }
-
- /**
- * @param allowedValues The allowedValues to set.
- */
- public void setAllowedValues(Collection allowedValues) {
- this.allowedValues = allowedValues;
- }
-
- /**
- * @param defaultValue The defaultValue to set.
- */
- public void setDefaultValue(Serializable defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
-
- /**
- * @param expert The value of expert to set.
- */
- public void setAdvanced(boolean expert) {
- this.advanced = expert;
- }
-
- /**
- * @param masked The value of masked to set.
- */
- public void setMasked(boolean masked) {
- this.masked = masked;
- }
- /**
- * @param modifiable The value of modifiable to set.
- */
- public void setModifiable(boolean modifiable) {
- this.modifiable = modifiable;
- }
-
- /**
- * @param propertyTypeClassName The propertyTypeName to set.
- */
- public void setPropertyTypeClassName(String propertyTypeClassName) {
- this.propertyTypeClassName = propertyTypeClassName;
- }
-
-
- /**
- * @param required The value of required to set.
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- /**
- * @param requiresRestart The value of requiresRestart to set.
- */
- public void setRequiresRestart(RestartType requiresRestart) {
- this.requiresRestart = requiresRestart;
- }
-
- @Override
- public boolean isConstrainedToAllowedValues() {
- return allowedValues != null && !allowedValues.isEmpty();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <pre>
- * <complexType name="property">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "property")
-public class PropertyMetadata implements Serializable{
- private static final long serialVersionUID = -5040224539939758816L;
-
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "value", required = true)
- protected String value;
-
- public PropertyMetadata() {
- }
-
- public PropertyMetadata(String key, String value) {
- this.name = key;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString() {
- return this.name+"="+this.value; //$NON-NLS-1$
- }
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,160 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.util.Date;
-
-import org.teiid.adminapi.Request;
-import org.teiid.core.util.HashCodeUtil;
-
-
-
-public class RequestMetadata extends AdminObjectImpl implements Request {
-
- private static final long serialVersionUID = -2779106368517784259L;
-
- private long executionId;
- private String sessionId;
- private String command;
- private long startTime;
- private boolean sourceRequest;
- private Integer nodeID;
- private String transactionId;
- private ProcessingState processingState = ProcessingState.PROCESSING;
- private ThreadState threadState = ThreadState.RUNNING;
-
- @Override
- public long getExecutionId() {
- return executionId;
- }
-
- public void setExecutionId(long id) {
- this.executionId = id;
- }
-
- @Override
- public ProcessingState getState() {
- return processingState;
- }
-
- public void setState(ProcessingState state) {
- this.processingState = state;
- }
-
- @Override
- public ThreadState getThreadState() {
- return threadState;
- }
-
- public void setThreadState(ThreadState threadState) {
- this.threadState = threadState;
- }
-
- @Override
- public String getSessionId() {
- return this.sessionId;
- }
-
- public void setSessionId(String session) {
- this.sessionId = session;
- }
-
- @Override
- public long getStartTime() {
- return this.startTime;
- }
-
- public void setStartTime(long time) {
- this.startTime = time;
- }
-
- @Override
- public String getCommand() {
- return this.command;
- }
-
- public void setCommand(String cmd) {
- this.command = cmd;
- }
-
- @Override
- public boolean sourceRequest() {
- return sourceRequest;
- }
-
- public void setSourceRequest(boolean sourceRequest) {
- this.sourceRequest = sourceRequest;
- }
-
- @Override
- public Integer getNodeId() {
- return this.nodeID;
- }
-
- public void setNodeId(Integer nodeID) {
- this.nodeID = nodeID;
- }
-
- @Override
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String id) {
- this.transactionId = id;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof RequestMetadata)) {
- return false;
- }
- RequestMetadata value = (RequestMetadata)obj;
- if (!sourceRequest()) {
- return sessionId == value.sessionId && executionId == value.executionId;
- }
- return sessionId == value.sessionId && executionId == value.executionId && nodeID.equals(value.nodeID);
- }
-
- public int hashCode() {
- return HashCodeUtil.hashCode((int)executionId, sessionId);
- }
-
- @SuppressWarnings("nls")
- public String toString() {
- StringBuilder str = new StringBuilder();
- str.append("Request: sessionid=").append(sessionId);
- str.append("; executionId=").append(executionId);
- if (nodeID != null) {
- str.append("; nodeId=").append(nodeID);
- }
- if (transactionId != null) {
- str.append("; transactionId=").append(transactionId);
- }
- str.append("; sourceRequest=").append(sourceRequest);
- str.append("; processingTime=").append(new Date(startTime));
- str.append("; command=").append(command);
-
- return str.toString();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,217 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.Date;
-
-import javax.security.auth.Subject;
-
-import org.teiid.adminapi.Session;
-import org.teiid.client.security.SessionToken;
-
-
-
-/**
- * Add and delete properties also in the Mapper class for correct wrapping for profile service.
- *
- */
-/* TODO: it would probably be good to let ipAddress denote the connecting address
- and add clientIpAdress as the client reported value */
-public class SessionMetadata extends AdminObjectImpl implements Session {
-
- private static final long serialVersionUID = 918638989081830034L;
- private String applicationName;
- private long lastPingTime = System.currentTimeMillis();
- private long createdTime;
- private String ipAddress;
- private String clientHostName;
- private String clientHardwareAddress;
- private String userName;
- private String vdbName;
- private int vdbVersion;
- private String sessionId;
- private String securityDomain;
-
- //server session state
- private transient VDBMetaData vdb;
- private transient SessionToken sessionToken;
- private transient Subject subject;
- private transient Object securityContext;
- private transient boolean embedded;
-
- @Override
- public String getApplicationName() {
- return this.applicationName;
- }
-
- public void setApplicationName(String applicationName) {
- this.applicationName = applicationName;
- }
-
- @Override
- public long getCreatedTime() {
- return this.createdTime;
- }
-
- public void setCreatedTime(long createdTime) {
- this.createdTime = createdTime;
- }
-
- @Override
- public String getClientHostName() {
- return this.clientHostName;
- }
-
- public void setClientHostName(String clientHostname) {
- this.clientHostName = clientHostname;
- }
-
- @Override
- public String getIPAddress() {
- return this.ipAddress;
- }
-
- public void setIPAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- @Override
- public long getLastPingTime() {
- return this.lastPingTime;
- }
-
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
- @Override
- public String getSessionId() {
- return this.sessionId;
- }
-
- public void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- }
-
- @Override
- public String getUserName() {
- return this.userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- public String getVDBName() {
- return this.vdbName;
- }
-
- public void setVDBName(String vdbName) {
- this.vdbName = vdbName;
- }
-
- @Override
- public int getVDBVersion() {
- return this.vdbVersion;
- }
-
- public void setVDBVersion(int vdbVersion) {
- this.vdbVersion = vdbVersion;
- }
-
- @Override
- public String getSecurityDomain() {
- return this.securityDomain;
- }
-
- public void setSecurityDomain(String domain) {
- this.securityDomain = domain;
- }
-
- @SuppressWarnings("nls")
- public String toString() {
- StringBuilder str = new StringBuilder();
- str.append("session: sessionid=").append(sessionId);
- str.append("; userName=").append(userName);
- str.append("; vdbName=").append(vdbName);
- str.append("; vdbVersion=").append(vdbVersion);
- str.append("; createdTime=").append(new Date(createdTime));
- str.append("; applicationName=").append(applicationName);
- str.append("; clientHostName=").append(clientHostName);
- str.append("; clientHardwareAddress=").append(clientHardwareAddress);
- str.append("; IPAddress=").append(ipAddress);
- str.append("; securityDomain=").append(securityDomain);
- str.append("; lastPingTime=").append(new Date(lastPingTime));
- return str.toString();
- }
-
- public VDBMetaData getVdb() {
- return vdb;
- }
-
- public void setVdb(VDBMetaData vdb) {
- this.vdb = vdb;
- }
-
- public SessionToken getSessionToken() {
- return sessionToken;
- }
-
- public void setSessionToken(SessionToken sessionToken) {
- this.sessionToken = sessionToken;
- }
-
- public void setSubject(Subject subject) {
- this.subject = subject;
- }
-
- public Object getSecurityContext() {
- return securityContext;
- }
-
- public void setSecurityContext(Object securityContext) {
- this.securityContext = securityContext;
- }
-
- public Subject getSubject() {
- return this.subject;
- }
-
- public void setEmbedded(boolean embedded) {
- this.embedded = embedded;
- }
-
- public boolean isEmbedded() {
- return embedded;
- }
-
- @Override
- public String getClientHardwareAddress() {
- return this.clientHardwareAddress;
- }
-
- public void setClientHardwareAddress(String clientHardwareAddress) {
- this.clientHardwareAddress = clientHardwareAddress;
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "")
-public class SourceMappingMetadata implements Serializable {
- private static final long serialVersionUID = -4417878417697685794L;
-
- @XmlAttribute(name = "name", required = true)
- private String name;
-
- @XmlAttribute(name = "connection-jndi-name")
- private String jndiName;
-
- @XmlAttribute(name = "translator-name",required = true)
- private String translatorName;
-
- public SourceMappingMetadata() {}
-
- public SourceMappingMetadata(String name, String translatorName, String connJndiName) {
- this.name = name;
- this.translatorName = translatorName;
- this.jndiName = connJndiName;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getConnectionJndiName() {
- // this default could be controlled if needed.
- if (this.jndiName == null) {
- return "java:"+name; //$NON-NLS-1$
- }
- return jndiName;
- }
-
- public void setConnectionJndiName(String jndiName) {
- this.jndiName = jndiName;
- }
-
- public String getTranslatorName() {
- return translatorName;
- }
-
- public void setTranslatorName(String translatorName) {
- this.translatorName = translatorName;
- }
-
- public String toString() {
- return getName()+"/"+getTranslatorName()+"/"+getConnectionJndiName(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.util.Date;
-
-import org.teiid.adminapi.Transaction;
-
-
-public class TransactionMetadata extends AdminObjectImpl implements Transaction {
-
- private static final long serialVersionUID = -8588785315218789068L;
- private String associatedSession;
- private String scope;
- private String id;
- private long createdTime;
-
- @Override
- public String getAssociatedSession() {
- return associatedSession;
- }
-
- public void setAssociatedSession(String associatedSession) {
- this.associatedSession = associatedSession;
- }
-
- @Override
- public String getScope() {
- return scope;
- }
-
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public long getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(long time) {
- this.createdTime = time;
- }
-
- @Override
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append("Associated Session:").append(associatedSession); //$NON-NLS-1$
- result.append("Scope:").append(scope); //$NON-NLS-1$
- result.append("Id:").append(id); //$NON-NLS-1$
- result.append("CreatedTime:").append(new Date(createdTime)); //$NON-NLS-1$
- return result.toString();
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,343 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.net.URL;
-import java.util.*;
-
-import javax.xml.bind.annotation.*;
-
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.core.util.StringUtil;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "models",
- "translators",
- "dataPolicies"
-})
-@XmlRootElement(name = "vdb")
-public class VDBMetaData extends AdminObjectImpl implements VDB {
-
- private static final String VERSION_DELIM = "."; //$NON-NLS-1$
-
- private static final long serialVersionUID = -4723595252013356436L;
-
- /**
- * This simulating a list over a map. JAXB requires a list and performance recommends
- * map and we would like to keep one variable to represent both.
- */
- @XmlElement(name = "model", required = true, type = ModelMetaData.class)
- protected ListOverMap<ModelMetaData> models = new ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
- private static final long serialVersionUID = 846247100420118961L;
-
- @Override
- public String getKey(ModelMetaData entry) {
- return entry.getName();
- }
- });
-
- @XmlElement(name = "translator", required = true, type = VDBTranslatorMetaData.class)
- protected ListOverMap<VDBTranslatorMetaData> translators = new ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
- private static final long serialVersionUID = 3890502172003653563L;
-
- @Override
- public String getKey(VDBTranslatorMetaData entry) {
- return entry.getName();
- }
- });
-
- @XmlElement(name = "data-role", required = true, type = DataPolicyMetadata.class)
- protected ListOverMap<DataPolicyMetadata> dataPolicies = new ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
- private static final long serialVersionUID = 4954591545242715254L;
-
- @Override
- public String getKey(DataPolicyMetadata entry) {
- return entry.getName();
- }
- });
-
- @XmlAttribute(name = "version", required = true)
- private int version = 1;
-
- @XmlElement(name = "description")
- protected String description;
-
- private String fileUrl = null;
- private boolean dynamic = false;
- private VDB.Status status = VDB.Status.INACTIVE;
- private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
- private boolean removed;
-
- @XmlAttribute(name = "name", required = true)
- public String getName() {
- return super.getName();
- }
-
- public String getFullName() {
- return getName() + VERSION_DELIM + getVersion();
- }
-
- // This needed by JAXB marshaling
- public void setName(String name) {
- super.setName(name);
- }
-
- public boolean isRemoved() {
- return removed;
- }
-
- public void setRemoved(boolean removed) {
- this.removed = removed;
- }
-
- @Override
- public ConnectionType getConnectionType() {
- return this.connectionType;
- }
-
- public void setConnectionType(ConnectionType allowConnections) {
- this.connectionType = allowConnections;
- }
-
- public void setConnectionType(String allowConnections) {
- this.connectionType = ConnectionType.valueOf(allowConnections);
- }
-
- @Override
- public Status getStatus() {
- return this.status;
- }
-
- public void setStatus(Status s) {
- this.status = s;
- }
-
- public void setStatus(String s) {
- this.status = Status.valueOf(s);
- }
-
-
- @Override
- public int getVersion() {
- return this.version;
- }
-
- public void setVersion(int version) {
- this.version = version;
- }
-
- @Override
- public String getUrl() {
- return this.fileUrl;
- }
-
- public void setUrl(String url) {
- this.fileUrl = url;
- }
-
- public void setUrl(URL url) {
- this.setUrl(url.toExternalForm());
- String path = url.getPath();
- if (path.endsWith("/")) { //$NON-NLS-1$
- path = path.substring(0, path.length() - 1);
- }
- String fileName = StringUtil.getLastToken(path, "/"); //$NON-NLS-1$
- String[] parts = fileName.split("\\."); //$NON-NLS-1$
- if (parts[0].equalsIgnoreCase(getName()) && parts.length >= 3) {
- try {
- int fileVersion = Integer.parseInt(parts[parts.length - 2]);
- this.setVersion(fileVersion);
- } catch (NumberFormatException e) {
-
- }
- }
- }
-
- @Override
- public List<Model> getModels(){
- return new ArrayList<Model>(this.models.getMap().values());
- }
-
- public Map<String, ModelMetaData> getModelMetaDatas() {
- return this.models.getMap();
- }
-
- /**
- * 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) {
- for (Model obj : models) {
- ModelMetaData model = (ModelMetaData) obj;
- addModel(model);
- }
- }
-
- public void addModel(ModelMetaData m) {
- this.models.getMap().put(m.getName(), m);
- }
-
- @Override
- public List<Translator> getOverrideTranslators() {
- return new ArrayList<Translator>(this.translators.getMap().values());
- }
-
- public void setOverrideTranslators(List<Translator> translators) {
- for (Translator t: translators) {
- this.translators.getMap().put(t.getName(), (VDBTranslatorMetaData)t);
- }
- }
-
- public void addOverideTranslator(VDBTranslatorMetaData t) {
- this.translators.getMap().put(t.getName(), t);
- }
-
- @Override
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String desc) {
- this.description = desc;
- }
-
- @Override
- public List<String> getValidityErrors(){
- List<String> allErrors = new ArrayList<String>();
- for (ModelMetaData model:this.models.getMap().values()) {
- List<ValidationError> errors = model.getErrors();
- if (errors != null && !errors.isEmpty()) {
- for (ValidationError m:errors) {
- if (ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR)) {
- allErrors.add(m.getValue());
- }
- }
- }
- }
- return allErrors;
- }
-
- @Override
- public boolean isValid() {
- if (!getValidityErrors().isEmpty()) {
- return false;
- }
-
- if (getModels().isEmpty()) {
- return false;
- }
- for(ModelMetaData m: this.models.getMap().values()) {
- if (m.isSource()) {
- List<String> resourceNames = m.getSourceNames();
- if (resourceNames.isEmpty()) {
- return false;
- }
- for (String sourceName:resourceNames) {
- if (m.getSourceConnectionJndiName(sourceName) == null) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public String toString() {
- return getName()+VERSION_DELIM+getVersion()+ models.getMap().values();
- }
-
- public boolean isVisible(String modelName) {
- ModelMetaData model = getModel(modelName);
- return model == null || model.isVisible();
- }
-
- public ModelMetaData getModel(String modelName) {
- return this.models.getMap().get(modelName);
- }
-
- public Set<String> getMultiSourceModelNames(){
- Set<String> list = new HashSet<String>();
- for(ModelMetaData m: models.getMap().values()) {
- if (m.isSupportsMultiSourceBindings()) {
- list.add(m.getName());
- }
- }
- return list;
- }
-
- // This one manages the JAXB binding
- @Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
- public boolean isDynamic() {
- return dynamic;
- }
-
- public void setDynamic(boolean dynamic) {
- this.dynamic = dynamic;
- }
-
- @Override
- public List<DataPolicy> getDataPolicies(){
- return new ArrayList<DataPolicy>(this.dataPolicies.getMap().values());
- }
-
- /**
- * This method is required by the Management framework to write the mappings to the persistent form. The actual assignment is done
- * in the VDBMetaDataClassInstancefactory
- * @param policies
- */
- public void setDataPolicies(List<DataPolicy> policies){
- this.dataPolicies.getMap().clear();
- for (DataPolicy policy:policies) {
- this.dataPolicies.getMap().put(policy.getName(), (DataPolicyMetadata)policy);
- }
- }
-
- public void addDataPolicy(DataPolicyMetadata policy){
- this.dataPolicies.getMap().put(policy.getName(), policy);
- }
-
- public DataPolicyMetadata getDataPolicy(String policyName) {
- return this.dataPolicies.getMap().get(policyName);
- }
-
- public VDBTranslatorMetaData getTranslator(String name) {
- return this.translators.getMap().get(name);
- }
-
- public boolean isPreview() {
- return Boolean.valueOf(getPropertyValue("preview")); //$NON-NLS-1$
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,310 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.adminapi.impl.VDBMetaData;
-
-@SuppressWarnings("nls")
-public class VDBMetadataParser {
-
- public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
- XMLInputFactory inputFactory=XMLInputFactory.newInstance();
- XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
-
- // elements
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case VDB:
- VDBMetaData vdb = new VDBMetaData();
- Properties props = getAttributes(reader);
- vdb.setName(props.getProperty(Element.NAME.getLocalName()));
- vdb.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
- parseVDB(reader, vdb);
- return vdb;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- return null;
- }
-
- private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException {
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case DESCRIPTION:
- vdb.setDescription(reader.getElementText());
- break;
- case PROPERTY:
- parseProperty(reader, vdb);
- break;
- case MODEL:
- ModelMetaData model = new ModelMetaData();
- parseModel(reader, model);
- vdb.addModel(model);
- break;
- case TRANSLATOR:
- VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
- parseTranslator(reader, translator);
- vdb.addOverideTranslator(translator);
- break;
- case DATA_ROLE:
- DataPolicyMetadata policy = new DataPolicyMetadata();
- parseDataRole(reader, policy);
- vdb.addDataPolicy(policy);
- break;
- case ENTRY:
- // this is designer specific.
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
- throws XMLStreamException {
- if (reader.getAttributeCount() > 0) {
- String key = null;
- String value = null;
- for(int i=0; i<reader.getAttributeCount(); i++) {
- String attrName = reader.getAttributeLocalName(i);
- String attrValue = reader.getAttributeValue(i);
- if (attrName.equals(Element.NAME.getLocalName())) {
- key = attrValue;
- }
- if (attrName.equals(Element.VALUE.getLocalName())) {
- value = attrValue;
- }
- }
- anObj.addProperty(key, value);
- }
- while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
- }
-
- private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy) throws XMLStreamException {
- Properties props = getAttributes(reader);
- policy.setName(props.getProperty(Element.NAME.getLocalName()));
- policy.setAnyAuthenticated(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName())));
- policy.setAllowCreateTemporaryTables(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName())));
-
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case DESCRIPTION:
- policy.setDescription(reader.getElementText());
- break;
- case PERMISSION:
- PermissionMetaData permission = new PermissionMetaData();
- parsePermission(reader, permission);
- policy.addPermission(permission);
- break;
- case MAPPED_ROLE_NAME:
- policy.addMappedRoleName(reader.getElementText());
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parsePermission(XMLStreamReader reader, PermissionMetaData permission) throws XMLStreamException {
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case RESOURCE_NAME:
- permission.setResourceName(reader.getElementText());
- break;
- case ALLOW_ALTER:
- permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_CREATE:
- permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_DELETE:
- permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_EXECUTE:
- permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_READ:
- permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_UPADTE:
- permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
- break;
-
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parseTranslator(XMLStreamReader reader, VDBTranslatorMetaData translator) throws XMLStreamException {
- Properties props = getAttributes(reader);
- translator.setName(props.getProperty(Element.NAME.getLocalName()));
- translator.setType(props.getProperty(Element.TYPE.getLocalName()));
- translator.setDescription(props.getProperty(Element.DESCRIPTION.getLocalName()));
-
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case PROPERTY:
- parseProperty(reader, translator);
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parseModel(XMLStreamReader reader, ModelMetaData model) throws XMLStreamException {
- Properties props = getAttributes(reader);
- model.setName(props.getProperty(Element.NAME.getLocalName()));
- model.setModelType(Model.Type.valueOf(props.getProperty(Element.TYPE.getLocalName(), "PHYSICAL")));
- model.setVisible(Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(), "true")));
- model.setPath(props.getProperty(Element.PATH.getLocalName()));
-
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case DESCRIPTION:
- model.setDescription(reader.getElementText());
- break;
- case PROPERTY:
- parseProperty(reader, model);
- break;
- case SOURCE:
- Properties sourceProps = getAttributes(reader);
- String name = sourceProps.getProperty(Element.NAME.getLocalName());
- String translatorName = sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
- String connectionName = sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
- model.addSourceMapping(name, translatorName, connectionName);
- while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
- break;
- case VALIDATION_ERROR:
- Properties validationProps = getAttributes(reader);
- String msg = reader.getElementText();
- String severity = validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
- String path = validationProps.getProperty(Element.PATH.getLocalName());
- ValidationError ve = new ValidationError(severity, msg);
- ve.setPath(path);
- model.addError(ve);
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
-
- private static Properties getAttributes(XMLStreamReader reader) {
- Properties props = new Properties();
- if (reader.getAttributeCount() > 0) {
- for(int i=0; i<reader.getAttributeCount(); i++) {
- String attrName = reader.getAttributeLocalName(i);
- String attrValue = reader.getAttributeValue(i);
- props.setProperty(attrName, attrValue);
- }
- }
- return props;
- }
-
- enum Element {
- // must be first
- UNKNOWN(null),
- VDB("vdb"),
- NAME("name"),
- VERSION("version"),
- DESCRIPTION("description"),
- PROPERTY("property"),
- VALUE("value"),
- MODEL("model"),
- TYPE("type"),
- VISIBLE("visible"),
- PATH("path"),
- SOURCE("source"),
- SOURCE_TRANSLATOR_NAME_ATTR("translator-name"),
- SOURCE_CONNECTION_JNDI_NAME_ATTR("connection-jndi-name"),
- VALIDATION_ERROR("validation-error"),
- VALIDATION_SEVERITY_ATTR("severity"),
- TRANSLATOR("translator"),
- DATA_ROLE("data-role"),
- DATA_ROLE_ANY_ATHENTICATED_ATTR("any-authenticated"),
- DATA_ROLE_ALLOW_TEMP_TABLES_ATTR("allow-create-temporary-tables"),
- PERMISSION("permission"),
- RESOURCE_NAME("resource-name"),
- ALLOW_CREATE("allow-create"),
- ALLOW_READ("allow-read"),
- ALLOW_UPADTE("allow-update"),
- ALLOW_DELETE("allow-delete"),
- ALLOW_EXECUTE("allow-execute"),
- ALLOW_ALTER("allow-alyer"),
- MAPPED_ROLE_NAME("mapped-role-name"),
- ENTRY("entry");
-
- private final String name;
-
- Element(final String name) {
- this.name = name;
- }
-
- /**
- * Get the local name of this element.
- *
- * @return the local name
- */
- public String getLocalName() {
- return name;
- }
-
- private static final Map<String, Element> elements;
-
- static {
- final Map<String, Element> map = new HashMap<String, Element>();
- for (Element element : values()) {
- final String name = element.getLocalName();
- if (name != null) map.put(name, element);
- }
- elements = map;
- }
-
- public static Element forName(String localName) {
- final Element element = elements.get(localName);
- return element == null ? UNKNOWN : element;
- }
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
-import org.teiid.adminapi.Translator;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
- private static final long serialVersionUID = -3454161477587996138L;
- private String type;
- private Class<?> executionClass;
- private String description;
- private String moduleName;
-
- @Override
- public String getName() {
- return super.getName();
- }
-
- @XmlAttribute(name = "name", required = true)
- public void setName(String name) {
- super.setName(name);
- }
-
- @Override
- public String getType() {
- return type;
- }
-
- @XmlAttribute(name = "type",required = true)
- public void setType(String type) {
- this.type = type;
- }
-
- @Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
- public String toString() {
- return getName();
- }
-
- public Class<?> getExecutionFactoryClass() {
- return this.executionClass;
- }
-
- public void setExecutionFactoryClass(Class<?> clazz) {
- this.executionClass = clazz;
- addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
- }
-
- public String getDescription() {
- return this.description;
- }
-
- @XmlAttribute(name = "description")
- public void setDescription(String desc) {
- this.description = desc;
- }
-
- public String getModuleName() {
- return this.moduleName;
- }
-
- public void setModuleName(String name) {
- this.moduleName = name;
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,131 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import org.teiid.adminapi.WorkerPoolStatistics;
-
-/**
- * This class is a holder for all the statistics gathered about a worker pool.
- */
-public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements WorkerPoolStatistics {
-
- private static final long serialVersionUID = -4917902925523802295L;
-
- // Current state
- private int queued;
- private int highestQueued;
- private int maxThreads;
- private int activeThreads;
- private int highestActiveThreads;
- private long totalSubmitted;
- private long totalCompleted;
-
- @Override
- public int getActiveThreads() {
- return activeThreads;
- }
-
- @Override
- public int getHighestActiveThreads() {
- return highestActiveThreads;
- }
-
- @Override
- public long getTotalCompleted() {
- return totalCompleted;
- }
-
- @Override
- public long getTotalSubmitted() {
- return totalSubmitted;
- }
-
- @Override
- public String getQueueName() {
- return getName();
- }
-
- @Override
- public int getQueued() {
- return queued;
- }
-
- @Override
- public int getHighestQueued() {
- return highestQueued;
- }
-
- @Override
- public int getMaxThreads() {
- return maxThreads;
- }
-
- public void setQueued(int queued) {
- this.queued = queued;
- }
-
- public void setHighestQueued(int highestQueued) {
- this.highestQueued = highestQueued;
- }
-
- public void setMaxThreads(int maxThreads) {
- this.maxThreads = maxThreads;
- }
-
- public void setActiveThreads(int activeThreads) {
- this.activeThreads = activeThreads;
- }
-
- public void setHighestActiveThreads(int highestActiveThreads) {
- this.highestActiveThreads = highestActiveThreads;
- }
-
- public void setTotalSubmitted(long totalSubmitted) {
- this.totalSubmitted = totalSubmitted;
- }
-
- public void setTotalCompleted(long totalCompleted) {
- this.totalCompleted = totalCompleted;
- }
-
- public void setQueueName(String name) {
- setName(name);
- }
-
- public String toString() {
- StringBuilder str = new StringBuilder();
-
- str.append("WorkerPoolStats:"); //$NON-NLS-1$
- str.append(" queue-name = " + getName()); //$NON-NLS-1$
- str.append("; queued = " + queued); //$NON-NLS-1$
- str.append("; highestQueued = " + highestQueued); //$NON-NLS-1$
- str.append("; maxThreads = " + maxThreads); //$NON-NLS-1$
- str.append("; activeThreads = " + activeThreads); //$NON-NLS-1$
- str.append("; highestActiveThreads = " + highestActiveThreads); //$NON-NLS-1$
- str.append("; totalSubmitted = " + totalSubmitted); //$NON-NLS-1$
- str.append("; totalCompleted = " + totalCompleted); //$NON-NLS-1$
- return str.toString();
- }
-
-}
-
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.Arrays;
-
-import org.junit.Test;
-import org.teiid.adminapi.DataPolicy.PermissionType;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import static junit.framework.Assert.*;
-
-public class TestDataPolicyMetaData {
-
- @Test
- public void testAllowed() {
- DataPolicyMetadata policy = new DataPolicyMetadata();
- policy.setName("readOnly"); //$NON-NLS-1$
- policy.setDescription("Only has read only permissions"); //$NON-NLS-1$
- policy.setMappedRoleNames(Arrays.asList("jack", "susan")); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- PermissionMetaData perm1 = new PermissionMetaData();
- perm1.setResourceName("catalog.schema.Table1"); //$NON-NLS-1$
- perm1.setAllowRead(true);
-
- PermissionMetaData perm2 = new PermissionMetaData();
- perm2.setResourceName("catalog.schema.Table2"); //$NON-NLS-1$
- perm2.setAllowRead(false);
-
- PermissionMetaData perm3 = new PermissionMetaData();
- perm3.setResourceName("catalog.schema.Table3"); //$NON-NLS-1$
- perm3.setAllowRead(true);
-
- PermissionMetaData perm4 = new PermissionMetaData();
- perm4.setResourceName("catalog.schema.Table4"); //$NON-NLS-1$
- perm4.setAllowRead(true);
-
- PermissionMetaData perm5 = new PermissionMetaData();
- perm5.setResourceName("catalog.schema.Table5.column1"); //$NON-NLS-1$
- perm5.setAllowRead(true);
-
- policy.addPermission(perm1, perm2, perm3, perm4, perm5);
-
-
- assertTrue(policy.allows("catalog.schema.Table1", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table1", PermissionType.CREATE)); //$NON-NLS-1$
-
- assertFalse(policy.allows("catalog.schema", PermissionType.READ)); //$NON-NLS-1$
-
- assertFalse(policy.allows("catalog.schema.Table2.column", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table2", PermissionType.READ)); //$NON-NLS-1$
-
- assertTrue(policy.allows("catalog.schema.Table3.column", PermissionType.READ)); //$NON-NLS-1$
- assertTrue(policy.allows("catalog.schema.Table3", PermissionType.READ)); //$NON-NLS-1$
-
- assertTrue(policy.allows("catalog.schema.Table4.column", PermissionType.READ)); //$NON-NLS-1$
- assertTrue(policy.allows("catalog.schema.Table4", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table4", PermissionType.DELETE)); //$NON-NLS-1$
-
- assertTrue(policy.allows("catalog.schema.Table5.column1", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table5.column2", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table5", PermissionType.READ)); //$NON-NLS-1$
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.teiid.adminapi.Model;
-
-@SuppressWarnings("nls")
-public class TestModelMetaData {
-
- @Test
- public void testModelType() {
-
- ModelMetaData model = new ModelMetaData();
- model.modelType = "physical";
-
- assertTrue(model.getModelType() == Model.Type.PHYSICAL);
- assertTrue(model.isSource());
-
- model.modelType = "VIRTUAL";
- assertTrue(model.getModelType() == Model.Type.VIRTUAL);
-
- model.modelType = "TYPE";
- assertTrue(model.getModelType() == Model.Type.OTHER);
- assertTrue(!model.isSource());
- }
-
- @Test
- public void testSupportMultiSource() {
- ModelMetaData model = new ModelMetaData();
- assertFalse(model.isSupportsMultiSourceBindings());
- model.setSupportsMultiSourceBindings(true);
-
- assertTrue(model.isSupportsMultiSourceBindings());
-
- assertTrue(!model.getProperties().isEmpty());
- }
-
- public void testErrors() {
- ModelMetaData m = new ModelMetaData();
- m.addError("ERROR", "I am Error");
- m.addError("WARNING", "I am warning");
-
- assertFalse(m.getErrors().isEmpty());
- assertEquals(1, m.getErrors().size());
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,134 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-import org.teiid.adminapi.Request.ProcessingState;
-import org.teiid.adminapi.Request.ThreadState;
-@SuppressWarnings("nls")
-public class TestRequestMetadata {
-
- @Test public void testMapping() {
- RequestMetadata request = buildRequest();
-
- ModelNode node = MetadataMapper.RequestMetadataMapper.wrap(request, new ModelNode());
-
- RequestMetadata actual = MetadataMapper.RequestMetadataMapper.unwrap(node);
-
- assertEquals(request, actual);
- assertEquals(request.getState(), actual.getState());
- }
-
- private RequestMetadata buildRequest() {
- RequestMetadata request = new RequestMetadata();
- request.setState(ProcessingState.PROCESSING);
- request.setCommand("select * from foo"); //$NON-NLS-1$
- request.setExecutionId(1234);
- request.setName("request-name"); //$NON-NLS-1$
- request.setSessionId("session-id");//$NON-NLS-1$
- request.setSourceRequest(false);
- request.setStartTime(12345L);
- request.setTransactionId("transaction-id");//$NON-NLS-1$
- request.setThreadState(ThreadState.RUNNING);
- //request.setNodeId(1);
- return request;
- }
-
- public static final String desc = "{\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
- " },\n" +
- " \"attributes\" : {\n" +
- " \"execution-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Unique Identifier for Request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"session-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Session Identifier\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"start-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Start time for the request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"command\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Executing Command\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"source-request\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"BOOLEAN\"\n" +
- " },\n" +
- " \"description\" : \"Is this Connector level request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"node-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
- " },\n" +
- " \"description\" : \"Node Identifier\",\n" +
- " \"required\" : false\n" +
- " },\n" +
- " \"transaction-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Get Transaction XID if transaction involved\",\n" +
- " \"required\" : false\n" +
- " },\n" +
- " \"processing-state\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"State of the Request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"thread-state\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Thread state\",\n" +
- " \"required\" : true\n" +
- " }\n" +
- " }\n" +
- "}";
- @Test public void testDescribe() {
- assertEquals(desc, MetadataMapper.RequestMetadataMapper.describe(new ModelNode()).toJSONString(false));
- }
-
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class TestSessionMetadata {
-
- @Test public void testMapping() {
- SessionMetadata session = new SessionMetadata();
- session.setSessionId("test");
- session.setApplicationName("foo");
- session.setClientHostName("localhost");
- session.setCreatedTime(1234);
- session.setIPAddress("127.0.0.1");
- session.setVDBName("vdb-name");
- session.setVDBVersion(2);
- session.setSecurityContext("auth-domain");
- session.setUserName("user");
-
- ModelNode node = MetadataMapper.SessionMetadataMapper.wrap(session, new ModelNode());
-
- SessionMetadata session1 = MetadataMapper.SessionMetadataMapper.unwrap(node);
-
- assertEquals(session.getSessionId(), session1.getSessionId());
- assertEquals(session.getApplicationName(), session1.getApplicationName());
-
- }
-
- private static final String describe = "{\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
- " },\n" +
- " \"attributes\" : {\n" +
- " \"application-name\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Application assosiated with Session\",\n" +
- " \"required\" : false\n" +
- " },\n" +
- " \"created-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"When session created\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"client-host-address\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Host name from where the session created\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"ip-address\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"IP address from where session is created\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"last-ping-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Last ping time\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"session-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Session Identifier\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"user-name\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"User name associated with session\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"vdb-name\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"The Virtual Database Name\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"vdb-version\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
- " },\n" +
- " \"description\" : \"The Virtual Database Version\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"security-domain\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Security domain that session used for login\",\n" +
- " \"required\" : false\n" +
- " }\n" +
- " }\n" +
- "}";
-
- @Test public void testDescribe() {
- ModelNode n = MetadataMapper.SessionMetadataMapper.describe(new ModelNode());
- //System.out.println(n.toJSONString(false));
- assertEquals(describe, n.toJSONString(false));
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class TestTransactionMetadata {
-
- @Test public void testMapping() {
- TransactionMetadata tm = new TransactionMetadata();
- tm.setAssociatedSession("x");
- tm.setCreatedTime(1234);
- tm.setId("tnx-id");
- tm.setScope("scope");
-
- ModelNode node = MetadataMapper.TransactionMetadataMapper.wrap(tm, new ModelNode());
-
- TransactionMetadata tm1 = MetadataMapper.TransactionMetadataMapper.unwrap(node);
-
- assertEquals(tm.getAssociatedSession(), tm1.getAssociatedSession());
-
- assertEquals(tm.getCreatedTime(), tm1.getCreatedTime());
- assertEquals(tm.getId(), tm1.getId());
- assertEquals(tm.getScope(), tm1.getScope());
- }
-
- private static final String describe = "{\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
- " },\n" +
- " \"attributes\" : {\n" +
- " \"session-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Session Identifier\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"txn-created-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Transaction created time\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"txn-scope\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Transaction scope (Request, Local, Global)\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"txn-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Transaction Identifier (XID)\",\n" +
- " \"required\" : true\n" +
- " }\n" +
- " }\n" +
- "}";
- @Test
- public void testDescribe() {
- ModelNode n = MetadataMapper.TransactionMetadataMapper.describe(new ModelNode());
- //System.out.println(n.toJSONString(false));
- assertEquals(describe, n.toJSONString(false));
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,232 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.core.util.ObjectConverterUtil;
-import org.teiid.core.util.PropertiesUtils;
-import org.teiid.core.util.UnitTestUtil;
-
-@SuppressWarnings("nls")
-public class TestVDBMetaData {
-
- @Test
- public void testMarshellUnmarshell() throws Exception {
-
- VDBMetaData vdb = buildVDB();
-
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
- Marshaller marshell = jc.createMarshaller();
- marshell.setSchema(schema);
- marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
-
- StringWriter sw = new StringWriter();
- marshell.marshal(vdb, sw);
-
- System.out.println(sw.toString());
-
- // UnMarshell
- Unmarshaller un = jc.createUnmarshaller();
- un.setSchema(schema);
- vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
-
- validateVDB(vdb);
- }
-
- static void validateVDB(VDBMetaData vdb) {
- ModelMetaData modelOne;
- ModelMetaData modelTwo;
- assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
- assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
- assertEquals(1, vdb.getVersion());
- assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertNotNull(vdb.getModel("model-one")); //$NON-NLS-1$
- assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$
- assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$
-
- modelOne = vdb.getModel("model-one"); //$NON-NLS-1$
- assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$
- assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$
- assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
- assertEquals("model-value-override", modelOne.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse(modelOne.isVisible());
- assertEquals("model description", modelOne.getDescription());
-
- modelTwo = vdb.getModel("model-two"); //$NON-NLS-1$
- assertEquals("model-two", modelTwo.getName()); //$NON-NLS-1$
- assertTrue(modelTwo.getSourceNames().contains("s1")); //$NON-NLS-1$
- assertTrue(modelTwo.getSourceNames().contains("s2")); //$NON-NLS-1$
- assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
- assertEquals("model-value", modelTwo.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- assertTrue(vdb.getValidityErrors().contains("There is an error in VDB")); //$NON-NLS-1$
-
- List<Translator> translators = vdb.getOverrideTranslators();
- assertTrue(translators.size() == 1);
-
- Translator translator = translators.get(0);
- assertEquals("oracleOverride", translator.getName());
- assertEquals("oracle", translator.getType());
- assertEquals("my-value", translator.getPropertyValue("my-property"));
- assertEquals("hello world", translator.getDescription());
- List<DataPolicy> roles = vdb.getDataPolicies();
-
- assertTrue(roles.size() == 1);
-
- DataPolicyMetadata role = vdb.getDataPolicy("roleOne"); //$NON-NLS-1$
- assertTrue(role.isAllowCreateTemporaryTables());
- assertEquals("roleOne described", role.getDescription()); //$NON-NLS-1$
- assertNotNull(role.getMappedRoleNames());
- assertTrue(role.getMappedRoleNames().contains("ROLE1")); //$NON-NLS-1$
- assertTrue(role.getMappedRoleNames().contains("ROLE2")); //$NON-NLS-1$
-
- List<DataPolicy.DataPermission> permissions = role.getPermissions();
- assertEquals(2, permissions.size());
-
- for (DataPolicy.DataPermission p: permissions) {
- if (p.getResourceName().equalsIgnoreCase("myTable.T1")) { //$NON-NLS-1$
- assertTrue(p.getAllowRead());
- assertNull(p.getAllowDelete());
- }
- else {
- assertFalse(p.getAllowRead());
- assertTrue(p.getAllowDelete());
- }
- }
- }
-
- private VDBMetaData buildVDB() {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("myVDB"); //$NON-NLS-1$
- vdb.setDescription("vdb description"); //$NON-NLS-1$
- vdb.setVersion(1);
- vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$
- vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$ //$NON-NLS-2$
-
- ModelMetaData modelOne = new ModelMetaData();
- modelOne.setName("model-one"); //$NON-NLS-1$
- modelOne.addSourceMapping("s1", "translator", "java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setModelType(Model.Type.PHYSICAL); //$NON-NLS-1$
- modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.addProperty("model-prop", "model-value-override"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setVisible(false);
- modelOne.addError("ERROR", "There is an error in VDB"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setDescription("model description");
-
- vdb.addModel(modelOne);
-
- ModelMetaData modelTwo = new ModelMetaData();
- modelTwo.setName("model-two"); //$NON-NLS-1$
- modelTwo.addSourceMapping("s1", "translator", "java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
- modelTwo.addSourceMapping("s2", "translator", "java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
- modelTwo.setModelType(Model.Type.VIRTUAL); //$NON-NLS-1$
- modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
-
- vdb.addModel(modelTwo);
-
- VDBTranslatorMetaData t1 = new VDBTranslatorMetaData();
- t1.setName("oracleOverride");
- t1.setType("oracle");
- t1.setDescription("hello world");
- t1.addProperty("my-property", "my-value");
- List<Translator> list = new ArrayList<Translator>();
- list.add(t1);
- vdb.setOverrideTranslators(list);
-
- DataPolicyMetadata roleOne = new DataPolicyMetadata();
- roleOne.setName("roleOne"); //$NON-NLS-1$
- roleOne.setDescription("roleOne described"); //$NON-NLS-1$
- roleOne.setAllowCreateTemporaryTables(true);
- PermissionMetaData perm1 = new PermissionMetaData();
- perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
- perm1.setAllowRead(true);
- roleOne.addPermission(perm1);
-
- PermissionMetaData perm2 = new PermissionMetaData();
- perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
- perm2.setAllowRead(false);
- perm2.setAllowDelete(true);
- roleOne.addPermission(perm2);
-
- roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2")); //$NON-NLS-1$ //$NON-NLS-2$
-
- vdb.addDataPolicy(roleOne);
- return vdb;
- }
-
- @Test
- public void testAdminMOCreation() {
- VDBMetaData vdb = new VDBMetaData();
-
- PropertiesUtils.setBeanProperty(vdb, "url", "http://teiid.org/myvdb.vdb");
-
- assertEquals("http://teiid.org/myvdb.vdb", vdb.getUrl());
- }
-
- @Test public void testSetUrlVersion() throws MalformedURLException {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("foo");
- vdb.setUrl(new URL("file:///x/foo.2.vdb"));
- assertEquals(2, vdb.getVersion());
- }
-
- @Test public void testVDBMetaDataMapper() {
- VDBMetaData vdb = buildVDB();
-
- ModelNode node = MetadataMapper.wrap(vdb, new ModelNode());
-
- vdb = MetadataMapper.unwrap(node);
- validateVDB(vdb);
- }
-
- @Test
- public void testVDBMetaDataDescribe() throws Exception {
- ModelNode node = MetadataMapper.describe(new ModelNode());
- String actual = node.toJSONString(false);
- assertEquals(ObjectConverterUtil.convertFileToString(new File(UnitTestUtil.getTestDataPath() + "/vdb-describe.txt")), actual);
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,17 +0,0 @@
-package org.teiid.adminapi.impl;
-
-import java.io.FileInputStream;
-
-import org.junit.Test;
-import org.teiid.core.util.UnitTestUtil;
-
-@SuppressWarnings("nls")
-public class TestVDBMetadataParser {
-
- @Test
- public void testparseVDB() throws Exception {
- FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml");
- VDBMetaData vdb = VDBMetadataParser.unmarshell(in);
- TestVDBMetaData.validateVDB(vdb);
- }
-}
14 years, 5 months
teiid SVN: r3446 - branches/as7/admin.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 16:55:50 -0400 (Fri, 02 Sep 2011)
New Revision: 3446
Modified:
branches/as7/admin/
Log:
TEIID-1720: adding ignores
Property changes on: branches/as7/admin
___________________________________________________________________
Added: svn:ignore
+ .classpath
.project
.settings
14 years, 5 months
teiid SVN: r3445 - in branches/as7: admin and 35 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 16:49:18 -0400 (Fri, 02 Sep 2011)
New Revision: 3445
Added:
branches/as7/admin/
branches/as7/admin/pom.xml
branches/as7/admin/src/
branches/as7/admin/src/main/
branches/as7/admin/src/main/java/
branches/as7/admin/src/main/java/org/
branches/as7/admin/src/main/java/org/teiid/
branches/as7/admin/src/main/java/org/teiid/adminapi/
branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java
branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java
branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java
branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java
branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java
branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/as7/admin/src/main/resources/
branches/as7/admin/src/test/
branches/as7/admin/src/test/java/
branches/as7/admin/src/test/java/org/
branches/as7/admin/src/test/java/org/teiid/
branches/as7/admin/src/test/java/org/teiid/adminapi/
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
branches/as7/admin/src/test/resources/
branches/as7/admin/target/
branches/as7/admin/target/classes/
branches/as7/admin/target/classes/org/
branches/as7/admin/target/classes/org/teiid/
branches/as7/admin/target/classes/org/teiid/adminapi/
branches/as7/admin/target/classes/org/teiid/adminapi/impl/
branches/as7/admin/target/maven-archiver/
branches/as7/admin/target/test-classes/
branches/as7/admin/target/test-classes/org/
branches/as7/admin/target/test-classes/org/teiid/
branches/as7/admin/target/test-classes/org/teiid/adminapi/
branches/as7/admin/target/test-classes/org/teiid/adminapi/impl/
branches/as7/connectors/translator-ws/src/main/java/META-INF/
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java
Modified:
branches/as7/adminshell/pom.xml
branches/as7/api/pom.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
branches/as7/connectors/pom.xml
branches/as7/engine/pom.xml
branches/as7/jboss-integration/
branches/as7/jboss-integration/pom.xml
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/metadata/pom.xml
branches/as7/pom.xml
branches/as7/runtime/pom.xml
branches/as7/test-integration/pom.xml
Log:
TEIID-1720: Fixed the all the admin calls and resource models for engine and translator
Added: branches/as7/admin/pom.xml
===================================================================
--- branches/as7/admin/pom.xml (rev 0)
+++ branches/as7/admin/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>teiid-parent</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.6.0.Alpha1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>teiid-admin</artifactId>
+ <name>admin</name>
+ <description>Admin API for Teiid</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-dmr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-cli</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,298 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.Set;
+
+import org.teiid.adminapi.VDB.ConnectionType;
+
+public interface Admin {
+
+ public enum Cache {PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE};
+
+ /**
+ * Assign a {@link Translator} and Data source to a {@link VDB}'s Model
+ *
+ * @param vdbName Name of the VDB
+ * @param vdbVersion Version of the VDB
+ * @param modelName Name of the Model to map Connection Factory
+ * @param sourceName sourceName for the model
+ * @param translatorName
+ * @param dsName data source name that can found in the JNDI map.
+ * @throws AdminException
+ */
+ void assignToModel(String vdbName, int vdbVersion, String modelName, String sourceName, String translatorName, String dsName) throws AdminException;
+
+ /**
+ * Change the {@link ConnectionType} of the {@link VDB}.
+ * @param vdbName Name of the VDB
+ * @param vdbVersion Version of the VDB
+ * @param type
+ * @throws AdminException
+ */
+ void changeVDBConnectionType(String vdbName, int vdbVersion, ConnectionType type) throws AdminException;
+
+ /**
+ * Deploy a {@link VDB} file.
+ * @param name Name of the VDB file to save under
+ * @param VDB VDB.
+ * @throws AdminException
+ *
+ * @return the {@link VDB} representing the current property values and runtime state.
+ */
+ public void deployVDB(String fileName, InputStream vdb) throws AdminException;
+
+
+ /**
+ * Delete the VDB with the given name and version
+ * @param vdbName
+ * @param version
+ * @throws AdminException
+ */
+ void deleteVDB(String vdbName, int vdbVersion) throws AdminException;
+
+ /**
+ * Get the VDBs that currently deployed in the system
+ *
+ * @return Collection of {@link VDB}s. There could be multiple VDBs with the
+ * same name in the Collection but they will differ by VDB version.
+ * @throws AdminException
+ */
+ Set<VDB> getVDBs() throws AdminException;
+
+ /**
+ * Get the VDB
+ * @param vdbName
+ * @param vbdVersion
+ * @throws AdminException
+ * @return
+ */
+ VDB getVDB(String vdbName, int vbdVersion) throws AdminException;
+
+ /**
+ * Get the translators that are available in the configuration
+ *
+ * @return Collection of {@link Translator}
+ * @throws AdminException
+ */
+ Collection<Translator> getTranslators() throws AdminException;
+
+ /**
+ * Get the translator by the given the deployed name.
+ * @param deployedName - name of the deployed translator
+ * @return null if not found
+ * @throws AdminException
+ */
+ Translator getTranslator(String deployedName) throws AdminException;
+
+ /**
+ * Get the Worker Pool statistics in runtime engine.
+ *
+ * @return {@link WorkerPoolStatistics}
+ * @throws AdminException
+ */
+ WorkerPoolStatistics getWorkerPoolStats() throws AdminException;
+
+ /**
+ * Get the Caches that correspond to the specified identifier pattern
+ * @return Collection of {@link String}
+ * @throws AdminException
+ */
+ Collection<String> getCacheTypes() throws AdminException;
+
+ /**
+ * Get all the current Sessions.
+ * @return Collection of {@link Session}
+ * @throws AdminException
+ */
+ Collection<Session> getSessions() throws AdminException;
+
+ /**
+ * Get the all Requests that are currently in process
+ * @return Collection of {@link Request}
+ * @throws AdminException
+ */
+ Collection<Request> getRequests() throws AdminException;
+
+ /**
+ * Get the Requests for the given session
+ * @return Collection of {@link Request}
+ * @throws AdminException
+ */
+ Collection<Request> getRequestsForSession(String sessionId) throws AdminException;
+
+
+ /**
+ * Get all of the available configuration Properties for the specified connector
+ * @param templateName - Name of the connector
+ * @return
+ * @throws AdminException
+ */
+ Collection<PropertyDefinition> getTemplatePropertyDefinitions(String templateName) throws AdminException;
+
+
+ /**
+ * Get all transaction matching the identifier.
+ * @return
+ * @throws AdminException
+ */
+ Collection<Transaction> getTransactions() throws AdminException;
+
+ /**
+ * Clear the cache or caches specified by the cacheIdentifier.
+ * @param cacheType Cache Type
+ * No wild cards currently supported, must be explicit
+ * @throws AdminException
+ */
+ void clearCache(String cacheType) throws AdminException;
+
+ /**
+ * Clear the cache of the given VDB for provided cache type
+ * @param cacheType Cache Type
+ * No wild cards currently supported, must be explicit
+ * @param vdbName - Name of the VDB
+ * @param vdbVersion - VDB version
+ * @throws AdminException
+ */
+ void clearCache(String cacheType, String vdbName, int vdbVersion) throws AdminException;
+
+
+ /**
+ * Get the Cache Statistics for the given type
+ * @param cacheType Cache Type
+ * @return {@link CacheStatistics}
+ * @throws AdminException
+ */
+ CacheStatistics getCacheStats(String cacheType) throws AdminException;
+
+ /**
+ * Terminate the Session
+ *
+ * @param identifier Session Identifier {@link org.teiid.adminapi.Session}.
+ * No wild cards currently supported, must be explicit
+ * @throws AdminException
+ */
+ void terminateSession(String sessionId) throws AdminException;
+
+ /**
+ * Cancel Request
+ *
+ * @param sessionId session Identifier for the request.
+ * @param executionId request Identifier
+ *
+ * @throws AdminException
+ */
+ void cancelRequest(String sessionId, long executionId) throws AdminException;
+
+ /**
+ * Mark the given global transaction as rollback only.
+ * @param transactionId
+ * @throws AdminException
+ */
+ void terminateTransaction(String transactionId) throws AdminException;
+
+ /**
+ * Closes the admin connection
+ */
+ void close();
+
+ /**
+ * Assign a Role name to the Data Role in a given VDB
+ *
+ * @param vdbName
+ * @param vdbVersion
+ * @param dataRole
+ * @param mappedRoleName
+ */
+ void addDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
+
+ /**
+ * Remove a Role name to the Data Role in a given VDB
+ *
+ * @param vdbName
+ * @param vdbVersion
+ * @param dataRole
+ * @param mappedRoleName
+ */
+ void removeDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
+
+ /**
+ * Set the any authenticated flag on the Data Role in a given VDB
+ *
+ * @param vdbName
+ * @param vdbVersion
+ * @param dataRole
+ * @param anyAuthenticated
+ */
+ void setAnyAuthenticatedForDataRole(String vdbName, int vdbVersion, String dataRole, boolean anyAuthenticated) throws AdminException;
+
+ /**
+ * Merge the Source VDB into Target VDB. Both Source and Target VDBs must be present for this method to
+ * succeed. The changes will not be persistent between server restarts.
+ * @param sourceVDBName
+ * @param sourceVDBVersion
+ * @param targetVDBName
+ * @param targetVDBVersion
+ */
+ void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
+
+
+ /**
+ * Creates a JCA data source
+ * @param deploymentName - name of the source
+ * @param templateName - template of data source
+ * @param properties - properties
+ * @throws AdminException
+ */
+ void createDataSource(String deploymentName, String templateName, Properties properties) throws AdminException;
+
+ /**
+ * Delete data source.
+ * @param deployedName
+ * @throws AdminException
+ */
+ void deleteDataSource(String deployedName) throws AdminException;
+
+ /**
+ * Returns the all names of all the data sources available in the configuration.
+ */
+ Collection<String> getDataSourceNames() throws AdminException;
+
+ /**
+ * Get the Datasource templates available in the configuration.
+ *
+ * @return Set of template names.
+ * @throws AdminException
+ */
+ Set<String> getDataSourceTemplateNames() throws AdminException;
+
+ /**
+ * Tell the engine that the given source is available. Pending dynamic vdb metadata loads will be resumed.
+ * @param jndiName
+ * @throws AdminException
+ */
+ void markDataSourceAvailable(String jndiName) throws AdminException;
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+/**
+ * An <code>AdminComponentException</code> is thrown when an error occurs as a
+ * result of an internal component error.
+ *
+ * <p>This exception class is capable of containing multiple exceptions. See
+ * {@link AdminException} for details.
+ */
+public final class AdminComponentException extends AdminException {
+
+ private static final long serialVersionUID = 7117721841515240902L;
+
+
+ public AdminComponentException() {
+ super();
+ }
+
+ /**
+ * Construct with a message.
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminComponentException(String msg) {
+ super(msg);
+ }
+
+ public AdminComponentException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct with an optional error code and a message.
+ * @param code an optional error code
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminComponentException(int code, String msg) {
+ super(code, msg);
+ }
+
+ public AdminComponentException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public AdminComponentException(int code, String msg, Throwable cause) {
+ super(code, msg, cause);
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.core.TeiidException;
+
+
+/**
+ * <code>AdminException</code> is the base exception for the admin package. Many *Admin methods throw this
+ * exception. Instances will be one of the concrete subtypes:
+ * {@link AdminComponentException} or {@link AdminProcessingException}</p>
+ *
+ * <p><code>AdminException</code>s may contain multiple child exceptions. An example
+ * of this could be when performing an admin action results in multiple failures. Admin
+ * clients should be aware of this and use the {@link #hasMultiple()} method to
+ * determine if they need to check the child exceptions.</p>
+ */
+public abstract class AdminException extends TeiidException {
+
+ private static final long serialVersionUID = -4446936145500241358L;
+ // List of Admin exceptions in
+ // case of multiple failure
+ private List children;
+
+ /**
+ * No-arg ctor.
+ *
+ * @since 4.3
+ */
+ AdminException() {
+ super();
+ }
+
+ /**
+ * Construct with a message.
+ * @param msg the error message.
+ * @since 4.3
+ */
+ AdminException(String msg) {
+ super(msg);
+ }
+
+ AdminException(Throwable cause) {
+ this(cause.getMessage(), cause);
+ }
+
+ /**
+ * Construct with an optional error code and a message.
+ * @param code an optional error code
+ * @param msg the error message.
+ * @since 4.3
+ */
+ AdminException(int code, String msg) {
+ super(Integer.toString(code), msg);
+ }
+
+ AdminException(String msg, Throwable cause) {
+ super(cause, msg);
+ }
+
+ AdminException(int code, String msg, Throwable cause) {
+ super(cause, Integer.toString(code),msg);
+ }
+
+ /**
+ * Determine whether this exception is representing
+ * mutliple component failures.
+ * @return <code>true</code> iff this exception contains multiple
+ * component failure exceptions.
+ * @since 4.3
+ */
+ public boolean hasMultiple() {
+ return (children != null && children.size() > 0);
+ }
+
+ /**
+ * Returns a non-null list of failures (<code>AdminException</code>s), one for each
+ * component that failed.
+ *
+ * <p>The list will have members when {@link #hasMultiple()} returns <code>true</code>.</p>
+ * @return The non-null list of failures.
+ * @since 4.3
+ */
+ public List getChildren() {
+ return (children != null ? children : Collections.EMPTY_LIST);
+ }
+
+ /**
+ * Add a child <code>AdminException</code> for a particular failure
+ * if and action resulted in multiple failures.
+ *
+ * @param child a specific failure
+ * @since 4.3
+ */
+ public void addChild(AdminException child) {
+ if ( children == null ) {
+ children = new ArrayList();
+ }
+ children.add(child);
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.security.auth.callback.*;
+import javax.security.sasl.RealmCallback;
+import javax.security.sasl.RealmChoiceCallback;
+
+import org.jboss.as.cli.Util;
+import org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.teiid.adminapi.VDB.ConnectionType;
+
+
+/**
+ * Singleton factory for class for creating Admin connections to the Teiid
+ */
+public class AdminFactory {
+ private static AdminFactory INSTANCE = new AdminFactory();
+
+ public static AdminFactory getInstance() {
+ return INSTANCE;
+ }
+ /**
+ * Creates a ServerAdmin with the specified connection properties.
+ * @param userName
+ * @param password
+ * @param serverURL
+ * @param applicationName
+ * @return
+ * @throws AdminException
+ */
+ public Admin createAdmin(String host, int port, String userName, char[] password) throws AdminException {
+ if(host == null) {
+ host = "localhost"; //$NON-NLS-1$
+ }
+
+ if(port < 0) {
+ port = 9990;
+ }
+
+ try {
+ CallbackHandler cbh = new AuthenticationCallbackHandler(userName, password);
+ ModelControllerClient newClient = ModelControllerClient.Factory.create(host, port, cbh);
+
+ List<String> nodeTypes = Util.getNodeTypes(newClient, new DefaultOperationRequestAddress());
+ if (!nodeTypes.isEmpty()) {
+ boolean domainMode = nodeTypes.contains("server-group"); //$NON-NLS-1$
+ System.out.println("Connected to " //$NON-NLS-1$
+ + (domainMode ? "domain controller at " : "standalone controller at ") //$NON-NLS-1$ //$NON-NLS-2$
+ + host + ":" + port); //$NON-NLS-1$
+ return new AdminImpl(newClient);
+ }
+ System.out.println("The controller is not available at " + host + ":" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (UnknownHostException e) {
+ System.out.println("Failed to resolve host '" + host + "': " + e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+
+ private class AuthenticationCallbackHandler implements CallbackHandler {
+ private boolean realmShown = false;
+ private String userName = null;
+ private char[] password = null;
+
+ public AuthenticationCallbackHandler(String user, char[] password) {
+ this.userName = user;
+ this.password = password;
+ }
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ // Special case for anonymous authentication to avoid prompting user for their name.
+ if (callbacks.length == 1 && callbacks[0] instanceof NameCallback) {
+ ((NameCallback)callbacks[0]).setName("anonymous CLI user"); //$NON-NLS-1$
+ return;
+ }
+
+ for (Callback current : callbacks) {
+ if (current instanceof RealmCallback) {
+ RealmCallback rcb = (RealmCallback) current;
+ String defaultText = rcb.getDefaultText();
+ rcb.setText(defaultText); // For now just use the realm suggested.
+ if (realmShown == false) {
+ realmShown = true;
+ }
+ } else if (current instanceof RealmChoiceCallback) {
+ throw new UnsupportedCallbackException(current, "Realm choice not currently supported."); //$NON-NLS-1$
+ } else if (current instanceof NameCallback) {
+ NameCallback ncb = (NameCallback) current;
+ ncb.setName(userName);
+ } else if (current instanceof PasswordCallback) {
+ PasswordCallback pcb = (PasswordCallback) current;
+ pcb.setPassword(password);
+ } else {
+ throw new UnsupportedCallbackException(current);
+ }
+ }
+ }
+
+ }
+
+ private class AdminImpl implements Admin{
+ public AdminImpl (ModelControllerClient connection) {
+
+ }
+
+ @Override
+ public void addDataRoleMapping(String vdbName, int vdbVersion,
+ String dataRole, String mappedRoleName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void assignToModel(String vdbName, int vdbVersion,
+ String modelName, String sourceName, String translatorName,
+ String dsName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancelRequest(String sessionId, long executionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void changeVDBConnectionType(String vdbName, int vdbVersion,
+ ConnectionType type) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearCache(String cacheType) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearCache(String cacheType, String vdbName, int vdbVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void close() {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void createDataSource(String deploymentName,
+ String templateName, Properties properties)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteDataSource(String deployedName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteVDB(String vdbName, int vdbVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deployVDB(String fileName, InputStream vdb)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public CacheStatistics getCacheStats(String cacheType)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<String> getCacheTypes() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<String> getDataSourceNames() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<String> getDataSourceTemplateNames() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getRequests() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getRequestsForSession(String sessionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Session> getSessions() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<PropertyDefinition> getTemplatePropertyDefinitions(
+ String templateName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Translator getTranslator(String deployedName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Translator> getTranslators() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VDB getVDB(String vdbName, int vbdVersion) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<VDB> getVDBs() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public WorkerPoolStatistics getWorkerPoolStats() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void markDataSourceAvailable(String jndiName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
+ String targetVDBName, int targetVDBVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeDataRoleMapping(String vdbName, int vdbVersion,
+ String dataRole, String mappedRoleName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAnyAuthenticatedForDataRole(String vdbName,
+ int vdbVersion, String dataRole, boolean anyAuthenticated)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateSession(String sessionId) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * Base interface of client side admin objects. Specifies behaviors and properties common to all administrative objects.
+ * <p>
+ * Unique identifiers are available for all <code>AdminObject</code>s and their forms are specific to each object. See
+ * the javadoc on the individual object for its particular identifier pattern required.
+ * </p>
+ * <p>
+ * This interface need not be used directly by clients except when coding to constants.
+ * </p>
+ *
+ * @since 4.3
+ */
+public interface AdminObject extends Serializable {
+
+ /**
+ * The character that delimits the atomic components of the identifier.
+ * @see #DELIMITER
+ */
+ public static final char DELIMITER_CHAR = '|';
+
+ /**
+ * The character (as a <code>String</code>) that delimits the atomic components of the identifier.
+ *
+ * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>DELIMITER</code>
+ * rather than hard-coding a delimiter character in admin code. Doing this eliminates the possibility
+ * of admin client code breaking if/when the delimiter character must be changed.</p>
+ */
+ public static final String DELIMITER = new String(new char[] {DELIMITER_CHAR});
+
+ /**
+ * The delimiter character as a <code>String</code> escaped.
+ * @see #DELIMITER
+ */
+ public static final String ESCAPED_DELIMITER = "\\" + DELIMITER; //$NON-NLS-1$
+
+ /**
+ * The wildcard character (as a <code>String</code>) that can be used in may identifier patterns
+ * to indicate <i>"anything"</i> or, more specifically, replace <i>"zero or more"</i>
+ * identifier components.
+ *
+ * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>WILDCARD</code>
+ * rather than hard-coding a wildcard character in admin code. Doing this eliminates the possibility
+ * of admin client code breaking if/when the wildcard character must be changed.</p>
+ */
+ public static final String WILDCARD = "*"; //$NON-NLS-1$
+
+ /**
+ * The wildcard character as a <code>String</code> escaped.
+ * @see #WILDCARD
+ */
+ public static final String ESCAPED_WILDCARD = "\\" + WILDCARD; //$NON-NLS-1$
+
+ /**
+ * Get the name for this AdminObject, usually the last component of the identifier.
+ *
+ * @return String Name
+ * @since 4.3
+ */
+ String getName();
+
+ /**
+ * Get the Configuration Properties that defines this process
+ *
+ * @return Properties
+ * @since 4.3
+ */
+ Properties getProperties();
+
+ /**
+ * Searches for the property with the specified key in this Admin Object. If the key is not found the method returns
+ * <code>null</code>.
+ *
+ * @param name
+ * the property key.
+ * @return the value in this Admin Object with the specified key value.
+ * @since 4.3
+ */
+
+ String getPropertyValue(String name);
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -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.adminapi;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+public class AdminPlugin {
+ public static final String PLUGIN_ID = "org.teiid.adminapi" ; //$NON-NLS-1$
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+/**
+ * An <code>AdminProcessingException</code> indicates that an error occured during processing as a result
+ * of user input. This exception is the result of handling an invalid user
+ * request, not the result of an internal error.</p>
+ *
+ * <p>This exception class is capable of containing multiple exceptions. See
+ * {@link AdminException} for details.
+ */
+public final class AdminProcessingException extends AdminException {
+
+ private static final long serialVersionUID = -878521636838205857L;
+
+ /**
+ * No-arg ctor.
+ *
+ * @since 4.3
+ */
+ public AdminProcessingException() {
+ super();
+ }
+
+ /**
+ * Construct with a message.
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminProcessingException(String msg) {
+ super(msg);
+ }
+
+ public AdminProcessingException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct with an optional error code and a message.
+ * @param code an optional error code
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminProcessingException(int code, String msg) {
+ super(code, msg);
+ }
+
+ public AdminProcessingException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public AdminProcessingException(int code, String msg, Throwable cause) {
+ super(code, msg, cause);
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -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.adminapi;
+
+public interface CacheStatistics extends AdminObject {
+
+ double getHitRatio();
+
+ int getTotalEntries();
+
+ int getRequestCount();
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+import java.util.List;
+
+public interface DataPolicy {
+
+ public enum Context {
+ CREATE,
+ DROP,
+ QUERY,
+ INSERT,
+ UPDATE,
+ DELETE,
+ FUNCTION,
+ ALTER,
+ STORED_PROCEDURE;
+ }
+
+ public enum PermissionType {CREATE, READ, UPDATE, DELETE, ALTER, EXECUTE, DROP};
+
+ /**
+ * Get the Name of the Data Policy
+ * @return
+ */
+ String getName();
+
+ /**
+ * Get the description of the Data Policy
+ * @return
+ */
+ String getDescription();
+
+ /**
+ * Get the List of Permissions for this Data Policy.
+ * @return
+ */
+ List<DataPermission> getPermissions();
+
+ /**
+ * Mapped Container Role names for this Data Policy
+ * @return
+ */
+ List<String> getMappedRoleNames();
+
+ /**
+ * If the policy applies to any authenticated user
+ * @return
+ */
+ boolean isAnyAuthenticated();
+
+ /**
+ * If the policy allows for temporary table usage
+ * @return
+ */
+ Boolean isAllowCreateTemporaryTables();
+
+ interface DataPermission {
+ /**
+ * Get the Resource Name that Data Permission representing
+ * @return
+ */
+ String getResourceName();
+
+ /**
+ * Is "CREATE" allowed?
+ * @return
+ */
+ Boolean getAllowCreate();
+
+ /**
+ * Is "SELECT" allowed?
+ * @return
+ */
+ Boolean getAllowRead();
+
+ /**
+ * Is "INSERT/UPDATE" allowed?
+ * @return
+ */
+ Boolean getAllowUpdate();
+
+ /**
+ * Is "DELETE" allowed?
+ * @return
+ */
+ Boolean getAllowDelete();
+
+ /**
+ * Is "ALTER" allowed?
+ * @return
+ */
+ Boolean getAllowAlter();
+
+ /**
+ * Is "EXECUTE" allowed?
+ * @return
+ */
+ Boolean getAllowExecute();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.List;
+
+
+/**
+ * Represents a metadata model in the Teiid system.
+ *
+ * @since 4.3
+ */
+public interface Model extends AdminObject {
+
+ enum Type {PHYSICAL, VIRTUAL, FUNCTION, OTHER};
+
+ /**
+ * Description about the model
+ * @return
+ */
+ String getDescription();
+
+ /**
+ * Determine if this model is a Source model.
+ *
+ * @return <code>true</code> if it contains physical group(s).
+ */
+ boolean isSource();
+
+ /**
+ * Determine whether this model is exposed for querying.
+ *
+ * @return <code>true</code> if the model is visible
+ * for querying.
+ */
+ boolean isVisible();
+
+ /**
+ * Retrieve the model type.
+ * @return model type
+ */
+ Type getModelType();
+
+ /**
+ * Determine whether this model can support more than one source.
+ *
+ * @return <code>true</code> if this model supports multiple sources
+ */
+ boolean isSupportsMultiSourceBindings();
+
+ /**
+ * Associated Source Names for the Models
+ * @return String
+ */
+ List<String> getSourceNames();
+
+ /**
+ * Get the configured JNDI name for the given source name.
+ * @param sourceName - name of the source
+ * @return null if none configured.
+ */
+ String getSourceConnectionJndiName(String sourceName);
+
+
+ /**
+ * Get the configured translator name for the given source
+ * @param sourceName
+ * @return
+ */
+ String getSourceTranslatorName(String sourceName);
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.Collection;
+
+/**
+ * Information about a property of an AdminObject
+ */
+public interface PropertyDefinition extends AdminObject {
+
+ public enum RestartType {
+ NONE,
+ SERVICE,
+ PROCESS,
+ ALL_PROCESSES,
+ CLUSTER
+ }
+ /**
+ * The value of the maximum multiplicity if the multiplicity is considered unbounded.
+ */
+ public static final int UNBOUNDED_VALUE = Integer.MAX_VALUE;
+
+
+ /**
+ * Get the localized display name of this property.
+ * @return the displayable name for this property
+ */
+ String getDisplayName();
+
+ /**
+ * Get the description of this property.
+ * @return the description for this property
+ */
+ String getDescription();
+
+
+ /**
+ * Get the name of the java class that best represents the property type.
+ * @return the name of the java class that best represents the property type.
+ */
+ String getPropertyTypeClassName();
+
+
+ /**
+ * Get the default value for values of this property, or an empty String if
+ * there is no default value.
+ * @return the default value for this property, or an empty String
+ * if there is no default value.
+ */
+ Object getDefaultValue();
+
+ /**
+ * Get the allowed values for this property.
+ * @return the list of allowed values for this property, or an empty
+ * set if the values do not have to conform to a fixed set.
+ */
+ Collection getAllowedValues();
+
+ /**
+ * Get whether this property requires the system to be restarted before it takes effect.
+ * @return true if this property requires the system to be restarted before it takes effect.
+ */
+ public RestartType getRequiresRestart();
+
+ /**
+ * The modifiable flag is used to identify features that may not be changed once
+ * they are set.
+ * @return true if this property is marked with the modifyable
+ * flag, or false otherwise.
+ */
+ boolean isModifiable();
+
+ /**
+ * Return whether the value or values for this property are constrained to be only
+ * those in the AllowedValues list.
+ * @see #getAllowedValues
+ * @return true if this property's value must be with the list of AllowedValues.
+ */
+ boolean isConstrainedToAllowedValues();
+
+ /**
+ * The "expert" flag is used to distinguish between features that are
+ * intended for expert users from those that are intended for normal users.
+ * @return true if this property is to be marked with the expert flag,
+ * or false otherwise.
+ */
+ boolean isAdvanced();
+ /**
+ * The "required" flag is used to identify features that require at least
+ * one value (possibly a default value) by the consumer of the property. Whether
+ * a property definition is required or not can be determined entirely from the
+ * multiplicity: if the multiplicity includes '0', then the property is
+ * not required.
+ * <p>
+ * Whether a property is required by the consumer is unrelated to whether
+ * there is a default value, which only simplifies the task of the property
+ * provider. A property may be required, meaning it must have at least one
+ * value, but that same property definition may or may not have a default.
+ * The combination of required and whether it has a default will determine
+ * whether the user must supply a value.
+ * @return true if this property requires at least one value.
+ */
+ boolean isRequired();
+ /**
+ * The "masked" flag is used to tell whether the value should be masked
+ * when displayed to users.
+ * @return true if this property value is to be masked,
+ * or false otherwise.
+ */
+ boolean isMasked();
+
+
+
+}
+
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+
+
+/**
+ * When a user submits a SQL command to the system for processing, usually that represents
+ * a single request. A single request might have one or more source
+ * requests (the requests that are being processed on the physical data sources) as part
+ * of original request.
+ *
+ * <p>A request is identified by a numbers separated by '|'. usually in they are arranged
+ * in the pattern [session]|[request] or [session]|[request]|[source request] </p>
+ */
+public interface Request extends AdminObject {
+
+ public enum ProcessingState {
+ PROCESSING,
+ DONE,
+ CANCELED
+ }
+
+ public enum ThreadState {
+ RUNNING,
+ QUEUED,
+ IDLE
+ }
+
+ /**
+ * Get the ExecutionId for a Request
+ * @return ExecutionId
+ */
+ public long getExecutionId();
+
+ /**
+ * Get the SessionID for a Request
+ *
+ * @return String SessionID
+ */
+ public String getSessionId();
+
+ /**
+ * Get the SQL Command sent to the Server for a Request
+ *
+ * @return SQL Command
+ */
+ public String getCommand();
+
+ /**
+ * Get when the processing began for this Request
+ * @return Date processing began
+ */
+ public long getStartTime();
+
+ /**
+ * Get the TransactionID of the Request
+ *
+ * @return String of TransactionID if in a transaction
+ */
+ public String getTransactionId();
+
+ /**
+ * @return Returns whether this is a Source Request.
+ */
+ public boolean sourceRequest();
+
+ /**
+ * @return In the case that this is a source request this represents the node id. Otherwise null
+ */
+ public Integer getNodeId();
+
+ /**
+ * @return The request state
+ */
+ ProcessingState getState();
+
+ /**
+ * @return The thread state
+ */
+ ThreadState getThreadState();
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+/**
+ * A Session represents a single connection between a client and the server.
+ *
+ * A user is allowed to have multiple sessions active simultaneously.
+ */
+public interface Session extends AdminObject {
+
+ /**
+ * Get the Last time Client has check to see if the server is still available
+ *
+ * @return Date of the last ping to the server.
+ */
+ public long getLastPingTime();
+
+
+ /**
+ * Get the Application Name
+ *
+ * @return String of the Application Name
+ */
+ public String getApplicationName();
+
+ /**
+ * Get the unique Teiid session
+ * within a given Teiid System
+ *
+ * @return String of the Session ID
+ */
+ public String getSessionId();
+
+ /**
+ * Get User Name for this Session
+ *
+ * @return String of UserName
+ */
+ public String getUserName();
+
+ /**
+ * Get the VDB Name for this Session
+ *
+ * @return String name of the VDB
+ */
+ public String getVDBName();
+
+ /**
+ * Get the VDB Version for this Session
+ *
+ * @return String name/number of the VDB Version
+ */
+ public int getVDBVersion();
+
+ /**
+ * Get the IPAddress for this Session. Note this value is reported from the client.
+ * @return
+ */
+ public String getIPAddress();
+
+
+ /**
+ * Get the host name of the machine the client is
+ * accessing from. Note this value is reported from the client.
+ * @return
+ */
+ public String getClientHostName();
+
+ /**
+ * Get the client hardware (typically MAC) address. Note this value is reported from the client.
+ * @return the hardware address as a hex string or null if not available.
+ */
+ public String getClientHardwareAddress();
+
+ /**
+ * Get the time the {@link Session} was created.
+ * @return
+ */
+ public long getCreatedTime();
+
+
+ /**
+ * Security Domain user logged into currently
+ * @return
+ */
+ public String getSecurityDomain();
+
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+public interface Transaction extends AdminObject {
+
+ /**
+ * Get the session associated with the this transaction.
+ * May be null for an unassociated Global transaction.
+ * @return
+ */
+ String getAssociatedSession();
+
+ /**
+ * Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
+ * @return
+ */
+ String getScope();
+
+ /**
+ * Returns the Xid string for GLOBAL transactions or the Transaction id string LOCAL/REQUEST.
+ * @return
+ */
+ String getId();
+
+
+ /**
+ * Get the local creation time.
+ * @return
+ */
+ long getCreatedTime();
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+
+public interface Translator extends AdminObject{
+ public static final String EXECUTION_FACTORY_CLASS = "execution-factory-class"; //$NON-NLS-1$
+ public static final String TRANSLATOR_PROPERTY = "property"; //$NON-NLS-1$
+
+ /**
+ * Get the Translator type
+ * @return
+ */
+ public String getType();
+
+ /**
+ * Get the Translator description
+ * @return
+ */
+ public String getDescription();
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.List;
+
+/**
+ * Represents a Virtual Database in the Teiid System.
+ * <br>A VDB has a name and a version.</br>
+ *
+ * <p>The identifier pattern for a VDB is <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>,
+ * where the name of the VDB and its version represent its unique identifier in the Teiid system.
+ * There are no spaces allowed in a given VDB name, and VDB name must start with a letter.
+ * A version number is automatically assigned to a VDB when it is deployed into
+ * a system. A VDB is uniquely identified by <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>.
+ * For example: <CODE>"Accounts<{@link #DELIMITER_CHAR}>1"</CODE>, <CODE>"UnifiedSales<{@link #DELIMITER_CHAR}>4</CODE>" etc.
+ * </p>
+ *
+ * @since 4.3
+ */
+public interface VDB extends AdminObject {
+
+ public static enum Status{INACTIVE, ACTIVE};
+
+ public enum ConnectionType {NONE, BY_VERSION, ANY}
+
+ /**
+ * @return Collection of Teiid Models
+ */
+ public List<Model> getModels();
+
+ /**
+ * @return the status
+ */
+ public Status getStatus();
+
+ /**
+ * @return the connection status
+ */
+ public ConnectionType getConnectionType();
+
+ /**
+ * @return the VDB version
+ */
+ public int getVersion();
+
+ /**
+ * Get the URL for the VDB
+ * @return
+ */
+ public String getUrl();
+
+ /**
+ * Get the description of the VDB
+ * @return
+ */
+ public String getDescription();
+
+ /**
+ * Shows any validity errors present in the VDB
+ * @return
+ */
+ public List<String> getValidityErrors();
+
+ /**
+ * Shows if VDB is a valid entity
+ * @return
+ */
+ public boolean isValid();
+
+ /**
+ * Get the data roles defined on this VDB
+ * @return
+ */
+ public List<DataPolicy> getDataPolicies();
+
+ /**
+ * Get the list of translators defined in the VDB
+ * @return
+ */
+ public List<Translator> getOverrideTranslators();
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+public interface WorkerPoolStatistics extends AdminObject {
+
+ /**
+ * Current active thread count
+ * @return
+ */
+ public int getActiveThreads();
+
+ /**
+ * Highest Active threads recorded so far
+ * @return
+ */
+ public int getHighestActiveThreads();
+
+
+ /**
+ * Queue Name
+ * @return
+ */
+ public String getQueueName();
+
+
+ /**
+ * Max number of active threads allowed
+ * @return
+ */
+ public int getMaxThreads();
+
+ /**
+ * @return Returns the number of requests queued.
+ * @since 4.3
+ */
+ public int getQueued();
+
+ /**
+ * @return The number of completed tasks
+ */
+ long getTotalCompleted();
+
+
+ /**
+ * @return The number of submitted tasks
+ */
+ long getTotalSubmitted();
+
+ /**
+ * @return Returns the highest queue size
+ */
+ public int getHighestQueued();
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.teiid.adminapi.AdminObject;
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+public abstract class AdminObjectImpl implements AdminObject, Serializable {
+
+ private static final long serialVersionUID = -6381303538713462682L;
+
+ private String name;
+
+ private ListOverMap<PropertyMetadata> properties = new ListOverMap<PropertyMetadata>(new KeyBuilder<PropertyMetadata>() {
+ private static final long serialVersionUID = 3687928367250819142L;
+
+ @Override
+ public String getKey(PropertyMetadata entry) {
+ return entry.getName();
+ }
+ });
+
+ private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Properties getProperties() {
+ Properties props = new Properties();
+ for (PropertyMetadata p:this.properties.getMap().values()) {
+ props.setProperty(p.getName(), p.getValue());
+ }
+ return props;
+ }
+
+ public void setProperties(Properties props) {
+ this.properties.clear();
+ if (props != null) {
+ for (String key:props.stringPropertyNames()) {
+ addProperty(key, props.getProperty(key));
+ }
+ }
+ }
+
+ public List<PropertyMetadata> getJAXBProperties(){
+ return properties;
+ }
+
+ public void setJAXBProperties(List<PropertyMetadata> props){
+ this.properties.clear();
+ if (props != null) {
+ for (PropertyMetadata prop:props) {
+ addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ @Override
+ public String getPropertyValue(String name) {
+ PropertyMetadata prop = this.properties.getMap().get(name);
+ if (prop == null) {
+ return null;
+ }
+ return prop.getValue();
+ }
+
+ public void addProperty(String key, String value) {
+ this.properties.getMap().put(key, new PropertyMetadata(key, value));
+ }
+
+ /**
+ * Add attachment
+ *
+ * @param <T> the expected type
+ * @param attachment the attachment
+ * @param type the type
+ * @return any previous attachment
+ * @throws IllegalArgumentException for a null name, attachment or type
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ public <T> T addAttchment(Class<T> type, T attachment) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.put(type.getName(), attachment);
+ if (result == null)
+ return null;
+ return type.cast(result);
+
+ }
+
+ public Object addAttchment(String key, Object attachment) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.put(key, attachment);
+ if (result == null)
+ return null;
+ return result;
+ }
+
+ /**
+ * Remove attachment
+ *
+ * @param <T> the expected type
+ * @return the attachment or null if not present
+ * @param type the type
+ * @throws IllegalArgumentException for a null name or type
+ */
+ public <T> T removeAttachment(Class<T> type) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.remove(type.getName());
+ if (result == null)
+ return null;
+ return type.cast(result);
+ }
+
+ public Object removeAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.remove(key);
+ if (result == null)
+ return null;
+ return result;
+ }
+ /**
+ * Get attachment
+ *
+ * @param <T> the expected type
+ * @param type the type
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or type
+ */
+ public <T> T getAttachment(Class<T> type) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.get(type.getName());
+ if (result == null)
+ return null;
+ return type.cast(result);
+ }
+
+ public Object getAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.get(key);
+ if (result == null)
+ return null;
+ return result;
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.teiid.adminapi.CacheStatistics;
+
+public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
+
+ private static final long serialVersionUID = -3514505497661004560L;
+
+ private double hitRatio;
+ private int totalEntries;
+ private int requestCount;
+
+ @Override
+ public int getRequestCount() {
+ return requestCount;
+ }
+
+ public void setRequestCount(int count) {
+ this.requestCount = count;
+ }
+
+ @Override
+ public double getHitRatio() {
+ return this.hitRatio;
+ }
+
+ @Override
+ public int getTotalEntries() {
+ return this.totalEntries;
+ }
+
+ public void setHitRatio(double value) {
+ this.hitRatio = value;
+ }
+
+ public void setTotalEntries(int value) {
+ this.totalEntries = value;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("hitRatio=").append(hitRatio);//$NON-NLS-1$
+ sb.append("; totalEntries=").append(totalEntries); //$NON-NLS-1$
+ sb.append("; requestCount=").append(requestCount); //$NON-NLS-1$
+ return sb.toString();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.adminapi.AdminException;
+
+
+public interface DQPManagement {
+ List<RequestMetadata> getRequestsForSession(String sessionId) ;
+ List<RequestMetadata> getRequests();
+ WorkerPoolStatisticsMetadata getWorkerPoolStatistics();
+ void terminateSession(String terminateeId);
+ boolean cancelRequest(String sessionId, long requestId) throws AdminException;
+ Collection<String> getCacheTypes();
+ void clearCache(String cacheType);
+ void clearCache(String cacheType, String vdbName, int version);
+ Collection<SessionMetadata> getActiveSessions() throws AdminException;
+ int getActiveSessionsCount() throws AdminException;
+ Collection<TransactionMetadata> getTransactions();
+ void terminateTransaction(String xid) throws AdminException ;
+ List<RequestMetadata> getLongRunningRequests();
+ List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) throws AdminException;
+ CacheStatisticsMetadata getCacheStatistics(String cacheType);
+ List<List> executeQuery(String vdbName, int version, String command, long timoutInMilli) throws AdminException;
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,291 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.*;
+
+import org.teiid.adminapi.DataPolicy;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "permissions",
+ "mappedRoleNames"
+})
+public class DataPolicyMetadata implements DataPolicy, Serializable {
+ private static final long serialVersionUID = -4119646357275977190L;
+
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlElement(name = "description")
+ protected String description;
+ @XmlAttribute(name = "any-authenticated")
+ protected boolean anyAuthenticated;
+ @XmlAttribute(name = "allow-create-temporary-tables")
+ protected Boolean allowCreateTemporaryTables;
+
+ @XmlElement(name = "permission")
+ protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
+ private static final long serialVersionUID = -6992984146431492449L;
+ @Override
+ public String getKey(PermissionMetaData entry) {
+ return entry.getResourceName().toLowerCase();
+ }
+ });
+
+ @XmlElement(name = "mapped-role-name")
+ protected List<String> mappedRoleNames = new ArrayList<String>();
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String value) {
+ this.description = value;
+ }
+
+ @Override
+ public List<DataPermission> getPermissions() {
+ return new ArrayList<DataPermission>(this.permissions.getMap().values());
+ }
+
+ public void setPermissions(List<DataPermission> permissions) {
+ this.permissions.getMap().clear();
+ for (DataPermission permission:permissions) {
+ this.permissions.add((PermissionMetaData)permission);
+ }
+ }
+
+ public void addPermission(PermissionMetaData... permissions) {
+ for (PermissionMetaData permission:permissions) {
+ this.permissions.add(permission);
+ }
+ }
+
+ @Override
+ public List<String> getMappedRoleNames() {
+ return mappedRoleNames;
+ }
+
+ public void setMappedRoleNames(List<String> names) {
+ this.mappedRoleNames.clear();
+ this.mappedRoleNames.addAll(names);
+ }
+
+ public void addMappedRoleName(String name) {
+ this.mappedRoleNames.add(name);
+ }
+
+ public boolean allows(String resourceName, DataPolicy.PermissionType type) {
+ resourceName = resourceName.toLowerCase();
+ while (resourceName.length() > 0) {
+ PermissionMetaData p = this.permissions.getMap().get(resourceName);
+ if (p != null) {
+ Boolean allowed = p.allows(type);
+ if (allowed != null) {
+ return allowed;
+ }
+ }
+ resourceName = resourceName.substring(0, Math.max(0, resourceName.lastIndexOf('.')));
+ }
+ return false;
+ }
+
+
+ @XmlAccessorType(XmlAccessType.NONE)
+ @XmlType(name = "", propOrder = {
+ "resourceName",
+ "allowCreate",
+ "allowRead",
+ "allowUpdate",
+ "allowDelete",
+ "allowExecute",
+ "allowAlter"
+ })
+ public static class PermissionMetaData implements DataPermission, Serializable {
+ private static final long serialVersionUID = 7034744531663164277L;
+
+ // XML based fields
+ private String resourceName;
+ @XmlElement(name = "allow-create")
+ protected Boolean allowCreate;
+ @XmlElement(name = "allow-read")
+ protected Boolean allowRead;
+ @XmlElement(name = "allow-update")
+ protected Boolean allowUpdate;
+ @XmlElement(name = "allow-delete")
+ protected Boolean allowDelete;
+ @XmlElement(name = "allow-execute")
+ protected Boolean allowExecute;
+ @XmlElement(name = "allow-alter")
+ protected Boolean allowAlter;
+
+ @Override
+ @XmlElement(name = "resource-name", required = true)
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
+
+ @Override
+ public Boolean getAllowCreate() {
+ return allowCreate;
+ }
+
+ public void setAllowCreate(Boolean value) {
+ this.allowCreate = value;
+ }
+
+ @Override
+ public Boolean getAllowRead() {
+ return allowRead;
+ }
+
+ public void setAllowRead(Boolean value) {
+ this.allowRead = value;
+ }
+
+ @Override
+ public Boolean getAllowUpdate() {
+ return allowUpdate;
+ }
+
+ public void setAllowUpdate(Boolean value) {
+ this.allowUpdate = value;
+ }
+
+ @Override
+ public Boolean getAllowDelete() {
+ return allowDelete;
+ }
+
+ public void setAllowDelete(Boolean value) {
+ this.allowDelete = value;
+ }
+
+ public String getType() {
+ StringBuilder sb = new StringBuilder();
+ if (Boolean.TRUE.equals(getAllowCreate())) {
+ sb.append("C");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowRead())) {
+ sb.append("R");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowUpdate())) {
+ sb.append("U");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowDelete())) {
+ sb.append("D");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowExecute())) {
+ sb.append("E");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowAlter())) {
+ sb.append("A");//$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+
+ public Boolean allows(PermissionType type) {
+ switch (type) {
+ case ALTER:
+ return getAllowAlter();
+ case CREATE:
+ return getAllowCreate();
+ case EXECUTE:
+ if (getAllowExecute() != null) {
+ return getAllowExecute();
+ }
+ case READ:
+ return getAllowRead();
+ case UPDATE:
+ return getAllowUpdate();
+ case DELETE:
+ return getAllowDelete();
+ }
+ throw new AssertionError();
+ }
+
+ @Override
+ public Boolean getAllowAlter() {
+ return allowAlter;
+ }
+
+ @Override
+ public Boolean getAllowExecute() {
+ return allowExecute;
+ }
+
+ public void setAllowAlter(Boolean allowAlter) {
+ this.allowAlter = allowAlter;
+ }
+
+ public void setAllowExecute(Boolean allowExecute) {
+ this.allowExecute = allowExecute;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getResourceName());
+ sb.append("["); //$NON-NLS-1$
+ sb.append(getType());
+ sb.append("]");//$NON-NLS-1$
+ return sb.toString();
+ }
+ }
+
+ public Boolean isAllowCreateTemporaryTables() {
+ return allowCreateTemporaryTables;
+ }
+
+ public void setAllowCreateTemporaryTables(Boolean allowCreateTemporaryTables) {
+ this.allowCreateTemporaryTables = allowCreateTemporaryTables;
+ }
+
+ @Override
+ public boolean isAnyAuthenticated() {
+ return this.anyAuthenticated;
+ }
+
+ public void setAnyAuthenticated(boolean anyAuthenticated) {
+ this.anyAuthenticated = anyAuthenticated;
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.AbstractList;
+import java.util.LinkedHashMap;
+import java.util.Set;
+
+class ListOverMap<E> extends AbstractList<E> implements Serializable {
+
+ private static final long serialVersionUID = 5171741731121210240L;
+
+ protected LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
+ protected KeyBuilder<E> builder;
+
+ public ListOverMap(KeyBuilder<E> builder) {
+ this.builder = builder;
+ }
+
+ public LinkedHashMap<String, E> getMap() {
+ return map;
+ }
+
+ @Override
+ public void add(int index, E element) {
+ this.map.put(builder.getKey(element), element);
+ }
+
+ @Override
+ public E remove(int index) {
+ String key = getKey(index);
+ if (key == null) {
+ throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return this.map.remove(key);
+ }
+
+ @Override
+ public E get(int index) {
+ String key = getKey(index);
+ if (key == null) {
+ throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return this.map.get(key);
+ }
+
+ private String getKey(int index) {
+ Set<String> keys = this.map.keySet();
+ int i = 0;
+ for (String key:keys) {
+ if (i == index) {
+ return key;
+ }
+ i++;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.map.size();
+ }
+}
+
+interface KeyBuilder<E> extends Serializable {
+ String getKey(E entry);
+}
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,1071 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.teiid.adminapi.AdminPlugin;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.Request.ProcessingState;
+import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.VDB.Status;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+
+
+public class MetadataMapper {
+ private static final String VDBNAME = "vdb-name"; //$NON-NLS-1$
+ private static final String CONNECTIONTYPE = "connection-type"; //$NON-NLS-1$
+ private static final String STATUS = "status"; //$NON-NLS-1$
+ private static final String VERSION = "vdb-version"; //$NON-NLS-1$
+ private static final String URL = "url"; //$NON-NLS-1$
+ private static final String MODELS = "models"; //$NON-NLS-1$
+ private static final String OVERRIDE_TRANSLATORS = "override-translators"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String DYNAMIC = "dynamic"; //$NON-NLS-1$
+ private static final String DATA_POLICIES = "data-policies"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(VDBMetaData vdb, ModelNode node) {
+ if (vdb == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(VDBNAME).set(vdb.getName());
+ node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
+ node.get(STATUS).set(vdb.getStatus().toString());
+ node.get(VERSION).set(vdb.getVersion());
+ if (vdb.getUrl() != null) {
+ }
+ if (vdb.getDescription() != null) {
+ node.get(DESCRIPTION).set(vdb.getDescription());
+ }
+ node.get(DYNAMIC).set(vdb.isDynamic());
+
+ //PROPERTIES
+ List<PropertyMetadata> properties = vdb.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
+ }
+ }
+
+ // MODELS
+ Map<String, ModelMetaData> models = vdb.getModelMetaDatas();
+ if (models != null && !models.isEmpty()) {
+ ModelNode modelNodes = node.get(CHILDREN, MODELS);
+ for(ModelMetaData model:models.values()) {
+ modelNodes.add(ModelMetadataMapper.wrap(model, new ModelNode()));
+ }
+ }
+
+ // OVERRIDE_TRANSLATORS
+ List<Translator> translators = vdb.getOverrideTranslators();
+ if (translators != null && !translators.isEmpty()) {
+ ModelNode translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
+ for (Translator translator:translators) {
+ translatorNodes.add(VDBTranslatorMetaDataMapper.wrap((VDBTranslatorMetaData)translator, new ModelNode()));
+ }
+ }
+
+ // DATA_POLICIES
+ List<DataPolicy> policies = vdb.getDataPolicies();
+ if (policies != null && !policies.isEmpty()) {
+ ModelNode dataPoliciesNodes = node.get(CHILDREN, DATA_POLICIES);
+ for (DataPolicy policy:policies) {
+ dataPoliciesNodes.add(DataPolicyMetadataMapper.wrap((DataPolicyMetadata)policy, new ModelNode()));
+ }
+ }
+ return node;
+ }
+
+ public static VDBMetaData unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ VDBMetaData vdb = new VDBMetaData();
+ if (node.has(VDBNAME)) {
+ vdb.setName(node.get(VDBNAME).asString());
+ }
+ if (node.has(CONNECTIONTYPE)) {
+ vdb.setConnectionType(node.get(CONNECTIONTYPE).asString());
+ }
+ if (node.has(STATUS)) {
+ vdb.setStatus(node.get(STATUS).asString());
+ }
+ if (node.has(VERSION)) {
+ vdb.setVersion(node.get(VERSION).asInt());
+ }
+ if (node.has(URL)) {
+ vdb.setUrl(node.get(URL).asString());
+ }
+ if(node.has(DESCRIPTION)) {
+ vdb.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(DYNAMIC)) {
+ vdb.setDynamic(node.get(DYNAMIC).asBoolean());
+ }
+
+ //PROPERTIES
+ if (node.get(CHILDREN, PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ vdb.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ // MODELS
+ if (node.get(CHILDREN, MODELS).isDefined()) {
+ List<ModelNode> modelNodes = node.get(CHILDREN, MODELS).asList();
+ for(ModelNode modelNode:modelNodes) {
+ ModelMetaData model = ModelMetadataMapper.unwrap(modelNode);
+ if (model != null) {
+ vdb.addModel(model);
+ }
+ }
+ }
+
+ // OVERRIDE_TRANSLATORS
+ if (node.get(CHILDREN, OVERRIDE_TRANSLATORS).isDefined()) {
+ List<ModelNode> translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS).asList();
+ for (ModelNode translatorNode:translatorNodes) {
+ VDBTranslatorMetaData translator = VDBTranslatorMetaDataMapper.unwrap(translatorNode);
+ if (translator != null) {
+ vdb.addOverideTranslator(translator);
+ }
+ }
+ }
+
+ // DATA_POLICIES
+ if (node.get(CHILDREN, DATA_POLICIES).isDefined()) {
+ List<ModelNode> policiesNodes = node.get(CHILDREN, DATA_POLICIES).asList();
+ for (ModelNode policyNode:policiesNodes) {
+ DataPolicyMetadata policy = DataPolicyMetadataMapper.unwrap(policyNode);
+ if (policy != null) {
+ vdb.addDataPolicy(policy);
+ }
+
+ }
+ }
+ return vdb;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, VDBNAME, ModelType.STRING, true);
+
+ ModelNode connectionsAllowed = new ModelNode();
+ connectionsAllowed.add(ConnectionType.NONE.toString());
+ connectionsAllowed.add(ConnectionType.ANY.toString());
+ connectionsAllowed.add(ConnectionType.BY_VERSION.toString());
+ addAttribute(node, CONNECTIONTYPE, ModelType.STRING, false).get(ALLOWED).set(connectionsAllowed);
+
+ ModelNode statusAllowed = new ModelNode();
+ statusAllowed.add(Status.ACTIVE.toString());
+ statusAllowed.add(Status.INACTIVE.toString());
+ addAttribute(node, STATUS, ModelType.STRING, true).get(ALLOWED).set(statusAllowed);
+
+ addAttribute(node, VERSION, ModelType.INT, true);
+ addAttribute(node, URL, ModelType.STRING, false);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+
+ ModelNode models = node.get(CHILDREN, MODELS);
+ ModelMetadataMapper.describe(models);
+ models.get(DESCRIPTION).set(AdminPlugin.Util.getString(MODELS+DOT_DESC));
+ models.get(MIN_OCCURS).set(1);
+
+ ModelNode translators = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
+ translators.get(DESCRIPTION).set(AdminPlugin.Util.getString(OVERRIDE_TRANSLATORS+DOT_DESC));
+ VDBTranslatorMetaDataMapper.describe(translators);
+
+ ModelNode dataPolicies = node.get(CHILDREN, DATA_POLICIES);
+ dataPolicies.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_POLICIES+DOT_DESC));
+ DataPolicyMetadataMapper.describe(dataPolicies);
+ return node;
+ }
+
+ /**
+ * model metadata mapper
+ */
+ public static class ModelMetadataMapper {
+ private static final String MODEL_NAME = "model-name"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String VISIBLE = "visible"; //$NON-NLS-1$
+ private static final String MODEL_TYPE = "model-type"; //$NON-NLS-1$
+ private static final String MODELPATH = "model-path"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String SOURCE_MAPPINGS = "source-mappings"; //$NON-NLS-1$
+ private static final String VALIDITY_ERRORS = "validity-errors"; //$NON-NLS-1$
+
+ public static ModelNode wrap(ModelMetaData model, ModelNode node) {
+ if (model == null) {
+ return null;
+ }
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(MODEL_NAME).set(model.getName());
+ if (model.getDescription() != null) {
+ node.get(DESCRIPTION).set(model.getDescription());
+ }
+ node.get(VISIBLE).set(model.isVisible());
+ node.get(MODEL_TYPE).set(model.getModelType().toString());
+ if (model.getPath() != null) {
+ node.get(MODELPATH).set(model.getPath());
+ }
+
+ List<PropertyMetadata> properties = model.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
+ }
+ }
+
+ List<SourceMappingMetadata> sources = model.getSourceMappings();
+ if (sources != null && !sources.isEmpty()) {
+ ModelNode sourceMappingNode = node.get(CHILDREN, SOURCE_MAPPINGS);
+ for(SourceMappingMetadata source:sources) {
+ sourceMappingNode.add(SourceMappingMetadataMapper.wrap(source, new ModelNode()));
+ }
+ }
+
+ List<ValidationError> errors = model.getErrors();
+ if (errors != null && !errors.isEmpty()) {
+ ModelNode errorsNode = node.get(CHILDREN, VALIDITY_ERRORS);
+ for (ValidationError error:errors) {
+ errorsNode.add(ValidationErrorMapper.wrap(error));
+ }
+ }
+ return node;
+ }
+
+ public static ModelMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ ModelMetaData model = new ModelMetaData();
+ if (node.has(MODEL_NAME)) {
+ model.setName(node.get(MODEL_NAME).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ model.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(VISIBLE)) {
+ model.setVisible(node.get(VISIBLE).asBoolean());
+ }
+ if(node.has(MODEL_TYPE)) {
+ model.setModelType(node.get(MODEL_TYPE).asString());
+ }
+ if(node.has(MODELPATH)) {
+ model.setPath(node.get(MODELPATH).asString());
+ }
+
+ if (node.get(CHILDREN, PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ model.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ if (node.get(CHILDREN, SOURCE_MAPPINGS).isDefined()) {
+ List<ModelNode> sourceMappingNodes = node.get(CHILDREN, SOURCE_MAPPINGS).asList();
+ for (ModelNode sourceMapping:sourceMappingNodes) {
+ SourceMappingMetadata source = SourceMappingMetadataMapper.unwrap(sourceMapping);
+ if (source != null) {
+ model.addSourceMapping(source);
+ }
+ }
+ }
+
+ if (node.get(CHILDREN, VALIDITY_ERRORS).isDefined()) {
+ List<ModelNode> errorNodes = node.get(CHILDREN, VALIDITY_ERRORS).asList();
+ for(ModelNode errorNode:errorNodes) {
+ ValidationError error = ValidationErrorMapper.unwrap(errorNode);
+ if (error != null) {
+ model.addError(error);
+ }
+ }
+ }
+ return model;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ ModelNode modelTypes = new ModelNode();
+ modelTypes.add(Model.Type.PHYSICAL.toString());
+ modelTypes.add(Model.Type.VIRTUAL.toString());
+ modelTypes.add(Model.Type.FUNCTION.toString());
+ modelTypes.add(Model.Type.OTHER.toString());
+ addAttribute(node, MODEL_NAME, ModelType.STRING, true).get(ALLOWED).set(modelTypes);
+
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, VISIBLE, ModelType.BOOLEAN, false);
+ addAttribute(node, MODEL_TYPE, ModelType.STRING, true);
+ addAttribute(node, MODELPATH, ModelType.STRING, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+
+ ModelNode source = node.get(CHILDREN, SOURCE_MAPPINGS);
+ source.get(DESCRIPTION).set(AdminPlugin.Util.getString(SOURCE_MAPPINGS+DOT_DESC));
+ SourceMappingMetadataMapper.describe(source);
+
+ ModelNode errors = node.get(CHILDREN, VALIDITY_ERRORS);
+ errors.get(DESCRIPTION).set(AdminPlugin.Util.getString(VALIDITY_ERRORS+DOT_DESC));
+ ValidationErrorMapper.describe(errors);
+
+ return node;
+ }
+ }
+
+ /**
+ * validation error mapper
+ */
+ public static class ValidationErrorMapper {
+ private static final String ERROR_PATH = "error-path"; //$NON-NLS-1$
+ private static final String SEVERITY = "severity"; //$NON-NLS-1$
+ private static final String MESSAGE = "message"; //$NON-NLS-1$
+
+ public static ModelNode wrap(ValidationError error) {
+ if (error == null) {
+ return null;
+ }
+
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+ if (error.getPath() != null) {
+ node.get(ERROR_PATH).set(error.getPath());
+ }
+ node.get(SEVERITY).set(error.getSeverity());
+ node.get(MESSAGE).set(error.getValue());
+
+ return node;
+ }
+
+ public static ValidationError unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ ValidationError error = new ValidationError();
+ if (node.has(ERROR_PATH)) {
+ error.setPath(node.get(ERROR_PATH).asString());
+ }
+ if (node.has(SEVERITY)) {
+ error.setSeverity(node.get(SEVERITY).asString());
+ }
+ if(node.has(MESSAGE)) {
+ error.setValue(node.get(MESSAGE).asString());
+ }
+ return error;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ERROR_PATH, ModelType.STRING, false);
+ addAttribute(node, SEVERITY, ModelType.STRING, true);
+ addAttribute(node, MESSAGE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * Source Mapping Metadata mapper
+ */
+ public static class SourceMappingMetadataMapper {
+ private static final String SOURCE_NAME = "source-name"; //$NON-NLS-1$
+ private static final String JNDI_NAME = "jndi-name"; //$NON-NLS-1$
+ private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
+
+ public static ModelNode wrap(SourceMappingMetadata source, ModelNode node) {
+ if (source == null) {
+ return null;
+ }
+
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(SOURCE_NAME).set(source.getName());
+ node.get(JNDI_NAME).set(source.getConnectionJndiName());
+ node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
+ return node;
+ }
+
+ public static SourceMappingMetadata unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ SourceMappingMetadata source = new SourceMappingMetadata();
+ if (node.has(SOURCE_NAME)) {
+ source.setName(node.get(SOURCE_NAME).asString());
+ }
+ if (node.has(JNDI_NAME)) {
+ source.setConnectionJndiName(node.get(JNDI_NAME).asString());
+ }
+ if (node.has(TRANSLATOR_NAME)) {
+ source.setTranslatorName(node.get(TRANSLATOR_NAME).asString());
+ }
+ return source;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, SOURCE_NAME, ModelType.STRING, true);
+ addAttribute(node, JNDI_NAME, ModelType.STRING, true);
+ addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * Source Mapping Metadata mapper
+ */
+ public static class VDBTranslatorMetaDataMapper {
+ private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
+ private static final String BASETYPE = "base-type"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String MODULE_NAME = "module-name"; //$NON-NLS-1$
+
+ public static ModelNode wrap(VDBTranslatorMetaData translator, ModelNode node) {
+ if (translator == null) {
+ return null;
+ }
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(TRANSLATOR_NAME).set(translator.getName());
+ if (translator.getType() != null) {
+ node.get(BASETYPE).set(translator.getType());
+ }
+ if (translator.getDescription() != null) {
+ node.get(DESCRIPTION).set(translator.getDescription());
+ }
+
+ if (translator.getModuleName() != null) {
+ node.get(MODULE_NAME).set(translator.getModuleName());
+ }
+
+ List<PropertyMetadata> properties = translator.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
+ }
+ }
+ return node;
+ }
+
+ public static VDBTranslatorMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ if (node.has(TRANSLATOR_NAME)) {
+ translator.setName(node.get(TRANSLATOR_NAME).asString());
+ }
+ if (node.has(BASETYPE)) {
+ translator.setType(node.get(BASETYPE).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ translator.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(MODULE_NAME)) {
+ translator.setModuleName(node.get(MODULE_NAME).asString());
+ }
+
+ if (node.get(CHILDREN,PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ translator.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+ return translator;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
+ addAttribute(node, BASETYPE, ModelType.STRING, true);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, MODULE_NAME, ModelType.STRING, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+ return node;
+ }
+ }
+
+ /**
+ * Property Metadata mapper
+ */
+ public static class PropertyMetaDataMapper {
+ private static final String PROPERTY_NAME = "property-name"; //$NON-NLS-1$
+ private static final String PROPERTY_VALUE = "property-value"; //$NON-NLS-1$
+
+ public static ModelNode wrap(PropertyMetadata property, ModelNode node) {
+ if (property == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(PROPERTY_NAME).set(property.getName());
+ node.get(PROPERTY_VALUE).set(property.getValue());
+
+ return node;
+ }
+
+ public static PropertyMetadata unwrap(ModelNode node) {
+ if(node == null) {
+ return null;
+ }
+ PropertyMetadata property = new PropertyMetadata();
+ if (node.has(PROPERTY_NAME)) {
+ property.setName(node.get(PROPERTY_NAME).asString());
+ }
+ if(node.has(PROPERTY_VALUE)) {
+ property.setValue(node.get(PROPERTY_VALUE).asString());
+ }
+ return property;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, PROPERTY_NAME, ModelType.STRING, true);
+ addAttribute(node, PROPERTY_VALUE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * DataPolicy Metadata mapper
+ */
+ public static class DataPolicyMetadataMapper {
+ private static final String POLICY_NAME = "policy-name"; //$NON-NLS-1$
+ private static final String DATA_PERMISSIONS = "data-permissions"; //$NON-NLS-1$
+ private static final String MAPPED_ROLE_NAMES = "mapped-role-names"; //$NON-NLS-1$
+ private static final String ALLOW_CREATE_TEMP_TABLES = "allow-create-temp-tables"; //$NON-NLS-1$
+ private static final String ANY_AUTHENTICATED = "any-authenticated"; //$NON-NLS-1$
+
+ public static ModelNode wrap(DataPolicyMetadata policy, ModelNode node) {
+ if (policy == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(POLICY_NAME).set(policy.getName());
+ if (policy.getDescription() != null) {
+ node.get(DESCRIPTION).set(policy.getDescription());
+ }
+ if (policy.isAllowCreateTemporaryTables() != null) {
+ node.get(ALLOW_CREATE_TEMP_TABLES).set(policy.isAllowCreateTemporaryTables());
+ }
+ node.get(ANY_AUTHENTICATED).set(policy.isAnyAuthenticated());
+
+ //DATA_PERMISSIONS
+ List<DataPolicy.DataPermission> permissions = policy.getPermissions();
+ if (permissions != null && !permissions.isEmpty()) {
+ ModelNode permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS);
+ for (DataPolicy.DataPermission dataPermission:permissions) {
+ permissionNodes.add(PermissionMetaDataMapper.wrap((PermissionMetaData)dataPermission, new ModelNode()));
+ }
+ }
+
+ //MAPPED_ROLE_NAMES
+ if (policy.getMappedRoleNames() != null && !policy.getMappedRoleNames().isEmpty()) {
+ ModelNode mappedRoleNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES);
+ for (String role:policy.getMappedRoleNames()) {
+ mappedRoleNodes.add(role);
+ }
+ }
+ return node;
+ }
+
+ public static DataPolicyMetadata unwrap(ModelNode node) {
+ if(node == null) {
+ return null;
+ }
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ if (node.has(POLICY_NAME)) {
+ policy.setName(node.get(POLICY_NAME).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ policy.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(ALLOW_CREATE_TEMP_TABLES)) {
+ policy.setAllowCreateTemporaryTables(node.get(ALLOW_CREATE_TEMP_TABLES).asBoolean());
+ }
+ if (node.has(ANY_AUTHENTICATED)) {
+ policy.setAnyAuthenticated(node.get(ANY_AUTHENTICATED).asBoolean());
+ }
+
+ //DATA_PERMISSIONS
+ if (node.get(CHILDREN, DATA_PERMISSIONS).isDefined()) {
+ List<ModelNode> permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS).asList();
+ for (ModelNode permissionNode:permissionNodes) {
+ PermissionMetaData permission = PermissionMetaDataMapper.unwrap(permissionNode);
+ if (permission != null) {
+ policy.addPermission(permission);
+ }
+ }
+ }
+
+ //MAPPED_ROLE_NAMES
+ if (node.get(CHILDREN, MAPPED_ROLE_NAMES).isDefined()) {
+ List<ModelNode> roleNameNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES).asList();
+ for (ModelNode roleNameNode:roleNameNodes) {
+ policy.addMappedRoleName(roleNameNode.asString());
+ }
+ }
+ return policy;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, POLICY_NAME, ModelType.STRING, true);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, ALLOW_CREATE_TEMP_TABLES, ModelType.BOOLEAN, false);
+ addAttribute(node, ANY_AUTHENTICATED, ModelType.BOOLEAN, false);
+
+ ModelNode permissions = node.get(CHILDREN, DATA_PERMISSIONS);
+ PropertyMetaDataMapper.describe(permissions);
+ permissions.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_PERMISSIONS+DOT_DESC));
+ permissions.get(MIN_OCCURS).set(1);
+
+ ModelNode roleNames = node.get(CHILDREN, MAPPED_ROLE_NAMES);
+ roleNames.get(TYPE).set(ModelType.LIST);
+ roleNames.get(DESCRIPTION).set(AdminPlugin.Util.getString(MAPPED_ROLE_NAMES+DOT_DESC));
+ roleNames.get("value-type").set(ModelType.STRING); //$NON-NLS-1$
+ return node;
+ }
+ }
+
+ public static class PermissionMetaDataMapper{
+ private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
+ private static final String ALLOW_CREATE = "allow-create"; //$NON-NLS-1$
+ private static final String ALLOW_DELETE = "allow-delete"; //$NON-NLS-1$
+ private static final String ALLOW_UPADTE = "allow-update"; //$NON-NLS-1$
+ private static final String ALLOW_READ = "allow-read"; //$NON-NLS-1$
+ private static final String ALLOW_EXECUTE = "allow-execute"; //$NON-NLS-1$
+ private static final String ALLOW_ALTER = "allow-alter"; //$NON-NLS-1$
+
+
+
+ public static ModelNode wrap(PermissionMetaData permission, ModelNode node) {
+ if (permission == null) {
+ return null;
+ }
+
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(RESOURCE_NAME).set(permission.getResourceName());
+ if (permission.getAllowCreate() != null) {
+ node.get(ALLOW_CREATE).set(permission.getAllowCreate().booleanValue());
+ }
+ if (permission.getAllowDelete() != null) {
+ node.get(ALLOW_DELETE).set(permission.getAllowDelete().booleanValue());
+ }
+ if (permission.getAllowUpdate() != null) {
+ node.get(ALLOW_UPADTE).set(permission.getAllowUpdate().booleanValue());
+ }
+ if (permission.getAllowRead() != null) {
+ node.get(ALLOW_READ).set(permission.getAllowRead().booleanValue());
+ }
+ if (permission.getAllowExecute() != null) {
+ node.get(ALLOW_EXECUTE).set(permission.getAllowExecute().booleanValue());
+ }
+ if(permission.getAllowAlter() != null) {
+ node.get(ALLOW_ALTER).set(permission.getAllowAlter().booleanValue());
+ }
+ return node;
+ }
+
+ public static PermissionMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ PermissionMetaData permission = new PermissionMetaData();
+ if (node.get(RESOURCE_NAME) != null) {
+ permission.setResourceName(node.get(RESOURCE_NAME).asString());
+ }
+ if (node.has(ALLOW_CREATE)) {
+ permission.setAllowCreate(node.get(ALLOW_CREATE).asBoolean());
+ }
+ if (node.has(ALLOW_DELETE)) {
+ permission.setAllowDelete(node.get(ALLOW_DELETE).asBoolean());
+ }
+ if (node.has(ALLOW_UPADTE)) {
+ permission.setAllowUpdate(node.get(ALLOW_UPADTE).asBoolean());
+ }
+ if (node.has(ALLOW_READ)) {
+ permission.setAllowRead(node.get(ALLOW_READ).asBoolean());
+ }
+ if (node.has(ALLOW_EXECUTE)) {
+ permission.setAllowExecute(node.get(ALLOW_EXECUTE).asBoolean());
+ }
+ if (node.has(ALLOW_ALTER)) {
+ permission.setAllowAlter(node.get(ALLOW_ALTER).asBoolean());
+ }
+ return permission;
+ }
+ public static ModelNode describe(ModelNode node) {
+ addAttribute(node, RESOURCE_NAME, ModelType.STRING, true);
+ addAttribute(node, ALLOW_CREATE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_DELETE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_UPADTE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_READ, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_EXECUTE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_ALTER, ModelType.BOOLEAN, false);
+ return node;
+ }
+ }
+
+ public static class CacheStatisticsMetadataMapper {
+ private static final String HITRATIO = "hit-ratio"; //$NON-NLS-1$
+ private static final String TOTAL_ENTRIES = "total-entries"; //$NON-NLS-1$
+ private static final String REQUEST_COUNT = "request-count"; //$NON-NLS-1$
+
+ public static ModelNode wrap(CacheStatisticsMetadata object, ModelNode node) {
+ if (object == null)
+ return null;
+
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(TOTAL_ENTRIES).set(object.getTotalEntries());
+ node.get(HITRATIO).set(object.getHitRatio());
+ node.get(REQUEST_COUNT).set(object.getRequestCount());
+
+ return node;
+ }
+
+ public static CacheStatisticsMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
+ cache.setTotalEntries(node.get(TOTAL_ENTRIES).asInt());
+ cache.setHitRatio(node.get(HITRATIO).asDouble());
+ cache.setRequestCount(node.get(REQUEST_COUNT).asInt());
+ return cache;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, TOTAL_ENTRIES, ModelType.STRING, true);
+ addAttribute(node, HITRATIO, ModelType.STRING, true);
+ addAttribute(node, REQUEST_COUNT, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class RequestMetadataMapper {
+ private static final String TRANSACTION_ID = "transaction-id"; //$NON-NLS-1$
+ private static final String NODE_ID = "node-id"; //$NON-NLS-1$
+ private static final String SOURCE_REQUEST = "source-request"; //$NON-NLS-1$
+ private static final String COMMAND = "command"; //$NON-NLS-1$
+ private static final String START_TIME = "start-time"; //$NON-NLS-1$
+ private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
+ private static final String EXECUTION_ID = "execution-id"; //$NON-NLS-1$
+ private static final String STATE = "processing-state"; //$NON-NLS-1$
+ private static final String THREAD_STATE = "thread-state"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(RequestMetadata request, ModelNode node) {
+ if (request == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(EXECUTION_ID).set(request.getExecutionId());
+ node.get(SESSION_ID).set(request.getSessionId());
+ node.get(START_TIME).set(request.getStartTime());
+ node.get(COMMAND).set(request.getCommand());
+ node.get(SOURCE_REQUEST).set(request.sourceRequest());
+ if (request.getNodeId() != null) {
+ node.get(NODE_ID).set(request.getNodeId());
+ }
+ if (request.getTransactionId() != null) {
+ node.get(TRANSACTION_ID).set(request.getTransactionId());
+ }
+ node.get(STATE).set(request.getState().name());
+ node.get(THREAD_STATE).set(request.getThreadState().name());
+ return node;
+ }
+
+ public static RequestMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ RequestMetadata request = new RequestMetadata();
+ request.setExecutionId(node.get(EXECUTION_ID).asLong());
+ request.setSessionId(node.get(SESSION_ID).asString());
+ request.setStartTime(node.get(START_TIME).asLong());
+ request.setCommand(node.get(COMMAND).asString());
+ request.setSourceRequest(node.get(SOURCE_REQUEST).asBoolean());
+ if (node.has(NODE_ID)) {
+ request.setNodeId(node.get(NODE_ID).asInt());
+ }
+ if (node.has(TRANSACTION_ID)) {
+ request.setTransactionId(node.get(TRANSACTION_ID).asString());
+ }
+ request.setState(ProcessingState.valueOf(node.get(STATE).asString()));
+ request.setThreadState(ThreadState.valueOf(node.get(THREAD_STATE).asString()));
+ return request;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, EXECUTION_ID, ModelType.LONG, true);
+ addAttribute(node, SESSION_ID, ModelType.STRING, true);
+ addAttribute(node, START_TIME, ModelType.LONG, true);
+ addAttribute(node, COMMAND, ModelType.STRING, true);
+ addAttribute(node, SOURCE_REQUEST, ModelType.BOOLEAN, true);
+ addAttribute(node, NODE_ID, ModelType.INT, false);
+ addAttribute(node, TRANSACTION_ID, ModelType.STRING, false);
+ addAttribute(node, STATE, ModelType.STRING, true);
+ addAttribute(node, THREAD_STATE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class SessionMetadataMapper {
+ private static final String SECURITY_DOMAIN = "security-domain"; //$NON-NLS-1$
+ private static final String VDB_VERSION = "vdb-version"; //$NON-NLS-1$
+ private static final String VDB_NAME = "vdb-name"; //$NON-NLS-1$
+ private static final String USER_NAME = "user-name"; //$NON-NLS-1$
+ private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
+ private static final String LAST_PING_TIME = "last-ping-time"; //$NON-NLS-1$
+ private static final String IP_ADDRESS = "ip-address"; //$NON-NLS-1$
+ private static final String CLIENT_HOST_NAME = "client-host-address"; //$NON-NLS-1$
+ private static final String CREATED_TIME = "created-time"; //$NON-NLS-1$
+ private static final String APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+ private static final String CLIENT_HARDWARE_ADRESS = "client-hardware-address"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(SessionMetadata session, ModelNode node) {
+ if (session == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ if (session.getApplicationName() != null) {
+ node.get(APPLICATION_NAME).set(session.getApplicationName());
+ }
+ node.get(CREATED_TIME).set(session.getCreatedTime());
+ node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
+ node.get(IP_ADDRESS).set(session.getIPAddress());
+ node.get(LAST_PING_TIME).set(session.getLastPingTime());
+ node.get(SESSION_ID).set(session.getSessionId());
+ node.get(USER_NAME).set(session.getUserName());
+ node.get(VDB_NAME).set(session.getVDBName());
+ node.get(VDB_VERSION).set(session.getVDBVersion());
+ if (session.getSecurityDomain() != null){
+ node.get(SECURITY_DOMAIN).set(session.getSecurityDomain());
+ }
+ if (session.getClientHardwareAddress() != null) {
+ node.get(CLIENT_HARDWARE_ADRESS).set(session.getClientHardwareAddress());
+ }
+ return node;
+ }
+
+ public static SessionMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ SessionMetadata session = new SessionMetadata();
+ if (node.has(APPLICATION_NAME)) {
+ session.setApplicationName(node.get(APPLICATION_NAME).asString());
+ }
+ session.setCreatedTime(node.get(CREATED_TIME).asLong());
+ session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
+ session.setIPAddress(node.get(IP_ADDRESS).asString());
+ session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
+ session.setSessionId(node.get(SESSION_ID).asString());
+ session.setUserName(node.get(USER_NAME).asString());
+ session.setVDBName(node.get(VDB_NAME).asString());
+ session.setVDBVersion(node.get(VDB_VERSION).asInt());
+ if (node.has(SECURITY_DOMAIN)) {
+ session.setSecurityDomain(node.get(SECURITY_DOMAIN).asString());
+ }
+ if (node.has(CLIENT_HARDWARE_ADRESS)) {
+ session.setClientHardwareAddress(node.get(CLIENT_HARDWARE_ADRESS).asString());
+ }
+ return session;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, APPLICATION_NAME, ModelType.STRING, false);
+ addAttribute(node, CREATED_TIME, ModelType.LONG, true);
+ addAttribute(node, CLIENT_HOST_NAME, ModelType.LONG, true);
+ addAttribute(node, IP_ADDRESS, ModelType.STRING, true);
+ addAttribute(node, LAST_PING_TIME, ModelType.LONG, true);
+ addAttribute(node, SESSION_ID, ModelType.STRING, true);
+ addAttribute(node, USER_NAME, ModelType.STRING, true);
+ addAttribute(node, VDB_NAME, ModelType.STRING, true);
+ addAttribute(node, VDB_VERSION, ModelType.INT, true);
+ addAttribute(node, SECURITY_DOMAIN, ModelType.STRING, false);
+ return node;
+ }
+ }
+
+ public static class TransactionMetadataMapper {
+ private static final String ID = "txn-id"; //$NON-NLS-1$
+ private static final String SCOPE = "txn-scope"; //$NON-NLS-1$
+ private static final String CREATED_TIME = "txn-created-time"; //$NON-NLS-1$
+ private static final String ASSOCIATED_SESSION = "session-id"; //$NON-NLS-1$
+
+ public static ModelNode wrap(TransactionMetadata object, ModelNode transaction) {
+ if (object == null)
+ return null;
+
+ transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+ transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
+ transaction.get(CREATED_TIME).set(object.getCreatedTime());
+ transaction.get(SCOPE).set(object.getScope());
+ transaction.get(ID).set(object.getId());
+
+ return transaction;
+ }
+
+ public static TransactionMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ TransactionMetadata transaction = new TransactionMetadata();
+ transaction.setAssociatedSession(node.get(ASSOCIATED_SESSION).asString());
+ transaction.setCreatedTime(node.get(CREATED_TIME).asLong());
+ transaction.setScope(node.get(SCOPE).asString());
+ transaction.setId(node.get(ID).asString());
+ return transaction;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ASSOCIATED_SESSION, ModelType.STRING, true);
+ addAttribute(node, CREATED_TIME, ModelType.LONG, true);
+ addAttribute(node, SCOPE, ModelType.LONG, true);
+ addAttribute(node, ID, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class WorkerPoolStatisticsMetadataMapper {
+ private static final String MAX_THREADS = "max-threads"; //$NON-NLS-1$
+ private static final String HIGHEST_QUEUED = "highest-queued"; //$NON-NLS-1$
+ private static final String QUEUED = "queued"; //$NON-NLS-1$
+ private static final String QUEUE_NAME = "queue-name"; //$NON-NLS-1$
+ private static final String TOTAL_SUBMITTED = "total-submitted"; //$NON-NLS-1$
+ private static final String TOTAL_COMPLETED = "total-completed"; //$NON-NLS-1$
+ private static final String HIGHEST_ACTIVE_THREADS = "highest-active-threads"; //$NON-NLS-1$
+ private static final String ACTIVE_THREADS = "active-threads"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(WorkerPoolStatisticsMetadata stats, ModelNode node) {
+ if (stats == null)
+ return null;
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(ACTIVE_THREADS).set(stats.getActiveThreads());
+ node.get(HIGHEST_ACTIVE_THREADS).set(stats.getHighestActiveThreads());
+ node.get(TOTAL_COMPLETED).set(stats.getTotalCompleted());
+ node.get(TOTAL_SUBMITTED).set(stats.getTotalSubmitted());
+ node.get(QUEUE_NAME).set(stats.getQueueName());
+ node.get(QUEUED).set(stats.getQueued());
+ node.get(HIGHEST_QUEUED).set(stats.getHighestQueued());
+ node.get(MAX_THREADS).set(stats.getMaxThreads());
+
+ return node;
+ }
+
+ public static WorkerPoolStatisticsMetadata unwrapMetaValue(ModelNode node) {
+ if (node == null)
+ return null;
+
+ WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+ stats.setActiveThreads(node.get(ACTIVE_THREADS).asInt());
+ stats.setHighestActiveThreads(node.get(HIGHEST_ACTIVE_THREADS).asInt());
+ stats.setTotalCompleted(node.get(TOTAL_COMPLETED).asLong());
+ stats.setTotalSubmitted(node.get(TOTAL_SUBMITTED).asLong());
+ stats.setQueueName(node.get(QUEUE_NAME).asString());
+ stats.setQueued(node.get(QUEUED).asInt());
+ stats.setHighestQueued(node.get(HIGHEST_QUEUED).asInt());
+ stats.setMaxThreads(node.get(MAX_THREADS).asInt());
+ return stats;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ACTIVE_THREADS, ModelType.INT, true);
+ addAttribute(node, HIGHEST_ACTIVE_THREADS, ModelType.INT, true);
+ addAttribute(node, TOTAL_COMPLETED, ModelType.LONG, true);
+ addAttribute(node, TOTAL_SUBMITTED, ModelType.LONG, true);
+ addAttribute(node, QUEUE_NAME, ModelType.STRING, true);
+ addAttribute(node, QUEUED, ModelType.INT, true);
+ addAttribute(node, HIGHEST_QUEUED, ModelType.INT, true);
+ addAttribute(node, MAX_THREADS, ModelType.INT, true);
+ return node;
+ }
+ }
+
+ private static final String CHILDREN = "children"; //$NON-NLS-1$
+ private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ private static final String DOT_DESC = ".describe"; //$NON-NLS-1$
+ private static final String TYPE = "type"; //$NON-NLS-1$
+ private static final String MIN_OCCURS = "min-occurs"; //$NON-NLS-1$
+ private static final String REQUIRED = "required"; //$NON-NLS-1$
+ private static final String ALLOWED = "allowed"; //$NON-NLS-1$
+ static ModelNode addAttribute(ModelNode node, String name, ModelType dataType, boolean required) {
+ node.get(ATTRIBUTES, name, TYPE).set(dataType);
+ node.get(ATTRIBUTES, name, DESCRIPTION).set(AdminPlugin.Util.getString(name+DOT_DESC));
+ node.get(ATTRIBUTES, name, REQUIRED).set(required);
+ return node;
+ }
+}
+
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,321 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.bind.annotation.*;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "JAXBProperties",
+ "sources",
+ "errors"
+})
+public class ModelMetaData extends AdminObjectImpl implements Model {
+
+ private static final int DEFAULT_ERROR_HISTORY = 10;
+ private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY = "supports-multi-source-bindings"; //$NON-NLS-1$
+ private static final long serialVersionUID = 3714234763056162230L;
+
+ @XmlElement(name = "source")
+ protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
+ private static final long serialVersionUID = 2273673984691112369L;
+
+ @Override
+ public String getKey(SourceMappingMetadata entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlAttribute(name = "type")
+ protected String modelType = Type.PHYSICAL.name();
+
+ @XmlElement(name = "description")
+ protected String description;
+
+ @XmlAttribute(name = "path")
+ protected String path;
+
+ @XmlAttribute(name = "visible")
+ protected Boolean visible = true;
+
+ @XmlElement(name = "validation-error")
+ protected List<ValidationError> errors;
+
+ @XmlAttribute(name = "name", required = true)
+ public String getName() {
+ return super.getName();
+ }
+
+ // This is needed by JAXB
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public boolean isSource() {
+ return getModelType() == Model.Type.PHYSICAL;
+ }
+
+ @Override
+ public boolean isVisible() {
+ return this.visible;
+ }
+
+ @Override
+ public Type getModelType() {
+ try {
+ return Type.valueOf(modelType.toUpperCase());
+ } catch(IllegalArgumentException e) {
+ return Type.OTHER;
+ }
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public boolean isSupportsMultiSourceBindings() {
+ String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
+ return Boolean.parseBoolean(supports);
+ }
+
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
+ public void setSupportsMultiSourceBindings(boolean supports) {
+ addProperty(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY, Boolean.toString(supports));
+ }
+
+ public void setModelType(Model.Type modelType) {
+ this.modelType = modelType.name();
+ }
+
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ public String toString() {
+ return getName() + this.sources;
+ }
+
+ public void setVisible(Boolean value) {
+ this.visible = value;
+ }
+
+ public List<SourceMappingMetadata> getSourceMappings(){
+ return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
+ }
+
+ public void setSourceMappings(List<SourceMappingMetadata> sources){
+ for (SourceMappingMetadata source: sources) {
+ addSourceMapping(source.getName(), source.getTranslatorName(), source.getConnectionJndiName());
+ }
+ }
+
+ @Override
+ public List<String> getSourceNames() {
+ return new ArrayList<String>(this.sources.getMap().keySet());
+ }
+
+ @Override
+ public String getSourceConnectionJndiName(String sourceName) {
+ SourceMappingMetadata s = this.sources.getMap().get(sourceName);
+ if (s == null) {
+ return null;
+ }
+ return s.getConnectionJndiName();
+ }
+
+ @Override
+ public String getSourceTranslatorName(String sourceName) {
+ SourceMappingMetadata s = this.sources.getMap().get(sourceName);
+ if (s == null) {
+ return null;
+ }
+ return s.getTranslatorName();
+ }
+
+ public void addSourceMapping(String name, String translatorName, String connJndiName) {
+ this.sources.getMap().put(name, new SourceMappingMetadata(name, translatorName, connJndiName));
+ }
+
+ public void addSourceMapping(SourceMappingMetadata source) {
+ this.sources.getMap().put(source.getName(), new SourceMappingMetadata(source.getName(), source.getTranslatorName(), source.getConnectionJndiName()));
+ }
+
+ public List<ValidationError> getErrors(){
+ return getValidationErrors(Severity.ERROR);
+ }
+
+ public void setErrors(List<ValidationError> errors){
+ this.errors = errors;
+ }
+
+ public synchronized List<ValidationError> getValidationErrors(ValidationError.Severity severity){
+ if (this.errors == null) {
+ return Collections.emptyList();
+ }
+ List<ValidationError> list = new ArrayList<ValidationError>();
+ for (ValidationError ve: this.errors) {
+ if (Severity.valueOf(ve.severity) == severity) {
+ list.add(ve);
+ }
+ }
+ return list;
+ }
+
+ public synchronized ValidationError addError(String severity, String message) {
+ if (this.errors == null) {
+ this.errors = new LinkedList<ValidationError>();
+ }
+ ValidationError ve = new ValidationError(severity, message);
+ this.errors.add(ve);
+ if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
+ this.errors.remove(0);
+ }
+ return ve;
+ }
+
+ public synchronized ValidationError addError(ValidationError ve) {
+ if (this.errors == null) {
+ this.errors = new LinkedList<ValidationError>();
+ }
+ this.errors.add(ve);
+ if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
+ this.errors.remove(0);
+ }
+ return ve;
+ }
+
+
+ public synchronized boolean removeError(ValidationError remove) {
+ if (this.errors == null) {
+ return false;
+ }
+ return this.errors.remove(remove);
+ }
+
+ public synchronized void clearErrors() {
+ this.errors.clear();
+ }
+
+ @XmlAccessorType(XmlAccessType.NONE)
+ @XmlType(name = "", propOrder = {
+ "value"
+ })
+ public static class ValidationError implements Serializable{
+ private static final long serialVersionUID = 2044197069467559527L;
+
+ public enum Severity {ERROR, WARNING};
+
+ @XmlValue
+ protected String value;
+
+ @XmlAttribute(name = "severity", required = true)
+ protected String severity;
+
+ @XmlAttribute(name = "path")
+ protected String path;
+
+ public ValidationError() {};
+
+ public ValidationError(String severity, String msg) {
+ this.severity = severity;
+ this.value = msg;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getSeverity() {
+ return severity;
+ }
+
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ValidationError other = (ValidationError) obj;
+ if (severity == null) {
+ if (other.severity != null)
+ return false;
+ } else if (!severity.equals(other.severity))
+ return false;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+
+public class ModelNodeConstants {
+ public static final String TYPE = "type";//$NON-NLS-1$
+ public static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ public static final String DESCRIPTION = "description"; //$NON-NLS-1$
+
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+
+public class PermissionMap extends ListOverMap<PermissionMetaData> {
+
+ private static final long serialVersionUID = -1170556665834875267L;
+
+ public PermissionMap(KeyBuilder<PermissionMetaData> builder) {
+ super(builder);
+ }
+
+ @Override
+ public void add(int index, PermissionMetaData element) {
+ PermissionMetaData previous = this.map.get(builder.getKey(element));
+ if (previous != null) {
+ if (element.allowCreate != null) {
+ previous.setAllowCreate(element.allowCreate);
+ }
+ if (element.allowRead != null) {
+ previous.setAllowRead(element.allowRead);
+ }
+ if (element.allowUpdate != null) {
+ previous.setAllowUpdate(element.allowUpdate);
+ }
+ if (element.allowDelete != null) {
+ previous.setAllowDelete(element.allowDelete);
+ }
+ }
+ else {
+ super.add(index, element);
+ }
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.teiid.adminapi.PropertyDefinition;
+
+
+
+public class PropertyDefinitionMetadata extends AdminObjectImpl implements PropertyDefinition {
+ private static final long serialVersionUID = 6612838530524627205L;
+ private Collection allowedValues = new ArrayList();
+ private Object defaultValue = null;
+ private String description = null;
+ private String displayName = null;
+ private String propertyTypeClassName = String.class.getName();
+ private RestartType requiresRestart = RestartType.NONE;
+ private boolean advanced = false;
+ private boolean masked = false;
+ private boolean modifiable = true;
+ private boolean required = false;
+
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Display Name:").append(getDisplayName()); //$NON-NLS-1$
+ result.append(" Description:").append(getDescription()); //$NON-NLS-1$
+ result.append(" Property Type Classname:").append(getPropertyTypeClassName()); //$NON-NLS-1$
+ result.append(" Default Value:").append(getDefaultValue()); //$NON-NLS-1$
+ result.append(" Constrained To Allow Values:").append(isConstrainedToAllowedValues()); //$NON-NLS-1$
+ result.append(" Allowed Values:").append(getAllowedValues()); //$NON-NLS-1$
+ result.append(" Required:").append(isRequired()); //$NON-NLS-1$
+ result.append(" Expert:").append(isAdvanced()); //$NON-NLS-1$
+ result.append(" Masked:").append(isMasked()); //$NON-NLS-1$
+ result.append(" Modifiable:").append(isModifiable()); //$NON-NLS-1$
+ result.append(" RequiresRestart:").append(getRequiresRestart()); //$NON-NLS-1$
+ return result.toString();
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getAllowedValues()
+ */
+ public Collection getAllowedValues() {
+ return allowedValues;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getDisplayName()
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getPropertyTypeClassName()
+ */
+ public String getPropertyTypeClassName() {
+ return propertyTypeClassName;
+ }
+
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getRequiresRestart()
+ */
+ public RestartType getRequiresRestart() {
+ return requiresRestart;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isExpert()
+ * @since 4.3
+ */
+ public boolean isAdvanced() {
+ return advanced;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isMasked()
+ */
+ public boolean isMasked() {
+ return masked;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isModifiable()
+ */
+ public boolean isModifiable() {
+ return modifiable;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isRequired()
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @param allowedValues The allowedValues to set.
+ */
+ public void setAllowedValues(Collection allowedValues) {
+ this.allowedValues = allowedValues;
+ }
+
+ /**
+ * @param defaultValue The defaultValue to set.
+ */
+ public void setDefaultValue(Serializable defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+ /**
+ * @param displayName The displayName to set.
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+
+ /**
+ * @param expert The value of expert to set.
+ */
+ public void setAdvanced(boolean expert) {
+ this.advanced = expert;
+ }
+
+ /**
+ * @param masked The value of masked to set.
+ */
+ public void setMasked(boolean masked) {
+ this.masked = masked;
+ }
+ /**
+ * @param modifiable The value of modifiable to set.
+ */
+ public void setModifiable(boolean modifiable) {
+ this.modifiable = modifiable;
+ }
+
+ /**
+ * @param propertyTypeClassName The propertyTypeName to set.
+ */
+ public void setPropertyTypeClassName(String propertyTypeClassName) {
+ this.propertyTypeClassName = propertyTypeClassName;
+ }
+
+
+ /**
+ * @param required The value of required to set.
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * @param requiresRestart The value of requiresRestart to set.
+ */
+ public void setRequiresRestart(RestartType requiresRestart) {
+ this.requiresRestart = requiresRestart;
+ }
+
+ @Override
+ public boolean isConstrainedToAllowedValues() {
+ return allowedValues != null && !allowedValues.isEmpty();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <pre>
+ * <complexType name="property">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "property")
+public class PropertyMetadata implements Serializable{
+ private static final long serialVersionUID = -5040224539939758816L;
+
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "value", required = true)
+ protected String value;
+
+ public PropertyMetadata() {
+ }
+
+ public PropertyMetadata(String key, String value) {
+ this.name = key;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return this.name+"="+this.value; //$NON-NLS-1$
+ }
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.util.Date;
+
+import org.teiid.adminapi.Request;
+import org.teiid.core.util.HashCodeUtil;
+
+
+
+public class RequestMetadata extends AdminObjectImpl implements Request {
+
+ private static final long serialVersionUID = -2779106368517784259L;
+
+ private long executionId;
+ private String sessionId;
+ private String command;
+ private long startTime;
+ private boolean sourceRequest;
+ private Integer nodeID;
+ private String transactionId;
+ private ProcessingState processingState = ProcessingState.PROCESSING;
+ private ThreadState threadState = ThreadState.RUNNING;
+
+ @Override
+ public long getExecutionId() {
+ return executionId;
+ }
+
+ public void setExecutionId(long id) {
+ this.executionId = id;
+ }
+
+ @Override
+ public ProcessingState getState() {
+ return processingState;
+ }
+
+ public void setState(ProcessingState state) {
+ this.processingState = state;
+ }
+
+ @Override
+ public ThreadState getThreadState() {
+ return threadState;
+ }
+
+ public void setThreadState(ThreadState threadState) {
+ this.threadState = threadState;
+ }
+
+ @Override
+ public String getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(String session) {
+ this.sessionId = session;
+ }
+
+ @Override
+ public long getStartTime() {
+ return this.startTime;
+ }
+
+ public void setStartTime(long time) {
+ this.startTime = time;
+ }
+
+ @Override
+ public String getCommand() {
+ return this.command;
+ }
+
+ public void setCommand(String cmd) {
+ this.command = cmd;
+ }
+
+ @Override
+ public boolean sourceRequest() {
+ return sourceRequest;
+ }
+
+ public void setSourceRequest(boolean sourceRequest) {
+ this.sourceRequest = sourceRequest;
+ }
+
+ @Override
+ public Integer getNodeId() {
+ return this.nodeID;
+ }
+
+ public void setNodeId(Integer nodeID) {
+ this.nodeID = nodeID;
+ }
+
+ @Override
+ public String getTransactionId() {
+ return this.transactionId;
+ }
+
+ public void setTransactionId(String id) {
+ this.transactionId = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RequestMetadata)) {
+ return false;
+ }
+ RequestMetadata value = (RequestMetadata)obj;
+ if (!sourceRequest()) {
+ return sessionId == value.sessionId && executionId == value.executionId;
+ }
+ return sessionId == value.sessionId && executionId == value.executionId && nodeID.equals(value.nodeID);
+ }
+
+ public int hashCode() {
+ return HashCodeUtil.hashCode((int)executionId, sessionId);
+ }
+
+ @SuppressWarnings("nls")
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+ str.append("Request: sessionid=").append(sessionId);
+ str.append("; executionId=").append(executionId);
+ if (nodeID != null) {
+ str.append("; nodeId=").append(nodeID);
+ }
+ if (transactionId != null) {
+ str.append("; transactionId=").append(transactionId);
+ }
+ str.append("; sourceRequest=").append(sourceRequest);
+ str.append("; processingTime=").append(new Date(startTime));
+ str.append("; command=").append(command);
+
+ return str.toString();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.Date;
+
+import javax.security.auth.Subject;
+
+import org.teiid.adminapi.Session;
+import org.teiid.client.security.SessionToken;
+
+
+
+/**
+ * Add and delete properties also in the Mapper class for correct wrapping for profile service.
+ *
+ */
+/* TODO: it would probably be good to let ipAddress denote the connecting address
+ and add clientIpAdress as the client reported value */
+public class SessionMetadata extends AdminObjectImpl implements Session {
+
+ private static final long serialVersionUID = 918638989081830034L;
+ private String applicationName;
+ private long lastPingTime = System.currentTimeMillis();
+ private long createdTime;
+ private String ipAddress;
+ private String clientHostName;
+ private String clientHardwareAddress;
+ private String userName;
+ private String vdbName;
+ private int vdbVersion;
+ private String sessionId;
+ private String securityDomain;
+
+ //server session state
+ private transient VDBMetaData vdb;
+ private transient SessionToken sessionToken;
+ private transient Subject subject;
+ private transient Object securityContext;
+ private transient boolean embedded;
+
+ @Override
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ @Override
+ public long getCreatedTime() {
+ return this.createdTime;
+ }
+
+ public void setCreatedTime(long createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ @Override
+ public String getClientHostName() {
+ return this.clientHostName;
+ }
+
+ public void setClientHostName(String clientHostname) {
+ this.clientHostName = clientHostname;
+ }
+
+ @Override
+ public String getIPAddress() {
+ return this.ipAddress;
+ }
+
+ public void setIPAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ @Override
+ public long getLastPingTime() {
+ return this.lastPingTime;
+ }
+
+ public void setLastPingTime(long lastPingTime) {
+ this.lastPingTime = lastPingTime;
+ }
+
+ @Override
+ public String getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public String getUserName() {
+ return this.userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public String getVDBName() {
+ return this.vdbName;
+ }
+
+ public void setVDBName(String vdbName) {
+ this.vdbName = vdbName;
+ }
+
+ @Override
+ public int getVDBVersion() {
+ return this.vdbVersion;
+ }
+
+ public void setVDBVersion(int vdbVersion) {
+ this.vdbVersion = vdbVersion;
+ }
+
+ @Override
+ public String getSecurityDomain() {
+ return this.securityDomain;
+ }
+
+ public void setSecurityDomain(String domain) {
+ this.securityDomain = domain;
+ }
+
+ @SuppressWarnings("nls")
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+ str.append("session: sessionid=").append(sessionId);
+ str.append("; userName=").append(userName);
+ str.append("; vdbName=").append(vdbName);
+ str.append("; vdbVersion=").append(vdbVersion);
+ str.append("; createdTime=").append(new Date(createdTime));
+ str.append("; applicationName=").append(applicationName);
+ str.append("; clientHostName=").append(clientHostName);
+ str.append("; clientHardwareAddress=").append(clientHardwareAddress);
+ str.append("; IPAddress=").append(ipAddress);
+ str.append("; securityDomain=").append(securityDomain);
+ str.append("; lastPingTime=").append(new Date(lastPingTime));
+ return str.toString();
+ }
+
+ public VDBMetaData getVdb() {
+ return vdb;
+ }
+
+ public void setVdb(VDBMetaData vdb) {
+ this.vdb = vdb;
+ }
+
+ public SessionToken getSessionToken() {
+ return sessionToken;
+ }
+
+ public void setSessionToken(SessionToken sessionToken) {
+ this.sessionToken = sessionToken;
+ }
+
+ public void setSubject(Subject subject) {
+ this.subject = subject;
+ }
+
+ public Object getSecurityContext() {
+ return securityContext;
+ }
+
+ public void setSecurityContext(Object securityContext) {
+ this.securityContext = securityContext;
+ }
+
+ public Subject getSubject() {
+ return this.subject;
+ }
+
+ public void setEmbedded(boolean embedded) {
+ this.embedded = embedded;
+ }
+
+ public boolean isEmbedded() {
+ return embedded;
+ }
+
+ @Override
+ public String getClientHardwareAddress() {
+ return this.clientHardwareAddress;
+ }
+
+ public void setClientHardwareAddress(String clientHardwareAddress) {
+ this.clientHardwareAddress = clientHardwareAddress;
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "")
+public class SourceMappingMetadata implements Serializable {
+ private static final long serialVersionUID = -4417878417697685794L;
+
+ @XmlAttribute(name = "name", required = true)
+ private String name;
+
+ @XmlAttribute(name = "connection-jndi-name")
+ private String jndiName;
+
+ @XmlAttribute(name = "translator-name",required = true)
+ private String translatorName;
+
+ public SourceMappingMetadata() {}
+
+ public SourceMappingMetadata(String name, String translatorName, String connJndiName) {
+ this.name = name;
+ this.translatorName = translatorName;
+ this.jndiName = connJndiName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getConnectionJndiName() {
+ // this default could be controlled if needed.
+ if (this.jndiName == null) {
+ return "java:"+name; //$NON-NLS-1$
+ }
+ return jndiName;
+ }
+
+ public void setConnectionJndiName(String jndiName) {
+ this.jndiName = jndiName;
+ }
+
+ public String getTranslatorName() {
+ return translatorName;
+ }
+
+ public void setTranslatorName(String translatorName) {
+ this.translatorName = translatorName;
+ }
+
+ public String toString() {
+ return getName()+"/"+getTranslatorName()+"/"+getConnectionJndiName(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.util.Date;
+
+import org.teiid.adminapi.Transaction;
+
+
+public class TransactionMetadata extends AdminObjectImpl implements Transaction {
+
+ private static final long serialVersionUID = -8588785315218789068L;
+ private String associatedSession;
+ private String scope;
+ private String id;
+ private long createdTime;
+
+ @Override
+ public String getAssociatedSession() {
+ return associatedSession;
+ }
+
+ public void setAssociatedSession(String associatedSession) {
+ this.associatedSession = associatedSession;
+ }
+
+ @Override
+ public String getScope() {
+ return scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public long getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(long time) {
+ this.createdTime = time;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Associated Session:").append(associatedSession); //$NON-NLS-1$
+ result.append("Scope:").append(scope); //$NON-NLS-1$
+ result.append("Id:").append(id); //$NON-NLS-1$
+ result.append("CreatedTime:").append(new Date(createdTime)); //$NON-NLS-1$
+ return result.toString();
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.net.URL;
+import java.util.*;
+
+import javax.xml.bind.annotation.*;
+
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.core.util.StringUtil;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "JAXBProperties",
+ "models",
+ "translators",
+ "dataPolicies"
+})
+@XmlRootElement(name = "vdb")
+public class VDBMetaData extends AdminObjectImpl implements VDB {
+
+ private static final String VERSION_DELIM = "."; //$NON-NLS-1$
+
+ private static final long serialVersionUID = -4723595252013356436L;
+
+ /**
+ * This simulating a list over a map. JAXB requires a list and performance recommends
+ * map and we would like to keep one variable to represent both.
+ */
+ @XmlElement(name = "model", required = true, type = ModelMetaData.class)
+ protected ListOverMap<ModelMetaData> models = new ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
+ private static final long serialVersionUID = 846247100420118961L;
+
+ @Override
+ public String getKey(ModelMetaData entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlElement(name = "translator", required = true, type = VDBTranslatorMetaData.class)
+ protected ListOverMap<VDBTranslatorMetaData> translators = new ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
+ private static final long serialVersionUID = 3890502172003653563L;
+
+ @Override
+ public String getKey(VDBTranslatorMetaData entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlElement(name = "data-role", required = true, type = DataPolicyMetadata.class)
+ protected ListOverMap<DataPolicyMetadata> dataPolicies = new ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
+ private static final long serialVersionUID = 4954591545242715254L;
+
+ @Override
+ public String getKey(DataPolicyMetadata entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlAttribute(name = "version", required = true)
+ private int version = 1;
+
+ @XmlElement(name = "description")
+ protected String description;
+
+ private String fileUrl = null;
+ private boolean dynamic = false;
+ private VDB.Status status = VDB.Status.INACTIVE;
+ private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
+ private boolean removed;
+
+ @XmlAttribute(name = "name", required = true)
+ public String getName() {
+ return super.getName();
+ }
+
+ public String getFullName() {
+ return getName() + VERSION_DELIM + getVersion();
+ }
+
+ // This needed by JAXB marshaling
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ public boolean isRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(boolean removed) {
+ this.removed = removed;
+ }
+
+ @Override
+ public ConnectionType getConnectionType() {
+ return this.connectionType;
+ }
+
+ public void setConnectionType(ConnectionType allowConnections) {
+ this.connectionType = allowConnections;
+ }
+
+ public void setConnectionType(String allowConnections) {
+ this.connectionType = ConnectionType.valueOf(allowConnections);
+ }
+
+ @Override
+ public Status getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(Status s) {
+ this.status = s;
+ }
+
+ public void setStatus(String s) {
+ this.status = Status.valueOf(s);
+ }
+
+
+ @Override
+ public int getVersion() {
+ return this.version;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getUrl() {
+ return this.fileUrl;
+ }
+
+ public void setUrl(String url) {
+ this.fileUrl = url;
+ }
+
+ public void setUrl(URL url) {
+ this.setUrl(url.toExternalForm());
+ String path = url.getPath();
+ if (path.endsWith("/")) { //$NON-NLS-1$
+ path = path.substring(0, path.length() - 1);
+ }
+ String fileName = StringUtil.getLastToken(path, "/"); //$NON-NLS-1$
+ String[] parts = fileName.split("\\."); //$NON-NLS-1$
+ if (parts[0].equalsIgnoreCase(getName()) && parts.length >= 3) {
+ try {
+ int fileVersion = Integer.parseInt(parts[parts.length - 2]);
+ this.setVersion(fileVersion);
+ } catch (NumberFormatException e) {
+
+ }
+ }
+ }
+
+ @Override
+ public List<Model> getModels(){
+ return new ArrayList<Model>(this.models.getMap().values());
+ }
+
+ public Map<String, ModelMetaData> getModelMetaDatas() {
+ return this.models.getMap();
+ }
+
+ /**
+ * 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) {
+ for (Model obj : models) {
+ ModelMetaData model = (ModelMetaData) obj;
+ addModel(model);
+ }
+ }
+
+ public void addModel(ModelMetaData m) {
+ this.models.getMap().put(m.getName(), m);
+ }
+
+ @Override
+ public List<Translator> getOverrideTranslators() {
+ return new ArrayList<Translator>(this.translators.getMap().values());
+ }
+
+ public void setOverrideTranslators(List<Translator> translators) {
+ for (Translator t: translators) {
+ this.translators.getMap().put(t.getName(), (VDBTranslatorMetaData)t);
+ }
+ }
+
+ public void addOverideTranslator(VDBTranslatorMetaData t) {
+ this.translators.getMap().put(t.getName(), t);
+ }
+
+ @Override
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String desc) {
+ this.description = desc;
+ }
+
+ @Override
+ public List<String> getValidityErrors(){
+ List<String> allErrors = new ArrayList<String>();
+ for (ModelMetaData model:this.models.getMap().values()) {
+ List<ValidationError> errors = model.getErrors();
+ if (errors != null && !errors.isEmpty()) {
+ for (ValidationError m:errors) {
+ if (ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR)) {
+ allErrors.add(m.getValue());
+ }
+ }
+ }
+ }
+ return allErrors;
+ }
+
+ @Override
+ public boolean isValid() {
+ if (!getValidityErrors().isEmpty()) {
+ return false;
+ }
+
+ if (getModels().isEmpty()) {
+ return false;
+ }
+ for(ModelMetaData m: this.models.getMap().values()) {
+ if (m.isSource()) {
+ List<String> resourceNames = m.getSourceNames();
+ if (resourceNames.isEmpty()) {
+ return false;
+ }
+ for (String sourceName:resourceNames) {
+ if (m.getSourceConnectionJndiName(sourceName) == null) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public String toString() {
+ return getName()+VERSION_DELIM+getVersion()+ models.getMap().values();
+ }
+
+ public boolean isVisible(String modelName) {
+ ModelMetaData model = getModel(modelName);
+ return model == null || model.isVisible();
+ }
+
+ public ModelMetaData getModel(String modelName) {
+ return this.models.getMap().get(modelName);
+ }
+
+ public Set<String> getMultiSourceModelNames(){
+ Set<String> list = new HashSet<String>();
+ for(ModelMetaData m: models.getMap().values()) {
+ if (m.isSupportsMultiSourceBindings()) {
+ list.add(m.getName());
+ }
+ }
+ return list;
+ }
+
+ // This one manages the JAXB binding
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+ public void setDynamic(boolean dynamic) {
+ this.dynamic = dynamic;
+ }
+
+ @Override
+ public List<DataPolicy> getDataPolicies(){
+ return new ArrayList<DataPolicy>(this.dataPolicies.getMap().values());
+ }
+
+ /**
+ * This method is required by the Management framework to write the mappings to the persistent form. The actual assignment is done
+ * in the VDBMetaDataClassInstancefactory
+ * @param policies
+ */
+ public void setDataPolicies(List<DataPolicy> policies){
+ this.dataPolicies.getMap().clear();
+ for (DataPolicy policy:policies) {
+ this.dataPolicies.getMap().put(policy.getName(), (DataPolicyMetadata)policy);
+ }
+ }
+
+ public void addDataPolicy(DataPolicyMetadata policy){
+ this.dataPolicies.getMap().put(policy.getName(), policy);
+ }
+
+ public DataPolicyMetadata getDataPolicy(String policyName) {
+ return this.dataPolicies.getMap().get(policyName);
+ }
+
+ public VDBTranslatorMetaData getTranslator(String name) {
+ return this.translators.getMap().get(name);
+ }
+
+ public boolean isPreview() {
+ return Boolean.valueOf(getPropertyValue("preview")); //$NON-NLS-1$
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+@SuppressWarnings("nls")
+public class VDBMetadataParser {
+
+ public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
+ XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
+
+ // elements
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case VDB:
+ VDBMetaData vdb = new VDBMetaData();
+ Properties props = getAttributes(reader);
+ vdb.setName(props.getProperty(Element.NAME.getLocalName()));
+ vdb.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
+ parseVDB(reader, vdb);
+ return vdb;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ return null;
+ }
+
+ private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ vdb.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, vdb);
+ break;
+ case MODEL:
+ ModelMetaData model = new ModelMetaData();
+ parseModel(reader, model);
+ vdb.addModel(model);
+ break;
+ case TRANSLATOR:
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ parseTranslator(reader, translator);
+ vdb.addOverideTranslator(translator);
+ break;
+ case DATA_ROLE:
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ parseDataRole(reader, policy);
+ vdb.addDataPolicy(policy);
+ break;
+ case ENTRY:
+ // this is designer specific.
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
+ throws XMLStreamException {
+ if (reader.getAttributeCount() > 0) {
+ String key = null;
+ String value = null;
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (attrName.equals(Element.NAME.getLocalName())) {
+ key = attrValue;
+ }
+ if (attrName.equals(Element.VALUE.getLocalName())) {
+ value = attrValue;
+ }
+ }
+ anObj.addProperty(key, value);
+ }
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ }
+
+ private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ policy.setName(props.getProperty(Element.NAME.getLocalName()));
+ policy.setAnyAuthenticated(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName())));
+ policy.setAllowCreateTemporaryTables(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName())));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ policy.setDescription(reader.getElementText());
+ break;
+ case PERMISSION:
+ PermissionMetaData permission = new PermissionMetaData();
+ parsePermission(reader, permission);
+ policy.addPermission(permission);
+ break;
+ case MAPPED_ROLE_NAME:
+ policy.addMappedRoleName(reader.getElementText());
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parsePermission(XMLStreamReader reader, PermissionMetaData permission) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case RESOURCE_NAME:
+ permission.setResourceName(reader.getElementText());
+ break;
+ case ALLOW_ALTER:
+ permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_CREATE:
+ permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_DELETE:
+ permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_EXECUTE:
+ permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_READ:
+ permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_UPADTE:
+ permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseTranslator(XMLStreamReader reader, VDBTranslatorMetaData translator) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ translator.setName(props.getProperty(Element.NAME.getLocalName()));
+ translator.setType(props.getProperty(Element.TYPE.getLocalName()));
+ translator.setDescription(props.getProperty(Element.DESCRIPTION.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case PROPERTY:
+ parseProperty(reader, translator);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseModel(XMLStreamReader reader, ModelMetaData model) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ model.setName(props.getProperty(Element.NAME.getLocalName()));
+ model.setModelType(Model.Type.valueOf(props.getProperty(Element.TYPE.getLocalName(), "PHYSICAL")));
+ model.setVisible(Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(), "true")));
+ model.setPath(props.getProperty(Element.PATH.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ model.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, model);
+ break;
+ case SOURCE:
+ Properties sourceProps = getAttributes(reader);
+ String name = sourceProps.getProperty(Element.NAME.getLocalName());
+ String translatorName = sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
+ String connectionName = sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
+ model.addSourceMapping(name, translatorName, connectionName);
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ break;
+ case VALIDATION_ERROR:
+ Properties validationProps = getAttributes(reader);
+ String msg = reader.getElementText();
+ String severity = validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
+ String path = validationProps.getProperty(Element.PATH.getLocalName());
+ ValidationError ve = new ValidationError(severity, msg);
+ ve.setPath(path);
+ model.addError(ve);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+
+ private static Properties getAttributes(XMLStreamReader reader) {
+ Properties props = new Properties();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ props.setProperty(attrName, attrValue);
+ }
+ }
+ return props;
+ }
+
+ enum Element {
+ // must be first
+ UNKNOWN(null),
+ VDB("vdb"),
+ NAME("name"),
+ VERSION("version"),
+ DESCRIPTION("description"),
+ PROPERTY("property"),
+ VALUE("value"),
+ MODEL("model"),
+ TYPE("type"),
+ VISIBLE("visible"),
+ PATH("path"),
+ SOURCE("source"),
+ SOURCE_TRANSLATOR_NAME_ATTR("translator-name"),
+ SOURCE_CONNECTION_JNDI_NAME_ATTR("connection-jndi-name"),
+ VALIDATION_ERROR("validation-error"),
+ VALIDATION_SEVERITY_ATTR("severity"),
+ TRANSLATOR("translator"),
+ DATA_ROLE("data-role"),
+ DATA_ROLE_ANY_ATHENTICATED_ATTR("any-authenticated"),
+ DATA_ROLE_ALLOW_TEMP_TABLES_ATTR("allow-create-temporary-tables"),
+ PERMISSION("permission"),
+ RESOURCE_NAME("resource-name"),
+ ALLOW_CREATE("allow-create"),
+ ALLOW_READ("allow-read"),
+ ALLOW_UPADTE("allow-update"),
+ ALLOW_DELETE("allow-delete"),
+ ALLOW_EXECUTE("allow-execute"),
+ ALLOW_ALTER("allow-alyer"),
+ MAPPED_ROLE_NAME("mapped-role-name"),
+ ENTRY("entry");
+
+ private final String name;
+
+ Element(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Element> elements;
+
+ static {
+ final Map<String, Element> map = new HashMap<String, Element>();
+ for (Element element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ elements = map;
+ }
+
+ public static Element forName(String localName) {
+ final Element element = elements.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.teiid.adminapi.Translator;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
+ private static final long serialVersionUID = -3454161477587996138L;
+ private String type;
+ private Class<?> executionClass;
+ private String description;
+ private String moduleName;
+
+ @Override
+ public String getName() {
+ return super.getName();
+ }
+
+ @XmlAttribute(name = "name", required = true)
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @XmlAttribute(name = "type",required = true)
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public Class<?> getExecutionFactoryClass() {
+ return this.executionClass;
+ }
+
+ public void setExecutionFactoryClass(Class<?> clazz) {
+ this.executionClass = clazz;
+ addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ @XmlAttribute(name = "description")
+ public void setDescription(String desc) {
+ this.description = desc;
+ }
+
+ public String getModuleName() {
+ return this.moduleName;
+ }
+
+ public void setModuleName(String name) {
+ this.moduleName = name;
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import org.teiid.adminapi.WorkerPoolStatistics;
+
+/**
+ * This class is a holder for all the statistics gathered about a worker pool.
+ */
+public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements WorkerPoolStatistics {
+
+ private static final long serialVersionUID = -4917902925523802295L;
+
+ // Current state
+ private int queued;
+ private int highestQueued;
+ private int maxThreads;
+ private int activeThreads;
+ private int highestActiveThreads;
+ private long totalSubmitted;
+ private long totalCompleted;
+
+ @Override
+ public int getActiveThreads() {
+ return activeThreads;
+ }
+
+ @Override
+ public int getHighestActiveThreads() {
+ return highestActiveThreads;
+ }
+
+ @Override
+ public long getTotalCompleted() {
+ return totalCompleted;
+ }
+
+ @Override
+ public long getTotalSubmitted() {
+ return totalSubmitted;
+ }
+
+ @Override
+ public String getQueueName() {
+ return getName();
+ }
+
+ @Override
+ public int getQueued() {
+ return queued;
+ }
+
+ @Override
+ public int getHighestQueued() {
+ return highestQueued;
+ }
+
+ @Override
+ public int getMaxThreads() {
+ return maxThreads;
+ }
+
+ public void setQueued(int queued) {
+ this.queued = queued;
+ }
+
+ public void setHighestQueued(int highestQueued) {
+ this.highestQueued = highestQueued;
+ }
+
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
+ }
+
+ public void setActiveThreads(int activeThreads) {
+ this.activeThreads = activeThreads;
+ }
+
+ public void setHighestActiveThreads(int highestActiveThreads) {
+ this.highestActiveThreads = highestActiveThreads;
+ }
+
+ public void setTotalSubmitted(long totalSubmitted) {
+ this.totalSubmitted = totalSubmitted;
+ }
+
+ public void setTotalCompleted(long totalCompleted) {
+ this.totalCompleted = totalCompleted;
+ }
+
+ public void setQueueName(String name) {
+ setName(name);
+ }
+
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+
+ str.append("WorkerPoolStats:"); //$NON-NLS-1$
+ str.append(" queue-name = " + getName()); //$NON-NLS-1$
+ str.append("; queued = " + queued); //$NON-NLS-1$
+ str.append("; highestQueued = " + highestQueued); //$NON-NLS-1$
+ str.append("; maxThreads = " + maxThreads); //$NON-NLS-1$
+ str.append("; activeThreads = " + activeThreads); //$NON-NLS-1$
+ str.append("; highestActiveThreads = " + highestActiveThreads); //$NON-NLS-1$
+ str.append("; totalSubmitted = " + totalSubmitted); //$NON-NLS-1$
+ str.append("; totalCompleted = " + totalCompleted); //$NON-NLS-1$
+ return str.toString();
+ }
+
+}
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.teiid.adminapi.DataPolicy.PermissionType;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import static junit.framework.Assert.*;
+
+public class TestDataPolicyMetaData {
+
+ @Test
+ public void testAllowed() {
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ policy.setName("readOnly"); //$NON-NLS-1$
+ policy.setDescription("Only has read only permissions"); //$NON-NLS-1$
+ policy.setMappedRoleNames(Arrays.asList("jack", "susan")); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("catalog.schema.Table1"); //$NON-NLS-1$
+ perm1.setAllowRead(true);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("catalog.schema.Table2"); //$NON-NLS-1$
+ perm2.setAllowRead(false);
+
+ PermissionMetaData perm3 = new PermissionMetaData();
+ perm3.setResourceName("catalog.schema.Table3"); //$NON-NLS-1$
+ perm3.setAllowRead(true);
+
+ PermissionMetaData perm4 = new PermissionMetaData();
+ perm4.setResourceName("catalog.schema.Table4"); //$NON-NLS-1$
+ perm4.setAllowRead(true);
+
+ PermissionMetaData perm5 = new PermissionMetaData();
+ perm5.setResourceName("catalog.schema.Table5.column1"); //$NON-NLS-1$
+ perm5.setAllowRead(true);
+
+ policy.addPermission(perm1, perm2, perm3, perm4, perm5);
+
+
+ assertTrue(policy.allows("catalog.schema.Table1", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table1", PermissionType.CREATE)); //$NON-NLS-1$
+
+ assertFalse(policy.allows("catalog.schema", PermissionType.READ)); //$NON-NLS-1$
+
+ assertFalse(policy.allows("catalog.schema.Table2.column", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table2", PermissionType.READ)); //$NON-NLS-1$
+
+ assertTrue(policy.allows("catalog.schema.Table3.column", PermissionType.READ)); //$NON-NLS-1$
+ assertTrue(policy.allows("catalog.schema.Table3", PermissionType.READ)); //$NON-NLS-1$
+
+ assertTrue(policy.allows("catalog.schema.Table4.column", PermissionType.READ)); //$NON-NLS-1$
+ assertTrue(policy.allows("catalog.schema.Table4", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table4", PermissionType.DELETE)); //$NON-NLS-1$
+
+ assertTrue(policy.allows("catalog.schema.Table5.column1", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table5.column2", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table5", PermissionType.READ)); //$NON-NLS-1$
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.teiid.adminapi.Model;
+
+@SuppressWarnings("nls")
+public class TestModelMetaData {
+
+ @Test
+ public void testModelType() {
+
+ ModelMetaData model = new ModelMetaData();
+ model.modelType = "physical";
+
+ assertTrue(model.getModelType() == Model.Type.PHYSICAL);
+ assertTrue(model.isSource());
+
+ model.modelType = "VIRTUAL";
+ assertTrue(model.getModelType() == Model.Type.VIRTUAL);
+
+ model.modelType = "TYPE";
+ assertTrue(model.getModelType() == Model.Type.OTHER);
+ assertTrue(!model.isSource());
+ }
+
+ @Test
+ public void testSupportMultiSource() {
+ ModelMetaData model = new ModelMetaData();
+ assertFalse(model.isSupportsMultiSourceBindings());
+ model.setSupportsMultiSourceBindings(true);
+
+ assertTrue(model.isSupportsMultiSourceBindings());
+
+ assertTrue(!model.getProperties().isEmpty());
+ }
+
+ public void testErrors() {
+ ModelMetaData m = new ModelMetaData();
+ m.addError("ERROR", "I am Error");
+ m.addError("WARNING", "I am warning");
+
+ assertFalse(m.getErrors().isEmpty());
+ assertEquals(1, m.getErrors().size());
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+import org.teiid.adminapi.Request.ProcessingState;
+import org.teiid.adminapi.Request.ThreadState;
+@SuppressWarnings("nls")
+public class TestRequestMetadata {
+
+ @Test public void testMapping() {
+ RequestMetadata request = buildRequest();
+
+ ModelNode node = MetadataMapper.RequestMetadataMapper.wrap(request, new ModelNode());
+
+ RequestMetadata actual = MetadataMapper.RequestMetadataMapper.unwrap(node);
+
+ assertEquals(request, actual);
+ assertEquals(request.getState(), actual.getState());
+ }
+
+ private RequestMetadata buildRequest() {
+ RequestMetadata request = new RequestMetadata();
+ request.setState(ProcessingState.PROCESSING);
+ request.setCommand("select * from foo"); //$NON-NLS-1$
+ request.setExecutionId(1234);
+ request.setName("request-name"); //$NON-NLS-1$
+ request.setSessionId("session-id");//$NON-NLS-1$
+ request.setSourceRequest(false);
+ request.setStartTime(12345L);
+ request.setTransactionId("transaction-id");//$NON-NLS-1$
+ request.setThreadState(ThreadState.RUNNING);
+ //request.setNodeId(1);
+ return request;
+ }
+
+ public static final String desc = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"execution-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Unique Identifier for Request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"start-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Start time for the request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"command\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Executing Command\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"source-request\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"BOOLEAN\"\n" +
+ " },\n" +
+ " \"description\" : \"Is this Connector level request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"node-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
+ " },\n" +
+ " \"description\" : \"Node Identifier\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"transaction-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Get Transaction XID if transaction involved\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"processing-state\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"State of the Request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"thread-state\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Thread state\",\n" +
+ " \"required\" : true\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ @Test public void testDescribe() {
+ assertEquals(desc, MetadataMapper.RequestMetadataMapper.describe(new ModelNode()).toJSONString(false));
+ }
+
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestSessionMetadata {
+
+ @Test public void testMapping() {
+ SessionMetadata session = new SessionMetadata();
+ session.setSessionId("test");
+ session.setApplicationName("foo");
+ session.setClientHostName("localhost");
+ session.setCreatedTime(1234);
+ session.setIPAddress("127.0.0.1");
+ session.setVDBName("vdb-name");
+ session.setVDBVersion(2);
+ session.setSecurityContext("auth-domain");
+ session.setUserName("user");
+
+ ModelNode node = MetadataMapper.SessionMetadataMapper.wrap(session, new ModelNode());
+
+ SessionMetadata session1 = MetadataMapper.SessionMetadataMapper.unwrap(node);
+
+ assertEquals(session.getSessionId(), session1.getSessionId());
+ assertEquals(session.getApplicationName(), session1.getApplicationName());
+
+ }
+
+ private static final String describe = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"application-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Application assosiated with Session\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"created-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"When session created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"client-host-address\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Host name from where the session created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"ip-address\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"IP address from where session is created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"last-ping-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Last ping time\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"user-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"User name associated with session\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"vdb-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"The Virtual Database Name\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"vdb-version\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
+ " },\n" +
+ " \"description\" : \"The Virtual Database Version\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"security-domain\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Security domain that session used for login\",\n" +
+ " \"required\" : false\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ @Test public void testDescribe() {
+ ModelNode n = MetadataMapper.SessionMetadataMapper.describe(new ModelNode());
+ //System.out.println(n.toJSONString(false));
+ assertEquals(describe, n.toJSONString(false));
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestTransactionMetadata {
+
+ @Test public void testMapping() {
+ TransactionMetadata tm = new TransactionMetadata();
+ tm.setAssociatedSession("x");
+ tm.setCreatedTime(1234);
+ tm.setId("tnx-id");
+ tm.setScope("scope");
+
+ ModelNode node = MetadataMapper.TransactionMetadataMapper.wrap(tm, new ModelNode());
+
+ TransactionMetadata tm1 = MetadataMapper.TransactionMetadataMapper.unwrap(node);
+
+ assertEquals(tm.getAssociatedSession(), tm1.getAssociatedSession());
+
+ assertEquals(tm.getCreatedTime(), tm1.getCreatedTime());
+ assertEquals(tm.getId(), tm1.getId());
+ assertEquals(tm.getScope(), tm1.getScope());
+ }
+
+ private static final String describe = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-created-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction created time\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-scope\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction scope (Request, Local, Global)\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction Identifier (XID)\",\n" +
+ " \"required\" : true\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ @Test
+ public void testDescribe() {
+ ModelNode n = MetadataMapper.TransactionMetadataMapper.describe(new ModelNode());
+ //System.out.println(n.toJSONString(false));
+ assertEquals(describe, n.toJSONString(false));
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestVDBMetaData {
+
+ @Test
+ public void testMarshellUnmarshell() throws Exception {
+
+ VDBMetaData vdb = buildVDB();
+
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
+ Marshaller marshell = jc.createMarshaller();
+ marshell.setSchema(schema);
+ marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
+
+ StringWriter sw = new StringWriter();
+ marshell.marshal(vdb, sw);
+
+ System.out.println(sw.toString());
+
+ // UnMarshell
+ Unmarshaller un = jc.createUnmarshaller();
+ un.setSchema(schema);
+ vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
+
+ validateVDB(vdb);
+ }
+
+ static void validateVDB(VDBMetaData vdb) {
+ ModelMetaData modelOne;
+ ModelMetaData modelTwo;
+ assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
+ assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
+ assertEquals(1, vdb.getVersion());
+ assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertNotNull(vdb.getModel("model-one")); //$NON-NLS-1$
+ assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$
+ assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$
+
+ modelOne = vdb.getModel("model-one"); //$NON-NLS-1$
+ assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$
+ assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$
+ assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
+ assertEquals("model-value-override", modelOne.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse(modelOne.isVisible());
+ assertEquals("model description", modelOne.getDescription());
+
+ modelTwo = vdb.getModel("model-two"); //$NON-NLS-1$
+ assertEquals("model-two", modelTwo.getName()); //$NON-NLS-1$
+ assertTrue(modelTwo.getSourceNames().contains("s1")); //$NON-NLS-1$
+ assertTrue(modelTwo.getSourceNames().contains("s2")); //$NON-NLS-1$
+ assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
+ assertEquals("model-value", modelTwo.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ assertTrue(vdb.getValidityErrors().contains("There is an error in VDB")); //$NON-NLS-1$
+
+ List<Translator> translators = vdb.getOverrideTranslators();
+ assertTrue(translators.size() == 1);
+
+ Translator translator = translators.get(0);
+ assertEquals("oracleOverride", translator.getName());
+ assertEquals("oracle", translator.getType());
+ assertEquals("my-value", translator.getPropertyValue("my-property"));
+ assertEquals("hello world", translator.getDescription());
+ List<DataPolicy> roles = vdb.getDataPolicies();
+
+ assertTrue(roles.size() == 1);
+
+ DataPolicyMetadata role = vdb.getDataPolicy("roleOne"); //$NON-NLS-1$
+ assertTrue(role.isAllowCreateTemporaryTables());
+ assertEquals("roleOne described", role.getDescription()); //$NON-NLS-1$
+ assertNotNull(role.getMappedRoleNames());
+ assertTrue(role.getMappedRoleNames().contains("ROLE1")); //$NON-NLS-1$
+ assertTrue(role.getMappedRoleNames().contains("ROLE2")); //$NON-NLS-1$
+
+ List<DataPolicy.DataPermission> permissions = role.getPermissions();
+ assertEquals(2, permissions.size());
+
+ for (DataPolicy.DataPermission p: permissions) {
+ if (p.getResourceName().equalsIgnoreCase("myTable.T1")) { //$NON-NLS-1$
+ assertTrue(p.getAllowRead());
+ assertNull(p.getAllowDelete());
+ }
+ else {
+ assertFalse(p.getAllowRead());
+ assertTrue(p.getAllowDelete());
+ }
+ }
+ }
+
+ private VDBMetaData buildVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("myVDB"); //$NON-NLS-1$
+ vdb.setDescription("vdb description"); //$NON-NLS-1$
+ vdb.setVersion(1);
+ vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$
+ vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ ModelMetaData modelOne = new ModelMetaData();
+ modelOne.setName("model-one"); //$NON-NLS-1$
+ modelOne.addSourceMapping("s1", "translator", "java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setModelType(Model.Type.PHYSICAL); //$NON-NLS-1$
+ modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.addProperty("model-prop", "model-value-override"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setVisible(false);
+ modelOne.addError("ERROR", "There is an error in VDB"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setDescription("model description");
+
+ vdb.addModel(modelOne);
+
+ ModelMetaData modelTwo = new ModelMetaData();
+ modelTwo.setName("model-two"); //$NON-NLS-1$
+ modelTwo.addSourceMapping("s1", "translator", "java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.addSourceMapping("s2", "translator", "java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.setModelType(Model.Type.VIRTUAL); //$NON-NLS-1$
+ modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ vdb.addModel(modelTwo);
+
+ VDBTranslatorMetaData t1 = new VDBTranslatorMetaData();
+ t1.setName("oracleOverride");
+ t1.setType("oracle");
+ t1.setDescription("hello world");
+ t1.addProperty("my-property", "my-value");
+ List<Translator> list = new ArrayList<Translator>();
+ list.add(t1);
+ vdb.setOverrideTranslators(list);
+
+ DataPolicyMetadata roleOne = new DataPolicyMetadata();
+ roleOne.setName("roleOne"); //$NON-NLS-1$
+ roleOne.setDescription("roleOne described"); //$NON-NLS-1$
+ roleOne.setAllowCreateTemporaryTables(true);
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
+ perm1.setAllowRead(true);
+ roleOne.addPermission(perm1);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
+ perm2.setAllowRead(false);
+ perm2.setAllowDelete(true);
+ roleOne.addPermission(perm2);
+
+ roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ vdb.addDataPolicy(roleOne);
+ return vdb;
+ }
+
+ @Test
+ public void testAdminMOCreation() {
+ VDBMetaData vdb = new VDBMetaData();
+
+ PropertiesUtils.setBeanProperty(vdb, "url", "http://teiid.org/myvdb.vdb");
+
+ assertEquals("http://teiid.org/myvdb.vdb", vdb.getUrl());
+ }
+
+ @Test public void testSetUrlVersion() throws MalformedURLException {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("foo");
+ vdb.setUrl(new URL("file:///x/foo.2.vdb"));
+ assertEquals(2, vdb.getVersion());
+ }
+
+ @Test public void testVDBMetaDataMapper() {
+ VDBMetaData vdb = buildVDB();
+
+ ModelNode node = MetadataMapper.wrap(vdb, new ModelNode());
+
+ vdb = MetadataMapper.unwrap(node);
+ validateVDB(vdb);
+ }
+
+ @Test
+ public void testVDBMetaDataDescribe() throws Exception {
+ ModelNode node = MetadataMapper.describe(new ModelNode());
+ String actual = node.toJSONString(false);
+ assertEquals(ObjectConverterUtil.convertFileToString(new File(UnitTestUtil.getTestDataPath() + "/vdb-describe.txt")), actual);
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,17 @@
+package org.teiid.adminapi.impl;
+
+import java.io.FileInputStream;
+
+import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestVDBMetadataParser {
+
+ @Test
+ public void testparseVDB() throws Exception {
+ FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml");
+ VDBMetaData vdb = VDBMetadataParser.unmarshell(in);
+ TestVDBMetaData.validateVDB(vdb);
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/adminshell/pom.xml
===================================================================
--- branches/as7/adminshell/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/adminshell/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -25,6 +25,10 @@
<artifactId>teiid-client</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
Modified: branches/as7/api/pom.xml
===================================================================
--- branches/as7/api/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/api/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -25,6 +25,12 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -9,6 +9,7 @@
<resource-root path="teiid-metadata-${project.version}.jar" />
<resource-root path="teiid-runtime-${project.version}.jar" />
<resource-root path="teiid-engine-${project.version}.jar" />
+ <resource-root path="teiid-admin-${project.version}.jar" />
<resource-root path="saxonhe-9.2.1.5.jar" />
<resource-root path="json-simple-1.1.jar" />
<resource-root path="conf" />
Modified: branches/as7/connectors/pom.xml
===================================================================
--- branches/as7/connectors/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/connectors/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -44,6 +44,11 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-engine</artifactId>
<scope>test</scope>
</dependency>
Modified: branches/as7/engine/pom.xml
===================================================================
--- branches/as7/engine/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/engine/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -47,6 +47,12 @@
<artifactId>teiid-client</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
Property changes on: branches/as7/jboss-integration
___________________________________________________________________
Modified: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
transaction.log
Modified: branches/as7/jboss-integration/pom.xml
===================================================================
--- branches/as7/jboss-integration/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -30,6 +30,11 @@
</dependency>
<dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<scope>provided</scope>
Added: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.OperationStepHandler;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+
+public abstract class BaseOperationHandler<T> implements DescriptionProvider, OperationStepHandler {
+ private static final String DESCRIBE = ".describe"; //$NON-NLS-1$
+ protected static final String MISSING = ".missing"; //$NON-NLS-1$
+
+ private String operationName;
+
+ protected BaseOperationHandler(String operationName){
+ this.operationName = operationName;
+ }
+
+ public void register(ManagementResourceRegistration subsystem) {
+ subsystem.registerOperationHandler(this.operationName, this, this);
+ }
+
+ public String name() {
+ return this.operationName;
+ }
+
+ public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
+ if (context.getType() == OperationContext.Type.SERVER) {
+ context.addStep(new OperationStepHandler() {
+ public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
+
+ ModelNode model = context.getResult();
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ executeOperation(getService(context, pathAddress), operation, model);
+
+ context.completeStep();
+ }
+
+ }, OperationContext.Stage.RUNTIME);
+ }
+ else {
+ context.getResult().set("no metrics available"); //$NON-NLS-1$
+ }
+ context.completeStep();
+ }
+
+ @SuppressWarnings("unused")
+ protected T getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException{
+ return null;
+ }
+
+ @Override
+ public ModelNode getModelDescription(final Locale locale) {
+ final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
+ final ModelNode operation = new ModelNode();
+ operation.get(OPERATION_NAME).set(this.operationName);
+ operation.get(DESCRIPTION).set(bundle.getString(name()+DESCRIBE));
+ describeParameters(operation, bundle);
+ return operation;
+ }
+
+ protected String getReplyName() {
+ return name()+".reply"+DESCRIBE; //$NON-NLS-1$
+ }
+
+ protected String getParameterDescription(ResourceBundle bundle, String paramName) {
+ return bundle.getString(name()+"."+paramName+DESCRIBE); //$NON-NLS-1$
+ }
+
+ abstract protected void executeOperation(T service, ModelNode operation, ModelNode node) throws OperationFailedException;
+
+ protected void describeParameters(@SuppressWarnings("unused") ModelNode operationNode, @SuppressWarnings("unused")ResourceBundle bundle) {
+ }
+}
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -33,10 +33,7 @@
import javax.resource.spi.work.WorkManager;
import javax.transaction.TransactionManager;
-import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.*;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.NamingStore;
@@ -63,7 +60,7 @@
import org.teiid.transport.SSLConfiguration;
import org.teiid.transport.SocketConfiguration;
-class QueryEngineAdd extends AbstractBoottimeAddStepHandler implements DescriptionProvider {
+class QueryEngineAdd extends AbstractAddStepHandler implements DescriptionProvider {
@Override
public ModelNode getModelDescription(Locale locale) {
@@ -80,18 +77,27 @@
@Override
protected void populateModel(ModelNode operation, ModelNode model) {
- populateQueryEngine(operation, model);
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+ final String engineName = pathAddress.getLastElement().getValue();
+
+ populateQueryEngine(engineName, operation, model);
}
@Override
- protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
+ protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
+ final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
ServiceTarget target = context.getServiceTarget();
final JBossLifeCycleListener shutdownListener = new JBossLifeCycleListener();
-
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+ final String engineName = pathAddress.getLastElement().getValue();
+
// now build the engine
- final RuntimeEngineDeployer engine = buildQueryEngine(operation);
+ final RuntimeEngineDeployer engine = buildQueryEngine(engineName, operation);
engine.setSecurityHelper(new JBossSecurityHelper());
engine.setContainerLifeCycleListener(shutdownListener);
// TODO: none of the caching is configured..
@@ -161,8 +167,8 @@
}
- private RuntimeEngineDeployer buildQueryEngine(ModelNode node) {
- RuntimeEngineDeployer engine = new RuntimeEngineDeployer(node.require(Configuration.ENGINE_NAME).asString());
+ private RuntimeEngineDeployer buildQueryEngine(String engineName, ModelNode node) {
+ RuntimeEngineDeployer engine = new RuntimeEngineDeployer(engineName);
if (node.hasDefined(Configuration.MAX_THREADS)) {
engine.setMaxThreads(node.get(Configuration.MAX_THREADS).asInt());
@@ -280,7 +286,6 @@
}
static void describeQueryEngine(ModelNode node, String type, ResourceBundle bundle) {
- addAttribute(node, Configuration.ENGINE_NAME, type, bundle.getString(Configuration.ENGINE_NAME+Configuration.DESC), ModelType.STRING, true, null);
addAttribute(node, Configuration.MAX_THREADS, type, bundle.getString(Configuration.MAX_THREADS+DESC), ModelType.INT, false, "64"); //$NON-NLS-1$
addAttribute(node, Configuration.MAX_ACTIVE_PLANS, type, bundle.getString(Configuration.MAX_ACTIVE_PLANS+DESC), ModelType.INT, false, "20"); //$NON-NLS-1$
addAttribute(node, Configuration.USER_REQUEST_SOURCE_CONCURRENCY, type, bundle.getString(Configuration.USER_REQUEST_SOURCE_CONCURRENCY+DESC), ModelType.INT, false, "0"); //$NON-NLS-1$
@@ -343,10 +348,10 @@
addAttribute(node, Configuration.AUTH_MODE, type, bundle.getString(Configuration.AUTH_MODE+DESC), ModelType.STRING, false, "anonymous"); //$NON-NLS-1$
}
- private void populateQueryEngine(ModelNode operation, ModelNode model) {
- model.get(Configuration.ENGINE_NAME).set(operation.require(Configuration.ENGINE_NAME).asString());
+ private void populateQueryEngine(String engineName, ModelNode operation, ModelNode model) {
+ model.get(Configuration.ENGINE_NAME).set(engineName);
- if (operation.hasDefined(Configuration.MAX_THREADS)) {
+ if (operation.hasDefined(Configuration.MAX_THREADS)) {
model.get(Configuration.MAX_THREADS).set(operation.get(Configuration.MAX_THREADS).asInt());
}
if (operation.hasDefined(Configuration.MAX_ACTIVE_PLANS)) {
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -22,73 +22,49 @@
package org.teiid.jboss;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import static org.teiid.jboss.Configuration.addAttribute;
import java.util.Collection;
import java.util.List;
-import java.util.Locale;
import java.util.ResourceBundle;
-import org.jboss.as.controller.*;
-import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.impl.*;
+import org.teiid.adminapi.impl.MetadataMapper.TransactionMetadataMapper;
import org.teiid.adminapi.impl.MetadataMapper.VDBTranslatorMetaDataMapper;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.jboss.deployers.RuntimeEngineDeployer;
-abstract class QueryEngineOperationHandler extends AbstractAddStepHandler implements DescriptionProvider {
- private static final String DESCRIBE = ".describe"; //$NON-NLS-1$
+abstract class QueryEngineOperationHandler extends BaseOperationHandler<RuntimeEngineDeployer> {
- private String operationName;
-
protected QueryEngineOperationHandler(String operationName){
- this.operationName = operationName;
+ super(operationName);
}
@Override
- protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException{
-
+ protected RuntimeEngineDeployer getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ String serviceName = pathAddress.getLastElement().getValue();
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.engineServiceName(serviceName));
+ return RuntimeEngineDeployer.class.cast(sc.getValue());
}
+}
+
+abstract class TranslatorOperationHandler extends BaseOperationHandler<TranslatorRepository> {
+ protected TranslatorOperationHandler(String operationName){
+ super(operationName);
+ }
+
@Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.engineServiceName(operation.require(Configuration.ENGINE_NAME).asString()));
- RuntimeEngineDeployer engine = RuntimeEngineDeployer.class.cast(sc.getValue());
- executeOperation(engine, operation, model);
- }
-
-
- @Override
- public ModelNode getModelDescription(final Locale locale) {
- final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
- final ModelNode operation = new ModelNode();
- operation.get(OPERATION_NAME).set(this.operationName);
- operation.get(DESCRIPTION).set(bundle.getString(getBundleOperationName()+DESCRIBE));
- addAttribute(operation, Configuration.ENGINE_NAME, REQUEST_PROPERTIES, bundle.getString(Configuration.ENGINE_NAME+Configuration.DESC), ModelType.STRING, true, null);
- describeParameters(operation, bundle);
- return operation;
- }
-
- protected String getBundleOperationName() {
- return RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName; //$NON-NLS-1$
- }
-
- protected String getReplyName() {
- return getBundleOperationName()+".reply"+DESCRIBE; //$NON-NLS-1$
- }
-
- protected String getParameterDescription(ResourceBundle bundle, String parmName) {
- return bundle.getString(RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName+"."+parmName+DESCRIBE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- abstract protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException;
-
- protected void describeParameters(@SuppressWarnings("unused") ModelNode operationNode, @SuppressWarnings("unused")ResourceBundle bundle) {
+ public TranslatorRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.TRANSLATOR_REPO);
+ return TranslatorRepository.class.cast(sc.getValue());
}
}
@@ -100,6 +76,10 @@
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
node.set(engine.getRuntimeVersion());
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.STRING);
+ operationNode.get(REPLY_PROPERTIES, DESCRIBE).set(bundle.getString(getReplyName()));
+ }
}
class GetActiveSessionsCount extends QueryEngineOperationHandler{
@@ -114,38 +94,45 @@
// TODO: handle exception in model node terms
}
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.INT);
+ operationNode.get(REPLY_PROPERTIES, DESCRIBE).set(bundle.getString(getReplyName()));
+ }
}
class GetActiveSessions extends QueryEngineOperationHandler{
- protected GetActiveSessions(String operationName) {
- super(operationName);
+ protected GetActiveSessions() {
+ super("active-sessions"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
try {
Collection<SessionMetadata> sessions = engine.getActiveSessions();
for (SessionMetadata session:sessions) {
- node.add(MetadataMapper.SessionMetadataMapper.wrap(session, node.add()));
+ MetadataMapper.SessionMetadataMapper.wrap(session, node.add());
}
} catch (AdminException e) {
// TODO: handle exception in model node terms
}
}
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.SessionMetadataMapper.describe(new ModelNode()));
+ }
}
class GetRequestsPerSession extends QueryEngineOperationHandler{
- protected GetRequestsPerSession(String operationName) {
- super(operationName);
+ protected GetRequestsPerSession() {
+ super("requests-per-session"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
List<RequestMetadata> requests = engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
for (RequestMetadata request:requests) {
- node.add(MetadataMapper.RequestMetadataMapper.wrap(request, node.add()));
+ MetadataMapper.RequestMetadataMapper.wrap(request, node.add());
}
}
@@ -154,27 +141,33 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
- //TODO: define response??
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.RequestMetadataMapper.describe(new ModelNode()));
}
}
class GetRequestsPerVDB extends QueryEngineOperationHandler{
- protected GetRequestsPerVDB(String operationName) {
- super(operationName);
+ protected GetRequestsPerVDB() {
+ super("requests-per-vdb"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
try {
+
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
List<RequestMetadata> requests = engine.getRequestsUsingVDB(vdbName,vdbVersion);
for (RequestMetadata request:requests) {
- node.add(MetadataMapper.RequestMetadataMapper.wrap(request, node.add()));
+ MetadataMapper.RequestMetadataMapper.wrap(request, node.add());
}
} catch (AdminException e) {
- // TODO: handle exception in model node terms
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
}
}
@@ -187,31 +180,35 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
- //TODO: define response??
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.RequestMetadataMapper.describe(new ModelNode()));
}
}
class GetLongRunningQueries extends QueryEngineOperationHandler{
- protected GetLongRunningQueries(String operationName) {
- super(operationName);
+ protected GetLongRunningQueries() {
+ super("long-running-queries"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
List<RequestMetadata> requests = engine.getLongRunningRequests();
for (RequestMetadata request:requests) {
- node.add(MetadataMapper.RequestMetadataMapper.wrap(request, node.add()));
+ MetadataMapper.RequestMetadataMapper.wrap(request, node.add());
}
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.RequestMetadataMapper.describe(new ModelNode()));
+ }
}
class TerminateSession extends QueryEngineOperationHandler{
- protected TerminateSession(String operationName) {
- super(operationName);
+ protected TerminateSession() {
+ super("terminate-session"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
engine.terminateSession(operation.get(OperationsConstants.SESSION).asString());
}
@@ -223,15 +220,19 @@
}
class CancelQuery extends QueryEngineOperationHandler{
- protected CancelQuery(String operationName) {
- super(operationName);
+ protected CancelQuery() {
+ super("cancel-query"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
try {
- engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(), operation.get(OperationsConstants.EXECUTION_ID).asLong());
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
+ boolean pass = engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(), operation.get(OperationsConstants.EXECUTION_ID).asLong());
+ node.set(pass);
} catch (AdminException e) {
- // TODO: handle exception in model node terms
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
}
}
@@ -243,30 +244,45 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, TYPE).set(ModelType.LONG);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.EXECUTION_ID));
+
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.BOOLEAN);
+ operationNode.get(REPLY_PROPERTIES, DESCRIBE).set(bundle.getString(getReplyName()));
}
}
class CacheTypes extends QueryEngineOperationHandler{
- protected CacheTypes(String operationName) {
- super(operationName);
+ protected CacheTypes() {
+ super("cache-types"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
- node.get(TYPE).set(ModelType.LIST);
Collection<String> types = engine.getCacheTypes();
for (String type:types) {
node.add(type);
}
}
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ ModelNode node = new ModelNode();
+ node.get(OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
+ node.get(OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
+ node.get(OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+ operationNode.get(REPLY_PROPERTIES).add(node);
+ }
}
class ClearCache extends QueryEngineOperationHandler{
- protected ClearCache(String operationName) {
- super(operationName);
+ protected ClearCache() {
+ super("clear-cache"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
+
String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
if (operation.get(OperationsConstants.VDB_NAME) != null && operation.get(OperationsConstants.VDB_VERSION) != null) {
@@ -297,11 +313,14 @@
class CacheStatistics extends QueryEngineOperationHandler{
- protected CacheStatistics(String operationName) {
- super(operationName);
+ protected CacheStatistics() {
+ super("cache-statistics"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
CacheStatisticsMetadata stats = engine.getCacheStatistics(cacheType);
MetadataMapper.CacheStatisticsMetadataMapper.wrap(stats, node);
@@ -311,51 +330,62 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+
+ ModelNode node = new ModelNode();
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.CacheStatisticsMetadataMapper.describe(node));
}
}
class WorkerPoolStatistics extends QueryEngineOperationHandler{
- protected WorkerPoolStatistics(String operationName) {
- super(operationName);
+ protected WorkerPoolStatistics() {
+ super("workerpool-statistics"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
WorkerPoolStatisticsMetadata stats = engine.getWorkerPoolStatistics();
MetadataMapper.WorkerPoolStatisticsMetadataMapper.wrap(stats, node);
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.WorkerPoolStatisticsMetadataMapper.describe(new ModelNode()));
+ }
}
class ActiveTransactions extends QueryEngineOperationHandler{
- protected ActiveTransactions(String operationName) {
- super(operationName);
+ protected ActiveTransactions() {
+ super("active-transactions"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
Collection<TransactionMetadata> txns = engine.getTransactions();
-
- node.get(TYPE).set(ModelType.LIST);
-
for (TransactionMetadata txn:txns) {
- node.add(MetadataMapper.TransactionMetadataMapper.wrap(txn, node.add()));
+ MetadataMapper.TransactionMetadataMapper.wrap(txn, node.add());
}
-
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ ModelNode node = new ModelNode();
+ operationNode.get(REPLY_PROPERTIES).add(TransactionMetadataMapper.describe(node));
+ }
}
class TerminateTransaction extends QueryEngineOperationHandler{
- protected TerminateTransaction(String operationName) {
- super(operationName);
+ protected TerminateTransaction() {
+ super("terminate-transaction"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.XID)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.XID+MISSING)));
+ }
+
String xid = operation.get(OperationsConstants.XID).asString();
try {
engine.terminateTransaction(xid);
} catch (AdminException e) {
- // TODO: Handle exception
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
}
}
@@ -366,19 +396,40 @@
}
}
-class MergeVDBs extends QueryEngineOperationHandler{
+class MergeVDBs extends BaseOperationHandler<VDBRepository>{
- protected MergeVDBs(String operationName) {
- super(operationName);
+ protected MergeVDBs() {
+ super("merge-vdbs"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(VDBRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.SOURCE_VDBNAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBNAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.SOURCE_VDBVERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBVERSION+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.TARGET_VDBNAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBNAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.TARGET_VDBVERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBVERSION+MISSING)));
+ }
+
String sourceVDBName = operation.get(OperationsConstants.SOURCE_VDBNAME).asString();
int sourceVDBversion = operation.get(OperationsConstants.SOURCE_VDBVERSION).asInt();
String targetVDBName = operation.get(OperationsConstants.TARGET_VDBNAME).asString();
int targetVDBversion = operation.get(OperationsConstants.TARGET_VDBVERSION).asInt();
try {
- engine.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
+ repo.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
} catch (AdminException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -405,18 +456,30 @@
class ExecuteQuery extends QueryEngineOperationHandler{
- protected ExecuteQuery(String operationName) {
- super(operationName);
+ protected ExecuteQuery() {
+ super("execute-query"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.SQL_QUERY)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SQL_QUERY+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.TIMEOUT_IN_MILLI)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TIMEOUT_IN_MILLI+MISSING)));
+ }
+
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
String sql = operation.get(OperationsConstants.SQL_QUERY).asString();
int timeout = operation.get(OperationsConstants.TIMEOUT_IN_MILLI).asInt();
try {
- node.get(TYPE).set(ModelType.LIST);
-
List<List> results = engine.executeQuery(vdbName, vdbVersion, sql, timeout);
List colNames = results.get(0);
for (int rowNum = 1; rowNum < results.size(); rowNum++) {
@@ -452,20 +515,36 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TIMEOUT_IN_MILLI));
+
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.LIST);
}
}
-class GetVDB extends QueryEngineOperationHandler{
+class GetVDB extends BaseOperationHandler<VDBRepository>{
- protected GetVDB(String operationName) {
- super(operationName);
+ protected GetVDB() {
+ super("get-vdb"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(VDBRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- VDBMetaData vdb = engine.getVDB(vdbName, vdbVersion);
+ VDBMetaData vdb = repo.getVDB(vdbName, vdbVersion);
MetadataMapper.wrap(vdb, node);
}
@@ -477,59 +556,71 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ operationNode.get(REPLY_PROPERTIES).set(MetadataMapper.describe(new ModelNode()));
}
}
-class GetVDBs extends QueryEngineOperationHandler{
+class ListVDBs extends BaseOperationHandler<VDBRepository>{
- protected GetVDBs(String operationName) {
- super(operationName);
+ protected ListVDBs() {
+ super("list-vdbs"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
- List<VDBMetaData> vdbs = engine.getVDBs();
- node.get(TYPE).set(ModelType.LIST);
-
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(VDBRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ List<VDBMetaData> vdbs = repo.getVDBs();
for (VDBMetaData vdb:vdbs) {
node.add(MetadataMapper.wrap(vdb, node.add()));
}
}
-
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.describe(new ModelNode()));
+ }
}
-class GetTranslators extends QueryEngineOperationHandler{
+class GetTranslators extends TranslatorOperationHandler{
- protected GetTranslators(String operationName) {
- super(operationName);
+ protected GetTranslators() {
+ super("list-translators"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
- List<VDBTranslatorMetaData> translators = engine.getTranslators();
- node.get(TYPE).set(ModelType.OBJECT);
-
+ protected void executeOperation(TranslatorRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ List<VDBTranslatorMetaData> translators = repo.getTranslators();
for (VDBTranslatorMetaData t:translators) {
node.add(MetadataMapper.VDBTranslatorMetaDataMapper.wrap(t, node.add()));
}
}
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES, TYPE).set(ModelType.LIST);
- operationNode.get(REPLY_PROPERTIES, VALUE_TYPE).set(ModelType.OBJECT);
operationNode.get(REPLY_PROPERTIES, DESCRIPTION).set(bundle.getString(getReplyName()));
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.VDBTranslatorMetaDataMapper.describe(new ModelNode()));
}
}
-class GetTranslator extends QueryEngineOperationHandler{
+class GetTranslator extends TranslatorOperationHandler{
- protected GetTranslator(String operationName) {
- super(operationName);
+ protected GetTranslator() {
+ super("get-translator"); //$NON-NLS-1$
}
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ protected void executeOperation(TranslatorRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
+ }
+
String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
- VDBTranslatorMetaData translator = engine.getTranslator(translatorName);
+ VDBTranslatorMetaData translator = repo.getTranslatorMetaData(translatorName);
MetadataMapper.VDBTranslatorMetaDataMapper.wrap(translator, node);
}
@@ -538,7 +629,36 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
- VDBTranslatorMetaDataMapper.describe(operationNode.get(REPLY_PROPERTIES));
+ operationNode.get(REPLY_PROPERTIES).set(VDBTranslatorMetaDataMapper.describe(new ModelNode()));
operationNode.get(REPLY_PROPERTIES, DESCRIPTION).set(bundle.getString(getReplyName()));
}
+}
+
+class ListQueryEngines extends TranslatorOperationHandler{
+
+ protected ListQueryEngines() {
+ super("list-engines"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(TranslatorRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
+ }
+
+ String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
+
+ VDBTranslatorMetaData translator = repo.getTranslatorMetaData(translatorName);
+ MetadataMapper.VDBTranslatorMetaDataMapper.wrap(translator, node);
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
+
+ operationNode.get(REPLY_PROPERTIES).set(VDBTranslatorMetaDataMapper.describe(new ModelNode()));
+ operationNode.get(REPLY_PROPERTIES, DESCRIPTION).set(bundle.getString(getReplyName()));
+ }
}
\ No newline at end of file
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -21,53 +21,59 @@
*/
package org.teiid.jboss;
-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.REMOVE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.teiid.jboss.Configuration.addAttribute;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
+import org.teiid.transport.LocalServerConnection;
-public class QueryEngineRemove extends AbstractAddStepHandler implements DescriptionProvider {
+public class QueryEngineRemove extends AbstractRemoveStepHandler implements DescriptionProvider {
@Override
+ protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ String engineName = pathAddress.getLastElement().getValue();
+
+ final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
+ ServiceName serviceName = TeiidServiceNames.engineServiceName(engineName);
+ final ServiceController<?> controller = serviceRegistry.getService(serviceName);
+ if (controller != null) {
+ context.removeService(serviceName);
+ }
+
+ final ServiceName referenceFactoryServiceName = TeiidServiceNames.engineServiceName(engineName).append("reference-factory"); //$NON-NLS-1$
+ final ServiceController<?> referceFactoryController = serviceRegistry.getService(referenceFactoryServiceName);
+ if (referceFactoryController != null) {
+ context.removeService(referenceFactoryServiceName);
+ }
+
+ final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(LocalServerConnection.TEIID_RUNTIME_CONTEXT+engineName);
+ final ServiceController<?> binderController = serviceRegistry.getService(bindInfo.getBinderServiceName());
+ if (binderController != null) {
+ context.removeService(bindInfo.getBinderServiceName());
+ }
+ }
+
+ @Override
public ModelNode getModelDescription(Locale locale) {
final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
final ModelNode operation = new ModelNode();
operation.get(OPERATION_NAME).set(REMOVE);
- operation.get(DESCRIPTION).set(bundle.getString("engine.remove")); //$NON-NLS-1$
- addAttribute(operation, Configuration.ENGINE_NAME, REQUEST_PROPERTIES, bundle.getString(Configuration.ENGINE_NAME+Configuration.DESC), ModelType.STRING, true, null);
+ operation.get(DESCRIPTION).set(bundle.getString(REMOVE+DESCRIBE));
return operation;
}
-
- @Override
- protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
- final String name = model.require(Configuration.ENGINE_NAME).asString();
- model.get(Configuration.ENGINE_NAME).set(name);
- }
-
- @Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- final String engineName = model.require(Configuration.ENGINE_NAME).asString();
- final ServiceRegistry registry = context.getServiceRegistry(true);
- final ServiceController<?> controller = registry.getService(TeiidServiceNames.translatorServiceName(engineName));
- if (controller != null) {
- controller.setMode(ServiceController.Mode.REMOVE);
- }
- }
+
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -117,6 +117,10 @@
}
populateBufferManager(operation, model);
//TODO: add cache model descriptions
+
+ // these are just place holders
+// model.get(Configuration.QUERY_ENGINE);
+// model.get(Configuration.TRANSLATOR);
}
@Override
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -45,22 +45,6 @@
private static final String ACTIVE_SESSION_COUNT = "active-session-count"; //$NON-NLS-1$
private static final String RUNTIME_VERSION = "runtime-version"; //$NON-NLS-1$
- private static final String REQUESTS_PER_SESSION = "requests-per-session"; //$NON-NLS-1$
- private static final String ACTIVE_SESSIONS = "active-sessions"; //$NON-NLS-1$
- private static final String REQUESTS_PER_VDB = "requests-per-vdb"; //$NON-NLS-1$
- private static final String LONG_RUNNING_QUERIES = "long-running-queries"; //$NON-NLS-1$
- private static final String TERMINATE_SESSION = "terminate-session";//$NON-NLS-1$
- private static final String CANCEL_QUERY = "cancel-query";//$NON-NLS-1$
- private static final String CACHE_TYPES = "cache-types";//$NON-NLS-1$
- private static final String CLEAR_CACHE = "clear-cache";//$NON-NLS-1$
- private static final String CACHE_STATISTICS = "cache-statistics";//$NON-NLS-1$
- private static final String WORKERPOOL_STATISTICS = "workerpool-statistics";//$NON-NLS-1$
- private static final String ACTIVE_TRANSACTIONS = "active-transactions";//$NON-NLS-1$
- private static final String TERMINATE_TRANSACTION = "terminate-transaction";//$NON-NLS-1$
- private static final String MERGE_VDBS = "merge-vdbs";//$NON-NLS-1$
- private static final String EXECUTE_QUERY = "execute-query";//$NON-NLS-1$
- private static final String GETVDBS = "getVDBs";//$NON-NLS-1$
- private static final String GETVDB = "getVDB";//$NON-NLS-1$
public static final String TEIID_SUBSYSTEM = "teiid"; //$NON-NLS-1$
private static TeiidSubsystemParser parser = new TeiidSubsystemParser();
@@ -92,10 +76,10 @@
TeiidBootServicesAdd.describeTeiidRoot(bundle, ATTRIBUTES, node);
node.get(CHILDREN, Configuration.QUERY_ENGINE, DESCRIPTION).set(bundle.getString(Configuration.QUERY_ENGINE+Configuration.DESC));
- node.get(CHILDREN, Configuration.QUERY_ENGINE, REQUIRED).set(false);
+ node.get(CHILDREN, Configuration.QUERY_ENGINE, REQUIRED).set(true);
node.get(CHILDREN, Configuration.TRANSLATOR, DESCRIPTION).set(bundle.getString(Configuration.TRANSLATOR+Configuration.DESC));
- node.get(CHILDREN, Configuration.TRANSLATOR, REQUIRED).set(false);
+ node.get(CHILDREN, Configuration.TRANSLATOR, REQUIRED).set(true);
return node;
}
@@ -113,8 +97,6 @@
node.get(DESCRIPTION).set(bundle.getString(Configuration.TRANSLATOR+Configuration.DESC));
node.get(HEAD_COMMENT_ALLOWED).set(true);
node.get(TAIL_COMMENT_ALLOWED).set(true);
-
- addAttribute(node, Configuration.TRANSLATOR_NAME, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_NAME+Configuration.DESC), ModelType.STRING, true, null);
addAttribute(node, Configuration.TRANSLATOR_MODULE, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_MODULE+Configuration.DESC), ModelType.STRING, true, null);
return node;
}
@@ -141,57 +123,30 @@
engineSubsystem.registerOperationHandler(REMOVE, ENGINE_REMOVE, ENGINE_REMOVE, false);
- QueryEngineOperationHandler op;
engineSubsystem.registerReadOnlyAttribute(RUNTIME_VERSION, new GetRuntimeVersion(RUNTIME_VERSION), Storage.RUNTIME);
engineSubsystem.registerReadOnlyAttribute(ACTIVE_SESSION_COUNT, new GetActiveSessionsCount(ACTIVE_SESSION_COUNT), Storage.RUNTIME);
- op = new GetActiveSessions(ACTIVE_SESSIONS);
- engineSubsystem.registerOperationHandler(ACTIVE_SESSIONS, op, op);
+ // teiid level admin api operation handlers
+ new GetTranslator().register(teiidSubsystem);
+ new GetTranslators().register(teiidSubsystem);
+ new MergeVDBs().register(teiidSubsystem);
+ new ListVDBs().register(teiidSubsystem);
+ new GetVDB().register(teiidSubsystem);
- op = new GetRequestsPerSession(REQUESTS_PER_SESSION);
- engineSubsystem.registerOperationHandler(REQUESTS_PER_SESSION, op, op);
-
- op = new GetRequestsPerVDB(REQUESTS_PER_VDB);
- engineSubsystem.registerOperationHandler(REQUESTS_PER_VDB, op, op);
-
- op = new GetLongRunningQueries(LONG_RUNNING_QUERIES);
- engineSubsystem.registerOperationHandler(LONG_RUNNING_QUERIES, op, op);
-
- op = new TerminateSession(TERMINATE_SESSION);
- engineSubsystem.registerOperationHandler(TERMINATE_SESSION, op, op);
-
- op = new CancelQuery(CANCEL_QUERY);
- engineSubsystem.registerOperationHandler(CANCEL_QUERY, op, op);
-
- op = new CacheTypes(CACHE_TYPES);
- engineSubsystem.registerOperationHandler(CACHE_TYPES, op, op);
-
- op = new ClearCache(CLEAR_CACHE);
- engineSubsystem.registerOperationHandler(CLEAR_CACHE, op, op);
-
- op = new CacheStatistics(CACHE_STATISTICS);
- engineSubsystem.registerOperationHandler(CACHE_STATISTICS, op, op);
-
- op = new WorkerPoolStatistics(WORKERPOOL_STATISTICS);
- engineSubsystem.registerOperationHandler(WORKERPOOL_STATISTICS, op, op);
-
- op = new ActiveTransactions(ACTIVE_TRANSACTIONS);
- engineSubsystem.registerOperationHandler(ACTIVE_TRANSACTIONS, op, op);
-
- op = new TerminateTransaction(TERMINATE_TRANSACTION);
- engineSubsystem.registerOperationHandler(TERMINATE_TRANSACTION, op, op);
-
- op = new MergeVDBs(MERGE_VDBS);
- engineSubsystem.registerOperationHandler(MERGE_VDBS, op, op);
-
- op = new ExecuteQuery(EXECUTE_QUERY);
- engineSubsystem.registerOperationHandler(EXECUTE_QUERY, op, op);
-
- op = new GetVDBs(GETVDBS);
- engineSubsystem.registerOperationHandler(GETVDBS, op, op);
-
- op = new GetVDB(GETVDB);
- engineSubsystem.registerOperationHandler(GETVDB, op, op);
+ // engine level admin api handlers
+ new GetActiveSessions().register(engineSubsystem);
+ new GetRequestsPerSession().register(engineSubsystem);
+ new GetRequestsPerVDB().register(engineSubsystem);
+ new GetLongRunningQueries().register(engineSubsystem);
+ new TerminateSession().register(engineSubsystem);
+ new CancelQuery().register(engineSubsystem);
+ new CacheTypes().register(engineSubsystem);
+ new ClearCache().register(engineSubsystem);
+ new CacheStatistics().register(engineSubsystem);
+ new WorkerPoolStatistics().register(engineSubsystem);
+ new ActiveTransactions().register(engineSubsystem);
+ new TerminateTransaction().register(engineSubsystem);
+ new ExecuteQuery().register(engineSubsystem);
}
@Override
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -348,11 +348,11 @@
case SECURITY_DOMAIN_ELEMENT:
node.get(reader.getLocalName()).add(reader.getElementText());
break;
-
case JDBC_ELEMENT:
node.get(reader.getLocalName()).set(parseSocketConfiguration(reader));
break;
+
case ODBC_ELEMENT:
node.get(reader.getLocalName()).set(parseSocketConfiguration(reader));
break;
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -55,7 +55,6 @@
operation.get(OPERATION_NAME).set(ADD);
operation.get(DESCRIPTION).set(bundle.getString("translator.add")); //$NON-NLS-1$
- addAttribute(operation, Configuration.TRANSLATOR_NAME, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_NAME+Configuration.DESC), ModelType.STRING, true, null);
addAttribute(operation, Configuration.TRANSLATOR_MODULE, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_MODULE+Configuration.DESC), ModelType.STRING, true, null);
return operation;
}
@@ -75,7 +74,11 @@
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
- final String name = operation.require(Configuration.TRANSLATOR_NAME).asString();
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ final String translatorName = pathAddress.getLastElement().getValue();
+
final String moduleName = operation.require(Configuration.TRANSLATOR_MODULE).asString();
final ServiceTarget target = context.getServiceTarget();
@@ -86,25 +89,32 @@
moduleId = ModuleIdentifier.create(moduleName);
module = Module.getCallerModuleLoader().loadModule(moduleId);
} catch (ModuleLoadException e) {
- throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName, name))); //$NON-NLS-1$
+ throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName, translatorName))); //$NON-NLS-1$
}
+
+ boolean added = false;
final ServiceLoader<ExecutionFactory> serviceLoader = module.loadService(ExecutionFactory.class);
if (serviceLoader != null) {
for (ExecutionFactory ef:serviceLoader) {
VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(ef, moduleName);
if (metadata == null) {
- throw new OperationFailedException( new ModelNode().set(IntegrationPlugin.Util.getString("error_adding_translator", name))); //$NON-NLS-1$
+ throw new OperationFailedException( new ModelNode().set(IntegrationPlugin.Util.getString("error_adding_translator", translatorName))); //$NON-NLS-1$
}
- if (name.equalsIgnoreCase(metadata.getName())) {
+ if (translatorName.equalsIgnoreCase(metadata.getName())) {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("translator.added", metadata.getName())); //$NON-NLS-1$
TranslatorService translatorService = new TranslatorService(metadata);
ServiceBuilder<VDBTranslatorMetaData> builder = target.addService(TeiidServiceNames.translatorServiceName(metadata.getName()), translatorService);
builder.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, translatorService.repositoryInjector);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
+ added = true;
}
}
}
+
+ if (!added) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString("translator.failed-to-load", translatorName, moduleName))); //$NON-NLS-1$
+ }
}
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -23,25 +23,24 @@
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.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.teiid.jboss.Configuration.addAttribute;
-import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
-public class TranslatorRemove extends AbstractAddStepHandler implements DescriptionProvider {
+public class TranslatorRemove extends AbstractRemoveStepHandler implements DescriptionProvider {
@Override
public ModelNode getModelDescription(Locale locale) {
@@ -49,25 +48,23 @@
final ModelNode operation = new ModelNode();
operation.get(OPERATION_NAME).set(REMOVE);
operation.get(DESCRIPTION).set(bundle.getString("translator.remove")); //$NON-NLS-1$
- addAttribute(operation, Configuration.TRANSLATOR_NAME, REQUEST_PROPERTIES, bundle.getString(Configuration.TRANSLATOR_NAME+Configuration.DESC), ModelType.STRING, true, null);
return operation;
}
@Override
- protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
- final String translatorName = model.require(Configuration.TRANSLATOR_NAME).asString();
- model.get(Configuration.TRANSLATOR_NAME).set(translatorName);
- }
-
- @Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- final String translatorName = model.require(Configuration.TRANSLATOR_NAME).asString();
- final ServiceRegistry registry = context.getServiceRegistry(true);
- final ServiceController<?> controller = registry.getService(TeiidServiceNames.translatorServiceName(translatorName));
+ protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ String translatorName = pathAddress.getLastElement().getValue();
+
+ final ServiceRegistry registry = context.getServiceRegistry(true);
+ final ServiceName serviceName = TeiidServiceNames.translatorServiceName(translatorName);
+ final ServiceController<?> controller = registry.getService(serviceName);
if (controller != null) {
- controller.setMode(ServiceController.Mode.REMOVE);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("translator.removed", translatorName)); //$NON-NLS-1$
+ context.removeService(serviceName);
}
}
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -466,12 +466,6 @@
}
@Override
- public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
- String targetVDBName, int targetVDBVersion) throws AdminException {
- this.vdbRepository.mergeVDBs(sourceVDBName, sourceVDBVersion, targetVDBName, targetVDBVersion);
- }
-
- @Override
public List<List> executeQuery(final String vdbName, final int version, final String command, final long timoutInMilli) throws AdminException {
String user = "JOPR ADMIN"; //$NON-NLS-1$
@@ -773,22 +767,6 @@
this.securityDomainNames.add(domain);
}
- public List<VDBMetaData> getVDBs(){
- return this.vdbRepository.getVDBs();
- }
-
- public VDBMetaData getVDB(String vdbName, int version){
- return this.vdbRepository.getVDB(vdbName, version);
- }
-
- public List<VDBTranslatorMetaData> getTranslators(){
- return getTranslatorRepositoryInjector().getValue().getTranslators();
- }
-
- public VDBTranslatorMetaData getTranslator(String translatorName) {
- return getTranslatorRepositoryInjector().getValue().getTranslatorMetaData(translatorName);
- }
-
private DQPCore.ContextProvider getContextProvider() {
return new DQPCore.ContextProvider() {
@Override
Modified: branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-09-02 20:49:18 UTC (rev 3445)
@@ -33,6 +33,7 @@
datasource_not_found=Datasource {0} not found in the configuration.
sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
vdb_file_not_found = VDB file {0} not found at the location specified.
+socket_not_enabled=Socket based remote JDBC protocol is not enabled.
no_operation=No operation found with given name = {0}
failed_to_remove=Failed to remove the deployment
@@ -146,43 +147,43 @@
susbsystem.add = Add the Teiid Subsystem
#engine managed operations
-RuntimeEngineDeployer.active-sessions.describe=List of all the current active sessions in the Teiid subsystem.
-RuntimeEngineDeployer.requests-per-session.describe=Current active requests in progress in the query engine for a given session identifier
-RuntimeEngineDeployer.requests-per-session.session.describe=The session Identifier
-RuntimeEngineDeployer.requests-per-vdb.describe=Current active requests in progress in the query engine for a given VDB name and its version.
-RuntimeEngineDeployer.requests-per-vdb.vdb_name.describe=VDB Name
-RuntimeEngineDeployer.requests-per-vdb.vdb_version.describe=VDB Version
-RuntimeEngineDeployer.long-running-queries.describe=Long running queries that exceeded the threshold set by the 'queryThresholdInSecs' configuration property.
-RuntimeEngineDeployer.terminate-session.describe=Terminate the session
-RuntimeEngineDeployer.terminate-session.session.describe=The session Identifier of session to be terminated
-RuntimeEngineDeployer.cancel-query.describe=Cancel the execution of the actively running query
-RuntimeEngineDeployer.cancel-query.session.describe=The session Identifier of the user
-RuntimeEngineDeployer.cancel-query.execution-id.describe=The Execution Identifier of the query
-RuntimeEngineDeployer.cache-types.describe=List the available cache types
+active-sessions.describe=List of all the current active sessions in the Teiid subsystem.
+requests-per-session.describe=Current active requests in progress in the query engine for a given session identifier
+requests-per-session.session.describe=The session Identifier
+requests-per-vdb.describe=Current active requests in progress in the query engine for a given VDB name and its version.
+requests-per-vdb.vdb_name.describe=VDB Name
+requests-per-vdb.vdb_version.describe=VDB Version
+long-running-queries.describe=Long running queries that exceeded the threshold set by the 'queryThresholdInSecs' configuration property.
+terminate-session.describe=Terminate the session
+terminate-session.session.describe=The session Identifier of session to be terminated
+cancel-query.describe=Cancel the execution of the actively running query
+cancel-query.session.describe=The session Identifier of the user
+cancel-query.execution-id.describe=The Execution Identifier of the query
+cache-types.describe=List the available cache types
-RuntimeEngineDeployer.clear-cache.describe=Clear the caches in the system of the given type
-RuntimeEngineDeployer.clear-cache.cache-type.describe=cache type to be cleared. (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
-RuntimeEngineDeployer.clear-cache.vdb-name.describe=VDB name
-RuntimeEngineDeployer.clear-cache.vdb_version.describe=VDB version
-RuntimeEngineDeployer.cache-statistics.describe=Get the cache statistics for the given cache type
-RuntimeEngineDeployer.cache-statistics.cache-type.describe=cache type (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
+clear-cache.describe=Clear the caches in the system of the given type
+clear-cache.cache-type.describe=cache type to be cleared. (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
+clear-cache.vdb-name.describe=VDB name
+clear-cache.vdb_version.describe=VDB version
+cache-statistics.describe=Get the cache statistics for the given cache type
+cache-statistics.cache-type.describe=cache type (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
-RuntimeEngineDeployer.workerpool-statistics.describe=Get thread statistics worker pool
-RuntimeEngineDeployer.active-transactions.describe=Active Transactions in the Query Engine
+workerpool-statistics.describe=Get thread statistics worker pool
+active-transactions.describe=Active Transactions in the Query Engine
-RuntimeEngineDeployer.terminate-transaction.describe=Terminate the XA transaction
-RuntimeEngineDeployer.terminate-transaction.xid.describe=xid identifier of the XA transaction
-RuntimeEngineDeployer.merge-vdbs.describe=Merge Two VDBs
-RuntimeEngineDeployer.merge-vdbs.source-vdb-name.describe=Source VDB name
-RuntimeEngineDeployer.merge-vdbs.source-vdb-version.describe=Source VDB version number
-RuntimeEngineDeployer.merge-vdbs.target-vdb-name.describe=Target VDB name
-RuntimeEngineDeployer.merge-vdbs.target-vdb-version.describe=Target VDB version number
+terminate-transaction.describe=Terminate the XA transaction
+terminate-transaction.xid.describe=xid identifier of the XA transaction
+merge-vdbs.describe=Merge Two VDBs
+merge-vdbs.source-vdb-name.describe=Source VDB name
+merge-vdbs.source-vdb-version.describe=Source VDB version number
+merge-vdbs.target-vdb-name.describe=Target VDB name
+merge-vdbs.target-vdb-version.describe=Target VDB version number
-RuntimeEngineDeployer.execute-query.describe=Execute a sql query
-RuntimeEngineDeployer.execute-query.vdb-name.describe=vdb name
-RuntimeEngineDeployer.execute-query.vdb-version.describe=vdb version
-RuntimeEngineDeployer.execute-query.sql-query.describe=sql query to execute
-RuntimeEngineDeployer.execute-query.timeout-in-milli.describe=timeout
+execute-query.describe=Execute a sql query
+execute-query.vdb-name.describe=vdb name
+execute-query.vdb-version.describe=vdb version
+execute-query.sql-query.describe=sql query to execute
+execute-query.timeout-in-milli.describe=timeout
socket-binding.not_defined=Teiid socket binding not defined for JDBC or ODBC port.
@@ -193,4 +194,41 @@
translator.describe = Teiid Translators
translator.add = Add Teiid translator
translator.remove = Remove Teiid translator
-teiid-boot.add = Teiid boot services
\ No newline at end of file
+teiid-boot.add = Teiid boot serviceshitRatio.describe
+
+total-entries.describe = Total entries in Cache
+hit-ratio.describe = Cache Hit ratio
+request-count.describe=Total request count
+
+cache-types.cache-type.describe=cache type
+get-translators.reply.describe=Returns list of translators registered in the teiid container
+get-translator.reply.describe=Returns translator if found with given name
+active-session-count.reply.describe=Returns the count of active sessions
+runtime-version.reply.describe=Teiid runtime version
+list-vdbs.describe=List the available virtual databases in the system
+cancel-query.reply.describe=True if successful; false otherwise.
+clear-cache.vdb-version.describe=vdb version
+get-vdb.describe=Get the VDB with the given name and version
+get-vdb.vdb-name.describe=name of the vdb
+get-vdb.vdb-version.describe=vdb version
+requests-per-vdb.vdb-name.describe=vdb name
+requests-per-vdb.vdb-version.describe=vdb version
+remove.reply.describe=remove service
+remove.describe=remove service
+
+vdb-name.missing=Parameter "vdb-name" is required
+vdb-version.missing=Parameter "vdb-version" is required
+cache-type.missing=Parameter "cache-type" is required
+session.missing=Parameter "session" is required
+execution-id.missing=Parameter "execution-id" is required
+xid.missing=Parameter "xid" is required
+source-vdb-name.missing=Parameter "source-vdb-name" is required
+source-vdb-version.missing=Parameter "source-vdb-version" is required
+target-vdb-name.missing=Parameter "target-vdb-name" is required
+target-vdb-version.missing=Parameter "target-vdb-version" is required
+sql-query.missing=Parameter "sql-query" is required
+timeout-in-milli.missing=Parameter "timeout-in-milli" is required
+translator-name.missing=Parameter "translator-name" is required
+engine_service_not_found= Query Engine Service with name {0} is not found
+translator.removed = Translator "{0}" removed
+translator.failed-to-load = Translator "{0}" not found in the module "{1}"
\ No newline at end of file
Modified: branches/as7/metadata/pom.xml
===================================================================
--- branches/as7/metadata/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/metadata/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -43,6 +43,12 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-api</artifactId>
<scope>provided</scope>
</dependency>
Modified: branches/as7/pom.xml
===================================================================
--- branches/as7/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -273,6 +273,11 @@
<artifactId>teiid-client</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
@@ -532,6 +537,7 @@
<module>jboss-integration</module>
<module>test-integration</module>
<module>client-jdk15</module>
+ <module>admin</module>
</modules>
<distributionManagement>
<repository>
Modified: branches/as7/runtime/pom.xml
===================================================================
--- branches/as7/runtime/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/runtime/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -33,6 +33,11 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-engine</artifactId>
</dependency>
<dependency>
Modified: branches/as7/test-integration/pom.xml
===================================================================
--- branches/as7/test-integration/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/test-integration/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -47,6 +47,10 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
14 years, 5 months
teiid SVN: r3444 - in branches/as7/client/src: test/java/org/teiid/net/socket and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 16:37:43 -0400 (Fri, 02 Sep 2011)
New Revision: 3444
Modified:
branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java
branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java
Log:
TEIID-1720: move the classes to admin module
Modified: branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java 2011-09-02 00:47:26 UTC (rev 3443)
+++ branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java 2011-09-02 20:37:43 UTC (rev 3444)
@@ -24,12 +24,8 @@
import java.lang.reflect.Method;
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminProcessingException;
import org.teiid.client.xa.XATransactionException;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
@@ -59,18 +55,11 @@
return exception;
}
canThrowComponentException |= TeiidComponentException.class.isAssignableFrom(exceptionClasses[i]);
- canThrowAdminException |= AdminException.class.isAssignableFrom(exceptionClasses[i]);
canThrowXATransactionException |= XATransactionException.class.isAssignableFrom(exceptionClasses[i]);
}
if (canThrowComponentException) {
return new TeiidComponentException(exception);
}
- if (canThrowAdminException) {
- if (exception instanceof TeiidProcessingException) {
- return new AdminProcessingException(exception);
- }
- return new AdminComponentException(exception);
- }
if (canThrowXATransactionException) {
return new XATransactionException(exception);
}
Modified: branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java 2011-09-02 00:47:26 UTC (rev 3443)
+++ branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java 2011-09-02 20:37:43 UTC (rev 3444)
@@ -26,8 +26,6 @@
import junit.framework.TestCase;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
import org.teiid.client.DQP;
import org.teiid.client.util.ExceptionUtil;
import org.teiid.client.xa.XATransactionException;
@@ -50,15 +48,6 @@
assertTrue(t instanceof TeiidRuntimeException);
}
- public void testAdminExceptionConversion() throws Exception {
-
- Method m = Admin.class.getMethod("getCacheStats", new Class[] {String.class});
-
- Throwable t = ExceptionUtil.convertException(m, new TeiidComponentException());
-
- assertTrue(t instanceof AdminException);
- }
-
public void testComponentExceptionConversion() throws Exception {
Method m = DQP.class.getMethod("getMetadata", new Class[] {Long.TYPE});
14 years, 5 months
teiid SVN: r3443 - in trunk: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-01 20:47:26 -0400 (Thu, 01 Sep 2011)
New Revision: 3443
Modified:
trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
Log:
TEIID-1737 fix for with pushdown
Modified: trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
+++ trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-02 00:47:26 UTC (rev 3443)
@@ -927,6 +927,7 @@
buffer.append(WITH);
buffer.append(Tokens.SPACE);
append(obj.getItems());
+ buffer.append(Tokens.SPACE);
}
@Override
@@ -940,6 +941,7 @@
buffer.append(Tokens.SPACE);
}
buffer.append(AS);
+ buffer.append(Tokens.SPACE);
buffer.append(Tokens.LPAREN);
append(obj.getSubquery());
buffer.append(Tokens.RPAREN);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-02 00:47:26 UTC (rev 3443)
@@ -200,5 +200,14 @@
Command obj = commandBuilder.getCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, trans, obj);
}
+
+ @Test public void testWith() throws Exception {
+ String input = "with x as (select intkey from bqt1.smalla) select intkey from x limit 100"; //$NON-NLS-1$
+ String output = "WITH x AS (SELECT SmallA.IntKey FROM SmallA) SELECT TOP 100 g_0.intkey AS c_0 FROM x g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, trans, obj);
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-02 00:46:32 UTC (rev 3442)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-02 00:47:26 UTC (rev 3443)
@@ -230,6 +230,7 @@
}
}
item.setSubquery(translate(withQueryCommand.getCommand()));
+ items.add(item);
}
result.setItems(items);
return result;
14 years, 5 months
teiid SVN: r3442 - in branches/7.4.x: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-01 20:46:32 -0400 (Thu, 01 Sep 2011)
New Revision: 3442
Modified:
branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
Log:
TEIID-1737 fix for with clause pushdown
Modified: branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-01 19:48:30 UTC (rev 3441)
+++ branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
@@ -887,6 +887,7 @@
buffer.append(WITH);
buffer.append(Tokens.SPACE);
append(obj.getItems());
+ buffer.append(Tokens.SPACE);
}
@Override
@@ -900,6 +901,7 @@
buffer.append(Tokens.SPACE);
}
buffer.append(AS);
+ buffer.append(Tokens.SPACE);
buffer.append(Tokens.LPAREN);
append(obj.getSubquery());
buffer.append(Tokens.RPAREN);
Modified: branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-01 19:48:30 UTC (rev 3441)
+++ branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
@@ -200,5 +200,14 @@
Command obj = commandBuilder.getCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, trans, obj);
}
+
+ @Test public void testWith() throws Exception {
+ String input = "with x as (select intkey from bqt1.smalla) select intkey from x limit 100"; //$NON-NLS-1$
+ String output = "WITH x AS (SELECT SmallA.IntKey FROM SmallA) SELECT TOP 100 g_0.intkey AS c_0 FROM x g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, trans, obj);
+ }
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-01 19:48:30 UTC (rev 3441)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-02 00:46:32 UTC (rev 3442)
@@ -235,6 +235,7 @@
}
}
item.setSubquery(translate(withQueryCommand.getCommand()));
+ items.add(item);
}
result.setItems(items);
return result;
14 years, 5 months