use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TestArrayProcessing method testLargeArrays.
@Test(expected = TeiidProcessingException.class)
public void testLargeArrays() throws Exception {
// $NON-NLS-1$
String sql = "WITH t(n) AS ( VALUES (1) UNION ALL SELECT n+1 FROM t WHERE n < 70000 ) SELECT array_agg((n, n, n, n, n)) FROM t;";
List<?>[] expected = new List[] { Arrays.asList(2080l) };
FakeDataManager dataManager = new FakeDataManager();
dataManager.setBlockOnce();
sampleData1(dataManager);
ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
CommandContext cc = createCommandContext();
cc.setSession(new SessionMetadata());
cc.setSessionVariable(TempTableStore.TEIID_MAX_RECURSION, 100000);
helpProcess(plan, cc, dataManager, expected);
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TempTableDataManager method createTemporarySession.
/**
* Create an unauthenticated session
* @param userName
* @param app
* @param vdb
* @return
*/
public static SessionMetadata createTemporarySession(String userName, String app, VDBMetaData vdb) {
long creationTime = System.currentTimeMillis();
SessionMetadata newSession = new SessionMetadata();
newSession.setSessionToken(new SessionToken(userName));
newSession.setSessionId(newSession.getSessionToken().getSessionID());
newSession.setUserName(userName);
newSession.setCreatedTime(creationTime);
newSession.setApplicationName(app);
newSession.setVDBName(vdb.getName());
newSession.setVDBVersion(vdb.getVersion());
newSession.setVdb(vdb);
newSession.setEmbedded(true);
return newSession;
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TestJBossSecurityHelper method validateSession.
public void validateSession(boolean securityEnabled) throws Exception {
final ArrayList<String> domains = new ArrayList<String>();
domains.add("somedomain");
AuthenticationManager authManager = Mockito.mock(AuthenticationManager.class);
Mockito.stub(authManager.isValid(new SimplePrincipal("steve"), "pass1", new Subject())).toReturn(true);
final SecurityDomainContext securityContext = new SecurityDomainContext(authManager, null, null, null, null, null);
SessionServiceImpl jss = new SessionServiceImpl() {
@Override
protected VDBMetaData getActiveVDB(String vdbName, String vdbVersion) throws SessionServiceException {
return Mockito.mock(VDBMetaData.class);
}
};
jss.setSecurityHelper(buildSecurityHelper("somedomain", securityContext));
jss.setSecurityDomain("somedomain");
try {
jss.validateSession(String.valueOf(1));
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
// $NON-NLS-1$ //$NON-NLS-2$
SessionMetadata info = jss.createSession("x", "1", AuthenticationType.USERPASSWORD, "steve", new Credentials("pass1".toCharArray()), "foo", new Properties());
if (securityEnabled) {
Mockito.verify(authManager).isValid(new SimplePrincipal("steve"), "pass1", new Subject());
}
String id1 = info.getSessionId();
jss.validateSession(id1);
assertEquals(1, jss.getActiveSessionsCount());
// $NON-NLS-1$
assertEquals(0, jss.getSessionsLoggedInToVDB(new VDBKey("a", 1)).size());
jss.closeSession(id1);
try {
jss.validateSession(id1);
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
try {
jss.closeSession(id1);
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TestSessionMetadata method testMapping.
@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 = VDBMetadataMapper.SessionMetadataMapper.INSTANCE.wrap(session, new ModelNode());
SessionMetadata session1 = VDBMetadataMapper.SessionMetadataMapper.INSTANCE.unwrap(node);
assertEquals(session.getSessionId(), session1.getSessionId());
assertEquals(session.getApplicationName(), session1.getApplicationName());
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class DQPCoreService method start.
@Override
public void start(final StartContext context) {
this.transactionServerImpl.setWorkManager(getWorkManagerInjector().getValue());
this.transactionServerImpl.setXaTerminator(getXaTerminatorInjector().getValue());
this.transactionServerImpl.setTransactionManager(getTxnManagerInjector().getValue());
this.transactionServerImpl.setDetectTransactions(true);
setPreParser(preParserInjector.getValue());
setAuthorizationValidator(authorizationValidatorInjector.getValue());
this.dqpCore.setBufferManager(bufferManagerInjector.getValue());
this.dqpCore.setTransactionService((TransactionService) LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, transactionServerImpl, new Class[] { TransactionService.class }, MessageLevel.DETAIL, Thread.currentThread().getContextClassLoader()));
this.dqpCore.setEventDistributor(getEventDistributorFactoryInjector().getValue().getReplicatedEventDistributor());
this.dqpCore.setResultsetCache(getResultSetCacheInjector().getValue());
this.dqpCore.setPreparedPlanCache(getPreparedPlanCacheInjector().getValue());
this.dqpCore.start(this);
// add vdb life cycle listeners
getVdbRepository().addListener(new VDBLifeCycleListener() {
@Override
public void removed(String name, CompositeVDB vdb) {
// terminate all the previous sessions
SessionService sessionService = (SessionService) context.getController().getServiceContainer().getService(TeiidServiceNames.SESSION).getValue();
Collection<SessionMetadata> sessions = sessionService.getSessionsLoggedInToVDB(vdb.getVDBKey());
for (SessionMetadata session : sessions) {
sessionService.terminateSession(session.getSessionId(), null);
}
// dump the caches.
try {
SessionAwareCache<?> value = getResultSetCacheInjector().getValue();
if (value != null) {
value.clearForVDB(vdb.getVDBKey());
}
value = getPreparedPlanCacheInjector().getValue();
if (value != null) {
value.clearForVDB(vdb.getVDBKey());
}
} catch (IllegalStateException e) {
// already shutdown
}
}
@Override
public void added(String name, CompositeVDB vdb) {
}
@Override
public void finishedDeployment(String name, CompositeVDB cvdb) {
}
@Override
public void beforeRemove(String name, CompositeVDB cvdb) {
}
});
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50001, this.dqpCore.getRuntimeVersion(), new Date(System.currentTimeMillis()).toString()));
}
Aggregations