Author: shawkins
Date: 2012-06-22 09:46:02 -0400 (Fri, 22 Jun 2012)
New Revision: 4197
Added:
trunk/engine/src/main/resources/META-INF/services/org.teiid.PolicyDecider
Removed:
trunk/engine/src/main/resources/META-INF/services/org.teiid.dqp.internal.process.AuthorizationValidator
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/jboss-integration/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
Log:
TEIID-2082 opted to use the policydecider as the server instead
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2012-06-22
01:39:29 UTC (rev 4196)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -29,6 +29,8 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.xml.XMLConstants;
import javax.xml.stream.XMLInputFactory;
@@ -78,8 +80,7 @@
try {
content.close();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger.getLogger(VDBMetadataParser.class.getName()).log(Level.FINE, "Exception
closing vdb stream", e);
}
}
return null;
Modified: trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli
===================================================================
--- trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli 2012-06-22
01:39:29 UTC (rev 4196)
+++ trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli 2012-06-22
13:46:02 UTC (rev 4197)
@@ -16,7 +16,7 @@
/profile=ha/subsystem=security/security-domain=teiid-security/authentication=classic:add(login-modules=[{"code"=>"org.jboss.security.auth.spi.UsersRolesLoginModule",
"flag"=>"required",
"module-options"=>[("usersProperties"=>"${jboss.domain.config.dir}/teiid-security-users.properties"),
("rolesProperties"=>"${jboss.domain.config.dir}/teiid-security-roles.properties")]}])
/profile=ha/subsystem=threads/bounded-queue-thread-pool=teiid-async:add(name=teiid-async,
max-threads=4, queue-length=100)
-/profile=ha/subsystem=teiid:add(async-thread-pool=teiid-async,
distributed-cache-jgroups-stack=udp, resultset-cache-infinispan-container=teiid-cache,
authorization-validator-module=org.jboss.teiid)
+/profile=ha/subsystem=teiid:add(async-thread-pool=teiid-async,
distributed-cache-jgroups-stack=udp, resultset-cache-infinispan-container=teiid-cache,
policy-decider-module=org.jboss.teiid)
/profile=ha/subsystem=teiid/transport=embedded:add()
/profile=ha/subsystem=teiid/transport=jdbc:add(protocol=teiid, socket-binding=teiid-jdbc,
ssl-mode=login, authentication-security-domain=teiid-security)
/profile=ha/subsystem=teiid/transport=odbc:add(protocol=pg, socket-binding=teiid-odbc,
authentication-security-domain=teiid-security)
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-06-22 01:39:29 UTC
(rev 4196)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-06-22 13:46:02 UTC
(rev 4197)
@@ -46,6 +46,7 @@
<li>FunctionMethod.getFullName returns the proper schema, not category qualified
name.
<li>VDB.getUrl has been removed.
<li>VDB.Status now has three states - LOADING, ACTIVE, REMOVED. To check for
validity use the isValid method, rather than checking for the VALID state.
+ <li>The standalone and cli configuration files specify a setting for the teiid
subsystem policy-decider-module. If a module is not specified, then data roles will not
be checked.
<ul>
<h4>from 7.x</h4>
Modified: trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
--- trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2012-06-22
01:39:29 UTC (rev 4196)
+++ trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2012-06-22
13:46:02 UTC (rev 4197)
@@ -278,7 +278,7 @@
<transport name="odbc" protocol="pg"
socket-binding="teiid-odbc">
<authentication security-domain="teiid-security"/>
</transport>
-
<authorization-validator-module>org.jboss.teiid</authorization-validator-module>
+ <policy-decider-module>org.jboss.teiid</policy-decider-module>
<translator name="jdbc-simple"
module="org.jboss.teiid.translator.jdbc"/>
<translator name="jdbc-ansi"
module="org.jboss.teiid.translator.jdbc"/>
<translator name="access"
module="org.jboss.teiid.translator.jdbc"/>
Modified:
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -101,6 +101,7 @@
*/
public class BufferFrontedFileStoreCache implements Cache<PhysicalInfo>,
StorageManager {
+ private static final long TIMEOUT_NANOS = TimeUnit.SECONDS.toNanos(120);
private static final int DEFAULT_MIN_DEFRAG = 1 << 26;
private static final byte[] HEADER_SKIP_BUFFER = new byte[16];
private static final int EVICTION_SCANS = 2;
@@ -1017,11 +1018,17 @@
}
freedLock.lock();
try {
- next = blocksInuse.getAndSetNextClearBit();
- if (next != EMPTY_ADDRESS) {
- return next;
+ long waitTime = TIMEOUT_NANOS;
+ while (true) {
+ next = blocksInuse.getAndSetNextClearBit();
+ if (next != EMPTY_ADDRESS) {
+ return next;
+ }
+ waitTime = blocksFreed.awaitNanos(waitTime);
+ if (waitTime <= 0) {
+ break;
+ }
}
- blocksFreed.await(120, TimeUnit.SECONDS);
} finally {
freedLock.unlock();
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -34,7 +34,6 @@
*/
public class DefaultAuthorizationValidator implements AuthorizationValidator {
- private boolean enabled = true;
private PolicyDecider policyDecider;
public DefaultAuthorizationValidator() {
@@ -45,7 +44,7 @@
QueryMetadataInterface metadata, CommandContext commandContext,
CommandType commandType) throws QueryValidatorException,
TeiidComponentException {
- if (enabled && policyDecider.validateCommand(commandContext)) {
+ if (policyDecider != null && policyDecider.validateCommand(commandContext)) {
AuthorizationValidationVisitor visitor = new
AuthorizationValidationVisitor(this.policyDecider, commandContext);
Request.validateWithVisitor(visitor, metadata, command);
}
@@ -54,7 +53,7 @@
@Override
public boolean hasRole(String roleName, CommandContext commandContext) {
- if (!enabled) {
+ if (policyDecider == null) {
return true;
}
return this.policyDecider.hasRole(roleName, commandContext);
@@ -64,16 +63,4 @@
this.policyDecider = policyDecider;
}
- public PolicyDecider getPolicyDecider() {
- return policyDecider;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
}
Copied: trunk/engine/src/main/resources/META-INF/services/org.teiid.PolicyDecider (from
rev 4196,
trunk/engine/src/main/resources/META-INF/services/org.teiid.dqp.internal.process.AuthorizationValidator)
===================================================================
--- trunk/engine/src/main/resources/META-INF/services/org.teiid.PolicyDecider
(rev 0)
+++ trunk/engine/src/main/resources/META-INF/services/org.teiid.PolicyDecider 2012-06-22
13:46:02 UTC (rev 4197)
@@ -0,0 +1 @@
+org.teiid.dqp.internal.process.DataRolePolicyDecider
\ No newline at end of file
Deleted:
trunk/engine/src/main/resources/META-INF/services/org.teiid.dqp.internal.process.AuthorizationValidator
===================================================================
---
trunk/engine/src/main/resources/META-INF/services/org.teiid.dqp.internal.process.AuthorizationValidator 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/engine/src/main/resources/META-INF/services/org.teiid.dqp.internal.process.AuthorizationValidator 2012-06-22
13:46:02 UTC (rev 4197)
@@ -1 +0,0 @@
-org.teiid.dqp.internal.process.DefaultAuthorizationValidator
\ No newline at end of file
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -242,7 +242,6 @@
serverRequest.initialize(request,
BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(),
null, workContext, prepPlanCache);
serverRequest.setMetadata(capFinder, metadata, null);
DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
- drav.setEnabled(false);
serverRequest.setAuthorizationValidator(drav);
serverRequest.processRequest();
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 2012-06-22
01:39:29 UTC (rev 4196)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -142,7 +142,6 @@
request.initialize(message, Mockito.mock(BufferManager.class),
new FakeDataManager(), new FakeTransactionService(), TEMP_TABLE_STORE, workContext,
null);
DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
- drav.setEnabled(false);
request.setAuthorizationValidator(drav);
request.processRequest();
return request;
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -91,7 +91,8 @@
// ################################## TEST HELPERS ################################
- private FunctionDescriptor helpCreateDescriptor(String name, Class<?>[] types)
{
+ @SuppressWarnings("serial")
+ private FunctionDescriptor helpCreateDescriptor(String name, Class<?>[] types) {
final String fname = name;
final Class<?>[] ftypes = types;
return new FunctionDescriptor() {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -95,6 +95,7 @@
TEIID50076,
TEIID50077,
TEIID50078,
- TEIID50088
+ TEIID50088,
+ TEIID50089
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-06-22
01:39:29 UTC (rev 4196)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -24,6 +24,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -77,7 +78,6 @@
import org.teiid.dqp.internal.process.AuthorizationValidator;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DataRolePolicyDecider;
import org.teiid.dqp.internal.process.DefaultAuthorizationValidator;
import org.teiid.dqp.internal.process.PreparedPlan;
import org.teiid.dqp.internal.process.SessionAwareCache;
@@ -281,14 +281,10 @@
edfsServiceBuilder.addDependency(replicatorAvailable?DependencyType.REQUIRED:DependencyType.OPTIONAL,
TeiidServiceNames.OBJECT_REPLICATOR, ObjectReplicator.class,
edfs.objectReplicatorInjector);
newControllers.add(edfsServiceBuilder.install());
- PolicyDecider policyDecider;
+ PolicyDecider policyDecider = null;
if (Element.POLICY_DECIDER_MODULE_ELEMENT.isDefined(operation)) {
policyDecider = buildService(PolicyDecider.class,
Element.POLICY_DECIDER_MODULE_ELEMENT.asString(operation));
}
- else {
- DataRolePolicyDecider drpd = new DataRolePolicyDecider();
- policyDecider = drpd;
- }
final AuthorizationValidator authValidator;
if (Element.AUTHORIZATION_VALIDATOR_MODULE_ELEMENT.isDefined(operation)) {
@@ -296,12 +292,9 @@
}
else {
DefaultAuthorizationValidator dap = new DefaultAuthorizationValidator();
- dap.setEnabled(false);
+ dap.setPolicyDecider(policyDecider);
authValidator = dap;
}
- if (authValidator instanceof DefaultAuthorizationValidator) {
- ((DefaultAuthorizationValidator)authValidator).setPolicyDecider(policyDecider);
- }
ValueService<AuthorizationValidator> authValidatorService = new
ValueService<AuthorizationValidator>(new
org.jboss.msc.value.Value<AuthorizationValidator>() {
@Override
@@ -426,12 +419,15 @@
moduleId = ModuleIdentifier.create(moduleName);
module = Module.getCallerModuleLoader().loadModule(moduleId);
} catch (ModuleLoadException e) {
- throw new OperationFailedException(e, new
ModelNode().set(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50069,
moduleName)));
+ throw new
OperationFailedException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50069,
moduleName), e);
}
ServiceLoader<T> services = module.loadService(type);
- return services.iterator().next();
+ Iterator<T> iter = services.iterator();
+ if (!iter.hasNext()) {
+ throw new
OperationFailedException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50089,
type.getName(), moduleName));
+ }
+ return iter.next();
}
-
private BufferManagerService buildBufferManager(ModelNode node) {
BufferManagerService bufferManger = new BufferManagerService();
Modified:
trunk/jboss-integration/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/jboss-integration/src/main/java/org/teiid/replication/jboss/JGroupsInputStream.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -50,13 +50,16 @@
if (buf == null) {
lock.lock();
try {
- write.await(timeout, TimeUnit.MILLISECONDS);
+ long waitTime = TimeUnit.MILLISECONDS.toNanos(timeout);
+ while (buf == null) {
+ waitTime = write.awaitNanos(waitTime);
+ if (waitTime <= 0) {
+ throw new IOException(new TimeoutException());
+ }
+ }
if (index < 0) {
return -1;
}
- if (buf == null) {
- throw new IOException(new TimeoutException());
- }
} catch(InterruptedException e) {
throw new IOException(e);
} finally {
@@ -95,7 +98,7 @@
if (index == -1) {
return;
}
- if (buf != null) {
+ while (buf != null) {
doneReading.await();
}
if (index == -1) {
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-22
01:39:29 UTC (rev 4196)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-22
13:46:02 UTC (rev 4197)
@@ -59,6 +59,7 @@
TEIID50042=error setting state {0}
TEIID50043=Invalid metadata file found at {0}; delete this file and restart server.
TEIID50069=Failed to load module {0}
+TEIID50089=Failed to find any services of type {0} from module {1}
TEIID50007=Failed to load module {1} for translator {2}
TEIID50088=Failed to load module {0} for UDF in VDB {1}.{2}:{3}
TEIID50072=The username "{0}" and/or password and/or payload token could not be
authenticated by any membership domain.
Modified:
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java 2012-06-22
01:39:29 UTC (rev 4196)
+++
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java 2012-06-22
13:46:02 UTC (rev 4197)
@@ -36,6 +36,8 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.internal.progress.OngoingStubbing;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
@@ -93,6 +95,7 @@
}
private static FakeReusableExecution execution;
+ private static boolean isDisposed;
@Before public void setup() throws DataNotAvailableException, TranslatorException {
execution = Mockito.mock(FakeReusableExecution.class);
@@ -100,6 +103,16 @@
for (int i = 1; i < EXEC_COUNT; i++) {
stubbing.toReturn((List<Object>) Arrays.asList((Object)null)).toReturn(null);
}
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ synchronized (TestExecutionReuse.class) {
+ isDisposed = true;
+ TestExecutionReuse.class.notify();
+ }
+ return null;
+ }
+ }).when(execution).dispose();
}
@BeforeClass public static void oneTimeSetUp() throws Exception {
@@ -160,7 +173,7 @@
@Override
public void onException(Statement stmt, Exception e) {
- result.getResultsReceiver().receiveResults(rowCount);
+ result.getResultsReceiver().exceptionOccurred(e);
}
@Override
@@ -168,6 +181,11 @@
result.getResultsReceiver().receiveResults(rowCount);
}
}, new RequestOptions().continuous(true));
+ synchronized (TestExecutionReuse.class) {
+ while (!isDisposed) {
+ TestExecutionReuse.class.wait();
+ }
+ }
assertEquals(EXEC_COUNT, result.get().intValue());
Mockito.verify(execution, Mockito.times(1)).dispose();
Mockito.verify(execution, Mockito.times(EXEC_COUNT)).execute();