Author: rareddy
Date: 2009-07-02 17:38:17 -0400 (Thu, 02 Jul 2009)
New Revision: 1094
Added:
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
Removed:
trunk/engine/src/main/java/com/metamatrix/dqp/service/ServerConnectionListener.java
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java
trunk/embedded/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
trunk/embedded/src/test/java/org/teiid/transport/TestCommSockets.java
trunk/embedded/src/test/java/org/teiid/transport/TestLogonImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
Log:
TEIID-703, TEIID-666
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -30,7 +30,6 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
@@ -55,7 +54,7 @@
import com.metamatrix.admin.objects.MMSystem;
import com.metamatrix.admin.objects.MMVDB;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeDefn;
import com.metamatrix.common.config.api.ConnectorBinding;
@@ -72,8 +71,10 @@
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
+import com.metamatrix.platform.security.api.service.SessionServiceInterface;
import com.metamatrix.platform.util.ProductInfoConstants;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -168,6 +169,10 @@
ConfigurationService getConfigurationService() {
return
(ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
}
+
+ SessionServiceInterface getSessionService() {
+ return
(SessionServiceInterface)getManager().findService(DQPServiceNames.SESSION_SERVICE);
+ }
protected Object convertToAdminObjects(Object src) {
return convertToAdminObjects(src,null);
@@ -243,8 +248,8 @@
com.metamatrix.common.queue.WorkerPoolStats stats =
(com.metamatrix.common.queue.WorkerPoolStats)src;
return Util.convertStats(stats, stats.getQueueName());
}
- else if (src != null && src instanceof DQPWorkContext) {
- DQPWorkContext conn = (DQPWorkContext)src;
+ else if (src != null && src instanceof MetaMatrixSessionInfo) {
+ MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
return convertConnection(conn);
}
else if (src != null && src instanceof
com.metamatrix.common.config.api.ExtensionModule) {
@@ -273,14 +278,16 @@
return module;
}
- private Session convertConnection(DQPWorkContext src) {
- MMSession session = new MMSession(new String[] {src.getSessionId().toString()});
- session.setVDBName(src.getVdbName());
- session.setVDBVersion(src.getVdbVersion());
- session.setApplicationName(src.getAppName());
- session.setIPAddress(src.getClientAddress());
+ private Session convertConnection(MetaMatrixSessionInfo src) {
+ MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
+ session.setVDBName(src.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
+ session.setVDBVersion(src.getProductInfo(ProductInfoConstants.VDB_VERSION));
+ session.setApplicationName(src.getApplicationName());
+ session.setIPAddress(src.getClientIp());
session.setHostName(src.getClientHostname());
session.setUserName(src.getUserName());
+ session.setLastPingTime(src.getLastPingTime());
+ session.setCreated(new Date(src.getTimeCreated()));
return session;
}
@@ -445,11 +452,11 @@
* @return
* @since 4.3
*/
- DQPWorkContext getClientConnection(String identifier) {
- Collection<DQPWorkContext> connections =
getConfigurationService().getClientConnections();
- for (DQPWorkContext context:connections) {
- if (context.getSessionId().toString().equals(identifier)) {
- return context;
+ MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
+ Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+ for (MetaMatrixSessionInfo info:sessions) {
+ if (info.getSessionID().toString().equals(identifier)) {
+ return info;
}
}
return null;
@@ -460,8 +467,13 @@
* @return
* @throws AdminException
*/
- Set<DQPWorkContext> getClientConnections() {
- return getConfigurationService().getClientConnections();
+ Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException
{
+ try {
+ return getSessionService().getActiveSessions();
+ } catch (SessionServiceException e) {
+ // SessionServiceException not in the client known exception (in common-internal)
+ throw new AdminComponentException(e.getMessage(), e.getCause());
+ }
}
boolean matches(String regEx, String value) {
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.Set;
import javax.transaction.xa.Xid;
@@ -38,18 +37,17 @@
import org.teiid.adminapi.EmbeddedLogger;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.RuntimeStateAdmin;
-import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.objects.MMRequest;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
/**
@@ -209,20 +207,20 @@
public void terminateSession(String identifier)
throws AdminException {
- Set<DQPWorkContext> connections = getClientConnections();
- ArrayList<DQPWorkContext> matchedConnections = new
ArrayList<DQPWorkContext>();
+ Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+ ArrayList<MetaMatrixSessionInfo> matchedConnections = new
ArrayList<MetaMatrixSessionInfo>();
- for (DQPWorkContext clientConnection:connections) {
- String id = clientConnection.getSessionId().toString();
+ for (MetaMatrixSessionInfo info:sessions) {
+ String id = info.getSessionID().toString();
if (matches(identifier, id)) {
- matchedConnections.add(clientConnection);
+ matchedConnections.add(info);
}
}
// Double iteration because to avoid concurrent modification of underlying map.
- for (DQPWorkContext clientConnection: matchedConnections) {
+ for (MetaMatrixSessionInfo info: matchedConnections) {
try {
- this.manager.getDQP().terminateConnection(clientConnection.getSessionId().toString());
+ this.manager.getDQP().terminateConnection(info.getSessionID().toString());
} catch (MetaMatrixComponentException e) {
throw new AdminComponentException(e);
}
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -30,19 +30,16 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import java.util.StringTokenizer;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.application.AbstractClassLoaderManager;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
@@ -74,9 +71,13 @@
import com.metamatrix.dqp.embedded.configuration.VDBConfigurationWriter;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.ConnectorBindingLifeCycleListener;
-import com.metamatrix.dqp.service.ServerConnectionListener;
+import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.VDBLifeCycleListener;
import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.service.SessionListener;
+import com.metamatrix.platform.security.api.service.SessionServiceInterface;
+import com.metamatrix.platform.util.ProductInfoConstants;
import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.function.UDFSource;
import com.metamatrix.vdb.runtime.BasicModelInfo;
@@ -109,11 +110,9 @@
// load time constructs
private Map<String, URL> availableVDBFiles = new HashMap<String, URL>();
ConfigurationModelContainer configurationModel;
- private Map<String, Integer> inuseVDBs = new HashMap<String, Integer>();
private ArrayList<VDBLifeCycleListener> vdbLifeCycleListeners = new
ArrayList<VDBLifeCycleListener>();
private ArrayList<ConnectorBindingLifeCycleListener>
connectorBindingLifeCycleListeners = new
ArrayList<ConnectorBindingLifeCycleListener>();
private UDFSource udfSource;
- private HashSet<DQPWorkContext> clientConnections = new
HashSet<DQPWorkContext>();
private AbstractClassLoaderManager classLoaderManager = new
AbstractClassLoaderManager(Thread.currentThread().getContextClassLoader(), true, true) {
@@ -329,7 +328,7 @@
public void saveVDB(VDBArchive srcVdb, String version) throws
MetaMatrixComponentException{
// if the vdb version being saved is DELETED then if nobody using it
- if (srcVdb.getStatus() == VDBStatus.DELETED && canDeleteVDB(srcVdb)) {
+ if (srcVdb.getStatus() == VDBStatus.DELETED &&
canDeleteVDB(srcVdb.getName(), srcVdb.getVersion())) {
deleteVDB(srcVdb);
return;
}
@@ -1231,75 +1230,45 @@
}
/**
- * @see com.metamatrix.dqp.service.ConfigurationService#getConnectionListener()
+ * @see com.metamatrix.dqp.service.ConfigurationService#getSessionListener()
* @since 4.3.2
*/
- public ServerConnectionListener getConnectionListener() {
- return new ServerConnectionListener() {
+ public SessionListener getSessionListener() {
+ return new SessionListener() {
/**
* A Client Connection to DQP has been added
*/
- public void connectionAdded(DQPWorkContext connection) {
- // Add to parent's collection
- clientConnections.add(connection);
-
- String key = vdbId(connection.getVdbName(), connection.getVdbVersion());
-
-
DQPEmbeddedPlugin.logInfo("EmbeddedConfigurationService.connectionAdded", new
Object[] {connection.getVdbName(), connection.getVdbVersion(),
connection.getSessionId()}); //$NON-NLS-1$
-
- Integer useCount = inuseVDBs.get(key);
- if (useCount == null) {
- inuseVDBs.put(key, new Integer(1));
- }
- else {
- inuseVDBs.put(key, new Integer(useCount.intValue()+1));
- }
+ public void sessionCreated(MetaMatrixSessionInfo connection) {
}
/**
* A Client Connection to DQP has been removed
*/
- public void connectionRemoved(DQPWorkContext connection) {
- // remove from the collection
- clientConnections.remove(connection);
+ public void sessionClosed(MetaMatrixSessionInfo session) {
- String key = vdbId(connection.getVdbName(), connection.getVdbVersion());
-
-
DQPEmbeddedPlugin.logInfo("EmbeddedConfigurationService.connectionRemoved", new
Object[] {connection.getVdbName(), connection.getVdbVersion(),
connection.getSessionId()}); //$NON-NLS-1$
-
- Integer useCount = inuseVDBs.get(key);
- if (useCount == null) {
- // not sure how this got in here..
- }
- else {
- // after decrementing if use count comes to zero we can
- // see if there are any VDBs to delete
- if ((useCount.intValue()-1) == 0) {
- runVDBCleanUp(connection.getVdbName(),
connection.getVdbVersion());
- inuseVDBs.remove(key);
- }
- else {
- // if there more users on this vdb then just decrement the
counter.
- inuseVDBs.put(key, new Integer((useCount.intValue()-1)));
- }
- }
+ String vdbName = session.getProductInfo(ProductInfoConstants.VIRTUAL_DB);
+ String vdbVersion =
session.getProductInfo(ProductInfoConstants.VDB_VERSION);
+ if (canDeleteVDB(vdbName, vdbVersion)) {
+ runVDBCleanUp(vdbName, vdbVersion);
+ }
}
};
}
- @Override
- public Set<DQPWorkContext> getClientConnections() {
- return new HashSet<DQPWorkContext>(clientConnections);
- }
-
/**
* Can the given VDB be deleted
* @param vdb
* @return true vdb can be deleted; false otherwise
*/
- boolean canDeleteVDB(VDBArchive vdb) {
- Integer useCount = inuseVDBs.get(vdbId(vdb));
- return (useCount == null || useCount.intValue() == 0);
+ private boolean canDeleteVDB(String vdbName, String vdbVersion) {
+ try {
+ SessionServiceInterface ssi =
(SessionServiceInterface)lookupService(DQPServiceNames.SESSION_SERVICE);
+ Collection<MetaMatrixSessionInfo> active = ssi.getSessionsLoggedInToVDB(vdbName,
vdbVersion);
+ return active.isEmpty();
+ } catch (SessionServiceException e) {
+ LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage());
+ }
+ return false;
}
/**
Modified:
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -32,12 +32,10 @@
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.transport.AdminAuthorizationInterceptor;
@@ -75,11 +73,9 @@
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.ServerConnectionListener;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.vm.controller.ProcessStatistics;
import com.metamatrix.platform.vm.controller.SocketListenerStats;
@@ -158,6 +154,9 @@
// used during VDB delete
ConfigurationService configService =
(ConfigurationService)findService(DQPServiceNames.CONFIGURATION_SERVICE);
+ SessionServiceInterface sessionService =
(SessionServiceInterface)this.dqp.getEnvironment().findService(DQPServiceNames.SESSION_SERVICE);
+ sessionService.register(configService.getSessionListener());
+
//in new class loader - all of these should be created lazily and held locally
this.clientServices = createClientServices(configService);
@@ -180,7 +179,7 @@
ClientServiceRegistry services = new ClientServiceRegistry();
SessionServiceInterface sessionService =
(SessionServiceInterface)this.dqp.getEnvironment().findService(DQPServiceNames.SESSION_SERVICE);
- services.registerClientService(ILogon.class, new LogonImpl(sessionService,
configService.getClusterName(), configService.getConnectionListener()),
com.metamatrix.common.util.LogConstants.CTX_SERVER);
+ services.registerClientService(ILogon.class, new LogonImpl(sessionService,
configService.getClusterName()), com.metamatrix.common.util.LogConstants.CTX_SERVER);
Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI());
services.registerClientService(Admin.class, roleCheckedServerAdmin,
com.metamatrix.common.util.LogConstants.CTX_ADMIN);
Modified:
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -36,7 +36,6 @@
import org.teiid.dqp.internal.process.DQPCore;
import com.google.inject.Inject;
-import com.google.inject.name.Named;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -51,7 +50,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
@@ -63,6 +61,7 @@
import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.service.AuthenticationToken;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
+import com.metamatrix.platform.security.api.service.SessionListener;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
import com.metamatrix.platform.util.ErrorMessageKeys;
import com.metamatrix.platform.util.LogMessageKeys;
@@ -89,6 +88,7 @@
private Map<MetaMatrixSessionID, MetaMatrixSessionInfo> sessionCache = new
HashMap<MetaMatrixSessionID, MetaMatrixSessionInfo>();
private Timer sessionMonitor;
private AtomicLong idSequence = new AtomicLong();
+ private SessionListener sessionListener;
//
-----------------------------------------------------------------------------------
// S E R V I C E - R E L A T E D M E T H O D S
@@ -126,6 +126,9 @@
LogManager.logWarning(LogConstants.CTX_SESSION,e,"Exception
terminitating session"); //$NON-NLS-1$
}
}
+ if (this.sessionListener != null) {
+ this.sessionListener.sessionClosed(info);
+ }
}
@Override
@@ -188,6 +191,9 @@
properties.getProperty(MMURL.CONNECTION.CLIENT_HOSTNAME));
newSession.setTrustedToken(trustedToken);
this.sessionCache.put(newSession.getSessionID(), newSession);
+ if (this.sessionListener != null) {
+ this.sessionListener.sessionCreated(newSession);
+ }
return newSession;
}
@@ -356,4 +362,9 @@
return vdbService;
}
+ @Override
+ public void register(SessionListener listener) {
+ this.sessionListener = listener;
+ }
+
}
Modified: trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java 2009-07-02 19:57:16
UTC (rev 1093)
+++ trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java 2009-07-02 21:38:17
UTC (rev 1094)
@@ -41,7 +41,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.service.ServerConnectionListener;
import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.security.api.Credentials;
@@ -57,12 +56,10 @@
private SessionServiceInterface service;
private String clusterName;
- private ServerConnectionListener connListener;
- public LogonImpl(SessionServiceInterface service, String clusterName,
ServerConnectionListener connListener) {
+ public LogonImpl(SessionServiceInterface service, String clusterName) {
this.service = service;
this.clusterName = clusterName;
- this.connListener = connListener;
}
public LogonResult logon(Properties connProps) throws LogonException,
@@ -87,7 +84,6 @@
try {
MetaMatrixSessionInfo sessionInfo = service.createSession(user,credential,
(Serializable) payload, applicationName, connProps);
MetaMatrixSessionID sessionID = updateDQPContext(sessionInfo);
- this.connListener.connectionAdded(DQPWorkContext.getWorkContext());
LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"Logon successful
for \"", user, "\" - created SessionID \"", "" +
sessionID, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
return new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getProductInfo(),
clusterName);
} catch (MetaMatrixAuthenticationException e) {
@@ -150,7 +146,6 @@
public ResultsFuture<?> logoff() throws InvalidSessionException,
MetaMatrixComponentException {
try {
this.service.closeSession(DQPWorkContext.getWorkContext().getSessionId());
- this.connListener.connectionRemoved(DQPWorkContext.getWorkContext());
} catch (SessionServiceException e) {
throw new MetaMatrixComponentException(e);
}
Modified:
trunk/embedded/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
===================================================================
---
trunk/embedded/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/embedded/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -10,6 +10,7 @@
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
+import com.metamatrix.platform.security.api.service.SessionListener;
import com.metamatrix.platform.security.api.service.SuccessfulAuthenticationToken;
public class TestSessionServiceImpl extends TestCase {
@@ -19,6 +20,8 @@
MembershipServiceInterface msi = Mockito.mock(MembershipServiceInterface.class);
Mockito.stub(msi.authenticateUser("steve", null, null,
"foo")).toReturn(new SuccessfulAuthenticationToken(null,
"steve@somedomain")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ssi.setMembershipService(msi);
+ SessionListener listener = Mockito.mock(SessionListener.class);
+ ssi.register(listener);
MetaMatrixSessionID id1 = new MetaMatrixSessionID(1);
try {
@@ -34,6 +37,7 @@
assertEquals(1, ssi.getActiveSessionsCount());
assertEquals(0, ssi.getSessionsLoggedInToVDB("a", "1").size());
//$NON-NLS-1$ //$NON-NLS-2$
+ Mockito.verify(listener, Mockito.times(1)).sessionCreated(info);
ssi.closeSession(id1);
@@ -50,6 +54,7 @@
} catch (InvalidSessionException e) {
}
+ Mockito.verify(listener, Mockito.times(1)).sessionClosed(info);
}
}
Modified: trunk/embedded/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/embedded/src/test/java/org/teiid/transport/TestCommSockets.java 2009-07-02
19:57:16 UTC (rev 1093)
+++ trunk/embedded/src/test/java/org/teiid/transport/TestCommSockets.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -35,8 +35,6 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.teiid.transport.LogonImpl;
-import org.teiid.transport.SocketListener;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.security.LogonException;
@@ -49,7 +47,6 @@
import com.metamatrix.common.comm.platform.socket.client.SocketServerConnectionFactory;
import com.metamatrix.common.comm.platform.socket.client.UrlServerDiscovery;
import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.dqp.service.ServerConnectionListener;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
@@ -74,7 +71,7 @@
@Test public void testFailedConnect() throws Exception {
ClientServiceRegistry csr = new ClientServiceRegistry();
SessionServiceInterface sessionService = mock(SessionServiceInterface.class);
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService,
"fakeCluster", mock(ServerConnectionListener.class)), "foo");
//$NON-NLS-1$ //$NON-NLS-2$
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService,
"fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),
csr, 1024, 1024, 1, null, true, sessionService);
@@ -145,7 +142,7 @@
if (listener == null) {
SessionServiceInterface sessionService = mock(SessionServiceInterface.class);
ClientServiceRegistry csr = new ClientServiceRegistry();
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService,
"fakeCluster", mock(ServerConnectionListener.class)) { //$NON-NLS-1$
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService,
"fakeCluster") { //$NON-NLS-1$
@Override
public LogonResult logon(Properties connProps)
throws LogonException, ComponentNotFoundException {
Modified: trunk/embedded/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- trunk/embedded/src/test/java/org/teiid/transport/TestLogonImpl.java 2009-07-02
19:57:16 UTC (rev 1093)
+++ trunk/embedded/src/test/java/org/teiid/transport/TestLogonImpl.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -23,18 +23,14 @@
package org.teiid.transport;
-import static org.mockito.Mockito.mock;
-
import java.util.Properties;
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.dqp.service.ServerConnectionListener;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
@@ -59,22 +55,16 @@
Mockito.stub(ssi.createSession(userName, null, null, applicationName,
p)).toReturn(resultInfo);
- ServerConnectionListener listener = mock(ServerConnectionListener.class);
- LogonImpl impl = new LogonImpl(ssi, "fakeCluster", listener); //$NON-NLS-1$
+ LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
assertEquals(new MetaMatrixSessionID(1), result.getSessionID());
- Mockito.verify(listener,
Mockito.times(1)).connectionAdded((DQPWorkContext)Mockito.anyObject());
- Mockito.verify(listener,
Mockito.times(0)).connectionRemoved((DQPWorkContext)Mockito.anyObject());
-
- impl.logoff();
- Mockito.verify(listener,
Mockito.times(1)).connectionRemoved((DQPWorkContext)Mockito.anyObject());
}
public void testCredentials() throws Exception {
SessionServiceInterface ssi = Mockito.mock(SessionServiceInterface.class);
- LogonImpl impl = new LogonImpl(ssi, "fakeCluster",
mock(ServerConnectionListener.class)); //$NON-NLS-1$
+ LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$
Properties p = new Properties();
p.put(MMURL.CONNECTION.CLIENT_TOKEN_PROP, new Object());
//invalid credentials
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -26,10 +26,7 @@
import java.net.URL;
import java.util.List;
import java.util.Properties;
-import java.util.Set;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.ClassLoaderManager;
@@ -39,6 +36,7 @@
import com.metamatrix.common.config.api.ConnectorBindingType;
import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.platform.security.api.service.SessionListener;
@@ -286,7 +284,7 @@
* @throws MetaMatrixComponentException
* @since 4.3.2
*/
- public ServerConnectionListener getConnectionListener();
+ public SessionListener getSessionListener();
/**
@@ -368,12 +366,6 @@
/**
- * This returns the active client connections that have been made to the DQP
- * @return list of connections which are currently available;never null
- */
- public Set<DQPWorkContext> getClientConnections();
-
- /**
* Gets the processor batch size
* @return
* @since 4.3
Deleted:
trunk/engine/src/main/java/com/metamatrix/dqp/service/ServerConnectionListener.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/dqp/service/ServerConnectionListener.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/engine/src/main/java/com/metamatrix/dqp/service/ServerConnectionListener.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -1,46 +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 com.metamatrix.dqp.service;
-
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-
-
-/**
- * An implementor of this interface, when registered with the ServerConnection will
- * receive notifications about the connection life cycle events.
- */
-public interface ServerConnectionListener {
- /**
- * A connection has been added to DQP
- * @param connection The client connection instance, never null
- */
- void connectionAdded(DQPWorkContext context);
-
- /**
- * A connection has been removed for DQP
- * @param connection The client connection instance, never null
- */
- void connectionRemoved(DQPWorkContext context);
-
-}
Added:
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
(rev 0)
+++
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -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 com.metamatrix.platform.security.api.service;
+
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+
+public interface SessionListener {
+
+ void sessionCreated(MetaMatrixSessionInfo info);
+
+ void sessionClosed(MetaMatrixSessionInfo info);
+}
Property changes on:
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -105,7 +105,7 @@
* @return The collection of MetaMatrixSessionInfo objects of active users on
* the system - possibly empty, never null.
*/
- Collection getActiveSessions() throws SessionServiceException;
+ Collection<MetaMatrixSessionInfo> getActiveSessions() throws
SessionServiceException;
/**
* Get the number of active user sessions on the system.
@@ -142,7 +142,7 @@
* @param VDBVersion The version of the VDB.
* @throws SessionServiceException when transaction with database fails or unexpected
exception happens
*/
- Collection getSessionsLoggedInToVDB(String VDBName, String VDBVersion)
+ Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName,
String VDBVersion)
throws SessionServiceException;
/**
@@ -152,4 +152,10 @@
*/
public void pingServer(MetaMatrixSessionID sessionID) throws
InvalidSessionException;
+ /**
+ * Register a session listener
+ * @param listener
+ */
+ public void register(SessionListener listener);
+
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-07-02
19:57:16 UTC (rev 1093)
+++
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-07-02
21:38:17 UTC (rev 1094)
@@ -243,7 +243,7 @@
* @throws ConfigurationException
*/
private void registerILogonAPI() throws ConfigurationException, ServiceException {
- this.clientServices.registerClientService(ILogon.class, new
LogonImpl(PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL),
CurrentConfiguration.getInstance().getClusterName(), null),
LogCommonConstants.CTX_LOGON);
+ this.clientServices.registerClientService(ILogon.class, new
LogonImpl(PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL),
CurrentConfiguration.getInstance().getClusterName()), LogCommonConstants.CTX_LOGON);
}
/**